From d77d1a52ca50ec23d48e754722f4fbff4a26e7b0 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Wed, 25 Aug 2021 19:07:51 +0200 Subject: [PATCH 001/246] Initial add of font driver for true type font renderings. --- Driver/Font/TrueType/local.mk | 20 + Driver/Font/TrueType/truetype.asm | 236 +++++++++++ Driver/Font/TrueType/truetype.gp | 45 +++ Driver/Font/TrueType/truetype.rev | 2 + Driver/Font/TrueType/truetypeChars.asm | 62 +++ Driver/Font/TrueType/truetypeConstant.def | 104 +++++ Driver/Font/TrueType/truetypeEC.asm | 99 +++++ Driver/Font/TrueType/truetypeEscape.asm | 60 +++ Driver/Font/TrueType/truetypeInit.asm | 368 ++++++++++++++++++ Driver/Font/TrueType/truetypeMacros.def | 70 ++++ Driver/Font/TrueType/truetypeMetrics.asm | 63 +++ Driver/Font/TrueType/truetypePath.asm | 107 +++++ Driver/Font/TrueType/truetypeVariable.def | 97 +++++ Driver/Font/TrueType/truetypeWidths.asm | 69 ++++ Include/fontID.def | 1 + Installed/Driver/Font/TrueType/Makefile | 30 ++ .../Driver/Font/TrueType/dependencies.mk | 15 + 17 files changed, 1448 insertions(+) create mode 100644 Driver/Font/TrueType/local.mk create mode 100644 Driver/Font/TrueType/truetype.asm create mode 100644 Driver/Font/TrueType/truetype.gp create mode 100644 Driver/Font/TrueType/truetype.rev create mode 100644 Driver/Font/TrueType/truetypeChars.asm create mode 100644 Driver/Font/TrueType/truetypeConstant.def create mode 100644 Driver/Font/TrueType/truetypeEC.asm create mode 100644 Driver/Font/TrueType/truetypeEscape.asm create mode 100644 Driver/Font/TrueType/truetypeInit.asm create mode 100644 Driver/Font/TrueType/truetypeMacros.def create mode 100644 Driver/Font/TrueType/truetypeMetrics.asm create mode 100644 Driver/Font/TrueType/truetypePath.asm create mode 100644 Driver/Font/TrueType/truetypeVariable.def create mode 100644 Driver/Font/TrueType/truetypeWidths.asm create mode 100644 Installed/Driver/Font/TrueType/Makefile create mode 100644 Installed/Driver/Font/TrueType/dependencies.mk diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk new file mode 100644 index 000000000..425ed4422 --- /dev/null +++ b/Driver/Font/TrueType/local.mk @@ -0,0 +1,20 @@ +############################################################################## +# +# Copyright (c) GeoWorks 1992 -- All Rights Reserved +# +# PROJECT: PC/GEOS +# MODULE: TrueType Driver -- special definitions +# FILE: local.mk +# AUTHOR: Gene Anderson +# +# DESCRIPTION: +# Special definitions required for the TrueType font driver +# +# $Id: local.mk,v 1.1 97/04/18 11:45:28 newdeal Exp $ +# +############################################################################### +ASMFLAGS += -i + +.PATH.asm .PATH.def: ../FontCom $(INSTALL_DIR:H)/FontCom \ + +#include <$(SYSMAKEFILE)> diff --git a/Driver/Font/TrueType/truetype.asm b/Driver/Font/TrueType/truetype.asm new file mode 100644 index 000000000..5101133c2 --- /dev/null +++ b/Driver/Font/TrueType/truetype.asm @@ -0,0 +1,236 @@ +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetype.asm + +AUTHOR: Gene Anderson + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Gene 11/03/89 Initial revision + +DESCRIPTION: + This file implements a font driver using TrueType. + + $Id: truetype.asm,v 1.1 97/04/18 11:45:30 newdeal Exp $ + +------------------------------------------------------------------------------@ + + +;------------------------------------------------------------------------------ +; System Definition +;------------------------------------------------------------------------------ + +_Driver = 1 +_FontDriver = 1 + +;------------------------------------------------------------------------------ +; Include files +;------------------------------------------------------------------------------ + +include geos.def +include heap.def +include geode.def +include resource.def +include ec.def +include driver.def +include graphics.def +include gstring.def +include sem.def +include file.def +include lmem.def +include font.def +include localize.def +include char.def +include system.def + +include fileEnum.def + +DefDriver Internal/fontDr.def +include Internal/tmatrix.def +include Internal/grWinInt.def +include Internal/gstate.def +include Internal/window.def +include Internal/threadIn.def + + + + + +; Font Driver specific include files +; +include truetypeConstant.def ; constants used for font driver +include truetypeVariable.def ; Variables + + +idata segment + +; Driver information table +; +DriverTable FontDriverInfoStruct < + , DRIVER_TYPE_FONT>, + FM_TRUETYPE ; FDIS_maker +> + +ForceRef DriverTable + +idata ends + +include truetypeMacros.def + +WidthMod segment resource +include truetypeWidths.asm +;include nimbusUtils.asm +;include nimbusSetTrans.asm +include fontcomUtils.asm +WidthMod ends + +CharMod segment resource +include truetypeChars.asm +;include nimbusRegions.asm +;include nimbusLoadFont.asm +;include nimbusBig.asm +;include nimbusBitmap.asm +NimbusStart label near +;include nimbusMakechar.asm +;include nimbusSegments.asm +;include nimbusTrans.asm +;include nimbusMul.asm +;include nimbusContinuity.asm +AA_NIMBUS_SIZE equ $-NimbusStart +CharMod ends + +MetricsMod segment resource +include truetypeMetrics.asm +include truetypePath.asm +MetricsMod ends + +InitMod segment resource +include truetypeInit.asm +include truetypeEscape.asm +include fontcomEscape.asm +InitMod ends + +include truetypeEC.asm + +Resident segment resource ;MODULE_FIXED + + +COMMENT }---------------------------------------------------------------------- + +FUNCTION: TrueTypeStrategy + +DESCRIPTION: Entry point for driver. All access to devices performed + through this function + +CALLED BY: EXTERNAL + +PASS: + di - one of the following function codes: + Function # routine called Function + ---------- -------------- -------- + DR_INIT NimbusInit initialize + DR_EXIT NimbusExit exit + DR_FONT_GEN_CHAR NimbusGenChar generate one char + DR_FONT_GEN_WIDTHS NimbusGenWidths generate char widths + DR_FONT_CHAR_METRICS NimbusCharMetrics return character metrics + DR_FONT_INIT_FONTS NimbusInitFonts init non-GEOS fonts + DR_FONT_GEN_PATH NimbusGenPath generate outline path + DR_FONT_GEN_IN_REGION NimbusGenInRegion gen in passed region + +RETURN: + depends on function called + carry - set if error + +DESTROYED: + depends on function called + +REGISTER/STACK USAGE: + +PSEUDO CODE/STRATEGY: + Calls routine from jump table + +KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Gene 5/89 modified for font driver + +------------------------------------------------------------------------------} + + +EC + +TrueTypeStrategy proc far + +EC < tst cs:[inDriverFlag] > +EC < ERROR_NZ RECURSIVE_CALL_TO_FONT_DRIVER > +EC < inc cs:[inDriverFlag] > + + tst di ;escape function (>=0x8000) ? + js escapeFunction ;branch if escape function + + push bx +EC < cmp di, (size offTable) ;> +EC < ERROR_AE FONT_BAD_ROUTINE ;> + mov ax, cs:offTable[di] ;ax <- addr of routine in module + mov bx, cs:hanTable[di] ;bx <- handle of module + pop di ;pass old bx in di + tst bx ; function supported? + jz ignoreCall ; => no (carry clear) + call ProcCallModuleRoutine +callComplete: +EC < mov cs:[inDriverFlag],0 > +done: +EC < call ECNukeVariableBlock ;> + ret + +ignoreCall: + mov bx, di + jmp callComplete + + ; + ; The function is an escape function, so we deal with it specially + ; +escapeFunction: + call TrueTypeFontEscape + jmp done + +;---------------------------- + +TrueTypeStrategy endp + +offTable nptr \ + offset TrueTypeInit, ;DR_INIT + offset TrueTypeExit, ;DR_EXIT + 0, ;DR_SUSPEND + 0, ;DR_UNSUSPEND + offset TrueTypeGenChar, ;DR_FONT_GEN_CHAR + offset TrueTypeGenWidths, ;DR_FONT_GEN_WIDTHS + offset TrueTypeCharMetrics, ;DR_FONT_CHAR_METRICS + offset TrueTypeInitFonts, ;DR_FONT_INIT_FONTS + offset TrueTypeGenPath, ;DR_FONT_GEN_PATH + offset TrueTypeGenInRegion ;DR_FONT_GEN_IN_REGION +hanTable hptr \ + handle InitMod, ;DR_INIT + handle InitMod, ;DR_EXIT + 0, ;DR_SUSPEND + 0, ;DR_UNSUSPEND + handle CharMod, ;DR_FONT_GEN_CHAR + handle WidthMod, ;DR_FONT_GEN_WIDTHS + handle MetricsMod, ;DR_FONT_CHAR_METRICS + handle InitMod, ;DR_FONT_INIT_FONTS + handle MetricsMod, ;DR_FONT_GEN_PATH + handle MetricsMod ;DR_FONT_GEN_IN_REGION + +CheckHack <(length offTable) eq (length hanTable)> + +Resident ends + + end diff --git a/Driver/Font/TrueType/truetype.gp b/Driver/Font/TrueType/truetype.gp new file mode 100644 index 000000000..7b23e0938 --- /dev/null +++ b/Driver/Font/TrueType/truetype.gp @@ -0,0 +1,45 @@ +############################################################################## +# +# Copyright (c) GeoWorks 1989 -- All Rights Reserved +# +# PROJECT: PC GEOS +# MODULE: TrueType Font Driver +# FILE: truetype.gp +# +# AUTHOR: Gene, 11/89 +# +# +# Parameters file for: truetype.geo +# +# $Id: truetype.gp,v 1.1 97/04/18 11:45:31 newdeal Exp $ +# +############################################################################## +# +# Specify permanent name first +# +name truetype.drvr +# +# Specify geode type +# +type driver, single +# +# Import kernel routine definitions +# +library geos +# +# Desktop-related things +# +longname "TrueType Font Driver" +tokenchars "FNTD" +tokenid 0 +usernotes "#FreeGEOS font driver to render TrueType fonts." +# +# Define resources other than standard discardable code +# +resource Resident fixed code read-only shared +resource InitMod code read-only shared discard-only + + +# +# XIP-enabled +# diff --git a/Driver/Font/TrueType/truetype.rev b/Driver/Font/TrueType/truetype.rev new file mode 100644 index 000000000..d5eeb408a --- /dev/null +++ b/Driver/Font/TrueType/truetype.rev @@ -0,0 +1,2 @@ +R 6.0.0.0 <15:25:40 Feb 10, 2004> <#FreeGEOS release> +P 1.0 diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/truetypeChars.asm new file mode 100644 index 000000000..4f5ecbdda --- /dev/null +++ b/Driver/Font/TrueType/truetypeChars.asm @@ -0,0 +1,62 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: RasterMod +FILE: truetypeChars.asm + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + This file contains routines for generating individual characters. + + $Id: truetypeChars.asm,v 1.1 97/04/18 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenChar +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate one character for a font. +CALLED BY: VidBuildChar (via TrueTypeStrategy) + +PASS: dx - character to build (Chars) + es - seg addr of font (locked) + bp - seg addr of gstate (locked) + GS_fontHandle - handle of font + GS_fontAttr - font attributes + ds - seg addr of font info block + +RETURN: es - seg addr of font (locked) (may have changed) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenChar proc far + uses ax, bx, cx, dx, ds, si, di, bp + .enter + + + .leave + stc ;indicate no error + ret +TrueTypeGenChar endp + + diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/truetypeConstant.def new file mode 100644 index 000000000..942764157 --- /dev/null +++ b/Driver/Font/TrueType/truetypeConstant.def @@ -0,0 +1,104 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeConstant.def + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 26/1/21 Initial revision + +DESCRIPTION: + Definitions, constants, etc needed for the PC/GEOS TrueType font driver + + $Id: truetypeConstant.def,v 1.1 21/01/26 11:45:25 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +;---------------------------------------------------------------------------- +; Font Style Factors +;---------------------------------------------------------------------------- + +SCRIPT_FACTOR_INT = 0 +SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 + +SUBSCRIPT_OFFSET_INT = 0 +SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below + +SUPERSCRIPT_OFFSET_INT = 0 +SUPERSCRIPT_OFFSET_FRAC = 0x6000 ;offset above + +BOLD_FACTOR_INT = 0x0001 +BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 + +ITALIC_FACTOR_INT = 0 +ITALIC_FACTOR_FRAC = 0x366A ;italic = tan(12) +NEG_ITALIC_FACTOR_INT = 0xffff +NEG_ITALIC_FACTOR_FRAC = 0xC996 ;italic = -tan(12) + +; +; Styles that affect the width of the character: +; +WIDTH_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_BOLD +; +; Styles that affect the transformation matrix used: +; +TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_ITALIC or \ + mask TS_BOLD + +;---------------------------------------------------------------------------- +; Miscellaneous constants +;---------------------------------------------------------------------------- + +DEFAULT_CHAR = '.' + +; +; These sizes are in pixels, not points, since that's what +; really matters for these cutoff points. +; +; Continuity checking is not done above: +; +MAX_CONTINUITY_SIZE = 30 +; +; Characters are stored as regions instead of bitmaps above: +; +MAX_BITMAP_SIZE = 125 +SCRIPT_SAFETY_SIZE = 10 + +TRUETYPE_BLOCK_SIZE equ 1024 ;initial block size + +;---------------------------------------------------------------------------- +; Region constants +;---------------------------------------------------------------------------- + +UNUSED_PER_LINE = 4 ;# of unused points / line + +;---------------------------------------------------------------------------- +; Font Errors +;---------------------------------------------------------------------------- + +if ERROR_CHECK + +FONT_BAD_CHAR_FLAG enum FatalErrors + +RECURSIVE_CALL_TO_FONT_DRIVER enum FatalErrors +; The TrueType driver is non-reentrant, so only one thread can be in the +; driver at a time. This may indicate a bug in the Font Manager. + +FONT_BAD_ROUTINE enum FatalErrors +; A bad function passed to the TrueType driver. The function passed in +; di must be in the FontFunction enumerated type. + +TRUETYPE_INTERNAL_ERROR enum FatalErrors + +endif + diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/truetypeEC.asm new file mode 100644 index 000000000..a87edeb5b --- /dev/null +++ b/Driver/Font/TrueType/truetypeEC.asm @@ -0,0 +1,99 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEC.asm +FILE: truetypeEC.asm + +AUTHOR: Falk Rehwagen, Jan 1, 2021 + +ROUTINES: + Name Description + ---- ----------- + ECNukeVariableBlock nuke variables so we don't inadvertently + re-use them + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Error checking code for TrueType driver + + $Id: truetypeEC.asm,v 1.1 21/01/24 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +if ERROR_CHECK + +CharMod segment resource + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ECNukeVariableBlock +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Nuke the TrueType variable block +CALLED BY: NimbusStrategy() + +PASS: none +RETURN: none +DESTROYED: none (flags preserved) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +ECNukeVariableBlock proc far + uses ax, bx, cx, di, es + .enter + + pushf + + ; + ; Lock the variable block + ; + mov ax, segment udata + mov es, ax ;es <- seg addr of idata + mov bx, es:variableHandle ;bx <- handle of vars + tst bx ;block freed? + jz done ;branch if freed + call MemLock + jc done ;branch if discarded + mov es, ax ;es <- seg addr of vars + ; + ; Zero the block + ; + clr al ;al <- byte to store + mov cx, (size TrueTypeVars) ;cx <- # of bytes + clr di ;es:di <- ptr to vars + rep stosb + ; + ; Nuke things we know are segments specially + ; + mov es:fontSegment, 0xa000 + mov es:gstateSegment, 0xa000 + mov es:infoSegment, 0xa000 + ; + ; All done... + ; + call MemUnlock +done: + + popf + + .leave + ret +ECNukeVariableBlock endp + + +CharMod ends + +endif + diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/truetypeEscape.asm new file mode 100644 index 000000000..3f3f33d6f --- /dev/null +++ b/Driver/Font/TrueType/truetypeEscape.asm @@ -0,0 +1,60 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEscape.asm +FILE: truetypeEscape.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeFontEscape handle any escape functions + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Code for handling driver escape functions + + $Id: truetypeEscape.asm,v 1.1 21/01/24 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeFontEscape +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Hand +CALLED BY: TrueTypeStrategy() + +PASS: di - escape function +RETURN: di - 0 if escape function not supported +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeFontEscape proc far + call FontCallEscape ;call general handling routine + ret +TrueTypeFontEscape endp + +;---------------------------------------------------------------------------- +; Escape Function Table +;---------------------------------------------------------------------------- + +DefEscapeTable 1 + +DefEscape FontQueryEscape, DRV_ESC_QUERY_ESC diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm new file mode 100644 index 000000000..37095323f --- /dev/null +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -0,0 +1,368 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Init +FILE: truetypeInit.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeInit initialize the TrueType font driver + TrueTypeExit clean up after TrueType font driver + TrueTypeInitFonts initialize any non-PC/GEOS fonts + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial revision + +DESCRIPTION: + Initialization & exit routines for TrueType font driver + + $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize the TrueType font driver. +CALLED BY: DR_INIT - TrueTypeStrategy + +PASS: none +RETURN: bitmapHandle - handle of block to use for bitmaps + bitmapSize - size of above block (0 at start) + variableHandle - handle of block containing variables + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + public TrueTypeInit +TrueTypeInit proc far + uses ax, bx, cx, si, di, ds, es + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + ; + ; First, we need a block of memory to use as a bitmap + ; for generating characters. We don't need to actually + ; allocate memory for it yet. + ; + mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:bitmapHandle, bx ;save handle of block + mov ds:bitmapSize, 0 ;no bytes yet + ; + ; We also need a block to use for variables. We don't + ; need it yet, either. + ; + mov ax, size TrueTypeVars ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:variableHandle, bx ;save handle of block + clc ;indicate no error + + .leave + ret +TrueTypeInit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeExit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Free up blocks used and exit the TrueType driver. +CALLED BY: DR_EXIT - TrueTypeStrategy + +PASS: bitmapHandle - handle of bitmap block + variableHandle - handle of variable block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeExit proc far + uses ax, bx, ds + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + mov bx, ds:bitmapHandle +EC < clr ds:bitmapHandle ;> + call MemFree ;done with bitmap block + mov bx, ds:variableHandle +EC < clr ds:variableHandle ;> + call MemFree ;done with variable block + clc ;indicate no error + + .leave + ret +TrueTypeExit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInitFonts +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize any non-GEOS fonts for the font driver. +CALLED BY: DR_FONT_INIT_FONTS - TrueTypeStrategy + +PASS: ds - seg addr of font info block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +initFontReturnAttr FileExtAttrDesc \ + , + + +TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp + + .enter + + ; + ; Enumerate files in SP_FONT + ; + call FilePushDir + mov ax, SP_FONT + call FileSetStandardPath + push ds + segmov ds, dgroup, ax + mov dx, offset truetypeDir + clr bx ; relative to CWD + call FileSetCurrentPath + pop ds + + ; + ; Lookup all .ttf files + sub sp, size FileEnumParams + mov bp, sp + ; GEOS datafiles + mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS + ; return longname + mov ss:[bp].FEP_returnAttrs.segment, cs + mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr + mov ss:[bp].FEP_returnSize, size FileLongName + mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED + ; callback sees all files + mov ss:[bp].FEP_matchAttrs.segment, 0 + + mov ss:[bp].FEP_skipCount, 0 + call FileEnum ; cx = # found, bx = handle + jc done ; error + jcxz done ; no files found + mov dx, ds ; ax = segment of font block + call MemLock ; ds:0 = first entry + mov ds, ax + mov si, 0 +fontLoop: + call ProcessFont + add si, size FileLongName + loop fontLoop + call MemFree ; free file block +done: + call FilePopDir + clc + .leave + ret + +TrueTypeInitFonts endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ProcessFont +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: initialize each font found + +CALLED BY: TrueTypeInitFonts + +PASS: ds:si - font file name (TTF) + dx - font block segment + +RETURN: dx - updated font block segment (may move) + +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 2/17/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +ProcessFont proc far + + uses ax, bx, cx, di, si, es, ds + +fontNameSeg local sptr push ds +fontNameOff local word push si +fontBlockSeg local sptr push dx +subTableHeader local TrueTypeSubTable +fontId local FontID +fontInfoChunk local word + + .enter +if 0 + ; + ; generate font id from file names first character for now + ; + clr ah + mov al, ds:[si] + add ax, FM_TRUETYPE + mov fontId, ax + + ; + ; open cached data file + ; + mov dx, si ; ds:dx = name + mov al, FILE_ACCESS_R or FILE_DENY_W + call FileOpen + jc done + + mov bx, ax ; file handle to bx + + segmov ds, ss + lea dx, subTableHeader + + mov al, 0 + + mov cx, size subTableHeader ; size to read + + call FileRead + jc doneClose + + + ; + ; create a new FontsAvailEntry + ; + mov ds, fontBlockSeg + mov ax, FONTS_AVAIL_HANDLE ; *ds:ax = chunk + clr bx ; insert at front + mov cx, size FontsAvailEntry ; cx = sizeof table entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + ; + ; fill in FontID + ; + mov si, ax + push si + mov si, ds:[si] ; ds:si = new FAE + mov ax, fontId + mov ds:[si].FAE_fontID, ax + ; + ; clear the name field because there is a font file for each font + ; rather than for each typeface (which this field is for) + ; + mov ds:[si].FAE_fileName, 0 + + ; + ; allocate a chunk for the FontInfo block + ; + mov cx, 1 ; font count + mov ax, size OutlineDataEntry + mul cx ; dx:ax = size +EC < tst dx > +EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > + mov cx, ax + add cx, size FontInfo + mov dx, cx ; save size for later + clr ax + call LMemAlloc ; ds updated, ax = chunk + mov fontBlockSeg, ds ; store it + mov fontInfoChunk, ax + ; + ; finish filling the FontsAvailEntry + ; dx = end of OutlineDataEntrys + ; + pop si ; *ds:si = FontsAvailEntry + mov si, ds:[si] ; ds:si = FontsAvailEntry + mov ds:[si].FAE_infoHandle, ax ; save FontInfo chunk handle + + ; + ; now fill in the FontInfo struct + ; dx = end of OutlineDataEntrys + ; + mov di, ax ; *ds:di = FontInfo + mov si, ds:[di] ; ds:si = FontInfo + mov ds:[si].FI_fileHandle, 0 ; not used + mov ax, fontId + mov ds:[si].FI_fontID, ax + mov ds:[si].FI_maker, FM_TRUETYPE + mov al, es:[FFLH_fontFamily] + mov ds:[si].FI_family, al + mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? + mov ds:[si].FI_pointSizeEnd, 0 + mov ds:[si].FI_outlineTab, size FontInfo + mov ds:[si].FI_outlineEnd, dx + ; + ; copy in the font face name + ; ds:si = FontInfo + ; es = FFLH + ; + push es, ds, si ; save FFLH, FontInfo + segxchg es, ds ; es:di = FI_faceName + mov di, si + add di, FI_faceName + mov si, offset FFLH_faceName ; ds:si = FFLH_faceName + mov cx, length FI_faceName ; dest. size + LocalCopyNString + LocalPrevChar esdi + mov ax, 0 + LocalPutChar esdi, ax ; ensure null term + pop es, ds, si ; restore FFLH, FontInfo + + +doneClose: + mov al, FILE_NO_ERRORS + call FileClose +endif +done: + .leave + + ret + +ProcessFont endp \ No newline at end of file diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/truetypeMacros.def new file mode 100644 index 000000000..02930d0ae --- /dev/null +++ b/Driver/Font/TrueType/truetypeMacros.def @@ -0,0 +1,70 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType +FILE: truetypeMacros.def + +AUTHOR: Falk Rehwagen, Jan 26, 2021 + +MACROS: + Name Description + ---- ----------- + Abs Absolute value of word + + TRUNC Truncate number + CEIL Get ceiling of number + ROUND Round number to integer + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/26/21 Initial revision + +DESCRIPTION: + Macros for the PC/GEOS TrueType font driver. + + $Id: truetypeMacros.def,v 1.1 21/01/26 11:45:27 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +; +; absolute value of integer +; +Abs macro int +local A_10 + tst int + jns A_10 + neg int +A_10: +endm + +; +;PASS: number in 16ths +;RETURN: floor(number), no fraction +; +TRUNC macro num + sar num, 1 + sar num, 1 + sar num, 1 + sar num, 1 +endm + +; +;PASS: number in 16ths +;RETURN: ceiling(number), no fraction +; +CEIL macro num + add num, FRACTION + TRUNC num +endm + +; +;PASS: number in 16ths +;RETURN: round(number), no fraction +; +ROUND macro num + add num, ONE_HALF + TRUNC num +endm diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/truetypeMetrics.asm new file mode 100644 index 000000000..647b96c0d --- /dev/null +++ b/Driver/Font/TrueType/truetypeMetrics.asm @@ -0,0 +1,63 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: MetricsMod +FILE: truetypeMetrics.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeCharMetrics Return character metric information. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial revision + +DESCRIPTION: + Routines for generating character metrics. + + $Id: truetypeMetrics.asm,v 1.1 97/04/18 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeCharMetrics +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Return character metrics information in document coords. +CALLED BY: DR_FONT_CHAR_METRICS - TrueTypeStrategy + +PASS: ds - seg addr of font info block + es - seg addr of GState + es:GS_fontAttr - font attributes + dx - character to get metrics of + cx - info to return (GCM_info) +RETURN: if GCMI_ROUNDED set: + dx - information (rounded) + else: + dx.ah - information (WBFixed) + carry - set if error (eg. data / font not available) +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeCharMetrics proc far + uses bx, cx, si, di, ds + .enter + + .leave + ret +TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/truetypePath.asm new file mode 100644 index 000000000..1b9950368 --- /dev/null +++ b/Driver/Font/TrueType/truetypePath.asm @@ -0,0 +1,107 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1991 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: GeoCalc +FILE: truetypePath.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenPath Generate path for character + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial revision + +DESCRIPTION: + Routines for generating graphics string of a character. + + $Id: truetypePath.asm,v 1.1 97/04/18 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenPath +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a path for the outline of a character +CALLED BY: DR_FONT_GEN_PATH (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in bx, locked) + dx - character to generate (Chars) + cl - FontGenPathFlags + FGPF_POSTSCRIPT - transform for use as Postscript + Type 1 or Type 3 font. + FGPF_SAVE_STATE - do save/restore for GState +RETURN: none +DESTROYED: ax, bx, di (on the way here) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenPath proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenPath endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenInRegion +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a character in the passed RegionPath +CALLED BY: DR_FONT_GEN_IN_REGION (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in BX) + dx - character to generate (Chars) + cx - RegionPath handle (locked) +RETURN: nothing +DESTROYED: ax, bx, di + +PSEUDO CODE/STRATEGY: + We want override some of the default functionality for + build a font's character. Essentially: + * Always build a character in a region + * Build this character in the passed region + + We accomplish this by: + 1) Find the character data + 2) Calculate/store the correct transformation + 3) Stuff in some new CharGenRouts + 4) Stuf in the pen position (in device coords) + 5) Go generate the character (via MakeBigCharInRegion) + +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/ 29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenInRegion proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenInRegion endp + + diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def new file mode 100644 index 000000000..6350bb8f8 --- /dev/null +++ b/Driver/Font/TrueType/truetypeVariable.def @@ -0,0 +1,97 @@ + +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeVariable.def + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Falk 11/6/89 Initial version + +DESCRIPTION: + initialized and unitialized variables for TrueType font driver + + $Id: nimbusVariable.def,v 1.1 97/04/18 11:45:28 newdeal Exp $ + +-----------------------------------------------------------------------------@ + + + +;------------------------------------------------------------------------------ +; Definition of variable block +;------------------------------------------------------------------------------ + +TrueTypeVars struct + +stackBot label byte +; +; The "stack" overlaps everything above this point +; + +x_offset sword ;x offset to create character +y_offset sword ;y offset to create character + +penPos Point <0, 0> ;pen position used for drawing + ;characters into a passed RegionPath + ;for NimbusGenInRegion(). +; +; Used to save passed variables: +; +genOffset word 0 ;offset of CharGenData +fontSegment word 0 ;seg addr of font +fontHandle hptr 0 ;handle of font +infoSegment word 0 ;seg addr of info block +gstateSegment word 0 ;seg addr of GState + +TrueTypeVars ends + +TrueTypeSubTable struct + TTST_scalerType dword + TTST_numTables word + TTST_searchRange word + TTST_entrySelector word + TTST_rangeShift word +TrueTypeSubTable ends + +TrueTypeTableHeader struct + TTTH_dword0 dword + TTTH_dword1 dword + TTTH_dword2 dword + TTTH_dword3 dword +TrueTypeTableHeader ends + + +;------------------------------------------------------------------------------ + +;------------------------------------------------------------------------------ +; Initialized variables +;------------------------------------------------------------------------------ + +idata segment + +if DBCS_PCGEOS +truetypeDir wchar 'TTF',0 +else +truetypeDir char 'TTF',0 +endif + +idata ends + +;------------------------------------------------------------------------------ +; Uninitialized varaibles +;------------------------------------------------------------------------------ + +udata segment + +bitmapHandle hptr ;handle of our bitmap block +bitmapSize word ;size of our bitmap block (in bytes) + +variableHandle hptr ;handle of our variable block + +udata ends + + diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/truetypeWidths.asm new file mode 100644 index 000000000..df274e67b --- /dev/null +++ b/Driver/Font/TrueType/truetypeWidths.asm @@ -0,0 +1,69 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType Font Driver +FILE: truetypeWidths.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenWidths Generate font header and widths for a font. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + Implements a font driver for: + The TrueType outline fonts + + $Id: truetypeWidths.asm,v 1.1 97/04/18 11:45:30 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenWidths +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate the character width table for a font. +CALLED BY: EXTERNAL: GrFindFont + +PASS: di - 0 for new font; handle to rebuild old font (P'd) + es - seg addr of gstate (locked) + GS_fontAttr - font attributes + bp:cx - transformation matrix (TMatrix) + ds - seg addr of font info block +RETURN: bx - handle of font (locked) + ax - seg addr of font (locked) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + di is the bx passed to TrueTypeStrategy. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenWidths proc far + uses cx, dx, si, di, ds, es, bp + + mov bx, bp + .enter + + clc ;indicate no error + + .leave + ret +TrueTypeGenWidths endp diff --git a/Include/fontID.def b/Include/fontID.def index cd15cf3dd..df671c2ee 100644 --- a/Include/fontID.def +++ b/Include/fontID.def @@ -33,6 +33,7 @@ FM_NIMBUSQ enum FontMaker FM_ADOBE enum FontMaker FM_BITSTREAM enum FontMaker FM_AGFA enum FontMaker +FM_TRUETYPE enum FontMaker FM_PUBLIC enum FontMaker, 0xc000 FM_ATECH enum FontMaker, 0xd000 FM_MICROLOGIC enum FontMaker, 0xe000 diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile new file mode 100644 index 000000000..44877a5af --- /dev/null +++ b/Installed/Driver/Font/TrueType/Makefile @@ -0,0 +1,30 @@ +# +# THIS FILE HAS BEEN GENERATED AUTOMATICALLY. +# +# If you edit it, you will lose your changes, should it be regenerated. +# +GEODE = truetype +ASM_TO_OBJS = truetype.asm +UI_TO_RDFS = +SRCS = truetype.asm truetypeChars.asm truetypeEC.asm\ + truetypeEscape.asm truetypeInit.asm truetypeMetrics.asm\ + truetypePath.asm truetypeWidths.asm fontcomUtils.asm\ + fontcomEscape.asm truetypeConstant.def truetypeMacros.def\ + truetypeVariable.def +OBJS = truetype.obj +LOBJS = + +SYSMAKEFILE = geode.mk + +#include +#include + +#if exists(local.mk) +#include "local.mk" +#else +#include <$(SYSMAKEFILE)> +#endif + +#if exists($(DEPFILE)) +#include "$(DEPFILE)" +#endif diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk new file mode 100644 index 000000000..52a9a0fe3 --- /dev/null +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -0,0 +1,15 @@ +truetype.obj \ +truetype.eobj: geos.def heap.def geode.def resource.def ec.def driver.def \ + lmem.def graphics.def fontID.def font.def color.def \ + gstring.def text.def char.def sem.def file.def \ + localize.def sllang.def system.def fileEnum.def \ + Internal/fontDr.def Internal/tmatrix.def \ + Internal/grWinInt.def Internal/gstate.def \ + Internal/window.def win.def Internal/threadIn.def \ + truetypeConstant.def truetypeVariable.def \ + truetypeMacros.def truetypeWidths.asm fontcomUtils.asm \ + truetypeChars.asm truetypeMetrics.asm truetypePath.asm \ + truetypeInit.asm truetypeEscape.asm fontcomEscape.asm \ + truetypeEC.asm + +truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file From bb56a5d87350f1486cdf0352b947c03933ea41a4 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Thu, 26 Aug 2021 00:11:36 +0200 Subject: [PATCH 002/246] Add TrueType fonr driver to the Ensemble build chain and the resulting Ensemble setup. #129 --- CInclude/fontID.h | 1 + Installed/Makefile | 5 ++++- Tools/build/product/bbxensem/Template/geos.ini | 5 +++++ Tools/build/product/bbxensem/bbxensem.filetree | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CInclude/fontID.h b/CInclude/fontID.h index 04a2a947c..78a721390 100644 --- a/CInclude/fontID.h +++ b/CInclude/fontID.h @@ -29,6 +29,7 @@ typedef word FontMaker; #define FM_MICROLOGIC 0xe000 #define FM_ATECH 0xd000 #define FM_PUBLIC 0xc000 +#define FM_TRUETYPE 0x5000 #define FM_AGFA 0x4000 #define FM_BITSTREAM 0x3000 #define FM_ADOBE 0x2000 diff --git a/Installed/Makefile b/Installed/Makefile index 1113182d0..7214dfbcb 100644 --- a/Installed/Makefile +++ b/Installed/Makefile @@ -165,7 +165,7 @@ minimalDriver : nimbus ms4 ntfat os2 cdrom stream dri gdi keyboard modem gdipoin ps2 msys msser msbus kbmouse absgen genmouse emm extmem \ xms filestr nonts sblaster comm spooltd \ vmtree filedd logibus logiser dma mslf kbd_drivers \ - etherodi etherpkt msnet cdados + etherodi etherpkt msnet cdados truetype printerDriver : deskjet dj500c lbp mercury pcl4 quietjet canon48 \ canonbjc epshi24 epson24 epson48 nec24 \ @@ -560,6 +560,9 @@ Installed/Driver/Stream: kernel MAKEDRV nimbus : Installed/Driver/Font/Nimbus Installed/Driver/Font/Nimbus: kernel MAKEDRV +truetype : Installed/Driver/Font/TrueType +Installed/Driver/Font/TrueType: kernel MAKEDRV + ms4 : Installed/Driver/IFS/DOS/MS4 Installed/Driver/IFS/DOS/MS4: kernel MAKEDRV diff --git a/Tools/build/product/bbxensem/Template/geos.ini b/Tools/build/product/bbxensem/Template/geos.ini index 1b6d97f26..c89e6a6ce 100644 --- a/Tools/build/product/bbxensem/Template/geos.ini +++ b/Tools/build/product/bbxensem/Template/geos.ini @@ -14,6 +14,11 @@ fontsize = 12 drive b = 0 editableTextFontID = Esquire +font = { + EC-dos(nimbus.geo) + EC-dos(truetype.geo) +} + [diskswap] size = 4096 diff --git a/Tools/build/product/bbxensem/bbxensem.filetree b/Tools/build/product/bbxensem/bbxensem.filetree index 42522c67f..b6ebcc538 100644 --- a/Tools/build/product/bbxensem/bbxensem.filetree +++ b/Tools/build/product/bbxensem/bbxensem.filetree @@ -422,6 +422,7 @@ DIR (ensemble) { DIR (font) { Driver/Font/Nimbus/{dbcs}/nimbus{ec}.geo GFS LOCALPC + Driver/Font/TrueType/{dbcs}/truetype{ec}.geo GFS LOCALPC } DIR (fs) { From 79303a38f9e81a5dde61354036769dacbc125f8f Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Sat, 28 Aug 2021 19:54:37 +0200 Subject: [PATCH 003/246] Make TrueType driver actually load and ttf file enumeration to start looking in the files header. #129 --- Driver/Font/TrueType/local.mk | 2 ++ Driver/Font/TrueType/truetypeInit.asm | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk index 425ed4422..d30315277 100644 --- a/Driver/Font/TrueType/local.mk +++ b/Driver/Font/TrueType/local.mk @@ -15,6 +15,8 @@ ############################################################################### ASMFLAGS += -i +_PROTO = 3.0 + .PATH.asm .PATH.def: ../FontCom $(INSTALL_DIR:H)/FontCom \ #include <$(SYSMAKEFILE)> diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm index 37095323f..9a1df5e44 100644 --- a/Driver/Font/TrueType/truetypeInit.asm +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -246,7 +246,6 @@ fontId local FontID fontInfoChunk local word .enter -if 0 ; ; generate font id from file names first character for now ; @@ -256,7 +255,7 @@ if 0 mov fontId, ax ; - ; open cached data file + ; open truetype file ; mov dx, si ; ds:dx = name mov al, FILE_ACCESS_R or FILE_DENY_W @@ -275,6 +274,7 @@ if 0 call FileRead jc doneClose +if 0 ; ; create a new FontsAvailEntry @@ -355,11 +355,11 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > LocalPutChar esdi, ax ; ensure null term pop es, ds, si ; restore FFLH, FontInfo +endif doneClose: mov al, FILE_NO_ERRORS call FileClose -endif done: .leave From 3c43c5521a57efa2525f1722044f00c3f19ab771 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Wed, 25 Aug 2021 19:07:51 +0200 Subject: [PATCH 004/246] Initial add of font driver for true type font renderings. --- Driver/Font/TrueType/local.mk | 20 + Driver/Font/TrueType/truetype.asm | 236 +++++++++++ Driver/Font/TrueType/truetype.gp | 45 +++ Driver/Font/TrueType/truetype.rev | 2 + Driver/Font/TrueType/truetypeChars.asm | 62 +++ Driver/Font/TrueType/truetypeConstant.def | 104 +++++ Driver/Font/TrueType/truetypeEC.asm | 99 +++++ Driver/Font/TrueType/truetypeEscape.asm | 60 +++ Driver/Font/TrueType/truetypeInit.asm | 368 ++++++++++++++++++ Driver/Font/TrueType/truetypeMacros.def | 70 ++++ Driver/Font/TrueType/truetypeMetrics.asm | 63 +++ Driver/Font/TrueType/truetypePath.asm | 107 +++++ Driver/Font/TrueType/truetypeVariable.def | 97 +++++ Driver/Font/TrueType/truetypeWidths.asm | 69 ++++ Include/fontID.def | 1 + Installed/Driver/Font/TrueType/Makefile | 30 ++ .../Driver/Font/TrueType/dependencies.mk | 15 + 17 files changed, 1448 insertions(+) create mode 100644 Driver/Font/TrueType/local.mk create mode 100644 Driver/Font/TrueType/truetype.asm create mode 100644 Driver/Font/TrueType/truetype.gp create mode 100644 Driver/Font/TrueType/truetype.rev create mode 100644 Driver/Font/TrueType/truetypeChars.asm create mode 100644 Driver/Font/TrueType/truetypeConstant.def create mode 100644 Driver/Font/TrueType/truetypeEC.asm create mode 100644 Driver/Font/TrueType/truetypeEscape.asm create mode 100644 Driver/Font/TrueType/truetypeInit.asm create mode 100644 Driver/Font/TrueType/truetypeMacros.def create mode 100644 Driver/Font/TrueType/truetypeMetrics.asm create mode 100644 Driver/Font/TrueType/truetypePath.asm create mode 100644 Driver/Font/TrueType/truetypeVariable.def create mode 100644 Driver/Font/TrueType/truetypeWidths.asm create mode 100644 Installed/Driver/Font/TrueType/Makefile create mode 100644 Installed/Driver/Font/TrueType/dependencies.mk diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk new file mode 100644 index 000000000..425ed4422 --- /dev/null +++ b/Driver/Font/TrueType/local.mk @@ -0,0 +1,20 @@ +############################################################################## +# +# Copyright (c) GeoWorks 1992 -- All Rights Reserved +# +# PROJECT: PC/GEOS +# MODULE: TrueType Driver -- special definitions +# FILE: local.mk +# AUTHOR: Gene Anderson +# +# DESCRIPTION: +# Special definitions required for the TrueType font driver +# +# $Id: local.mk,v 1.1 97/04/18 11:45:28 newdeal Exp $ +# +############################################################################### +ASMFLAGS += -i + +.PATH.asm .PATH.def: ../FontCom $(INSTALL_DIR:H)/FontCom \ + +#include <$(SYSMAKEFILE)> diff --git a/Driver/Font/TrueType/truetype.asm b/Driver/Font/TrueType/truetype.asm new file mode 100644 index 000000000..5101133c2 --- /dev/null +++ b/Driver/Font/TrueType/truetype.asm @@ -0,0 +1,236 @@ +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetype.asm + +AUTHOR: Gene Anderson + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Gene 11/03/89 Initial revision + +DESCRIPTION: + This file implements a font driver using TrueType. + + $Id: truetype.asm,v 1.1 97/04/18 11:45:30 newdeal Exp $ + +------------------------------------------------------------------------------@ + + +;------------------------------------------------------------------------------ +; System Definition +;------------------------------------------------------------------------------ + +_Driver = 1 +_FontDriver = 1 + +;------------------------------------------------------------------------------ +; Include files +;------------------------------------------------------------------------------ + +include geos.def +include heap.def +include geode.def +include resource.def +include ec.def +include driver.def +include graphics.def +include gstring.def +include sem.def +include file.def +include lmem.def +include font.def +include localize.def +include char.def +include system.def + +include fileEnum.def + +DefDriver Internal/fontDr.def +include Internal/tmatrix.def +include Internal/grWinInt.def +include Internal/gstate.def +include Internal/window.def +include Internal/threadIn.def + + + + + +; Font Driver specific include files +; +include truetypeConstant.def ; constants used for font driver +include truetypeVariable.def ; Variables + + +idata segment + +; Driver information table +; +DriverTable FontDriverInfoStruct < + , DRIVER_TYPE_FONT>, + FM_TRUETYPE ; FDIS_maker +> + +ForceRef DriverTable + +idata ends + +include truetypeMacros.def + +WidthMod segment resource +include truetypeWidths.asm +;include nimbusUtils.asm +;include nimbusSetTrans.asm +include fontcomUtils.asm +WidthMod ends + +CharMod segment resource +include truetypeChars.asm +;include nimbusRegions.asm +;include nimbusLoadFont.asm +;include nimbusBig.asm +;include nimbusBitmap.asm +NimbusStart label near +;include nimbusMakechar.asm +;include nimbusSegments.asm +;include nimbusTrans.asm +;include nimbusMul.asm +;include nimbusContinuity.asm +AA_NIMBUS_SIZE equ $-NimbusStart +CharMod ends + +MetricsMod segment resource +include truetypeMetrics.asm +include truetypePath.asm +MetricsMod ends + +InitMod segment resource +include truetypeInit.asm +include truetypeEscape.asm +include fontcomEscape.asm +InitMod ends + +include truetypeEC.asm + +Resident segment resource ;MODULE_FIXED + + +COMMENT }---------------------------------------------------------------------- + +FUNCTION: TrueTypeStrategy + +DESCRIPTION: Entry point for driver. All access to devices performed + through this function + +CALLED BY: EXTERNAL + +PASS: + di - one of the following function codes: + Function # routine called Function + ---------- -------------- -------- + DR_INIT NimbusInit initialize + DR_EXIT NimbusExit exit + DR_FONT_GEN_CHAR NimbusGenChar generate one char + DR_FONT_GEN_WIDTHS NimbusGenWidths generate char widths + DR_FONT_CHAR_METRICS NimbusCharMetrics return character metrics + DR_FONT_INIT_FONTS NimbusInitFonts init non-GEOS fonts + DR_FONT_GEN_PATH NimbusGenPath generate outline path + DR_FONT_GEN_IN_REGION NimbusGenInRegion gen in passed region + +RETURN: + depends on function called + carry - set if error + +DESTROYED: + depends on function called + +REGISTER/STACK USAGE: + +PSEUDO CODE/STRATEGY: + Calls routine from jump table + +KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Gene 5/89 modified for font driver + +------------------------------------------------------------------------------} + + +EC + +TrueTypeStrategy proc far + +EC < tst cs:[inDriverFlag] > +EC < ERROR_NZ RECURSIVE_CALL_TO_FONT_DRIVER > +EC < inc cs:[inDriverFlag] > + + tst di ;escape function (>=0x8000) ? + js escapeFunction ;branch if escape function + + push bx +EC < cmp di, (size offTable) ;> +EC < ERROR_AE FONT_BAD_ROUTINE ;> + mov ax, cs:offTable[di] ;ax <- addr of routine in module + mov bx, cs:hanTable[di] ;bx <- handle of module + pop di ;pass old bx in di + tst bx ; function supported? + jz ignoreCall ; => no (carry clear) + call ProcCallModuleRoutine +callComplete: +EC < mov cs:[inDriverFlag],0 > +done: +EC < call ECNukeVariableBlock ;> + ret + +ignoreCall: + mov bx, di + jmp callComplete + + ; + ; The function is an escape function, so we deal with it specially + ; +escapeFunction: + call TrueTypeFontEscape + jmp done + +;---------------------------- + +TrueTypeStrategy endp + +offTable nptr \ + offset TrueTypeInit, ;DR_INIT + offset TrueTypeExit, ;DR_EXIT + 0, ;DR_SUSPEND + 0, ;DR_UNSUSPEND + offset TrueTypeGenChar, ;DR_FONT_GEN_CHAR + offset TrueTypeGenWidths, ;DR_FONT_GEN_WIDTHS + offset TrueTypeCharMetrics, ;DR_FONT_CHAR_METRICS + offset TrueTypeInitFonts, ;DR_FONT_INIT_FONTS + offset TrueTypeGenPath, ;DR_FONT_GEN_PATH + offset TrueTypeGenInRegion ;DR_FONT_GEN_IN_REGION +hanTable hptr \ + handle InitMod, ;DR_INIT + handle InitMod, ;DR_EXIT + 0, ;DR_SUSPEND + 0, ;DR_UNSUSPEND + handle CharMod, ;DR_FONT_GEN_CHAR + handle WidthMod, ;DR_FONT_GEN_WIDTHS + handle MetricsMod, ;DR_FONT_CHAR_METRICS + handle InitMod, ;DR_FONT_INIT_FONTS + handle MetricsMod, ;DR_FONT_GEN_PATH + handle MetricsMod ;DR_FONT_GEN_IN_REGION + +CheckHack <(length offTable) eq (length hanTable)> + +Resident ends + + end diff --git a/Driver/Font/TrueType/truetype.gp b/Driver/Font/TrueType/truetype.gp new file mode 100644 index 000000000..7b23e0938 --- /dev/null +++ b/Driver/Font/TrueType/truetype.gp @@ -0,0 +1,45 @@ +############################################################################## +# +# Copyright (c) GeoWorks 1989 -- All Rights Reserved +# +# PROJECT: PC GEOS +# MODULE: TrueType Font Driver +# FILE: truetype.gp +# +# AUTHOR: Gene, 11/89 +# +# +# Parameters file for: truetype.geo +# +# $Id: truetype.gp,v 1.1 97/04/18 11:45:31 newdeal Exp $ +# +############################################################################## +# +# Specify permanent name first +# +name truetype.drvr +# +# Specify geode type +# +type driver, single +# +# Import kernel routine definitions +# +library geos +# +# Desktop-related things +# +longname "TrueType Font Driver" +tokenchars "FNTD" +tokenid 0 +usernotes "#FreeGEOS font driver to render TrueType fonts." +# +# Define resources other than standard discardable code +# +resource Resident fixed code read-only shared +resource InitMod code read-only shared discard-only + + +# +# XIP-enabled +# diff --git a/Driver/Font/TrueType/truetype.rev b/Driver/Font/TrueType/truetype.rev new file mode 100644 index 000000000..d5eeb408a --- /dev/null +++ b/Driver/Font/TrueType/truetype.rev @@ -0,0 +1,2 @@ +R 6.0.0.0 <15:25:40 Feb 10, 2004> <#FreeGEOS release> +P 1.0 diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/truetypeChars.asm new file mode 100644 index 000000000..4f5ecbdda --- /dev/null +++ b/Driver/Font/TrueType/truetypeChars.asm @@ -0,0 +1,62 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: RasterMod +FILE: truetypeChars.asm + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + This file contains routines for generating individual characters. + + $Id: truetypeChars.asm,v 1.1 97/04/18 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenChar +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate one character for a font. +CALLED BY: VidBuildChar (via TrueTypeStrategy) + +PASS: dx - character to build (Chars) + es - seg addr of font (locked) + bp - seg addr of gstate (locked) + GS_fontHandle - handle of font + GS_fontAttr - font attributes + ds - seg addr of font info block + +RETURN: es - seg addr of font (locked) (may have changed) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenChar proc far + uses ax, bx, cx, dx, ds, si, di, bp + .enter + + + .leave + stc ;indicate no error + ret +TrueTypeGenChar endp + + diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/truetypeConstant.def new file mode 100644 index 000000000..942764157 --- /dev/null +++ b/Driver/Font/TrueType/truetypeConstant.def @@ -0,0 +1,104 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeConstant.def + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 26/1/21 Initial revision + +DESCRIPTION: + Definitions, constants, etc needed for the PC/GEOS TrueType font driver + + $Id: truetypeConstant.def,v 1.1 21/01/26 11:45:25 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +;---------------------------------------------------------------------------- +; Font Style Factors +;---------------------------------------------------------------------------- + +SCRIPT_FACTOR_INT = 0 +SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 + +SUBSCRIPT_OFFSET_INT = 0 +SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below + +SUPERSCRIPT_OFFSET_INT = 0 +SUPERSCRIPT_OFFSET_FRAC = 0x6000 ;offset above + +BOLD_FACTOR_INT = 0x0001 +BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 + +ITALIC_FACTOR_INT = 0 +ITALIC_FACTOR_FRAC = 0x366A ;italic = tan(12) +NEG_ITALIC_FACTOR_INT = 0xffff +NEG_ITALIC_FACTOR_FRAC = 0xC996 ;italic = -tan(12) + +; +; Styles that affect the width of the character: +; +WIDTH_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_BOLD +; +; Styles that affect the transformation matrix used: +; +TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_ITALIC or \ + mask TS_BOLD + +;---------------------------------------------------------------------------- +; Miscellaneous constants +;---------------------------------------------------------------------------- + +DEFAULT_CHAR = '.' + +; +; These sizes are in pixels, not points, since that's what +; really matters for these cutoff points. +; +; Continuity checking is not done above: +; +MAX_CONTINUITY_SIZE = 30 +; +; Characters are stored as regions instead of bitmaps above: +; +MAX_BITMAP_SIZE = 125 +SCRIPT_SAFETY_SIZE = 10 + +TRUETYPE_BLOCK_SIZE equ 1024 ;initial block size + +;---------------------------------------------------------------------------- +; Region constants +;---------------------------------------------------------------------------- + +UNUSED_PER_LINE = 4 ;# of unused points / line + +;---------------------------------------------------------------------------- +; Font Errors +;---------------------------------------------------------------------------- + +if ERROR_CHECK + +FONT_BAD_CHAR_FLAG enum FatalErrors + +RECURSIVE_CALL_TO_FONT_DRIVER enum FatalErrors +; The TrueType driver is non-reentrant, so only one thread can be in the +; driver at a time. This may indicate a bug in the Font Manager. + +FONT_BAD_ROUTINE enum FatalErrors +; A bad function passed to the TrueType driver. The function passed in +; di must be in the FontFunction enumerated type. + +TRUETYPE_INTERNAL_ERROR enum FatalErrors + +endif + diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/truetypeEC.asm new file mode 100644 index 000000000..a87edeb5b --- /dev/null +++ b/Driver/Font/TrueType/truetypeEC.asm @@ -0,0 +1,99 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEC.asm +FILE: truetypeEC.asm + +AUTHOR: Falk Rehwagen, Jan 1, 2021 + +ROUTINES: + Name Description + ---- ----------- + ECNukeVariableBlock nuke variables so we don't inadvertently + re-use them + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Error checking code for TrueType driver + + $Id: truetypeEC.asm,v 1.1 21/01/24 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +if ERROR_CHECK + +CharMod segment resource + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ECNukeVariableBlock +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Nuke the TrueType variable block +CALLED BY: NimbusStrategy() + +PASS: none +RETURN: none +DESTROYED: none (flags preserved) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +ECNukeVariableBlock proc far + uses ax, bx, cx, di, es + .enter + + pushf + + ; + ; Lock the variable block + ; + mov ax, segment udata + mov es, ax ;es <- seg addr of idata + mov bx, es:variableHandle ;bx <- handle of vars + tst bx ;block freed? + jz done ;branch if freed + call MemLock + jc done ;branch if discarded + mov es, ax ;es <- seg addr of vars + ; + ; Zero the block + ; + clr al ;al <- byte to store + mov cx, (size TrueTypeVars) ;cx <- # of bytes + clr di ;es:di <- ptr to vars + rep stosb + ; + ; Nuke things we know are segments specially + ; + mov es:fontSegment, 0xa000 + mov es:gstateSegment, 0xa000 + mov es:infoSegment, 0xa000 + ; + ; All done... + ; + call MemUnlock +done: + + popf + + .leave + ret +ECNukeVariableBlock endp + + +CharMod ends + +endif + diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/truetypeEscape.asm new file mode 100644 index 000000000..3f3f33d6f --- /dev/null +++ b/Driver/Font/TrueType/truetypeEscape.asm @@ -0,0 +1,60 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEscape.asm +FILE: truetypeEscape.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeFontEscape handle any escape functions + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Code for handling driver escape functions + + $Id: truetypeEscape.asm,v 1.1 21/01/24 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeFontEscape +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Hand +CALLED BY: TrueTypeStrategy() + +PASS: di - escape function +RETURN: di - 0 if escape function not supported +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeFontEscape proc far + call FontCallEscape ;call general handling routine + ret +TrueTypeFontEscape endp + +;---------------------------------------------------------------------------- +; Escape Function Table +;---------------------------------------------------------------------------- + +DefEscapeTable 1 + +DefEscape FontQueryEscape, DRV_ESC_QUERY_ESC diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm new file mode 100644 index 000000000..37095323f --- /dev/null +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -0,0 +1,368 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Init +FILE: truetypeInit.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeInit initialize the TrueType font driver + TrueTypeExit clean up after TrueType font driver + TrueTypeInitFonts initialize any non-PC/GEOS fonts + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial revision + +DESCRIPTION: + Initialization & exit routines for TrueType font driver + + $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize the TrueType font driver. +CALLED BY: DR_INIT - TrueTypeStrategy + +PASS: none +RETURN: bitmapHandle - handle of block to use for bitmaps + bitmapSize - size of above block (0 at start) + variableHandle - handle of block containing variables + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + public TrueTypeInit +TrueTypeInit proc far + uses ax, bx, cx, si, di, ds, es + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + ; + ; First, we need a block of memory to use as a bitmap + ; for generating characters. We don't need to actually + ; allocate memory for it yet. + ; + mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:bitmapHandle, bx ;save handle of block + mov ds:bitmapSize, 0 ;no bytes yet + ; + ; We also need a block to use for variables. We don't + ; need it yet, either. + ; + mov ax, size TrueTypeVars ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:variableHandle, bx ;save handle of block + clc ;indicate no error + + .leave + ret +TrueTypeInit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeExit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Free up blocks used and exit the TrueType driver. +CALLED BY: DR_EXIT - TrueTypeStrategy + +PASS: bitmapHandle - handle of bitmap block + variableHandle - handle of variable block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeExit proc far + uses ax, bx, ds + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + mov bx, ds:bitmapHandle +EC < clr ds:bitmapHandle ;> + call MemFree ;done with bitmap block + mov bx, ds:variableHandle +EC < clr ds:variableHandle ;> + call MemFree ;done with variable block + clc ;indicate no error + + .leave + ret +TrueTypeExit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInitFonts +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize any non-GEOS fonts for the font driver. +CALLED BY: DR_FONT_INIT_FONTS - TrueTypeStrategy + +PASS: ds - seg addr of font info block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +initFontReturnAttr FileExtAttrDesc \ + , + + +TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp + + .enter + + ; + ; Enumerate files in SP_FONT + ; + call FilePushDir + mov ax, SP_FONT + call FileSetStandardPath + push ds + segmov ds, dgroup, ax + mov dx, offset truetypeDir + clr bx ; relative to CWD + call FileSetCurrentPath + pop ds + + ; + ; Lookup all .ttf files + sub sp, size FileEnumParams + mov bp, sp + ; GEOS datafiles + mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS + ; return longname + mov ss:[bp].FEP_returnAttrs.segment, cs + mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr + mov ss:[bp].FEP_returnSize, size FileLongName + mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED + ; callback sees all files + mov ss:[bp].FEP_matchAttrs.segment, 0 + + mov ss:[bp].FEP_skipCount, 0 + call FileEnum ; cx = # found, bx = handle + jc done ; error + jcxz done ; no files found + mov dx, ds ; ax = segment of font block + call MemLock ; ds:0 = first entry + mov ds, ax + mov si, 0 +fontLoop: + call ProcessFont + add si, size FileLongName + loop fontLoop + call MemFree ; free file block +done: + call FilePopDir + clc + .leave + ret + +TrueTypeInitFonts endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ProcessFont +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: initialize each font found + +CALLED BY: TrueTypeInitFonts + +PASS: ds:si - font file name (TTF) + dx - font block segment + +RETURN: dx - updated font block segment (may move) + +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 2/17/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +ProcessFont proc far + + uses ax, bx, cx, di, si, es, ds + +fontNameSeg local sptr push ds +fontNameOff local word push si +fontBlockSeg local sptr push dx +subTableHeader local TrueTypeSubTable +fontId local FontID +fontInfoChunk local word + + .enter +if 0 + ; + ; generate font id from file names first character for now + ; + clr ah + mov al, ds:[si] + add ax, FM_TRUETYPE + mov fontId, ax + + ; + ; open cached data file + ; + mov dx, si ; ds:dx = name + mov al, FILE_ACCESS_R or FILE_DENY_W + call FileOpen + jc done + + mov bx, ax ; file handle to bx + + segmov ds, ss + lea dx, subTableHeader + + mov al, 0 + + mov cx, size subTableHeader ; size to read + + call FileRead + jc doneClose + + + ; + ; create a new FontsAvailEntry + ; + mov ds, fontBlockSeg + mov ax, FONTS_AVAIL_HANDLE ; *ds:ax = chunk + clr bx ; insert at front + mov cx, size FontsAvailEntry ; cx = sizeof table entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + ; + ; fill in FontID + ; + mov si, ax + push si + mov si, ds:[si] ; ds:si = new FAE + mov ax, fontId + mov ds:[si].FAE_fontID, ax + ; + ; clear the name field because there is a font file for each font + ; rather than for each typeface (which this field is for) + ; + mov ds:[si].FAE_fileName, 0 + + ; + ; allocate a chunk for the FontInfo block + ; + mov cx, 1 ; font count + mov ax, size OutlineDataEntry + mul cx ; dx:ax = size +EC < tst dx > +EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > + mov cx, ax + add cx, size FontInfo + mov dx, cx ; save size for later + clr ax + call LMemAlloc ; ds updated, ax = chunk + mov fontBlockSeg, ds ; store it + mov fontInfoChunk, ax + ; + ; finish filling the FontsAvailEntry + ; dx = end of OutlineDataEntrys + ; + pop si ; *ds:si = FontsAvailEntry + mov si, ds:[si] ; ds:si = FontsAvailEntry + mov ds:[si].FAE_infoHandle, ax ; save FontInfo chunk handle + + ; + ; now fill in the FontInfo struct + ; dx = end of OutlineDataEntrys + ; + mov di, ax ; *ds:di = FontInfo + mov si, ds:[di] ; ds:si = FontInfo + mov ds:[si].FI_fileHandle, 0 ; not used + mov ax, fontId + mov ds:[si].FI_fontID, ax + mov ds:[si].FI_maker, FM_TRUETYPE + mov al, es:[FFLH_fontFamily] + mov ds:[si].FI_family, al + mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? + mov ds:[si].FI_pointSizeEnd, 0 + mov ds:[si].FI_outlineTab, size FontInfo + mov ds:[si].FI_outlineEnd, dx + ; + ; copy in the font face name + ; ds:si = FontInfo + ; es = FFLH + ; + push es, ds, si ; save FFLH, FontInfo + segxchg es, ds ; es:di = FI_faceName + mov di, si + add di, FI_faceName + mov si, offset FFLH_faceName ; ds:si = FFLH_faceName + mov cx, length FI_faceName ; dest. size + LocalCopyNString + LocalPrevChar esdi + mov ax, 0 + LocalPutChar esdi, ax ; ensure null term + pop es, ds, si ; restore FFLH, FontInfo + + +doneClose: + mov al, FILE_NO_ERRORS + call FileClose +endif +done: + .leave + + ret + +ProcessFont endp \ No newline at end of file diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/truetypeMacros.def new file mode 100644 index 000000000..02930d0ae --- /dev/null +++ b/Driver/Font/TrueType/truetypeMacros.def @@ -0,0 +1,70 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType +FILE: truetypeMacros.def + +AUTHOR: Falk Rehwagen, Jan 26, 2021 + +MACROS: + Name Description + ---- ----------- + Abs Absolute value of word + + TRUNC Truncate number + CEIL Get ceiling of number + ROUND Round number to integer + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/26/21 Initial revision + +DESCRIPTION: + Macros for the PC/GEOS TrueType font driver. + + $Id: truetypeMacros.def,v 1.1 21/01/26 11:45:27 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +; +; absolute value of integer +; +Abs macro int +local A_10 + tst int + jns A_10 + neg int +A_10: +endm + +; +;PASS: number in 16ths +;RETURN: floor(number), no fraction +; +TRUNC macro num + sar num, 1 + sar num, 1 + sar num, 1 + sar num, 1 +endm + +; +;PASS: number in 16ths +;RETURN: ceiling(number), no fraction +; +CEIL macro num + add num, FRACTION + TRUNC num +endm + +; +;PASS: number in 16ths +;RETURN: round(number), no fraction +; +ROUND macro num + add num, ONE_HALF + TRUNC num +endm diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/truetypeMetrics.asm new file mode 100644 index 000000000..647b96c0d --- /dev/null +++ b/Driver/Font/TrueType/truetypeMetrics.asm @@ -0,0 +1,63 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: MetricsMod +FILE: truetypeMetrics.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeCharMetrics Return character metric information. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial revision + +DESCRIPTION: + Routines for generating character metrics. + + $Id: truetypeMetrics.asm,v 1.1 97/04/18 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeCharMetrics +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Return character metrics information in document coords. +CALLED BY: DR_FONT_CHAR_METRICS - TrueTypeStrategy + +PASS: ds - seg addr of font info block + es - seg addr of GState + es:GS_fontAttr - font attributes + dx - character to get metrics of + cx - info to return (GCM_info) +RETURN: if GCMI_ROUNDED set: + dx - information (rounded) + else: + dx.ah - information (WBFixed) + carry - set if error (eg. data / font not available) +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeCharMetrics proc far + uses bx, cx, si, di, ds + .enter + + .leave + ret +TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/truetypePath.asm new file mode 100644 index 000000000..1b9950368 --- /dev/null +++ b/Driver/Font/TrueType/truetypePath.asm @@ -0,0 +1,107 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1991 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: GeoCalc +FILE: truetypePath.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenPath Generate path for character + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial revision + +DESCRIPTION: + Routines for generating graphics string of a character. + + $Id: truetypePath.asm,v 1.1 97/04/18 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenPath +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a path for the outline of a character +CALLED BY: DR_FONT_GEN_PATH (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in bx, locked) + dx - character to generate (Chars) + cl - FontGenPathFlags + FGPF_POSTSCRIPT - transform for use as Postscript + Type 1 or Type 3 font. + FGPF_SAVE_STATE - do save/restore for GState +RETURN: none +DESTROYED: ax, bx, di (on the way here) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenPath proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenPath endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenInRegion +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a character in the passed RegionPath +CALLED BY: DR_FONT_GEN_IN_REGION (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in BX) + dx - character to generate (Chars) + cx - RegionPath handle (locked) +RETURN: nothing +DESTROYED: ax, bx, di + +PSEUDO CODE/STRATEGY: + We want override some of the default functionality for + build a font's character. Essentially: + * Always build a character in a region + * Build this character in the passed region + + We accomplish this by: + 1) Find the character data + 2) Calculate/store the correct transformation + 3) Stuff in some new CharGenRouts + 4) Stuf in the pen position (in device coords) + 5) Go generate the character (via MakeBigCharInRegion) + +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/ 29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenInRegion proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenInRegion endp + + diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def new file mode 100644 index 000000000..6350bb8f8 --- /dev/null +++ b/Driver/Font/TrueType/truetypeVariable.def @@ -0,0 +1,97 @@ + +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeVariable.def + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Falk 11/6/89 Initial version + +DESCRIPTION: + initialized and unitialized variables for TrueType font driver + + $Id: nimbusVariable.def,v 1.1 97/04/18 11:45:28 newdeal Exp $ + +-----------------------------------------------------------------------------@ + + + +;------------------------------------------------------------------------------ +; Definition of variable block +;------------------------------------------------------------------------------ + +TrueTypeVars struct + +stackBot label byte +; +; The "stack" overlaps everything above this point +; + +x_offset sword ;x offset to create character +y_offset sword ;y offset to create character + +penPos Point <0, 0> ;pen position used for drawing + ;characters into a passed RegionPath + ;for NimbusGenInRegion(). +; +; Used to save passed variables: +; +genOffset word 0 ;offset of CharGenData +fontSegment word 0 ;seg addr of font +fontHandle hptr 0 ;handle of font +infoSegment word 0 ;seg addr of info block +gstateSegment word 0 ;seg addr of GState + +TrueTypeVars ends + +TrueTypeSubTable struct + TTST_scalerType dword + TTST_numTables word + TTST_searchRange word + TTST_entrySelector word + TTST_rangeShift word +TrueTypeSubTable ends + +TrueTypeTableHeader struct + TTTH_dword0 dword + TTTH_dword1 dword + TTTH_dword2 dword + TTTH_dword3 dword +TrueTypeTableHeader ends + + +;------------------------------------------------------------------------------ + +;------------------------------------------------------------------------------ +; Initialized variables +;------------------------------------------------------------------------------ + +idata segment + +if DBCS_PCGEOS +truetypeDir wchar 'TTF',0 +else +truetypeDir char 'TTF',0 +endif + +idata ends + +;------------------------------------------------------------------------------ +; Uninitialized varaibles +;------------------------------------------------------------------------------ + +udata segment + +bitmapHandle hptr ;handle of our bitmap block +bitmapSize word ;size of our bitmap block (in bytes) + +variableHandle hptr ;handle of our variable block + +udata ends + + diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/truetypeWidths.asm new file mode 100644 index 000000000..df274e67b --- /dev/null +++ b/Driver/Font/TrueType/truetypeWidths.asm @@ -0,0 +1,69 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType Font Driver +FILE: truetypeWidths.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenWidths Generate font header and widths for a font. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + Implements a font driver for: + The TrueType outline fonts + + $Id: truetypeWidths.asm,v 1.1 97/04/18 11:45:30 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenWidths +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate the character width table for a font. +CALLED BY: EXTERNAL: GrFindFont + +PASS: di - 0 for new font; handle to rebuild old font (P'd) + es - seg addr of gstate (locked) + GS_fontAttr - font attributes + bp:cx - transformation matrix (TMatrix) + ds - seg addr of font info block +RETURN: bx - handle of font (locked) + ax - seg addr of font (locked) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + di is the bx passed to TrueTypeStrategy. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenWidths proc far + uses cx, dx, si, di, ds, es, bp + + mov bx, bp + .enter + + clc ;indicate no error + + .leave + ret +TrueTypeGenWidths endp diff --git a/Include/fontID.def b/Include/fontID.def index cd15cf3dd..df671c2ee 100644 --- a/Include/fontID.def +++ b/Include/fontID.def @@ -33,6 +33,7 @@ FM_NIMBUSQ enum FontMaker FM_ADOBE enum FontMaker FM_BITSTREAM enum FontMaker FM_AGFA enum FontMaker +FM_TRUETYPE enum FontMaker FM_PUBLIC enum FontMaker, 0xc000 FM_ATECH enum FontMaker, 0xd000 FM_MICROLOGIC enum FontMaker, 0xe000 diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile new file mode 100644 index 000000000..44877a5af --- /dev/null +++ b/Installed/Driver/Font/TrueType/Makefile @@ -0,0 +1,30 @@ +# +# THIS FILE HAS BEEN GENERATED AUTOMATICALLY. +# +# If you edit it, you will lose your changes, should it be regenerated. +# +GEODE = truetype +ASM_TO_OBJS = truetype.asm +UI_TO_RDFS = +SRCS = truetype.asm truetypeChars.asm truetypeEC.asm\ + truetypeEscape.asm truetypeInit.asm truetypeMetrics.asm\ + truetypePath.asm truetypeWidths.asm fontcomUtils.asm\ + fontcomEscape.asm truetypeConstant.def truetypeMacros.def\ + truetypeVariable.def +OBJS = truetype.obj +LOBJS = + +SYSMAKEFILE = geode.mk + +#include +#include + +#if exists(local.mk) +#include "local.mk" +#else +#include <$(SYSMAKEFILE)> +#endif + +#if exists($(DEPFILE)) +#include "$(DEPFILE)" +#endif diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk new file mode 100644 index 000000000..52a9a0fe3 --- /dev/null +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -0,0 +1,15 @@ +truetype.obj \ +truetype.eobj: geos.def heap.def geode.def resource.def ec.def driver.def \ + lmem.def graphics.def fontID.def font.def color.def \ + gstring.def text.def char.def sem.def file.def \ + localize.def sllang.def system.def fileEnum.def \ + Internal/fontDr.def Internal/tmatrix.def \ + Internal/grWinInt.def Internal/gstate.def \ + Internal/window.def win.def Internal/threadIn.def \ + truetypeConstant.def truetypeVariable.def \ + truetypeMacros.def truetypeWidths.asm fontcomUtils.asm \ + truetypeChars.asm truetypeMetrics.asm truetypePath.asm \ + truetypeInit.asm truetypeEscape.asm fontcomEscape.asm \ + truetypeEC.asm + +truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file From 261069858d7eade6fcf62d43f16ef7e37adaf890 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Thu, 26 Aug 2021 00:11:36 +0200 Subject: [PATCH 005/246] Add TrueType fonr driver to the Ensemble build chain and the resulting Ensemble setup. #129 --- CInclude/fontID.h | 1 + Installed/Makefile | 5 ++++- Tools/build/product/bbxensem/Template/geos.ini | 5 +++++ Tools/build/product/bbxensem/bbxensem.filetree | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CInclude/fontID.h b/CInclude/fontID.h index 04a2a947c..78a721390 100644 --- a/CInclude/fontID.h +++ b/CInclude/fontID.h @@ -29,6 +29,7 @@ typedef word FontMaker; #define FM_MICROLOGIC 0xe000 #define FM_ATECH 0xd000 #define FM_PUBLIC 0xc000 +#define FM_TRUETYPE 0x5000 #define FM_AGFA 0x4000 #define FM_BITSTREAM 0x3000 #define FM_ADOBE 0x2000 diff --git a/Installed/Makefile b/Installed/Makefile index 1113182d0..7214dfbcb 100644 --- a/Installed/Makefile +++ b/Installed/Makefile @@ -165,7 +165,7 @@ minimalDriver : nimbus ms4 ntfat os2 cdrom stream dri gdi keyboard modem gdipoin ps2 msys msser msbus kbmouse absgen genmouse emm extmem \ xms filestr nonts sblaster comm spooltd \ vmtree filedd logibus logiser dma mslf kbd_drivers \ - etherodi etherpkt msnet cdados + etherodi etherpkt msnet cdados truetype printerDriver : deskjet dj500c lbp mercury pcl4 quietjet canon48 \ canonbjc epshi24 epson24 epson48 nec24 \ @@ -560,6 +560,9 @@ Installed/Driver/Stream: kernel MAKEDRV nimbus : Installed/Driver/Font/Nimbus Installed/Driver/Font/Nimbus: kernel MAKEDRV +truetype : Installed/Driver/Font/TrueType +Installed/Driver/Font/TrueType: kernel MAKEDRV + ms4 : Installed/Driver/IFS/DOS/MS4 Installed/Driver/IFS/DOS/MS4: kernel MAKEDRV diff --git a/Tools/build/product/bbxensem/Template/geos.ini b/Tools/build/product/bbxensem/Template/geos.ini index 1b6d97f26..c89e6a6ce 100644 --- a/Tools/build/product/bbxensem/Template/geos.ini +++ b/Tools/build/product/bbxensem/Template/geos.ini @@ -14,6 +14,11 @@ fontsize = 12 drive b = 0 editableTextFontID = Esquire +font = { + EC-dos(nimbus.geo) + EC-dos(truetype.geo) +} + [diskswap] size = 4096 diff --git a/Tools/build/product/bbxensem/bbxensem.filetree b/Tools/build/product/bbxensem/bbxensem.filetree index 42522c67f..b6ebcc538 100644 --- a/Tools/build/product/bbxensem/bbxensem.filetree +++ b/Tools/build/product/bbxensem/bbxensem.filetree @@ -422,6 +422,7 @@ DIR (ensemble) { DIR (font) { Driver/Font/Nimbus/{dbcs}/nimbus{ec}.geo GFS LOCALPC + Driver/Font/TrueType/{dbcs}/truetype{ec}.geo GFS LOCALPC } DIR (fs) { From c9790e6564ce5bab7a044c5c1d4d684f5f1a2238 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Sat, 28 Aug 2021 19:54:37 +0200 Subject: [PATCH 006/246] Make TrueType driver actually load and ttf file enumeration to start looking in the files header. #129 --- Driver/Font/TrueType/local.mk | 2 ++ Driver/Font/TrueType/truetypeInit.asm | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk index 425ed4422..d30315277 100644 --- a/Driver/Font/TrueType/local.mk +++ b/Driver/Font/TrueType/local.mk @@ -15,6 +15,8 @@ ############################################################################### ASMFLAGS += -i +_PROTO = 3.0 + .PATH.asm .PATH.def: ../FontCom $(INSTALL_DIR:H)/FontCom \ #include <$(SYSMAKEFILE)> diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm index 37095323f..9a1df5e44 100644 --- a/Driver/Font/TrueType/truetypeInit.asm +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -246,7 +246,6 @@ fontId local FontID fontInfoChunk local word .enter -if 0 ; ; generate font id from file names first character for now ; @@ -256,7 +255,7 @@ if 0 mov fontId, ax ; - ; open cached data file + ; open truetype file ; mov dx, si ; ds:dx = name mov al, FILE_ACCESS_R or FILE_DENY_W @@ -275,6 +274,7 @@ if 0 call FileRead jc doneClose +if 0 ; ; create a new FontsAvailEntry @@ -355,11 +355,11 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > LocalPutChar esdi, ax ; ensure null term pop es, ds, si ; restore FFLH, FontInfo +endif doneClose: mov al, FILE_NO_ERRORS call FileClose -endif done: .leave From 5f3b51787a709eac928d7f484836c26b091d5bfe Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Fri, 10 Sep 2021 23:56:00 +0200 Subject: [PATCH 007/246] First implementation of the generic integration of the TrueType font driver. It combines fonts by family and build up a list of outlines based on nique style and weight. #129 --- Driver/Font/TrueType/truetypeInit.asm | 641 +++++++++++++++++++++- Driver/Font/TrueType/truetypeVariable.def | 17 +- 2 files changed, 626 insertions(+), 32 deletions(-) diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm index 9a1df5e44..e61f76018 100644 --- a/Driver/Font/TrueType/truetypeInit.asm +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -22,7 +22,7 @@ REVISION HISTORY: DESCRIPTION: Initialization & exit routines for TrueType font driver - + $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ @@ -154,11 +154,11 @@ REVISION HISTORY: initFontReturnAttr FileExtAttrDesc \ , - + TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp - + .enter - + ; ; Enumerate files in SP_FONT ; @@ -177,7 +177,7 @@ TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp sub sp, size FileEnumParams mov bp, sp ; GEOS datafiles - mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS + mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS ; return longname mov ss:[bp].FEP_returnAttrs.segment, cs mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr @@ -185,7 +185,7 @@ TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED ; callback sees all files mov ss:[bp].FEP_matchAttrs.segment, 0 - + mov ss:[bp].FEP_skipCount, 0 call FileEnum ; cx = # found, bx = handle jc done ; error @@ -204,7 +204,7 @@ done: clc .leave ret - + TrueTypeInitFonts endp @@ -235,20 +235,28 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ProcessFont proc far - + uses ax, bx, cx, di, si, es, ds - + fontNameSeg local sptr push ds fontNameOff local word push si fontBlockSeg local sptr push dx subTableHeader local TrueTypeSubTable +tableDirectory local TrueTypeTableDirectory fontId local FontID fontInfoChunk local word - +tableCount local word +fontFile local hptr +fontName local FONT_NAME_LEN dup (char) +fontStyle local TextStyle +fontWeight local FontWeight + .enter ; ; generate font id from file names first character for now ; + mov fontWeight, FW_NORMAL + clr ah mov al, ds:[si] add ax, FM_TRUETYPE @@ -261,21 +269,231 @@ fontInfoChunk local word mov al, FILE_ACCESS_R or FILE_DENY_W call FileOpen jc done - + mov bx, ax ; file handle to bx - + mov fontFile, bx + segmov ds, ss lea dx, subTableHeader - + mov al, 0 - + mov cx, size subTableHeader ; size to read - - call FileRead + + call FileRead jc doneClose -if 0 + ; + ; scan all TTF file tables + ; keep structures and meta data needed to serve the font + ; + mov ah, subTableHeader.TTST_numTables.low + mov al, subTableHeader.TTST_numTables.high + mov tableCount, ax +nextEntry: + mov bx, fontFile + segmov ds, ss + lea dx, tableDirectory + mov al, 0 + + mov cx, size tableDirectory ; size to read + + call FileRead + jc doneClose + ; remember file position + mov cx, 0 + mov dx, 0 + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_RELATIVE ; jump from start + call FilePos ; get current pos to dx:ax + jc doneClose + mov cx, dx + mov dx, ax + + mov ax, 'na' + cmp ax, tableDirectory.TTTD_tag.low + jne tryOS_2 + mov ax, 'me' + cmp ax, tableDirectory.TTTD_tag.high + jne tryOS_2 + + lea si, tableDirectory + call LoadTable + + cmp bx, 0 ; failed to load? + je doneClose + + ; restore file position, cxdx hold position + push bx + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + call FilePos + pop bx + jnc parseName + + ; free the block we don't keep it, bx handle of block + call MemFree + jmp doneClose + +parseName: + ; get relevant data from name table + + ; first load sub family (and reuse the buffer fontName) and map + ; the value to TextStyle bits to describe the resulting + ; font entry + lea si, fontName ; ss:si point to buffer + mov cx, FONT_NAME_LEN ; buffer size + mov ax, 2 ; sub family name of the font + call GetNameFromTable + jc doneClose ; jump if no name found + + lea si, fontName ; ss:si point to buffer + call MapFontStyle + jc doneClose ; fail if style mapping fails + + mov fontStyle, al ; save fontStyle + ; (type TextStyle) + ; ds is pointing to the name table here + lea si, fontName ; ss:si point to buffer + mov cx, FONT_NAME_LEN ; buffer size + mov ax, 1 ; family name of the font + call GetNameFromTable + jc doneClose ; jump if no name found + + ; free the block we don't keep it, bx handle of block + call MemFree +tryOS_2: + mov ax, 'OS' + cmp ax, tableDirectory.TTTD_tag.low + jne cont + mov ax, '/2' + cmp ax, tableDirectory.TTTD_tag.high + jne cont +loadOS_2: + lea si, tableDirectory + call LoadTable + + cmp bx, 0 ; failed to load? + je doneClose + + ; restore file position, cxdx hold position + push bx + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + call FilePos + pop bx + jnc getWeight + + ; free the block we don't keep it, bx handle of block +freeAndClose: + call MemFree + jmp doneClose + +getWeight: + mov ah, ds:4 + mov al, ds:5 + mov dx, 0 + mov si, 100 + div si + cmp dx, 0 + jne freeAndClose + cmp ax, 10 + jnc freeAndClose + + mov si, ax + mov al, cs:weightAdjustTable[si] + mov fontWeight, al + +cont: + dec tableCount + jnz nextEntry + + ; we have one font and collected required meta data + ; let compute/determ the fontid to be used for the font + mov ax, 0 + lea si, fontName ; ss:si point to buffer + mov cx, 0 +calcFontId: + + xor al, ss:0[si] + + xor ah, ss:1[si] + + inc cx + cmp cx, FONT_NAME_LEN + je doneFontId + inc si + cmp ss:0[si], 0 + jnz calcFontId + + and ah, 00000001b + or ax, FM_TRUETYPE + or ah, 00001110b + mov fontId, ax +doneFontId: + + ; lookup if there is a FontsAvailEntry for the font already + mov cx, fontId + mov ds, fontBlockSeg + mov di, ds:[FONTS_AVAIL_HANDLE] ;di <- ptr to chunk + ChunkSizePtr ds, di, ax ;ax <- chunk size + add ax, di ;ax -> end of chunk +IFA_loop: + cmp di, ax ;are we thru the list? + jae noMatch ;yes, exit carry clear + cmp ds:[di].FAE_fontID, cx ;see if ID matches + je match ;we have a match, branch + add di, size FontsAvailEntry ;else move to next entry + jmp IFA_loop ;and loop + +match: + ; font already registered, check if there is already equal outline + ; outline is equal if style and weight is equal + mov di, ds:[di].FAE_infoHandle ; ds:si = FontInfo chunk handle + mov si, ds:[di] ; ds:si = FontInfo ptr + + mov cx, ds:[si].FI_outlineEnd + push si + mov si, ds:[si].FI_outlineTab + +checkOutline: + mov al, ds:[si].ODE_style + cmp al, fontStyle + jne nextOutline + + mov al, ds:[si].ODE_weight + cmp al, fontStyle + jne nextOutline + + ; matching outline found + pop ax + jmp doneClose ; skip this font + +nextOutline: + add si, size OutlineDataEntry + cmp si, cx + jne checkOutline + +appendOutline: + ; not found, append new outline + pop si + + mov bx, cx ; append at end + + push cx + add cx, size OutlineDataEntry + mov ds:[si].FI_outlineEnd, cx + + mov ax, di ; *ds:ax = chunk + mov cx, size OutlineDataEntry ; cx = sizeof outline entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + + pop si + jmp initEntry + +noMatch: ; ; create a new FontsAvailEntry ; @@ -298,7 +516,7 @@ if 0 ; rather than for each typeface (which this field is for) ; mov ds:[si].FAE_fileName, 0 - + ; ; allocate a chunk for the FontInfo block ; @@ -314,6 +532,7 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > call LMemAlloc ; ds updated, ax = chunk mov fontBlockSeg, ds ; store it mov fontInfoChunk, ax + ; ; finish filling the FontsAvailEntry ; dx = end of OutlineDataEntrys @@ -332,9 +551,10 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > mov ax, fontId mov ds:[si].FI_fontID, ax mov ds:[si].FI_maker, FM_TRUETYPE - mov al, es:[FFLH_fontFamily] - mov ds:[si].FI_family, al - mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? + mov al, FF_NON_PORTABLE + mov ds:[si].FI_family, al ; this is called family but it + ; actually is FontAttrs + mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? (for now) mov ds:[si].FI_pointSizeEnd, 0 mov ds:[si].FI_outlineTab, size FontInfo mov ds:[si].FI_outlineEnd, dx @@ -345,9 +565,10 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > ; push es, ds, si ; save FFLH, FontInfo segxchg es, ds ; es:di = FI_faceName + segmov ds, ss mov di, si add di, FI_faceName - mov si, offset FFLH_faceName ; ds:si = FFLH_faceName + lea si,fontName ; ds:si = fontName mov cx, length FI_faceName ; dest. size LocalCopyNString LocalPrevChar esdi @@ -355,14 +576,384 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > LocalPutChar esdi, ax ; ensure null term pop es, ds, si ; restore FFLH, FontInfo -endif - + add si, size FontInfo ; ds:si = first OutlineDataEntry +initEntry: + call initOutlineEntry + doneClose: + mov bx, fontFile mov al, FILE_NO_ERRORS call FileClose done: + mov dx, fontBlockSeg + .leave + ret + +weightAdjustTable byte \ + 80, ;FWE_ULTRA_LIGHT + 85, ;FWE_EXTRA_LIGHT + 90, ;FWE_LIGHT + 95, ;FWE_BOOK + 100, ;FWE_NORMAL + 105, ;FWE_DEMI + 110, ;FWE_BOLD + 115, ;FWE_EXTRA_BOLD + 120, ;FWE_ULTRA_BOLD + 125 ;FWE_BLACK + +initOutlineEntry label near + ; + ; style and weight + ; ds:si = OutlineDataEntry + ; + mov al, fontStyle ; font style + mov ds:[si].ODE_style, al + mov al, fontWeight ; font weight + mov ds:[si].ODE_weight, al + ; + ; now allocate and fill in a TrueTypeOutlineEntry + ; ds:si = OutlineDataEntry + ; fontNameSeg:fontNameOff = font file name + ; + mov bx, si + mov si, fontInfoChunk + mov si, ds:[si] + sub bx, si ; bx = offset to ODE + mov cx, size TrueTypeOutlineEntry ; fixed size + clr ax + call LMemAlloc ; ax = BOE chunk, ds updated + mov fontBlockSeg, ds ; store it + mov si, fontInfoChunk + mov si, ds:[si] ; ds:si = FontInfo + add si, bx ; ds:si = OutlineDataEntry +if DBCS_PCGEOS + mov ds:[si].ODE_extraData, ax +else + ; store chunk at OutlineEntrys + mov ds:[si][(size ODE_style + size ODE_weight)], ax +endif + mov si, ax + mov di, ds:[si] + mov bx, di ; es:bx = TrueTypeOutlineEntry + segmov es, ds ; es:di = TrueTypeOutlineEntry +.assert (offset TTOE_fontFileName) eq 0 + mov ds, fontNameSeg ; ds:si = font filename + mov si, fontNameOff + mov cx, size TTOE_fontFileName ; dest. size + rep movsb + retn + +ProcessFont endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + LoadTable +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Load ttf table into memory block + +CALLED BY: ProcessFont + +PASS: ss:si - table directory entry + bx - file handle + +RETURN: ds - segment of locked table (on success) + bx - handle of table block (0 if FAILURE) + +DESTROYED: Current file position in the given file. + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 8/30/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +LoadTable proc near + uses ax, cx, dx, di + +newBlock local hptr + .enter + + mov newBlock, handle 0 + + tst ss:[si].TTTD_length.low ; actually the high word + jnz err ; -> error if above 64K + mov al, ss:[si].TTTD_length.high.high + mov ah, ss:[si].TTTD_length.high.low + mov di, ax + + mov dx, bx ; keep file handle + mov bx, handle 0 ; bx <- make TrueType owner + mov cx, ALLOC_DYNAMIC_LOCK + call MemAllocSetOwner ; allocate blk for table + jc err + + mov newBlock, bx + segmov ds, ax + + mov bx, dx ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + mov dl, ss:[si].TTTD_offset.high.high + mov dh, ss:[si].TTTD_offset.high.low + mov cl, ss:[si].TTTD_offset.low.high + mov ch, ss:[si].TTTD_offset.low.low + + call FilePos + jc err + + mov dx, 0 ; buffer offset in segment + mov cx, di ; size + clr al + call FileRead + jc err + + mov bx, newBlock +done: + .leave + ret + +err: + mov bx, 0 + mov ax, newBlock + jz done + call MemFree + jmp done + +LoadTable endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + GetNameFromTable +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Load ttf table into memory block + +CALLED BY: ProcessFont + +PASS: ss:si - buffer to hold the result + cx - buffer size (to include \0 terminiation) + ds - name table segment + +RETURN: carry set on not found + Otherwise buffer filled, \0 terminated, if cx is not 0. + if cx is 0 then the buffer is filled but without \n termination. + +DESTROYED: ax, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 8/30/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +GetNameFromTable proc near + uses bx, di, dx + +dataOffset local word +encoding local byte + .enter + + mov bx, ax + mov di, si + + ; check version + mov ax, ds:0 + cmp ax, 0 + jne err + + ; scan the name record table + mov ah, ds:4 + mov al, ds:5 + mov dataOffset, ax + + mov dx, ds:2 + mov si, 6 +recordLoop: + mov ax, ds:0[si] + cmp ax, 0100h + je macEncoding + cmp ax, 0 ; unicode + jne next + mov ah, ds:2[si] + mov al, ds:3[si] + cmp ax, 3 ; Unicode 2.0 BPM + jne next + mov ax, ds:4[si] + cmp ax, 0 ; language should be 0 for + ; unicode + jne next + mov encoding, 0 + jmp enterLoop + +macEncoding: + mov ah, ds:2[si] + mov al, ds:3[si] + cmp ax, 0 ; Roman? + jne next + mov ax, ds:4[si] + cmp ax, 0 ; English? + jne next + + mov encoding, 1 ; 1 = non-unicode + +enterLoop: + ; match the name id + mov ah, ds:6[si] + mov al, ds:7[si] + cmp ax, bx + jne next + + mov dh, ds:8[si] + mov dl, ds:9[si] + + mov ah, ds:10[si] + mov al, ds:11[si] + add ax, dataOffset + mov si, ax +copyLoop: + cmp encoding, 0 + jne nextByte + mov ah, ds:0[si] + inc si + dec dx + jz endOfBuffer +nextByte: + mov al, ds:0[si] + inc si + + mov ss:0[di], al + inc di + dec cx + jz endOfBuffer + dec dx + jnz copyLoop +endOfBuffer: + cmp cx, 0 + jz success + mov ss:0[di], 0 + jmp success +next: + mov ax, si + add ax, 12 ; size of name record + mov si, ax + + dec dx + jnz recordLoop + jz err + +success: + clc +done: + .leave + ret + +err: + stc + jc done + +GetNameFromTable endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + MapFontStyle +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: MapFontStyle + +CALLED BY: ProcessFont + +PASS: ss:si - buffer to sub family name + +RETURN: carry set if mapping failed + al - on success, mapped TextStyle + +DESTROYED: ah + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 9/9/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +LocalDefNLString StyleRegular, <"Regular", 0> +LocalDefNLString StyleBold, <"Bold", 0> +LocalDefNLString StyleItalic, <"Italic", 0> +LocalDefNLString StyleBoldItalic, <"Bold Italic", 0> +LocalDefNLString StyleOblique, <"Oblique", 0> +LocalDefNLString StyleBoldOblique, <"Bold Oblique", 0> + +styleNames nptr \ + StyleRegular, + StyleBold, + StyleItalic, + StyleBoldItalic, + StyleOblique, + StyleBoldOblique + +styleFlags TextStyle \ + 0, + mask TS_BOLD, + mask TS_ITALIC, + mask TS_BOLD or mask TS_ITALIC, + mask TS_ITALIC, + mask TS_BOLD or mask TS_ITALIC + +MapFontStyle proc near + uses es, ds, di, si, cx, bx + + .enter +; +; Find the style +; + segmov es, ss + mov di, si ;es:di <- string to look for +; +; Find the sub family name in the table +; + mov cx, length styleNames ;cx <- # of entries + clr bx ;bx <- table index + segmov ds, cs +styleLoop: + push cx + mov si, cs:styleNames[bx] ;ds:si <- extension + clr cx ;cx <- NULL-terminated + call LocalCmpStringsNoCase + pop cx + je foundStyle ;branch if match + add bx, (size nptr) ;bx <- next entry + loop styleLoop ;loop for more + jmp notFound + +; +; Found the style -- return the flags +; +foundStyle: + sar bx, 1 + mov al, cs:styleFlags[bx] ;ds:si <- library name + clc ;carry <- no error +done: + .leave ret -ProcessFont endp \ No newline at end of file +notFound: + stc ;carry <- error + jmp done + +MapFontStyle endp diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def index 6350bb8f8..d5126e846 100644 --- a/Driver/Font/TrueType/truetypeVariable.def +++ b/Driver/Font/TrueType/truetypeVariable.def @@ -57,13 +57,16 @@ TrueTypeSubTable struct TTST_rangeShift word TrueTypeSubTable ends -TrueTypeTableHeader struct - TTTH_dword0 dword - TTTH_dword1 dword - TTTH_dword2 dword - TTTH_dword3 dword -TrueTypeTableHeader ends - +TrueTypeTableDirectory struct + TTTD_tag dword + TTTD_checkSum dword + TTTD_offset dword + TTTD_length dword +TrueTypeTableDirectory ends + +TrueTypeOutlineEntry struc + TTOE_fontFileName DosDotFileName +TrueTypeOutlineEntry ends ;------------------------------------------------------------------------------ From 7b8fba0b88b9ae7f5e749affcbea7e7cdc2a495f Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Wed, 25 Aug 2021 19:07:51 +0200 Subject: [PATCH 008/246] Initial add of font driver for true type font renderings. --- Driver/Font/TrueType/local.mk | 20 + Driver/Font/TrueType/truetype.asm | 236 +++++++++++ Driver/Font/TrueType/truetype.gp | 45 +++ Driver/Font/TrueType/truetype.rev | 2 + Driver/Font/TrueType/truetypeChars.asm | 62 +++ Driver/Font/TrueType/truetypeConstant.def | 104 +++++ Driver/Font/TrueType/truetypeEC.asm | 99 +++++ Driver/Font/TrueType/truetypeEscape.asm | 60 +++ Driver/Font/TrueType/truetypeInit.asm | 368 ++++++++++++++++++ Driver/Font/TrueType/truetypeMacros.def | 70 ++++ Driver/Font/TrueType/truetypeMetrics.asm | 63 +++ Driver/Font/TrueType/truetypePath.asm | 107 +++++ Driver/Font/TrueType/truetypeVariable.def | 97 +++++ Driver/Font/TrueType/truetypeWidths.asm | 69 ++++ Include/fontID.def | 1 + Installed/Driver/Font/TrueType/Makefile | 30 ++ .../Driver/Font/TrueType/dependencies.mk | 15 + 17 files changed, 1448 insertions(+) create mode 100644 Driver/Font/TrueType/local.mk create mode 100644 Driver/Font/TrueType/truetype.asm create mode 100644 Driver/Font/TrueType/truetype.gp create mode 100644 Driver/Font/TrueType/truetype.rev create mode 100644 Driver/Font/TrueType/truetypeChars.asm create mode 100644 Driver/Font/TrueType/truetypeConstant.def create mode 100644 Driver/Font/TrueType/truetypeEC.asm create mode 100644 Driver/Font/TrueType/truetypeEscape.asm create mode 100644 Driver/Font/TrueType/truetypeInit.asm create mode 100644 Driver/Font/TrueType/truetypeMacros.def create mode 100644 Driver/Font/TrueType/truetypeMetrics.asm create mode 100644 Driver/Font/TrueType/truetypePath.asm create mode 100644 Driver/Font/TrueType/truetypeVariable.def create mode 100644 Driver/Font/TrueType/truetypeWidths.asm create mode 100644 Installed/Driver/Font/TrueType/Makefile create mode 100644 Installed/Driver/Font/TrueType/dependencies.mk diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk new file mode 100644 index 000000000..425ed4422 --- /dev/null +++ b/Driver/Font/TrueType/local.mk @@ -0,0 +1,20 @@ +############################################################################## +# +# Copyright (c) GeoWorks 1992 -- All Rights Reserved +# +# PROJECT: PC/GEOS +# MODULE: TrueType Driver -- special definitions +# FILE: local.mk +# AUTHOR: Gene Anderson +# +# DESCRIPTION: +# Special definitions required for the TrueType font driver +# +# $Id: local.mk,v 1.1 97/04/18 11:45:28 newdeal Exp $ +# +############################################################################### +ASMFLAGS += -i + +.PATH.asm .PATH.def: ../FontCom $(INSTALL_DIR:H)/FontCom \ + +#include <$(SYSMAKEFILE)> diff --git a/Driver/Font/TrueType/truetype.asm b/Driver/Font/TrueType/truetype.asm new file mode 100644 index 000000000..5101133c2 --- /dev/null +++ b/Driver/Font/TrueType/truetype.asm @@ -0,0 +1,236 @@ +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetype.asm + +AUTHOR: Gene Anderson + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Gene 11/03/89 Initial revision + +DESCRIPTION: + This file implements a font driver using TrueType. + + $Id: truetype.asm,v 1.1 97/04/18 11:45:30 newdeal Exp $ + +------------------------------------------------------------------------------@ + + +;------------------------------------------------------------------------------ +; System Definition +;------------------------------------------------------------------------------ + +_Driver = 1 +_FontDriver = 1 + +;------------------------------------------------------------------------------ +; Include files +;------------------------------------------------------------------------------ + +include geos.def +include heap.def +include geode.def +include resource.def +include ec.def +include driver.def +include graphics.def +include gstring.def +include sem.def +include file.def +include lmem.def +include font.def +include localize.def +include char.def +include system.def + +include fileEnum.def + +DefDriver Internal/fontDr.def +include Internal/tmatrix.def +include Internal/grWinInt.def +include Internal/gstate.def +include Internal/window.def +include Internal/threadIn.def + + + + + +; Font Driver specific include files +; +include truetypeConstant.def ; constants used for font driver +include truetypeVariable.def ; Variables + + +idata segment + +; Driver information table +; +DriverTable FontDriverInfoStruct < + , DRIVER_TYPE_FONT>, + FM_TRUETYPE ; FDIS_maker +> + +ForceRef DriverTable + +idata ends + +include truetypeMacros.def + +WidthMod segment resource +include truetypeWidths.asm +;include nimbusUtils.asm +;include nimbusSetTrans.asm +include fontcomUtils.asm +WidthMod ends + +CharMod segment resource +include truetypeChars.asm +;include nimbusRegions.asm +;include nimbusLoadFont.asm +;include nimbusBig.asm +;include nimbusBitmap.asm +NimbusStart label near +;include nimbusMakechar.asm +;include nimbusSegments.asm +;include nimbusTrans.asm +;include nimbusMul.asm +;include nimbusContinuity.asm +AA_NIMBUS_SIZE equ $-NimbusStart +CharMod ends + +MetricsMod segment resource +include truetypeMetrics.asm +include truetypePath.asm +MetricsMod ends + +InitMod segment resource +include truetypeInit.asm +include truetypeEscape.asm +include fontcomEscape.asm +InitMod ends + +include truetypeEC.asm + +Resident segment resource ;MODULE_FIXED + + +COMMENT }---------------------------------------------------------------------- + +FUNCTION: TrueTypeStrategy + +DESCRIPTION: Entry point for driver. All access to devices performed + through this function + +CALLED BY: EXTERNAL + +PASS: + di - one of the following function codes: + Function # routine called Function + ---------- -------------- -------- + DR_INIT NimbusInit initialize + DR_EXIT NimbusExit exit + DR_FONT_GEN_CHAR NimbusGenChar generate one char + DR_FONT_GEN_WIDTHS NimbusGenWidths generate char widths + DR_FONT_CHAR_METRICS NimbusCharMetrics return character metrics + DR_FONT_INIT_FONTS NimbusInitFonts init non-GEOS fonts + DR_FONT_GEN_PATH NimbusGenPath generate outline path + DR_FONT_GEN_IN_REGION NimbusGenInRegion gen in passed region + +RETURN: + depends on function called + carry - set if error + +DESTROYED: + depends on function called + +REGISTER/STACK USAGE: + +PSEUDO CODE/STRATEGY: + Calls routine from jump table + +KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Gene 5/89 modified for font driver + +------------------------------------------------------------------------------} + + +EC + +TrueTypeStrategy proc far + +EC < tst cs:[inDriverFlag] > +EC < ERROR_NZ RECURSIVE_CALL_TO_FONT_DRIVER > +EC < inc cs:[inDriverFlag] > + + tst di ;escape function (>=0x8000) ? + js escapeFunction ;branch if escape function + + push bx +EC < cmp di, (size offTable) ;> +EC < ERROR_AE FONT_BAD_ROUTINE ;> + mov ax, cs:offTable[di] ;ax <- addr of routine in module + mov bx, cs:hanTable[di] ;bx <- handle of module + pop di ;pass old bx in di + tst bx ; function supported? + jz ignoreCall ; => no (carry clear) + call ProcCallModuleRoutine +callComplete: +EC < mov cs:[inDriverFlag],0 > +done: +EC < call ECNukeVariableBlock ;> + ret + +ignoreCall: + mov bx, di + jmp callComplete + + ; + ; The function is an escape function, so we deal with it specially + ; +escapeFunction: + call TrueTypeFontEscape + jmp done + +;---------------------------- + +TrueTypeStrategy endp + +offTable nptr \ + offset TrueTypeInit, ;DR_INIT + offset TrueTypeExit, ;DR_EXIT + 0, ;DR_SUSPEND + 0, ;DR_UNSUSPEND + offset TrueTypeGenChar, ;DR_FONT_GEN_CHAR + offset TrueTypeGenWidths, ;DR_FONT_GEN_WIDTHS + offset TrueTypeCharMetrics, ;DR_FONT_CHAR_METRICS + offset TrueTypeInitFonts, ;DR_FONT_INIT_FONTS + offset TrueTypeGenPath, ;DR_FONT_GEN_PATH + offset TrueTypeGenInRegion ;DR_FONT_GEN_IN_REGION +hanTable hptr \ + handle InitMod, ;DR_INIT + handle InitMod, ;DR_EXIT + 0, ;DR_SUSPEND + 0, ;DR_UNSUSPEND + handle CharMod, ;DR_FONT_GEN_CHAR + handle WidthMod, ;DR_FONT_GEN_WIDTHS + handle MetricsMod, ;DR_FONT_CHAR_METRICS + handle InitMod, ;DR_FONT_INIT_FONTS + handle MetricsMod, ;DR_FONT_GEN_PATH + handle MetricsMod ;DR_FONT_GEN_IN_REGION + +CheckHack <(length offTable) eq (length hanTable)> + +Resident ends + + end diff --git a/Driver/Font/TrueType/truetype.gp b/Driver/Font/TrueType/truetype.gp new file mode 100644 index 000000000..7b23e0938 --- /dev/null +++ b/Driver/Font/TrueType/truetype.gp @@ -0,0 +1,45 @@ +############################################################################## +# +# Copyright (c) GeoWorks 1989 -- All Rights Reserved +# +# PROJECT: PC GEOS +# MODULE: TrueType Font Driver +# FILE: truetype.gp +# +# AUTHOR: Gene, 11/89 +# +# +# Parameters file for: truetype.geo +# +# $Id: truetype.gp,v 1.1 97/04/18 11:45:31 newdeal Exp $ +# +############################################################################## +# +# Specify permanent name first +# +name truetype.drvr +# +# Specify geode type +# +type driver, single +# +# Import kernel routine definitions +# +library geos +# +# Desktop-related things +# +longname "TrueType Font Driver" +tokenchars "FNTD" +tokenid 0 +usernotes "#FreeGEOS font driver to render TrueType fonts." +# +# Define resources other than standard discardable code +# +resource Resident fixed code read-only shared +resource InitMod code read-only shared discard-only + + +# +# XIP-enabled +# diff --git a/Driver/Font/TrueType/truetype.rev b/Driver/Font/TrueType/truetype.rev new file mode 100644 index 000000000..d5eeb408a --- /dev/null +++ b/Driver/Font/TrueType/truetype.rev @@ -0,0 +1,2 @@ +R 6.0.0.0 <15:25:40 Feb 10, 2004> <#FreeGEOS release> +P 1.0 diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/truetypeChars.asm new file mode 100644 index 000000000..4f5ecbdda --- /dev/null +++ b/Driver/Font/TrueType/truetypeChars.asm @@ -0,0 +1,62 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: RasterMod +FILE: truetypeChars.asm + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + This file contains routines for generating individual characters. + + $Id: truetypeChars.asm,v 1.1 97/04/18 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenChar +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate one character for a font. +CALLED BY: VidBuildChar (via TrueTypeStrategy) + +PASS: dx - character to build (Chars) + es - seg addr of font (locked) + bp - seg addr of gstate (locked) + GS_fontHandle - handle of font + GS_fontAttr - font attributes + ds - seg addr of font info block + +RETURN: es - seg addr of font (locked) (may have changed) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenChar proc far + uses ax, bx, cx, dx, ds, si, di, bp + .enter + + + .leave + stc ;indicate no error + ret +TrueTypeGenChar endp + + diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/truetypeConstant.def new file mode 100644 index 000000000..942764157 --- /dev/null +++ b/Driver/Font/TrueType/truetypeConstant.def @@ -0,0 +1,104 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeConstant.def + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 26/1/21 Initial revision + +DESCRIPTION: + Definitions, constants, etc needed for the PC/GEOS TrueType font driver + + $Id: truetypeConstant.def,v 1.1 21/01/26 11:45:25 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +;---------------------------------------------------------------------------- +; Font Style Factors +;---------------------------------------------------------------------------- + +SCRIPT_FACTOR_INT = 0 +SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 + +SUBSCRIPT_OFFSET_INT = 0 +SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below + +SUPERSCRIPT_OFFSET_INT = 0 +SUPERSCRIPT_OFFSET_FRAC = 0x6000 ;offset above + +BOLD_FACTOR_INT = 0x0001 +BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 + +ITALIC_FACTOR_INT = 0 +ITALIC_FACTOR_FRAC = 0x366A ;italic = tan(12) +NEG_ITALIC_FACTOR_INT = 0xffff +NEG_ITALIC_FACTOR_FRAC = 0xC996 ;italic = -tan(12) + +; +; Styles that affect the width of the character: +; +WIDTH_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_BOLD +; +; Styles that affect the transformation matrix used: +; +TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_ITALIC or \ + mask TS_BOLD + +;---------------------------------------------------------------------------- +; Miscellaneous constants +;---------------------------------------------------------------------------- + +DEFAULT_CHAR = '.' + +; +; These sizes are in pixels, not points, since that's what +; really matters for these cutoff points. +; +; Continuity checking is not done above: +; +MAX_CONTINUITY_SIZE = 30 +; +; Characters are stored as regions instead of bitmaps above: +; +MAX_BITMAP_SIZE = 125 +SCRIPT_SAFETY_SIZE = 10 + +TRUETYPE_BLOCK_SIZE equ 1024 ;initial block size + +;---------------------------------------------------------------------------- +; Region constants +;---------------------------------------------------------------------------- + +UNUSED_PER_LINE = 4 ;# of unused points / line + +;---------------------------------------------------------------------------- +; Font Errors +;---------------------------------------------------------------------------- + +if ERROR_CHECK + +FONT_BAD_CHAR_FLAG enum FatalErrors + +RECURSIVE_CALL_TO_FONT_DRIVER enum FatalErrors +; The TrueType driver is non-reentrant, so only one thread can be in the +; driver at a time. This may indicate a bug in the Font Manager. + +FONT_BAD_ROUTINE enum FatalErrors +; A bad function passed to the TrueType driver. The function passed in +; di must be in the FontFunction enumerated type. + +TRUETYPE_INTERNAL_ERROR enum FatalErrors + +endif + diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/truetypeEC.asm new file mode 100644 index 000000000..a87edeb5b --- /dev/null +++ b/Driver/Font/TrueType/truetypeEC.asm @@ -0,0 +1,99 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEC.asm +FILE: truetypeEC.asm + +AUTHOR: Falk Rehwagen, Jan 1, 2021 + +ROUTINES: + Name Description + ---- ----------- + ECNukeVariableBlock nuke variables so we don't inadvertently + re-use them + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Error checking code for TrueType driver + + $Id: truetypeEC.asm,v 1.1 21/01/24 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +if ERROR_CHECK + +CharMod segment resource + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ECNukeVariableBlock +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Nuke the TrueType variable block +CALLED BY: NimbusStrategy() + +PASS: none +RETURN: none +DESTROYED: none (flags preserved) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +ECNukeVariableBlock proc far + uses ax, bx, cx, di, es + .enter + + pushf + + ; + ; Lock the variable block + ; + mov ax, segment udata + mov es, ax ;es <- seg addr of idata + mov bx, es:variableHandle ;bx <- handle of vars + tst bx ;block freed? + jz done ;branch if freed + call MemLock + jc done ;branch if discarded + mov es, ax ;es <- seg addr of vars + ; + ; Zero the block + ; + clr al ;al <- byte to store + mov cx, (size TrueTypeVars) ;cx <- # of bytes + clr di ;es:di <- ptr to vars + rep stosb + ; + ; Nuke things we know are segments specially + ; + mov es:fontSegment, 0xa000 + mov es:gstateSegment, 0xa000 + mov es:infoSegment, 0xa000 + ; + ; All done... + ; + call MemUnlock +done: + + popf + + .leave + ret +ECNukeVariableBlock endp + + +CharMod ends + +endif + diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/truetypeEscape.asm new file mode 100644 index 000000000..3f3f33d6f --- /dev/null +++ b/Driver/Font/TrueType/truetypeEscape.asm @@ -0,0 +1,60 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEscape.asm +FILE: truetypeEscape.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeFontEscape handle any escape functions + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Code for handling driver escape functions + + $Id: truetypeEscape.asm,v 1.1 21/01/24 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeFontEscape +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Hand +CALLED BY: TrueTypeStrategy() + +PASS: di - escape function +RETURN: di - 0 if escape function not supported +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeFontEscape proc far + call FontCallEscape ;call general handling routine + ret +TrueTypeFontEscape endp + +;---------------------------------------------------------------------------- +; Escape Function Table +;---------------------------------------------------------------------------- + +DefEscapeTable 1 + +DefEscape FontQueryEscape, DRV_ESC_QUERY_ESC diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm new file mode 100644 index 000000000..37095323f --- /dev/null +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -0,0 +1,368 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Init +FILE: truetypeInit.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeInit initialize the TrueType font driver + TrueTypeExit clean up after TrueType font driver + TrueTypeInitFonts initialize any non-PC/GEOS fonts + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial revision + +DESCRIPTION: + Initialization & exit routines for TrueType font driver + + $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize the TrueType font driver. +CALLED BY: DR_INIT - TrueTypeStrategy + +PASS: none +RETURN: bitmapHandle - handle of block to use for bitmaps + bitmapSize - size of above block (0 at start) + variableHandle - handle of block containing variables + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + public TrueTypeInit +TrueTypeInit proc far + uses ax, bx, cx, si, di, ds, es + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + ; + ; First, we need a block of memory to use as a bitmap + ; for generating characters. We don't need to actually + ; allocate memory for it yet. + ; + mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:bitmapHandle, bx ;save handle of block + mov ds:bitmapSize, 0 ;no bytes yet + ; + ; We also need a block to use for variables. We don't + ; need it yet, either. + ; + mov ax, size TrueTypeVars ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:variableHandle, bx ;save handle of block + clc ;indicate no error + + .leave + ret +TrueTypeInit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeExit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Free up blocks used and exit the TrueType driver. +CALLED BY: DR_EXIT - TrueTypeStrategy + +PASS: bitmapHandle - handle of bitmap block + variableHandle - handle of variable block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeExit proc far + uses ax, bx, ds + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + mov bx, ds:bitmapHandle +EC < clr ds:bitmapHandle ;> + call MemFree ;done with bitmap block + mov bx, ds:variableHandle +EC < clr ds:variableHandle ;> + call MemFree ;done with variable block + clc ;indicate no error + + .leave + ret +TrueTypeExit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInitFonts +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize any non-GEOS fonts for the font driver. +CALLED BY: DR_FONT_INIT_FONTS - TrueTypeStrategy + +PASS: ds - seg addr of font info block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +initFontReturnAttr FileExtAttrDesc \ + , + + +TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp + + .enter + + ; + ; Enumerate files in SP_FONT + ; + call FilePushDir + mov ax, SP_FONT + call FileSetStandardPath + push ds + segmov ds, dgroup, ax + mov dx, offset truetypeDir + clr bx ; relative to CWD + call FileSetCurrentPath + pop ds + + ; + ; Lookup all .ttf files + sub sp, size FileEnumParams + mov bp, sp + ; GEOS datafiles + mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS + ; return longname + mov ss:[bp].FEP_returnAttrs.segment, cs + mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr + mov ss:[bp].FEP_returnSize, size FileLongName + mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED + ; callback sees all files + mov ss:[bp].FEP_matchAttrs.segment, 0 + + mov ss:[bp].FEP_skipCount, 0 + call FileEnum ; cx = # found, bx = handle + jc done ; error + jcxz done ; no files found + mov dx, ds ; ax = segment of font block + call MemLock ; ds:0 = first entry + mov ds, ax + mov si, 0 +fontLoop: + call ProcessFont + add si, size FileLongName + loop fontLoop + call MemFree ; free file block +done: + call FilePopDir + clc + .leave + ret + +TrueTypeInitFonts endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ProcessFont +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: initialize each font found + +CALLED BY: TrueTypeInitFonts + +PASS: ds:si - font file name (TTF) + dx - font block segment + +RETURN: dx - updated font block segment (may move) + +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 2/17/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +ProcessFont proc far + + uses ax, bx, cx, di, si, es, ds + +fontNameSeg local sptr push ds +fontNameOff local word push si +fontBlockSeg local sptr push dx +subTableHeader local TrueTypeSubTable +fontId local FontID +fontInfoChunk local word + + .enter +if 0 + ; + ; generate font id from file names first character for now + ; + clr ah + mov al, ds:[si] + add ax, FM_TRUETYPE + mov fontId, ax + + ; + ; open cached data file + ; + mov dx, si ; ds:dx = name + mov al, FILE_ACCESS_R or FILE_DENY_W + call FileOpen + jc done + + mov bx, ax ; file handle to bx + + segmov ds, ss + lea dx, subTableHeader + + mov al, 0 + + mov cx, size subTableHeader ; size to read + + call FileRead + jc doneClose + + + ; + ; create a new FontsAvailEntry + ; + mov ds, fontBlockSeg + mov ax, FONTS_AVAIL_HANDLE ; *ds:ax = chunk + clr bx ; insert at front + mov cx, size FontsAvailEntry ; cx = sizeof table entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + ; + ; fill in FontID + ; + mov si, ax + push si + mov si, ds:[si] ; ds:si = new FAE + mov ax, fontId + mov ds:[si].FAE_fontID, ax + ; + ; clear the name field because there is a font file for each font + ; rather than for each typeface (which this field is for) + ; + mov ds:[si].FAE_fileName, 0 + + ; + ; allocate a chunk for the FontInfo block + ; + mov cx, 1 ; font count + mov ax, size OutlineDataEntry + mul cx ; dx:ax = size +EC < tst dx > +EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > + mov cx, ax + add cx, size FontInfo + mov dx, cx ; save size for later + clr ax + call LMemAlloc ; ds updated, ax = chunk + mov fontBlockSeg, ds ; store it + mov fontInfoChunk, ax + ; + ; finish filling the FontsAvailEntry + ; dx = end of OutlineDataEntrys + ; + pop si ; *ds:si = FontsAvailEntry + mov si, ds:[si] ; ds:si = FontsAvailEntry + mov ds:[si].FAE_infoHandle, ax ; save FontInfo chunk handle + + ; + ; now fill in the FontInfo struct + ; dx = end of OutlineDataEntrys + ; + mov di, ax ; *ds:di = FontInfo + mov si, ds:[di] ; ds:si = FontInfo + mov ds:[si].FI_fileHandle, 0 ; not used + mov ax, fontId + mov ds:[si].FI_fontID, ax + mov ds:[si].FI_maker, FM_TRUETYPE + mov al, es:[FFLH_fontFamily] + mov ds:[si].FI_family, al + mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? + mov ds:[si].FI_pointSizeEnd, 0 + mov ds:[si].FI_outlineTab, size FontInfo + mov ds:[si].FI_outlineEnd, dx + ; + ; copy in the font face name + ; ds:si = FontInfo + ; es = FFLH + ; + push es, ds, si ; save FFLH, FontInfo + segxchg es, ds ; es:di = FI_faceName + mov di, si + add di, FI_faceName + mov si, offset FFLH_faceName ; ds:si = FFLH_faceName + mov cx, length FI_faceName ; dest. size + LocalCopyNString + LocalPrevChar esdi + mov ax, 0 + LocalPutChar esdi, ax ; ensure null term + pop es, ds, si ; restore FFLH, FontInfo + + +doneClose: + mov al, FILE_NO_ERRORS + call FileClose +endif +done: + .leave + + ret + +ProcessFont endp \ No newline at end of file diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/truetypeMacros.def new file mode 100644 index 000000000..02930d0ae --- /dev/null +++ b/Driver/Font/TrueType/truetypeMacros.def @@ -0,0 +1,70 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType +FILE: truetypeMacros.def + +AUTHOR: Falk Rehwagen, Jan 26, 2021 + +MACROS: + Name Description + ---- ----------- + Abs Absolute value of word + + TRUNC Truncate number + CEIL Get ceiling of number + ROUND Round number to integer + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/26/21 Initial revision + +DESCRIPTION: + Macros for the PC/GEOS TrueType font driver. + + $Id: truetypeMacros.def,v 1.1 21/01/26 11:45:27 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +; +; absolute value of integer +; +Abs macro int +local A_10 + tst int + jns A_10 + neg int +A_10: +endm + +; +;PASS: number in 16ths +;RETURN: floor(number), no fraction +; +TRUNC macro num + sar num, 1 + sar num, 1 + sar num, 1 + sar num, 1 +endm + +; +;PASS: number in 16ths +;RETURN: ceiling(number), no fraction +; +CEIL macro num + add num, FRACTION + TRUNC num +endm + +; +;PASS: number in 16ths +;RETURN: round(number), no fraction +; +ROUND macro num + add num, ONE_HALF + TRUNC num +endm diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/truetypeMetrics.asm new file mode 100644 index 000000000..647b96c0d --- /dev/null +++ b/Driver/Font/TrueType/truetypeMetrics.asm @@ -0,0 +1,63 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: MetricsMod +FILE: truetypeMetrics.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeCharMetrics Return character metric information. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial revision + +DESCRIPTION: + Routines for generating character metrics. + + $Id: truetypeMetrics.asm,v 1.1 97/04/18 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeCharMetrics +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Return character metrics information in document coords. +CALLED BY: DR_FONT_CHAR_METRICS - TrueTypeStrategy + +PASS: ds - seg addr of font info block + es - seg addr of GState + es:GS_fontAttr - font attributes + dx - character to get metrics of + cx - info to return (GCM_info) +RETURN: if GCMI_ROUNDED set: + dx - information (rounded) + else: + dx.ah - information (WBFixed) + carry - set if error (eg. data / font not available) +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeCharMetrics proc far + uses bx, cx, si, di, ds + .enter + + .leave + ret +TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/truetypePath.asm new file mode 100644 index 000000000..1b9950368 --- /dev/null +++ b/Driver/Font/TrueType/truetypePath.asm @@ -0,0 +1,107 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1991 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: GeoCalc +FILE: truetypePath.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenPath Generate path for character + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial revision + +DESCRIPTION: + Routines for generating graphics string of a character. + + $Id: truetypePath.asm,v 1.1 97/04/18 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenPath +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a path for the outline of a character +CALLED BY: DR_FONT_GEN_PATH (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in bx, locked) + dx - character to generate (Chars) + cl - FontGenPathFlags + FGPF_POSTSCRIPT - transform for use as Postscript + Type 1 or Type 3 font. + FGPF_SAVE_STATE - do save/restore for GState +RETURN: none +DESTROYED: ax, bx, di (on the way here) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenPath proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenPath endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenInRegion +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a character in the passed RegionPath +CALLED BY: DR_FONT_GEN_IN_REGION (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in BX) + dx - character to generate (Chars) + cx - RegionPath handle (locked) +RETURN: nothing +DESTROYED: ax, bx, di + +PSEUDO CODE/STRATEGY: + We want override some of the default functionality for + build a font's character. Essentially: + * Always build a character in a region + * Build this character in the passed region + + We accomplish this by: + 1) Find the character data + 2) Calculate/store the correct transformation + 3) Stuff in some new CharGenRouts + 4) Stuf in the pen position (in device coords) + 5) Go generate the character (via MakeBigCharInRegion) + +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/ 29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenInRegion proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenInRegion endp + + diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def new file mode 100644 index 000000000..6350bb8f8 --- /dev/null +++ b/Driver/Font/TrueType/truetypeVariable.def @@ -0,0 +1,97 @@ + +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeVariable.def + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Falk 11/6/89 Initial version + +DESCRIPTION: + initialized and unitialized variables for TrueType font driver + + $Id: nimbusVariable.def,v 1.1 97/04/18 11:45:28 newdeal Exp $ + +-----------------------------------------------------------------------------@ + + + +;------------------------------------------------------------------------------ +; Definition of variable block +;------------------------------------------------------------------------------ + +TrueTypeVars struct + +stackBot label byte +; +; The "stack" overlaps everything above this point +; + +x_offset sword ;x offset to create character +y_offset sword ;y offset to create character + +penPos Point <0, 0> ;pen position used for drawing + ;characters into a passed RegionPath + ;for NimbusGenInRegion(). +; +; Used to save passed variables: +; +genOffset word 0 ;offset of CharGenData +fontSegment word 0 ;seg addr of font +fontHandle hptr 0 ;handle of font +infoSegment word 0 ;seg addr of info block +gstateSegment word 0 ;seg addr of GState + +TrueTypeVars ends + +TrueTypeSubTable struct + TTST_scalerType dword + TTST_numTables word + TTST_searchRange word + TTST_entrySelector word + TTST_rangeShift word +TrueTypeSubTable ends + +TrueTypeTableHeader struct + TTTH_dword0 dword + TTTH_dword1 dword + TTTH_dword2 dword + TTTH_dword3 dword +TrueTypeTableHeader ends + + +;------------------------------------------------------------------------------ + +;------------------------------------------------------------------------------ +; Initialized variables +;------------------------------------------------------------------------------ + +idata segment + +if DBCS_PCGEOS +truetypeDir wchar 'TTF',0 +else +truetypeDir char 'TTF',0 +endif + +idata ends + +;------------------------------------------------------------------------------ +; Uninitialized varaibles +;------------------------------------------------------------------------------ + +udata segment + +bitmapHandle hptr ;handle of our bitmap block +bitmapSize word ;size of our bitmap block (in bytes) + +variableHandle hptr ;handle of our variable block + +udata ends + + diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/truetypeWidths.asm new file mode 100644 index 000000000..df274e67b --- /dev/null +++ b/Driver/Font/TrueType/truetypeWidths.asm @@ -0,0 +1,69 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType Font Driver +FILE: truetypeWidths.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenWidths Generate font header and widths for a font. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + Implements a font driver for: + The TrueType outline fonts + + $Id: truetypeWidths.asm,v 1.1 97/04/18 11:45:30 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenWidths +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate the character width table for a font. +CALLED BY: EXTERNAL: GrFindFont + +PASS: di - 0 for new font; handle to rebuild old font (P'd) + es - seg addr of gstate (locked) + GS_fontAttr - font attributes + bp:cx - transformation matrix (TMatrix) + ds - seg addr of font info block +RETURN: bx - handle of font (locked) + ax - seg addr of font (locked) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + di is the bx passed to TrueTypeStrategy. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenWidths proc far + uses cx, dx, si, di, ds, es, bp + + mov bx, bp + .enter + + clc ;indicate no error + + .leave + ret +TrueTypeGenWidths endp diff --git a/Include/fontID.def b/Include/fontID.def index cd15cf3dd..df671c2ee 100644 --- a/Include/fontID.def +++ b/Include/fontID.def @@ -33,6 +33,7 @@ FM_NIMBUSQ enum FontMaker FM_ADOBE enum FontMaker FM_BITSTREAM enum FontMaker FM_AGFA enum FontMaker +FM_TRUETYPE enum FontMaker FM_PUBLIC enum FontMaker, 0xc000 FM_ATECH enum FontMaker, 0xd000 FM_MICROLOGIC enum FontMaker, 0xe000 diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile new file mode 100644 index 000000000..44877a5af --- /dev/null +++ b/Installed/Driver/Font/TrueType/Makefile @@ -0,0 +1,30 @@ +# +# THIS FILE HAS BEEN GENERATED AUTOMATICALLY. +# +# If you edit it, you will lose your changes, should it be regenerated. +# +GEODE = truetype +ASM_TO_OBJS = truetype.asm +UI_TO_RDFS = +SRCS = truetype.asm truetypeChars.asm truetypeEC.asm\ + truetypeEscape.asm truetypeInit.asm truetypeMetrics.asm\ + truetypePath.asm truetypeWidths.asm fontcomUtils.asm\ + fontcomEscape.asm truetypeConstant.def truetypeMacros.def\ + truetypeVariable.def +OBJS = truetype.obj +LOBJS = + +SYSMAKEFILE = geode.mk + +#include +#include + +#if exists(local.mk) +#include "local.mk" +#else +#include <$(SYSMAKEFILE)> +#endif + +#if exists($(DEPFILE)) +#include "$(DEPFILE)" +#endif diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk new file mode 100644 index 000000000..52a9a0fe3 --- /dev/null +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -0,0 +1,15 @@ +truetype.obj \ +truetype.eobj: geos.def heap.def geode.def resource.def ec.def driver.def \ + lmem.def graphics.def fontID.def font.def color.def \ + gstring.def text.def char.def sem.def file.def \ + localize.def sllang.def system.def fileEnum.def \ + Internal/fontDr.def Internal/tmatrix.def \ + Internal/grWinInt.def Internal/gstate.def \ + Internal/window.def win.def Internal/threadIn.def \ + truetypeConstant.def truetypeVariable.def \ + truetypeMacros.def truetypeWidths.asm fontcomUtils.asm \ + truetypeChars.asm truetypeMetrics.asm truetypePath.asm \ + truetypeInit.asm truetypeEscape.asm fontcomEscape.asm \ + truetypeEC.asm + +truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file From c999d1854ed55db344106c7536a5ff333f7d621f Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Thu, 26 Aug 2021 00:11:36 +0200 Subject: [PATCH 009/246] Add TrueType fonr driver to the Ensemble build chain and the resulting Ensemble setup. #129 --- CInclude/fontID.h | 1 + Installed/Makefile | 5 ++++- Tools/build/product/bbxensem/Template/geos.ini | 5 +++++ Tools/build/product/bbxensem/bbxensem.filetree | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CInclude/fontID.h b/CInclude/fontID.h index 04a2a947c..78a721390 100644 --- a/CInclude/fontID.h +++ b/CInclude/fontID.h @@ -29,6 +29,7 @@ typedef word FontMaker; #define FM_MICROLOGIC 0xe000 #define FM_ATECH 0xd000 #define FM_PUBLIC 0xc000 +#define FM_TRUETYPE 0x5000 #define FM_AGFA 0x4000 #define FM_BITSTREAM 0x3000 #define FM_ADOBE 0x2000 diff --git a/Installed/Makefile b/Installed/Makefile index 0c581e348..d29547b3d 100644 --- a/Installed/Makefile +++ b/Installed/Makefile @@ -165,7 +165,7 @@ minimalDriver : nimbus ms4 ntfat os2 cdrom stream dri gdi keyboard modem gdipoin ps2 msys msser msbus kbmouse absgen genmouse emm extmem \ xms filestr nonts sblaster comm spooltd \ vmtree filedd logibus logiser dma mslf kbd_drivers \ - etherodi etherpkt msnet cdados + etherodi etherpkt msnet cdados truetype printerDriver : deskjet dj500c lbp mercury pcl4 quietjet canon48 \ canonbjc epshi24 epson24 epson48 nec24 \ @@ -560,6 +560,9 @@ Installed/Driver/Stream: kernel MAKEDRV nimbus : Installed/Driver/Font/Nimbus Installed/Driver/Font/Nimbus: kernel MAKEDRV +truetype : Installed/Driver/Font/TrueType +Installed/Driver/Font/TrueType: kernel MAKEDRV + ms4 : Installed/Driver/IFS/DOS/MS4 Installed/Driver/IFS/DOS/MS4: kernel MAKEDRV diff --git a/Tools/build/product/bbxensem/Template/geos.ini b/Tools/build/product/bbxensem/Template/geos.ini index 1b6d97f26..c89e6a6ce 100644 --- a/Tools/build/product/bbxensem/Template/geos.ini +++ b/Tools/build/product/bbxensem/Template/geos.ini @@ -14,6 +14,11 @@ fontsize = 12 drive b = 0 editableTextFontID = Esquire +font = { + EC-dos(nimbus.geo) + EC-dos(truetype.geo) +} + [diskswap] size = 4096 diff --git a/Tools/build/product/bbxensem/bbxensem.filetree b/Tools/build/product/bbxensem/bbxensem.filetree index 42522c67f..b6ebcc538 100644 --- a/Tools/build/product/bbxensem/bbxensem.filetree +++ b/Tools/build/product/bbxensem/bbxensem.filetree @@ -422,6 +422,7 @@ DIR (ensemble) { DIR (font) { Driver/Font/Nimbus/{dbcs}/nimbus{ec}.geo GFS LOCALPC + Driver/Font/TrueType/{dbcs}/truetype{ec}.geo GFS LOCALPC } DIR (fs) { From e56a59ac8bb44acc8368ed4801bf9f6365b32455 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Sat, 28 Aug 2021 19:54:37 +0200 Subject: [PATCH 010/246] Make TrueType driver actually load and ttf file enumeration to start looking in the files header. #129 --- Driver/Font/TrueType/local.mk | 2 ++ Driver/Font/TrueType/truetypeInit.asm | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk index 425ed4422..d30315277 100644 --- a/Driver/Font/TrueType/local.mk +++ b/Driver/Font/TrueType/local.mk @@ -15,6 +15,8 @@ ############################################################################### ASMFLAGS += -i +_PROTO = 3.0 + .PATH.asm .PATH.def: ../FontCom $(INSTALL_DIR:H)/FontCom \ #include <$(SYSMAKEFILE)> diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm index 37095323f..9a1df5e44 100644 --- a/Driver/Font/TrueType/truetypeInit.asm +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -246,7 +246,6 @@ fontId local FontID fontInfoChunk local word .enter -if 0 ; ; generate font id from file names first character for now ; @@ -256,7 +255,7 @@ if 0 mov fontId, ax ; - ; open cached data file + ; open truetype file ; mov dx, si ; ds:dx = name mov al, FILE_ACCESS_R or FILE_DENY_W @@ -275,6 +274,7 @@ if 0 call FileRead jc doneClose +if 0 ; ; create a new FontsAvailEntry @@ -355,11 +355,11 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > LocalPutChar esdi, ax ; ensure null term pop es, ds, si ; restore FFLH, FontInfo +endif doneClose: mov al, FILE_NO_ERRORS call FileClose -endif done: .leave From 6a8b0b469fee3cdf092a2735d7c263d68284248d Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Fri, 10 Sep 2021 23:56:00 +0200 Subject: [PATCH 011/246] First implementation of the generic integration of the TrueType font driver. It combines fonts by family and build up a list of outlines based on nique style and weight. #129 --- Driver/Font/TrueType/truetypeInit.asm | 641 +++++++++++++++++++++- Driver/Font/TrueType/truetypeVariable.def | 17 +- 2 files changed, 626 insertions(+), 32 deletions(-) diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm index 9a1df5e44..e61f76018 100644 --- a/Driver/Font/TrueType/truetypeInit.asm +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -22,7 +22,7 @@ REVISION HISTORY: DESCRIPTION: Initialization & exit routines for TrueType font driver - + $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ @@ -154,11 +154,11 @@ REVISION HISTORY: initFontReturnAttr FileExtAttrDesc \ , - + TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp - + .enter - + ; ; Enumerate files in SP_FONT ; @@ -177,7 +177,7 @@ TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp sub sp, size FileEnumParams mov bp, sp ; GEOS datafiles - mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS + mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS ; return longname mov ss:[bp].FEP_returnAttrs.segment, cs mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr @@ -185,7 +185,7 @@ TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED ; callback sees all files mov ss:[bp].FEP_matchAttrs.segment, 0 - + mov ss:[bp].FEP_skipCount, 0 call FileEnum ; cx = # found, bx = handle jc done ; error @@ -204,7 +204,7 @@ done: clc .leave ret - + TrueTypeInitFonts endp @@ -235,20 +235,28 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ProcessFont proc far - + uses ax, bx, cx, di, si, es, ds - + fontNameSeg local sptr push ds fontNameOff local word push si fontBlockSeg local sptr push dx subTableHeader local TrueTypeSubTable +tableDirectory local TrueTypeTableDirectory fontId local FontID fontInfoChunk local word - +tableCount local word +fontFile local hptr +fontName local FONT_NAME_LEN dup (char) +fontStyle local TextStyle +fontWeight local FontWeight + .enter ; ; generate font id from file names first character for now ; + mov fontWeight, FW_NORMAL + clr ah mov al, ds:[si] add ax, FM_TRUETYPE @@ -261,21 +269,231 @@ fontInfoChunk local word mov al, FILE_ACCESS_R or FILE_DENY_W call FileOpen jc done - + mov bx, ax ; file handle to bx - + mov fontFile, bx + segmov ds, ss lea dx, subTableHeader - + mov al, 0 - + mov cx, size subTableHeader ; size to read - - call FileRead + + call FileRead jc doneClose -if 0 + ; + ; scan all TTF file tables + ; keep structures and meta data needed to serve the font + ; + mov ah, subTableHeader.TTST_numTables.low + mov al, subTableHeader.TTST_numTables.high + mov tableCount, ax +nextEntry: + mov bx, fontFile + segmov ds, ss + lea dx, tableDirectory + mov al, 0 + + mov cx, size tableDirectory ; size to read + + call FileRead + jc doneClose + ; remember file position + mov cx, 0 + mov dx, 0 + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_RELATIVE ; jump from start + call FilePos ; get current pos to dx:ax + jc doneClose + mov cx, dx + mov dx, ax + + mov ax, 'na' + cmp ax, tableDirectory.TTTD_tag.low + jne tryOS_2 + mov ax, 'me' + cmp ax, tableDirectory.TTTD_tag.high + jne tryOS_2 + + lea si, tableDirectory + call LoadTable + + cmp bx, 0 ; failed to load? + je doneClose + + ; restore file position, cxdx hold position + push bx + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + call FilePos + pop bx + jnc parseName + + ; free the block we don't keep it, bx handle of block + call MemFree + jmp doneClose + +parseName: + ; get relevant data from name table + + ; first load sub family (and reuse the buffer fontName) and map + ; the value to TextStyle bits to describe the resulting + ; font entry + lea si, fontName ; ss:si point to buffer + mov cx, FONT_NAME_LEN ; buffer size + mov ax, 2 ; sub family name of the font + call GetNameFromTable + jc doneClose ; jump if no name found + + lea si, fontName ; ss:si point to buffer + call MapFontStyle + jc doneClose ; fail if style mapping fails + + mov fontStyle, al ; save fontStyle + ; (type TextStyle) + ; ds is pointing to the name table here + lea si, fontName ; ss:si point to buffer + mov cx, FONT_NAME_LEN ; buffer size + mov ax, 1 ; family name of the font + call GetNameFromTable + jc doneClose ; jump if no name found + + ; free the block we don't keep it, bx handle of block + call MemFree +tryOS_2: + mov ax, 'OS' + cmp ax, tableDirectory.TTTD_tag.low + jne cont + mov ax, '/2' + cmp ax, tableDirectory.TTTD_tag.high + jne cont +loadOS_2: + lea si, tableDirectory + call LoadTable + + cmp bx, 0 ; failed to load? + je doneClose + + ; restore file position, cxdx hold position + push bx + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + call FilePos + pop bx + jnc getWeight + + ; free the block we don't keep it, bx handle of block +freeAndClose: + call MemFree + jmp doneClose + +getWeight: + mov ah, ds:4 + mov al, ds:5 + mov dx, 0 + mov si, 100 + div si + cmp dx, 0 + jne freeAndClose + cmp ax, 10 + jnc freeAndClose + + mov si, ax + mov al, cs:weightAdjustTable[si] + mov fontWeight, al + +cont: + dec tableCount + jnz nextEntry + + ; we have one font and collected required meta data + ; let compute/determ the fontid to be used for the font + mov ax, 0 + lea si, fontName ; ss:si point to buffer + mov cx, 0 +calcFontId: + + xor al, ss:0[si] + + xor ah, ss:1[si] + + inc cx + cmp cx, FONT_NAME_LEN + je doneFontId + inc si + cmp ss:0[si], 0 + jnz calcFontId + + and ah, 00000001b + or ax, FM_TRUETYPE + or ah, 00001110b + mov fontId, ax +doneFontId: + + ; lookup if there is a FontsAvailEntry for the font already + mov cx, fontId + mov ds, fontBlockSeg + mov di, ds:[FONTS_AVAIL_HANDLE] ;di <- ptr to chunk + ChunkSizePtr ds, di, ax ;ax <- chunk size + add ax, di ;ax -> end of chunk +IFA_loop: + cmp di, ax ;are we thru the list? + jae noMatch ;yes, exit carry clear + cmp ds:[di].FAE_fontID, cx ;see if ID matches + je match ;we have a match, branch + add di, size FontsAvailEntry ;else move to next entry + jmp IFA_loop ;and loop + +match: + ; font already registered, check if there is already equal outline + ; outline is equal if style and weight is equal + mov di, ds:[di].FAE_infoHandle ; ds:si = FontInfo chunk handle + mov si, ds:[di] ; ds:si = FontInfo ptr + + mov cx, ds:[si].FI_outlineEnd + push si + mov si, ds:[si].FI_outlineTab + +checkOutline: + mov al, ds:[si].ODE_style + cmp al, fontStyle + jne nextOutline + + mov al, ds:[si].ODE_weight + cmp al, fontStyle + jne nextOutline + + ; matching outline found + pop ax + jmp doneClose ; skip this font + +nextOutline: + add si, size OutlineDataEntry + cmp si, cx + jne checkOutline + +appendOutline: + ; not found, append new outline + pop si + + mov bx, cx ; append at end + + push cx + add cx, size OutlineDataEntry + mov ds:[si].FI_outlineEnd, cx + + mov ax, di ; *ds:ax = chunk + mov cx, size OutlineDataEntry ; cx = sizeof outline entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + + pop si + jmp initEntry + +noMatch: ; ; create a new FontsAvailEntry ; @@ -298,7 +516,7 @@ if 0 ; rather than for each typeface (which this field is for) ; mov ds:[si].FAE_fileName, 0 - + ; ; allocate a chunk for the FontInfo block ; @@ -314,6 +532,7 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > call LMemAlloc ; ds updated, ax = chunk mov fontBlockSeg, ds ; store it mov fontInfoChunk, ax + ; ; finish filling the FontsAvailEntry ; dx = end of OutlineDataEntrys @@ -332,9 +551,10 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > mov ax, fontId mov ds:[si].FI_fontID, ax mov ds:[si].FI_maker, FM_TRUETYPE - mov al, es:[FFLH_fontFamily] - mov ds:[si].FI_family, al - mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? + mov al, FF_NON_PORTABLE + mov ds:[si].FI_family, al ; this is called family but it + ; actually is FontAttrs + mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? (for now) mov ds:[si].FI_pointSizeEnd, 0 mov ds:[si].FI_outlineTab, size FontInfo mov ds:[si].FI_outlineEnd, dx @@ -345,9 +565,10 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > ; push es, ds, si ; save FFLH, FontInfo segxchg es, ds ; es:di = FI_faceName + segmov ds, ss mov di, si add di, FI_faceName - mov si, offset FFLH_faceName ; ds:si = FFLH_faceName + lea si,fontName ; ds:si = fontName mov cx, length FI_faceName ; dest. size LocalCopyNString LocalPrevChar esdi @@ -355,14 +576,384 @@ EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > LocalPutChar esdi, ax ; ensure null term pop es, ds, si ; restore FFLH, FontInfo -endif - + add si, size FontInfo ; ds:si = first OutlineDataEntry +initEntry: + call initOutlineEntry + doneClose: + mov bx, fontFile mov al, FILE_NO_ERRORS call FileClose done: + mov dx, fontBlockSeg + .leave + ret + +weightAdjustTable byte \ + 80, ;FWE_ULTRA_LIGHT + 85, ;FWE_EXTRA_LIGHT + 90, ;FWE_LIGHT + 95, ;FWE_BOOK + 100, ;FWE_NORMAL + 105, ;FWE_DEMI + 110, ;FWE_BOLD + 115, ;FWE_EXTRA_BOLD + 120, ;FWE_ULTRA_BOLD + 125 ;FWE_BLACK + +initOutlineEntry label near + ; + ; style and weight + ; ds:si = OutlineDataEntry + ; + mov al, fontStyle ; font style + mov ds:[si].ODE_style, al + mov al, fontWeight ; font weight + mov ds:[si].ODE_weight, al + ; + ; now allocate and fill in a TrueTypeOutlineEntry + ; ds:si = OutlineDataEntry + ; fontNameSeg:fontNameOff = font file name + ; + mov bx, si + mov si, fontInfoChunk + mov si, ds:[si] + sub bx, si ; bx = offset to ODE + mov cx, size TrueTypeOutlineEntry ; fixed size + clr ax + call LMemAlloc ; ax = BOE chunk, ds updated + mov fontBlockSeg, ds ; store it + mov si, fontInfoChunk + mov si, ds:[si] ; ds:si = FontInfo + add si, bx ; ds:si = OutlineDataEntry +if DBCS_PCGEOS + mov ds:[si].ODE_extraData, ax +else + ; store chunk at OutlineEntrys + mov ds:[si][(size ODE_style + size ODE_weight)], ax +endif + mov si, ax + mov di, ds:[si] + mov bx, di ; es:bx = TrueTypeOutlineEntry + segmov es, ds ; es:di = TrueTypeOutlineEntry +.assert (offset TTOE_fontFileName) eq 0 + mov ds, fontNameSeg ; ds:si = font filename + mov si, fontNameOff + mov cx, size TTOE_fontFileName ; dest. size + rep movsb + retn + +ProcessFont endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + LoadTable +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Load ttf table into memory block + +CALLED BY: ProcessFont + +PASS: ss:si - table directory entry + bx - file handle + +RETURN: ds - segment of locked table (on success) + bx - handle of table block (0 if FAILURE) + +DESTROYED: Current file position in the given file. + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 8/30/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +LoadTable proc near + uses ax, cx, dx, di + +newBlock local hptr + .enter + + mov newBlock, handle 0 + + tst ss:[si].TTTD_length.low ; actually the high word + jnz err ; -> error if above 64K + mov al, ss:[si].TTTD_length.high.high + mov ah, ss:[si].TTTD_length.high.low + mov di, ax + + mov dx, bx ; keep file handle + mov bx, handle 0 ; bx <- make TrueType owner + mov cx, ALLOC_DYNAMIC_LOCK + call MemAllocSetOwner ; allocate blk for table + jc err + + mov newBlock, bx + segmov ds, ax + + mov bx, dx ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + mov dl, ss:[si].TTTD_offset.high.high + mov dh, ss:[si].TTTD_offset.high.low + mov cl, ss:[si].TTTD_offset.low.high + mov ch, ss:[si].TTTD_offset.low.low + + call FilePos + jc err + + mov dx, 0 ; buffer offset in segment + mov cx, di ; size + clr al + call FileRead + jc err + + mov bx, newBlock +done: + .leave + ret + +err: + mov bx, 0 + mov ax, newBlock + jz done + call MemFree + jmp done + +LoadTable endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + GetNameFromTable +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Load ttf table into memory block + +CALLED BY: ProcessFont + +PASS: ss:si - buffer to hold the result + cx - buffer size (to include \0 terminiation) + ds - name table segment + +RETURN: carry set on not found + Otherwise buffer filled, \0 terminated, if cx is not 0. + if cx is 0 then the buffer is filled but without \n termination. + +DESTROYED: ax, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 8/30/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +GetNameFromTable proc near + uses bx, di, dx + +dataOffset local word +encoding local byte + .enter + + mov bx, ax + mov di, si + + ; check version + mov ax, ds:0 + cmp ax, 0 + jne err + + ; scan the name record table + mov ah, ds:4 + mov al, ds:5 + mov dataOffset, ax + + mov dx, ds:2 + mov si, 6 +recordLoop: + mov ax, ds:0[si] + cmp ax, 0100h + je macEncoding + cmp ax, 0 ; unicode + jne next + mov ah, ds:2[si] + mov al, ds:3[si] + cmp ax, 3 ; Unicode 2.0 BPM + jne next + mov ax, ds:4[si] + cmp ax, 0 ; language should be 0 for + ; unicode + jne next + mov encoding, 0 + jmp enterLoop + +macEncoding: + mov ah, ds:2[si] + mov al, ds:3[si] + cmp ax, 0 ; Roman? + jne next + mov ax, ds:4[si] + cmp ax, 0 ; English? + jne next + + mov encoding, 1 ; 1 = non-unicode + +enterLoop: + ; match the name id + mov ah, ds:6[si] + mov al, ds:7[si] + cmp ax, bx + jne next + + mov dh, ds:8[si] + mov dl, ds:9[si] + + mov ah, ds:10[si] + mov al, ds:11[si] + add ax, dataOffset + mov si, ax +copyLoop: + cmp encoding, 0 + jne nextByte + mov ah, ds:0[si] + inc si + dec dx + jz endOfBuffer +nextByte: + mov al, ds:0[si] + inc si + + mov ss:0[di], al + inc di + dec cx + jz endOfBuffer + dec dx + jnz copyLoop +endOfBuffer: + cmp cx, 0 + jz success + mov ss:0[di], 0 + jmp success +next: + mov ax, si + add ax, 12 ; size of name record + mov si, ax + + dec dx + jnz recordLoop + jz err + +success: + clc +done: + .leave + ret + +err: + stc + jc done + +GetNameFromTable endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + MapFontStyle +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: MapFontStyle + +CALLED BY: ProcessFont + +PASS: ss:si - buffer to sub family name + +RETURN: carry set if mapping failed + al - on success, mapped TextStyle + +DESTROYED: ah + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 9/9/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +LocalDefNLString StyleRegular, <"Regular", 0> +LocalDefNLString StyleBold, <"Bold", 0> +LocalDefNLString StyleItalic, <"Italic", 0> +LocalDefNLString StyleBoldItalic, <"Bold Italic", 0> +LocalDefNLString StyleOblique, <"Oblique", 0> +LocalDefNLString StyleBoldOblique, <"Bold Oblique", 0> + +styleNames nptr \ + StyleRegular, + StyleBold, + StyleItalic, + StyleBoldItalic, + StyleOblique, + StyleBoldOblique + +styleFlags TextStyle \ + 0, + mask TS_BOLD, + mask TS_ITALIC, + mask TS_BOLD or mask TS_ITALIC, + mask TS_ITALIC, + mask TS_BOLD or mask TS_ITALIC + +MapFontStyle proc near + uses es, ds, di, si, cx, bx + + .enter +; +; Find the style +; + segmov es, ss + mov di, si ;es:di <- string to look for +; +; Find the sub family name in the table +; + mov cx, length styleNames ;cx <- # of entries + clr bx ;bx <- table index + segmov ds, cs +styleLoop: + push cx + mov si, cs:styleNames[bx] ;ds:si <- extension + clr cx ;cx <- NULL-terminated + call LocalCmpStringsNoCase + pop cx + je foundStyle ;branch if match + add bx, (size nptr) ;bx <- next entry + loop styleLoop ;loop for more + jmp notFound + +; +; Found the style -- return the flags +; +foundStyle: + sar bx, 1 + mov al, cs:styleFlags[bx] ;ds:si <- library name + clc ;carry <- no error +done: + .leave ret -ProcessFont endp \ No newline at end of file +notFound: + stc ;carry <- error + jmp done + +MapFontStyle endp diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def index 6350bb8f8..d5126e846 100644 --- a/Driver/Font/TrueType/truetypeVariable.def +++ b/Driver/Font/TrueType/truetypeVariable.def @@ -57,13 +57,16 @@ TrueTypeSubTable struct TTST_rangeShift word TrueTypeSubTable ends -TrueTypeTableHeader struct - TTTH_dword0 dword - TTTH_dword1 dword - TTTH_dword2 dword - TTTH_dword3 dword -TrueTypeTableHeader ends - +TrueTypeTableDirectory struct + TTTD_tag dword + TTTD_checkSum dword + TTTD_offset dword + TTTD_length dword +TrueTypeTableDirectory ends + +TrueTypeOutlineEntry struc + TTOE_fontFileName DosDotFileName +TrueTypeOutlineEntry ends ;------------------------------------------------------------------------------ From f526fedec7a5ca28c2961377670501c1e2db5bac Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 15 Jan 2022 20:55:29 +0100 Subject: [PATCH 012/246] compilable version freetype 1 --- .../ttf2/FreeType/arch/amigaos/Makefile.gcc | 69 + .../ttf2/FreeType/arch/amigaos/freetype.c | 25 + .../ttf2/FreeType/arch/amigaos/ft_conf.h | 220 + .../ttf2/FreeType/arch/ansi/freetype.c | 32 + .../ttf2/FreeType/arch/ansi/ft_conf.h | 227 + .../ttf2/FreeType/arch/debugger/freetype.c | 32 + .../ttf2/FreeType/arch/debugger/ft_conf.h | 236 + .../ttf2/FreeType/arch/geos/ft_conf.h | 230 + .../testapps/ttf2/FreeType/arch/mac/README | 47 + .../ttf2/FreeType/arch/mac/freetype.c | 48 + .../testapps/ttf2/FreeType/arch/mac/ft_conf.h | 211 + .../testapps/ttf2/FreeType/arch/mac/ttmmap.c | 1069 +++ .../ttf2/FreeType/arch/msdos/Makefile.BC | 132 + .../ttf2/FreeType/arch/msdos/Makefile.MS | 117 + .../ttf2/FreeType/arch/msdos/Makefile.TC | 86 + .../ttf2/FreeType/arch/msdos/Makefile.VC | 117 + .../ttf2/FreeType/arch/msdos/Makefile.dm | 84 + .../ttf2/FreeType/arch/msdos/Makefile.gcc | 92 + .../ttf2/FreeType/arch/msdos/Makefile.wat | 88 + .../ttf2/FreeType/arch/msdos/depend.dos | 107 + .../ttf2/FreeType/arch/msdos/freetype.c | 39 + .../ttf2/FreeType/arch/msdos/ft_conf.h | 253 + .../ttf2/FreeType/arch/msdos/hugefile.c | 84 + .../ttf2/FreeType/arch/msdos/hugemem.c | 496 ++ .../testapps/ttf2/FreeType/arch/msdos/makedep | 26 + .../ttf2/FreeType/arch/os2/Makefile.dm | 84 + .../ttf2/FreeType/arch/os2/Makefile.emx | 91 + .../ttf2/FreeType/arch/os2/Makefile.icc | 73 + .../ttf2/FreeType/arch/os2/Makefile.wat | 88 + .../ttf2/FreeType/arch/os2/freetype.c | 32 + .../testapps/ttf2/FreeType/arch/os2/ft_conf.h | 239 + .../testapps/ttf2/FreeType/arch/os2/os2file.c | 1237 +++ .../ttf2/FreeType/arch/unix/.cvsignore | 1 + .../ttf2/FreeType/arch/unix/Makefile.in | 244 + .../ttf2/FreeType/arch/unix/freetype.c | 27 + .../testapps/ttf2/FreeType/arch/unix/ttmmap.c | 1027 +++ .../testapps/ttf2/FreeType/arch/vms/README | 20 + .../ttf2/FreeType/arch/vms/descrip.mms | 155 + .../testapps/ttf2/FreeType/arch/vms/ft_conf.h | 215 + .../ttf2/FreeType/arch/win16/Makefile.BC | 180 + .../ttf2/FreeType/arch/win16/Makefile.MS | 106 + .../ttf2/FreeType/arch/win16/Makefile.VC | 175 + .../ttf2/FreeType/arch/win16/depend.win | 109 + .../ttf2/FreeType/arch/win16/freetype.c | 39 + .../ttf2/FreeType/arch/win16/ft_conf.h | 209 + .../ttf2/FreeType/arch/win16/hugefile.c | 51 + .../ttf2/FreeType/arch/win16/hugemem.c | 539 ++ .../testapps/ttf2/FreeType/arch/win16/makedef | 24 + .../testapps/ttf2/FreeType/arch/win16/makedep | 32 + .../testapps/ttf2/FreeType/arch/win16/ttf.def | 127 + .../ttf2/FreeType/arch/win32/Makefile.BC | 161 + .../ttf2/FreeType/arch/win32/Makefile.CL | 165 + .../ttf2/FreeType/arch/win32/Makefile.Min | 98 + .../ttf2/FreeType/arch/win32/Makefile.VC | 195 + .../ttf2/FreeType/arch/win32/Makefile.gcc | 96 + .../ttf2/FreeType/arch/win32/depend.win | 103 + .../ttf2/FreeType/arch/win32/freetype.c | 42 + .../ttf2/FreeType/arch/win32/freetype.dsp | 104 + .../ttf2/FreeType/arch/win32/freetype.dsw | 29 + .../ttf2/FreeType/arch/win32/freetype.ide | Bin 0 -> 35589 bytes .../ttf2/FreeType/arch/win32/freetype.mak | 353 + .../ttf2/FreeType/arch/win32/ft_conf.h | 210 + .../testapps/ttf2/FreeType/arch/win32/makedef | 24 + .../testapps/ttf2/FreeType/arch/win32/makedep | 29 + .../testapps/ttf2/FreeType/arch/win32/ttf.def | 127 + .../testapps/ttf2/FreeType/freetype.h | 1147 +++ .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 231 + .../Breadbox/testapps/ttf2/FreeType/fterrid.h | 161 + .../testapps/ttf2/FreeType/ftnameid.h | 628 ++ Appl/Breadbox/testapps/ttf2/FreeType/header.h | 49 + Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 2219 ++++++ .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 463 ++ .../Breadbox/testapps/ttf2/FreeType/ttcache.h | 216 + Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.c | 403 + Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.h | 97 + Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c | 503 ++ Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h | 169 + .../testapps/ttf2/FreeType/ttconfig.h | 279 + .../Breadbox/testapps/ttf2/FreeType/ttdebug.c | 404 + .../Breadbox/testapps/ttf2/FreeType/ttdebug.h | 170 + .../testapps/ttf2/FreeType/ttengine.h | 115 + .../testapps/ttf2/FreeType/ttextend.c | 212 + .../testapps/ttf2/FreeType/ttextend.h | 168 + Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c | 1222 +++ Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h | 271 + .../Breadbox/testapps/ttf2/FreeType/ttgload.c | 1351 ++++ .../Breadbox/testapps/ttf2/FreeType/ttgload.h | 51 + .../testapps/ttf2/FreeType/ttinterp.c | 6654 +++++++++++++++++ .../testapps/ttf2/FreeType/ttinterp.h | 54 + Appl/Breadbox/testapps/ttf2/FreeType/ttload.c | 1574 ++++ Appl/Breadbox/testapps/ttf2/FreeType/ttload.h | 217 + .../testapps/ttf2/FreeType/ttmemory.c | 397 + .../testapps/ttf2/FreeType/ttmemory.h | 125 + .../Breadbox/testapps/ttf2/FreeType/ttmutex.c | 85 + .../Breadbox/testapps/ttf2/FreeType/ttmutex.h | 59 + Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 1494 ++++ Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 873 +++ .../testapps/ttf2/FreeType/ttraster.c | 2727 +++++++ .../testapps/ttf2/FreeType/ttraster.h | 127 + .../testapps/ttf2/FreeType/tttables.h | 215 + Appl/Breadbox/testapps/ttf2/FreeType/tttags.h | 61 + .../Breadbox/testapps/ttf2/FreeType/tttypes.h | 150 + Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 124 + Appl/Breadbox/testapps/ttf2/backlog.md | 22 + Appl/Breadbox/testapps/ttf2/ttf2.gp | 18 + Appl/Breadbox/testapps/ttf2/ttmutex.c | 85 + .../Appl/Breadbox/testapps/ttf2/Makefile | 40 + .../Breadbox/testapps/ttf2/dependencies.mk | 133 + 108 files changed, 36790 insertions(+) create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.TC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.VC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.dm create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c create mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.VC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/depend.win create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c create mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef create mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.Min create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.ide create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.mak create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ft_conf.h create mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef create mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/freetype.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/fterrid.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ftnameid.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/header.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttgload.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttgload.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttload.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttload.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/tttables.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/tttags.h create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/tttypes.h create mode 100644 Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc create mode 100644 Appl/Breadbox/testapps/ttf2/backlog.md create mode 100644 Appl/Breadbox/testapps/ttf2/ttf2.gp create mode 100644 Appl/Breadbox/testapps/ttf2/ttmutex.c create mode 100644 Installed/Appl/Breadbox/testapps/ttf2/Makefile create mode 100644 Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc new file mode 100644 index 000000000..94d01aa15 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc @@ -0,0 +1,69 @@ +# This file is part of the FreeType project. +# +# It builds the library and test programs for amiga using ADE Enviroment. +# +# You will need GNU make. +# +# Use this file while in the lib directory with the following statement: +# +# make -f arch/amigaos/Makefile.gcc + +ARCH = arch/amigaos +FT_MAKEFILE = $(ARCH)/Makefile.gcc + +AR = ar +RM = rm + +CC = gcc + +CFLAGS = -Wall -pedantic -ansi -O2 -g -noixemul -I$(ARCH) -I. -Iextend + +SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ + extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ + extend/ftxgsub.c extend/ftxgpos.c extend/ftxgdef.c \ + extend/ftxopen.c +OBJS_X = $(SRC_X:.c=.o) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttextend.c ttfile.c ttgload.c ttinterp.c ttload.c \ + ttmemory.c ttmutex.c ttobjs.c ttraster.c +OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) + +SRC_S = $(ARCH)/freetype.c +OBJ_S = $(SRC_S:.c=.o) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: all debug clean distclean + + +all: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a + +debug: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a + + +$(OBJ_S): $(SRC_S) $(SRC_M) + + +libttf.a: $($(LIB_FILES)) + $(AR) src $@ $^ + +clean: + $(RM) $($(LIB_FILES)) + +distclean: clean + $(RM) dep.end libttf.a + +depend: $(SRC_S) $(SRC_M) $(SRC_X) + $(CC) -E -M $^ > dep.end + +ifeq (dep.end,$(wildcard dep.end)) + include dep.end +endif + +# end of Makefile.gcc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c new file mode 100644 index 000000000..cdb9b6c72 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c @@ -0,0 +1,25 @@ +/* This file is part of the FreeType project */ + +/* Single object library component for AmigaOS */ +#define TT_MAKE_OPTION_SINGLE_OBJECT + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttfile.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttmemory.c" +#include "ttmutex.c" +#include "ttobjs.c" +#include "ttraster.c" + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h new file mode 100644 index 000000000..ea16de085 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h @@ -0,0 +1,220 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for AmigaOS using ADE enviroment */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the keyword does not work. */ + +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ + +/* #undef HAVE_MMAP */ + +/* Define if you have the header file. */ + +#define HAVE_STDLIB_H + +/* Define if the X Window System is missing or not being used. */ + +#define X_DISPLAY_MISSING + +/* The number of bytes in a int. */ + +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ + +#define SIZEOF_LONG 4 + +/* Define if you have the getpagesize function. */ + +#define HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ + +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ + +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ + +#define HAVE_VALLOC + +/* Define if you have the header file. */ + +#define HAVE_FCNTL_H + +/* Define if you have the header file. */ + +#define HAVE_UNISTD_H + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c new file mode 100644 index 000000000..f7d89e43d --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c @@ -0,0 +1,32 @@ +/* This file is part of the FreeType project */ + +/* Single file library component for the ANSI target */ +#define TT_MAKE_OPTION_SINGLE_OBJECT + +/* first include common core components */ + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* then system-specific (or ANSI) components */ + +#include "ttfile.c" +#include "ttmemory.c" +#include "ttmutex.c" + +/* the extensions are compiled separately, but we need to */ +/* include the file ttextend.c if we want to support them */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h new file mode 100644 index 000000000..839a229da --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h @@ -0,0 +1,227 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for the ANSI Build */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. Unix-specific */ +#undef HAVE_FCNTL_H + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + + +/* The number of bytes in a int. We use the ANSI header file limits.h */ +/* for determining it since there is no easy way to guess. */ +/* */ +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +/* We now try to guess the size of longs in the same way */ +/* */ +#if ULONG_MAX == 0xFFFFFFFF +#define SIZEOF_LONG 4 +#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF +#define SIZEOF_LONG 8 +#else +#error "Unsupported number of bytes in `long' type!" +#endif + + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#define TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c new file mode 100644 index 000000000..294f1992f --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c @@ -0,0 +1,32 @@ +/* This file is part of the FreeType project */ + +/* Single file library component for the debugging target */ +#define TT_MAKE_OPTION_SINGLE_OBJECT + +/* first include common core components */ + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* then system-specific (or ANSI) components */ + +#include "ttfile.c" +#include "ttmemory.c" +#include "ttmutex.c" + +/* the extensions are compiled separately, but we need to */ +/* include the file ttextend.c if we want to support them */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h new file mode 100644 index 000000000..5efa3876a --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h @@ -0,0 +1,236 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for a debugging build */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. Unix-specific */ +#undef HAVE_FCNTL_H + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + + +/* The number of bytes in a int. We use the ANSI header file limits.h */ +/* for determining it since there is no easy way to guess. */ +/* */ +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +/* We now try to guess the size of longs in the same way */ +/* */ +#if ULONG_MAX == 0xFFFFFFFF +#define SIZEOF_LONG 4 +#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF +#define SIZEOF_LONG 8 +#else +#error "Unsupported number of bytes in `long' type!" +#endif + + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ +/* */ +/* For debugging, we use a jump table; this allows some interesting */ +/* things during development. */ + +#undef TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a `static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine. */ +/* */ +/* We use a static interpreter in the debugger; this helps in setting */ +/* data breakpoints to fixed memory addresses. */ + +#define TT_CONFIG_OPTION_STATIC_INTERPRETER + +/* an extra for the debugger */ +#define DEBUG_INTERPRETER + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ + +#define TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode. */ +/* Set to DEBUG_LEVEL_TRACE for the debugger. */ +#define DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h new file mode 100644 index 000000000..089ca8b7e --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h @@ -0,0 +1,230 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for the FreeGEOS Build */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Under FreeGEOS we need this for the file operations. */ +#include + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. Unix-specific */ +#undef HAVE_FCNTL_H + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + + +/* The number of bytes in a int. We use the ANSI header file limits.h */ +/* for determining it since there is no easy way to guess. */ +/* */ +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +/* We now try to guess the size of longs in the same way */ +/* */ +#if ULONG_MAX == 0xFFFFFFFF +#define SIZEOF_LONG 4 +#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF +#define SIZEOF_LONG 8 +#else +#error "Unsupported number of bytes in `long' type!" +#endif + + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#undef TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#define TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README new file mode 100644 index 000000000..cb7962e88 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README @@ -0,0 +1,47 @@ + +This is the readme of the freetype.hqx archive in the contrib/mac +subdirectory. Please note that the FreeType team does *not* support the +Macintosh platform due to lack of knowledge. All questions regarding the +code should be sent to both David Williss and the freetype-devel list. + + +---------------------------------------------------------------------------- + + +These are CodeWarrior projects for building the FreeType library on a Macintosh +I've only provided PPC projects here, but building for 68K shouldn't be hard. +There are two directories here (OK, "folders"). One contains a project for +building freetype.ppc.lib and the other is for freetype.ppc.dll. (I havn't +actually tested the DLL yet.) + +The Macintosh stores TrueType fonts in a "Fonts" folder under the "System" +folder. There is a standard MacOS API for finding this folder, so I use it. +However, the fonts aren't normal flat files. They have all the data in +resources in the resource fork. Each font is an 'sfnt' resource, and each +file can have more than one 'sfnt' resource. + +To get at them, I made a copy of ttmmap.c from the Unix implementation and +modified it to load/release the resource and lock/unlock the handle as needed. +This only required a change to the open and close functions. After that, it +works just as if it was using Unix memory mapping. + +One thing however. Because of the bizarre scheme for storing the fonts, I +made up a way of specifying the font filename. + + fonts:/fontfile/fontname + +Where fonts:/ is a literal string that means "the fonts folder", fontfile is +the name of the actual file and fontname is the name of the 'sfnt' resource. +Currently, this is the only thing it understands. It might be nice if some +day (2.0 maybe?) ttfile.c and ttmmap.c wern't mutialy exclusive and it could +decide which method to use based on the filename or something. + +Another thing that I had to change to make this work. It seems that Macintosh +TrueType fonts have no OS/2 table, so ttload.c needs to be modified to make +that nonfatal, at least on a Macintosh. + +--- + +David Williss +MicroImages, Inc. +dwilliss@microimages.com diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c new file mode 100644 index 000000000..9eb7df1b0 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c @@ -0,0 +1,48 @@ +/* This file is *not* part of the FreeType project, because the team */ +/* lacks the necessary expertise to support it. */ + +/* freetype.c for MacOS */ +/* single object library component for MacOS */ + +/* Written by Dave Willis on 1998-07-30. */ +/* Modified by Antoine Leca for the 1.3 release, but untested. */ + +#define TT_MAKE_OPTION_SINGLE_OBJECT + +/* Note, you should define the EXPORT_DEF and EXPORT_FUNC macros here */ +/* if you want to build a DLL. If undefined, the macros are defined */ +/* as "export" and "" (i.e. nothing), which is the normal behaviour. */ +/* The macros are placed before each high-level API function */ +/* declaration. You can then use them to take any compiler-specific */ +/* pragma for DLL-exported symbols. See 'ttconfig.h' for details. */ + + +/* first include common core components */ + +#define MAC_MAIN_OBJECT +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* then system-specific (or ANSI) components */ + +#include "ttmmap.c" /* Was "ttfile.c" */ +#include "ttmemory.c" +#include "ttmutex.c" + +/* finally, add some extensions */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h new file mode 100644 index 000000000..ed80d02f1 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h @@ -0,0 +1,211 @@ +/* This file is *not* part of the FreeType project, because the team */ +/* lacks the necessary expertise to support it. */ + +/* ft_conf.h for MacOS */ + +/* Written by Dave Willis on 1998-07-30. */ +/* Modified by Antoine Leca for the 1.3 release, but untested. */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the 'const' keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c new file mode 100644 index 000000000..3dfc62d03 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c @@ -0,0 +1,1069 @@ +/******************************************************************* + * + * ttmmap.c 2.0 + * + * Memory-Mapped file component ( replaces ttfile.c ). + * + * Copyright 1996-1998 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. + * + * Changes between 2.0 and 1.3 : + * + * - adopted new design/separation introduced in ttfile.c 2.0 + * + ******************************************************************/ + +#include "ttconfig.h" + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + + +#ifdef HAVE_FCNTL_H +#include +#endif + +#include +#include + + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttmemory.h" +#include "ttfile.h" /* our prototypes */ + + /* This definition is mandatory for each file component! */ + EXPORT_FUNC + const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; + + /* It has proven useful to do some bounds checks during */ + /* development phase. Define DEBUG_FILE when compiling */ + /* this component to enable them. */ + +#ifdef DEBUG_FILE +#define CHECK_FRAME( frame, n ) \ + do { \ + if ( frame.cursor+n > frame.address + frame.size ) \ + Panic( "Frame boundary error!\n" ); \ + } while ( 0 ) +#else +#define CHECK_FRAME( frame, n ) \ + do { \ + } while( 0 ) +#endif + + struct _TFileMap + { + String* base; /* base address of mapped file */ + Int refcount; /* reference count for handle region */ + Long size; /* stream size in file */ + Long offset; /* offset in file */ + Handle handle; /* Macintosh style handle to lock/unlock */ + short resid; /* Id of resource file to close when done */ + }; + + typedef struct _TFileMap TFileMap; + +#define MAP_Address( map ) (Byte*)( (map)->base + (map)->offset ) + + /* The stream record structure */ + typedef struct _TStream_Rec + { + TFileMap* map; /* mapped file description */ + Long pos ; /* cursor in mapped file */ + } TStream_Rec; + + typedef TStream_Rec* PStream_Rec; + +#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /**** ****/ + /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ + /**** ****/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + + /* The TFile_Component structure holds all the data that was */ + /* previously declared static or global in this component. */ + /* */ + /* It is accessible through the 'engine.file_component' */ + /* variable in re-entrant builds, or directly through the */ + /* static 'files' variable in other builds. */ + + struct _TFile_Component + { + TMutex lock; /* used by the thread-safe build only */ + PStream_Rec stream; /* current stream */ + TFileFrame frame; /* current frame */ + }; + + typedef struct _TFile_Component TFile_Component; + +/* The macro CUR_Stream denotes the current input stream */ +/* Note that for the re-entrant version, the 'stream' name has been */ +/* chosen according to the macro STREAM_ARGS. */ + +/* The macro CUR_Frame denotes the current file frame */ +/* Note that for the re-entrant version, the 'frame' name has been */ +/* chosen according to the macro FRAME_ARGS. */ + +/* The macro STREAM_VAR is used when calling public functions */ +/* that need an 'optional' stream argument. */ + +#define CUR_Stream files.stream /* thread-safe macros */ +#define CUR_Frame files.frame + +#define STREAM_VARS /* void */ +#define STREAM_VAR /* void */ + + /* the 'files' variable is only defined in non-reentrant builds */ + + static TFile_Component files; + + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + MUTEX_Create( files.lock ); + files.stream = NULL; + ZERO_Frame( files.frame ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + MUTEX_Destroy( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ) + { + MUTEX_Lock( files.lock ); + *stream = org_stream; + files.stream = STREAM2REC( org_stream ); /* set current stream */ + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream + * + * Output : Error code + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + HANDLE_Set( *stream, NULL ); + MUTEX_Release( files.lock ); + + return TT_Err_Ok; + } + +#else /* TT_CONFIG_OPTION_THREAD_SAFE */ + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /******** ********/ + /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ + /******** ********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ +#define CUR_Frame (*frame) + +#define STREAM_VARS stream, +#define STREAM_VAR stream + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + engine.file_component = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code. The output stream is set to NULL in + * case of Failure. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream input_stream, + TT_Stream* copy ) + { + TT_Error error; + PStream_Rec stream_rec; + PStream_Rec copy_rec; + + + stream_rec = STREAM2REC( input_stream ); + + if ( ALLOC( copy_rec, sizeof ( TStream_Rec ) ) ) + goto Fail; + + HANDLE_Set( *copy, copy_rec ); + + copy_rec->map->refcount++; + copy_rec->pos = 0; + + return TT_Err_Ok; + + Fail: + HANDLE_Set( *copy, NULL ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream + * + * Output : error code + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + return TT_Close_Stream( stream ); + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /*********** ***********/ + /*********** C O M M O N I M P L E M E N T A T I O N ***********/ + /*********** ***********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/******************************************************************* + * + * Function : AllocateMap + * + * Description : Allocates a new map from the table. + * + * Output : Pointer to new stream rec. NULL in case of failure. + * + ******************************************************************/ + + static + TFileMap* Allocate_Map( void ) + { + TFileMap* result; + + + if ( MEM_Alloc( result, sizeof ( TFileMap ) ) ) + return NULL; + + result->refcount = 1; + return result; + } + + +/******************************************************************* + * + * Function : ReleaseMap + * + * Description : Releases a used map to the table if reference i + * counter reaches zero. + * + * Input : map + * + * Output : None. + * + * Note : Called by TT_Close_File() + * + ******************************************************************/ + + static + void Release_Map ( TFileMap* map ) + { + map->refcount--; + if ( map->refcount <= 0 ) + { + /* MacOS System calls */ + HUnlock(map->handle); + ReleaseResource(map->handle); + CloseResFile(map->resid); + + FREE( map ); + } + } + + +/* Whadda ya mean "strdup undefined"? Fine, I'll define my own! */ +static char *mystrdup(const char *str) { + char *ret; + + if ( TT_Alloc(strlen(str) + 1, (void**)&ret) != 0 ) return(NULL); + strcpy(ret, str); + return(ret); + } + +/******************************************************************* + * + * Function : TT_Open_Stream + * + * Description : Opens the font file and saves the total file size. + * + * Input : error address of stream's error variable + * (re-entrant build only). + * filepathname pathname of the file to open + * stream address of target TT_Stream structure + * + * Output : SUCCESS on success, FAILURE on error. + * The target stream is set to -1 in case of failure. + * + ******************************************************************/ +/* +** This is not a totally generic implementation. It currently assumes the filename +** starts with "fonts:" and uses slashes instead of colons like Mac code normally +** would. Given a filename of the form "fonts:/filename/resname", Load the resource +** and lock the handle +** +** The "fonts:" at the beginning is just a convention I came up with to +** indicate the Fonts folder inside the current System folder (find via FindFolder()) +*/ + + LOCAL_FUNC + TT_Error TT_Open_Stream( const String* filepathname, + TT_Stream* stream ) + { + TT_Error error; + Int file; + PStream_Rec stream_rec; + TFileMap* map; + + int size, err = 0; + short vRefNum, res = -1; + Str255 FontName; + char *cp, *p, *fname, *sep; + Str63 myName; + long dirID; + + + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) + return error; + + map = Allocate_Map(); + if ( !map ) + { + error = TT_Err_Out_Of_Memory; + goto Memory_Fail; + } + + stream_rec = STREAM2REC( *stream ); + + /* Find the dirID of the Fonts folder in the current System folder */ + if (FindFolder(kOnSystemDisk, kFontsFolderType, kDontCreateFolder, &vRefNum, &dirID)) + goto File_Fail; + + /* Break the name apart */ + fname = mystrdup(filepathname); /* Make a copy so we can muck with it */ + sep = ":/"; /* Things that can seperate file path componants */ + + strtok(fname, sep); /* Skip over "fonts:" */ + + if ((p = strtok(NULL, sep)) == NULL) /* Get filename */ + goto File_Fail; + strcpy(myName + 1, p); /* Make this a Pascal string (Yuck!) */ + myName[0] = strlen(p); + + if ((p = strtok(NULL, sep)) == NULL) /* Get res name */ + goto File_Fail; + strcpy(FontName+1, p); /* Make this a Pascal string (Yuck!) */ + FontName[0] = strlen(p); + + FREE( fname ); + + if ((cp = strchr(FontName, '.')) != NULL) /* Strip off ".ttf" , if any */ + *cp = 0; + + /* Read the font into a buffer */ + if ((map->resid = HOpenResFile(vRefNum, dirID, myName, fsRdPerm)) == -1) + goto File_Fail; + + if ((map->handle = Get1NamedResource('sfnt', FontName)) == NULL) + goto Map_Fail; + + HLock(map->handle); + map->base = *map->handle; + map->offset = 0; + map->size = GetResourceSizeOnDisk(map->handle); + + if ( map->base == NULL ) + goto Lock_Fail; + + stream_rec->map = map; + stream_rec->pos = 0; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + CUR_Stream = stream_rec; +#endif + + return TT_Err_Ok; + + Lock_Fail: + ReleaseResource(map->handle); + + Map_Fail: + CloseResFile(map->resid); + + File_Fail: + error = TT_Err_Could_Not_Open_File; + FREE( map ); + + Memory_Fail: + FREE( *stream ); + FREE( fname ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Close_Stream + * + * Description : Closes a stream. + * + * Input : stream + * + * Output : SUCCESS (always) + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Close_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + Release_Map( rec->map ); + FREE( rec ); + + HANDLE_Set( *stream, NULL ); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Stream + * + * Description : Flushes a stream, i.e., closes its file handle. + * + * Input : stream address of target TT_Stream structure + * + * Output : Error code + * + * NOTE : Never flush the current opened stream. This means that + * you should _never_ call this function between a + * TT_Use_Stream() and a TT_Done_Stream()! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Stream( TT_Stream* stream ) + { + /* XXX - DUMMY IMPLEMENTATION */ + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Stream_Size + * + * Description : Returns the length of a given stream, even if it + * is flushed. + * + * Input : stream the stream + * + * Output : Length of stream in bytes. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Stream_Size( TT_Stream stream ) + { + PStream_Rec rec = STREAM2REC( stream ); + + + if ( rec ) + return rec->map->size; + else + return 0; /* invalid stream - return 0 */ + } + + +/******************************************************************* + * + * Function : TT_Seek_File + * + * Description : Seeks the file cursor to a different position. + * + * Input : position new position in file + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Seek_File( STREAM_ARGS Long position ) + { + if ( position > CUR_Stream->map->size ) + return TT_Err_Invalid_File_Offset; + + CUR_Stream->pos = position; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Skip_File + * + * Description : Skips forward the file cursor. + * + * Input : distance number of bytes to skip + * + * Output : see TT_Seek_File + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Skip_File( STREAM_ARGS Long distance ) + { + return TT_Seek_File( STREAM_VARS CUR_Stream->pos + distance ); + } + + +/******************************************************************* + * + * Function : TT_Read_File + * + * Description : Reads a chunk of the file and copies it to memory. + * + * Input : buffer target buffer + * count length in bytes to read + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) + { + if ( CUR_Stream->pos + count > CUR_Stream->map->size ) + return TT_Err_Invalid_File_Read; + + MEM_Copy( buffer, + MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, count ); + CUR_Stream->pos += count; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Read_At_File + * + * Description : Reads file at a specified position. + * + * Input : position position to seek to before read + * buffer target buffer + * count number of bytes to read + * + * Output : SUCCESS on success. FAILURE if error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ) + { + TT_Error error; + + + if ( (error = TT_Seek_File( STREAM_VARS position )) || + (error = TT_Read_File( STREAM_VARS buffer, count )) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_File_Pos + * + * Description : Returns current file seek pointer. + * + * Input : none + * + * Output : current file position + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_File_Pos( STREAM_ARG ) + { + return CUR_Stream->pos; + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : Error code + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that aSize is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( CUR_Stream->pos + size > CUR_Stream->map->size ) + return TT_Err_Invalid_Frame_Access; + + CUR_Frame.size = size; + CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; + CUR_Frame.cursor = CUR_Frame.address; + + CUR_Stream->pos += size; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : Error code + * + * Notes: The function truncates 'size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that aSize is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. The 'overflow' is set to zero. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + readBytes = CUR_Stream->map->size - CUR_Stream->pos; + if ( size > readBytes ) + { + /* There is overflow, we allocate a new block then */ + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + + CUR_Frame.size = size; + + /* copy the valid part */ + MEM_Copy( CUR_Frame.address, + MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, + readBytes ); + } + else + { + CUR_Frame.size = size; + CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; + } + + CUR_Frame.cursor = CUR_Frame.address; + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + /* If we were using a duplicate in case of overflow, free it now */ + if ( CUR_Frame.address < (Byte*)CUR_Stream->map->base || + CUR_Frame.address >= (Byte*)CUR_Stream->map->base + + CUR_Stream->map->size ) + FREE( CUR_Frame.address ); + + ZERO_Frame( files.frame ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : GET_Byte + * + * Description : Extracts a byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted Byte + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + +#if 0 + + EXPORT_FUNC + Byte TT_Get_Byte( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Byte)(*CUR_Frame.cursor++); + } + +#endif + + +/******************************************************************* + * + * Function : GET_Char + * + * Description : Extracts a signed byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted char + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + + EXPORT_FUNC + Char TT_Get_Char( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Char)(*CUR_Frame.cursor++); + } + + +/******************************************************************* + * + * Function : GET_Short + * + * Description : Extracts a short from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted short + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + + EXPORT_FUNC + Short TT_Get_Short( FRAME_ARG ) + { + Short getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = ((Short)CUR_Frame.cursor[0] << 8) | + (Short)CUR_Frame.cursor[1]; + + CUR_Frame.cursor += 2; + + return getshort; + } + + +/******************************************************************* + * + * Function : GET_UShort + * + * Description : Extracts an unsigned short from the frame. + * + * Input : None or current frame + * + * Output : Extracted ushort + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + +#if 0 + + EXPORT_FUNC + UShort TT_Get_UShort( FRAME_ARG ) + { + UShort getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = ((UShort)CUR_Frame.cursor[0] << 8) | + (UShort)CUR_Frame.cursor[1]; + + CUR_Frame.cursor += 2; + + return getshort; + } + +#endif + + +/******************************************************************* + * + * Function : GET_Long + * + * Description : Extracts a long from the frame. + * + * Input : None or current frame + * + * Output : Extracted long + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Get_Long( FRAME_ARG ) + { + Long getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ((Long)CUR_Frame.cursor[0] << 24) | + ((Long)CUR_Frame.cursor[1] << 16) | + ((Long)CUR_Frame.cursor[2] << 8 ) | + (Long)CUR_Frame.cursor[3]; + + CUR_Frame.cursor += 4; + + return getlong; + } + + +/******************************************************************* + * + * Function : GET_ULong + * + * Description : Extracts an unsigned long from the frame. + * + * Input : None + * + * Output : Extracted ulong + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + +#if 0 + + EXPORT_FUNC + ULong TT_Get_ULong( FRAME_ARG ) + { + ULong getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | + ((ULong)CUR_Frame.cursor[1] << 16) | + ((ULong)CUR_Frame.cursor[2] << 8 ) | + (ULong)CUR_Frame.cursor[3] ); + + CUR_Frame.cursor += 4; + + return getlong; + } + +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC new file mode 100644 index 000000000..62469c087 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC @@ -0,0 +1,132 @@ +# This file is part of the FreeType project. +# +# It builds the library for Borland C++ for MS-DOS, large model. +# Due to size constraints, it does not try to pack all modules into one +# (`single-object mode'). +# +# You will need Borland MAKE. +# Tested with Borland C++ v.3.1, 4.02, 5.0. +# +# Use this file while in the lib directory with the following statement: +# +# make -farch/msdos/Makefile.BC +# +# +# A debug version 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 +LIB = tlib /c /e + +# Credits go to Dave Hoo for pointing out that modern +# Borland compilers (from BC++ 3.1 on) can increase the limit on +# the length of identifiers. +!if ! $d(DEBUG) +CFLAGS = -ml -A -O2 -3 -i40 -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -I$(ARCH);.;extend +!else +CFLAGS = -v -N -ml -A -i40 -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -I$(ARCH);.;extend +!endif + + +!if $d(BIGFONTS) +CFLAGS = $(CFLAGS) -DTT_HUGE_PTR=__huge + +TTFILE = $(ARCH)\.\hugefile.c +TTMEMORY = $(ARCH)\.\hugemem.c +!else +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +!endif +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +# Do not insert spaces before the \ at end of line, +# otherwise the substitution for TLIB command line will fail. +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ + extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c\ + extend\ftxsbit.c extend\ftxgsub.c extend\ftxgpos.c\ + extend\ftxopen.c extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c\ + ttgload.c ttinterp.c ttload.c ttobjs.c\ + ttraster.c ttextend.c ttdebug.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\.\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +# Since Borland's make does not handle $($(LIB_FILES)), and using +# -DLIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat +# by constructing TLIB's response file directly in the `all' target. +# +# Another solution, useful during debugging of part of the library, +# would be to include each .obj in the library as soon as it is compiled. +# It is commented out below. See Makefile.TC for an application. +.c.obj: + $(CC) -c -o$* @&&| + $(CFLAGS) $< +| +# $(LIB) libttf +-$*.obj + + +!if !$d(DEBUG) +# Skipped if DEBUG build +# (but it changes nothing, since we always build in multiple parts). +all: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(OBJS_M: = + ) +| + +!endif + + +debug: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(OBJS_M: = + ) +| + +$(OBJ_S): $(SRC_S) $(SRC_M) + +# Not used here because it excesses the capacity of COMMAND.COM... +libttf.lib: $(LIB_FILES) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(**: = + ) +| + +!if $d(BIGFONTS) +$(TTMEMORY:.c=.obj): $(TTMEMORY) + $(CC) -c -o$* @&&| + $(CFLAGS) -A- $*.c +| +!endif + + +clean: + -del *.obj + -del extend\*.obj + -del $(ARCH)\*.obj + -del libttf.bak + -del response + +distclean: clean + -del libttf.lib + +!include "$(ARCH)\depend.dos" + +# end of Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS new file mode 100644 index 000000000..611fd3a50 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS @@ -0,0 +1,117 @@ +# This file is part of the FreeType project. +# +# It builds the library 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. +# Due to size constraints, it does not try to pack all modules into one. +# +# You will need NMAKE. +# +# Use this file while in the lib directory with the following statement: +# +# nmake /f arch\msdos\Makefile.MS +# +# +# A debug version 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 + +CC = cl /nologo +LIB = lib /noignorecase /nologo + +!ifndef DEBUG +CFLAGS = /Ox /AL /W2 /G2 /I$(ARCH) /I. /Iextend +!else +CFLAGS = /Zi /AL /W2 /G2 /I$(ARCH) /I. /Iextend +!endif + + +!ifndef BIGFONTS +CFLAGS = $(CFLAGS) /Za + +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +!else +CFLAGS = $(CFLAGS) /DTT_HUGE_PTR=__huge /Ze + +TTFILE = $(ARCH)\hugefile.c +TTMEMORY = $(ARCH)\hugemem.c +!endif + +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +# Do not insert spaces between the file names or at end of line, otherwise +# the substitution for LIB command line will fail. Thank you. +# +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ +extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c extend\ftxsbit.c\ +extend\ftxopen.c extend\ftxgsub.c extend\ftxgpos.c extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ +ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +# Since Microsoft's NMAKE does not handle $($(LIB_FILES)), and using +# LIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat +# by constructing LIB's response file directly in the `all' target. +# +# Another solution, useful during debugging of part of the library, +# would be to include each .obj in the library as soon as it is compiled. +# It is commented out below. See Makefile.TC for an application. +.c.obj: + @$(CC) /c /Fo$@ @<< + $(CFLAGS) $*.c +<< +# $(LIB) libttf +-$*.obj + + +!ifndef DEBUG +# Skipped if DEBUG build +# (but it changes nothing, since we always build in multiple parts). +all: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @<&| + +CC = gcc + +CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend +# CFLAGS = -Wall -ansi -O2 -s -I$(ARCH) -I. -Iextend + +SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ + extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ + extend/ftxgsub.c extend/ftxgpos.c extend/ftxopen.c \ + extend/ftxgdef.c extend/ftxerr18.c +OBJS_X = $(SRC_X:.c=.o) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttfile.c ttgload.c ttinterp.c ttload.c \ + ttmemory.c ttmutex.c ttobjs.c ttraster.c ttextend.c +OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) + +SRC_S = $(ARCH)/freetype.c +OBJ_S = $(SRC_S:.c=.o) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: all debug clean distclean depend + + +all: + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a + +debug: + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a + + +$(OBJ_S): $(SRC_S) $(SRC_M) + $(CC) $(CFLAGS) -c -o $@ $(SRC_S) + +libttf.a: $($(LIB_FILES)) + +-del $@ + ar src $@ @$(mktmp $(<:t"\n")\n) + +clean: +-[ + del *.o + del extend\*.o + del $(ARCH)\*.o +] + +distclean: clean +-[ + del dep.end + del libttf.a +] + +# depend: $(SRC_S) $(SRC_M) $(SRC_X) +# $(CC) -E -M @$(mktmp $(<:t"\n")\n) > dep.end + +# ifeq (dep.end,$(wildcard dep.end)) +# include dep.end +# endif + +# end of Makefile.dm diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc new file mode 100644 index 000000000..44f4a633b --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc @@ -0,0 +1,92 @@ +# This file is part of the FreeType project. +# +# It builds the library for emx-gcc or djgpp under MSDOS. +# +# You will need GNU make. +# +# Use this file while in the lib 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 + +ifndef GETTEXT +GETTEXT=NO_GETTEXT +endif + +ifdef DEBUG +CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend -D$(GETTEXT) +else +CFLAGS = -Wall -ansi -pedantic -O2 -s -I$(ARCH) -I. -Iextend -D$(GETTEXT) +endif + + +TTFILE = ./ttfile.c +TTMEMORY = ./ttmemory.c +TTMUTEX = ./ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ + extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ + extend/ftxgsub.c extend/ftxgpos.c extend/ftxgdef.c \ + extend/ftxopen.c extend/ftxerr18.c +OBJS_X = $(SRC_X:.c=.o) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttgload.c ttinterp.c ttload.c ttobjs.c \ + ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) + +SRC_S = $(ARCH)/freetype.c +OBJ_S = $(SRC_S:.c=.o) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: all debug clean distclean depend + + +all: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a + +debug: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M DEBUG=1 libttf.a + +HAVE_GETTEXT: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S GETTEXT=HAVE_GETTEXT \ + libttf.a + +$(OBJ_S): $(SRC_S) $(SRC_M) + +libttf.a: $($(LIB_FILES)) + -del $@ + ar src $@ $^ + +clean: + -del *.o + -del extend\*.o + -del $(ARCH)\*.o + -del response + +distclean: clean + -del dep.end + -del libttf.a + +depend: $(SRS_S) $(SRC_M) $(SRC_X) + $(CC) -E -M $^ > dep.end + +ifeq (dep.end,$(wildcard dep.end)) + include dep.end +endif + +# end of Makefile.gcc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat new file mode 100644 index 000000000..7e5f6722b --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat @@ -0,0 +1,88 @@ +# This file is part of the FreeType project +# +# This builds the Watcom library with Watcom's wcc386 under DOS +# +# You'll need Watcom's wmake +# +# +# Invoke by "wmake -f arch\msdos\Makefile.wat" while in the "lib" directory +# +# This will build "freetype\lib\libttf.lib" +# + +ARCH = arch\msdos +FT_MAKEFILE = $(ARCH)\Makefile.wat +FT_MAKE = wmake -h + + +.EXTENSIONS: +.EXTENSIONS: .lib .obj .c .h +.obj:.;.\extend;.\$(ARCH) +.c:.;.\extend;.\$(ARCH) +.h:.;.\extend;.\$(ARCH) + +CC = wcc386 + +CCFLAGS = /otexanl+ /s /w4 /zq /d3 -I$(ARCH) -I. -Iextend + + +# FIXME: should use something like OBJ = $(SRC:.c=.obj) + +SRC_X = ftxgasp.c ftxkern.c ftxpost.c & + ftxcmap.c ftxwidth.c ftxsbit.c ftxerr18.c & + ftxgsub.c ftxgpos.c ftxopen.c ftxgdef.c +OBJS_X = ftxgasp.obj ftxkern.obj ftxpost.obj & + ftxcmap.obj ftxwidth.obj ftxsbit.obj ftxerr18.obj & + ftxgsub.obj ftxgpos.obj ftxopen.obj ftxgdef.obj + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c & + ttfile.c ttgload.c ttinterp.c & + ttload.c ttmemory.c ttmutex.c ttobjs.c ttraster.c & + ttextend.c +OBJS_M = ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj ttdebug.obj & + ttfile.obj ttgload.obj ttinterp.obj & + ttload.obj ttmemory.obj ttmutex.obj ttobjs.obj ttraster.obj & + ttextend.obj $(OBJS_X) + +SRC_S = freetype.c +OBJ_S = freetype.obj +OBJS_S = $(OBJ_S) $(OBJ_X) + + +.c.obj: + $(CC) $(CCFLAGS) $[* /fo=$[*.obj + +libname = libttf +libfile = $(libname).lib +cmdfile = $(libname).lst + + +all: .symbolic + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S $(libfile) + +debug: .symbolic + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M $(libfile) + + +$(libfile): $($(LIB_FILES)) + wlib -q -n $(libfile) @$(cmdfile) + +# is this correct? Know nothing about wmake and the Watcom compiler... +$(OBJ_S): $(SRC_S) $(SRC_M) + $(CC) $(CCFLAGS) $(SRC_S) /fo=$(OBJ_S) + +$(cmdfile): $($(LIB_FILES)) + @for %i in ($($(LIB_FILES))) do @%append $(cmdfile) +-%i + +clean: .symbolic + @-erase $(OBJ_S) + @-erase $(OBJS_M) + @-erase $(cmdfile) + +distclean: .symbolic clean + @-erase $(libfile) + +new: .symbolic + @-wtouch *.c + +# end of Makefile.wat diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos new file mode 100644 index 000000000..4fb22dbfa --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos @@ -0,0 +1,107 @@ +# This dependency file to be used with various MS-DOS compilers +# has been generated automatically with the script `makedep' on +# 03-Sep-1999. + +ttapi.obj: ttapi.c ttconfig.h arch\msdos\ft_conf.h freetype.h fterrid.h \ + ftnameid.h ttengine.h tttypes.h ttmutex.h ttcalc.h ttmemory.h \ + ttcache.h ttfile.h ttdebug.h ttobjs.h tttables.h ttcmap.h ttload.h \ + ttgload.h ttraster.h ttextend.h +ttcache.obj: ttcache.c ttengine.h tttypes.h ttconfig.h \ + arch\msdos\ft_conf.h freetype.h fterrid.h ftnameid.h ttmutex.h \ + ttmemory.h ttcache.h ttobjs.h tttables.h ttcmap.h ttdebug.h +ttcalc.obj: ttcalc.c ttcalc.h ttconfig.h arch\msdos\ft_conf.h freetype.h \ + fterrid.h ftnameid.h ttdebug.h tttypes.h tttables.h +ttcmap.obj: ttcmap.c ttobjs.h ttconfig.h arch\msdos\ft_conf.h ttengine.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ + tttables.h ttcmap.h ttdebug.h ttfile.h ttmemory.h ttload.h +ttdebug.obj: ttdebug.c ttdebug.h ttconfig.h arch\msdos\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h tttables.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h ttcmap.h +ttextend.obj: ttextend.c ttextend.h ttconfig.h arch\msdos\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttmemory.h +ttfile.obj: ttfile.c ttconfig.h arch\msdos\ft_conf.h freetype.h \ + fterrid.h ftnameid.h tttypes.h ttdebug.h ttengine.h ttmutex.h \ + ttmemory.h ttfile.h +ttgload.obj: ttgload.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ + ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h ttgload.h \ + ttmemory.h tttags.h ttload.h +ttinterp.obj: ttinterp.c freetype.h fterrid.h ftnameid.h tttypes.h \ + ttconfig.h arch\msdos\ft_conf.h ttdebug.h ttcalc.h ttmemory.h \ + ttinterp.h ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h \ + ttcmap.h +ttload.obj: ttload.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ + ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h \ + ttmemory.h tttags.h ttload.h +ttmemory.obj: ttmemory.c ttdebug.h ttconfig.h arch\msdos\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttmemory.h ttengine.h \ + ttmutex.h +ttmutex.obj: ttmutex.c ttmutex.h ttconfig.h arch\msdos\ft_conf.h +ttobjs.obj: ttobjs.c ttobjs.h ttconfig.h arch\msdos\ft_conf.h ttengine.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ + tttables.h ttcmap.h ttfile.h ttdebug.h ttcalc.h ttmemory.h ttload.h \ + ttinterp.h ttextend.h +ttraster.obj: ttraster.c ttraster.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttengine.h tttypes.h ttmutex.h \ + ttdebug.h ttcalc.h ttmemory.h +extend\ftxcmap.obj: extend\ftxcmap.c extend\ftxcmap.h freetype.h fterrid.h \ + ftnameid.h tttypes.h ttconfig.h arch\msdos\ft_conf.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h +extend\ftxerr18.obj: extend\ftxerr18.c ttconfig.h arch\msdos\ft_conf.h \ + extend\ftxerr18.h freetype.h fterrid.h ftnameid.h extend\ftxkern.h \ + extend\ftxpost.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h +extend\ftxgasp.obj: extend\ftxgasp.c extend\ftxgasp.h freetype.h fterrid.h \ + ftnameid.h tttypes.h ttconfig.h arch\msdos\ft_conf.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h +extend\ftxgdef.obj: extend\ftxgdef.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxgpos.obj: extend\ftxgpos.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxgsub.obj: extend\ftxgsub.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxkern.obj: extend\ftxkern.c extend\ftxkern.h freetype.h fterrid.h \ + ftnameid.h ttextend.h ttconfig.h arch\msdos\ft_conf.h tttypes.h \ + ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttdebug.h \ + ttmemory.h ttfile.h ttload.h tttags.h +extend\ftxopen.obj: extend\ftxopen.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxpost.obj: extend\ftxpost.c extend\ftxpost.h freetype.h fterrid.h \ + ftnameid.h tttypes.h ttconfig.h arch\msdos\ft_conf.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttload.h ttfile.h \ + ttdebug.h tttags.h ttmemory.h ttextend.h +extend\ftxsbit.obj: extend\ftxsbit.c extend\ftxsbit.h freetype.h fterrid.h \ + ftnameid.h ttobjs.h ttconfig.h arch\msdos\ft_conf.h ttengine.h \ + tttypes.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h ttdebug.h \ + ttload.h ttmemory.h tttags.h ttextend.h +extend\ftxwidth.obj: extend\ftxwidth.c extend\ftxwidth.h freetype.h fterrid.h \ + ftnameid.h ttdebug.h ttconfig.h arch\msdos\ft_conf.h tttypes.h \ + ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h \ + tttags.h ttload.h +arch\msdos\freetype.obj: arch\msdos\freetype.c ttapi.c ttconfig.h \ + arch\msdos\ft_conf.h freetype.h fterrid.h ftnameid.h ttengine.h \ + tttypes.h ttmutex.h ttcalc.h ttmemory.h ttcache.h ttfile.h ttdebug.h \ + ttobjs.h tttables.h ttcmap.h ttload.h ttgload.h ttraster.h ttextend.h \ + ttcache.c ttcalc.c ttcmap.c ttdebug.c ttgload.c tttags.h ttinterp.c \ + ttinterp.h ttload.c ttobjs.c ttraster.c arch\msdos\hugefile.c \ + ttfile.c arch\msdos\hugemem.c ttmutex.c ttextend.c +arch\msdos\hugefile.obj: arch\msdos\hugefile.c ttconfig.h arch\msdos\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttfile.c ttdebug.h \ + ttengine.h ttmutex.h ttmemory.h ttfile.h +arch\msdos\hugemem.obj: arch\msdos\hugemem.c ttdebug.h ttconfig.h \ + arch\msdos\ft_conf.h tttypes.h freetype.h fterrid.h ftnameid.h \ + ttmemory.h ttengine.h ttmutex.h diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c new file mode 100644 index 000000000..b6dc42b6d --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c @@ -0,0 +1,39 @@ +/* This file is part of the FreeType project */ + +/* Single object library component for MSDOS. */ +/* Note that low-optimizing 16-bit compilers (such as Borland ones) can't */ +/* successfully compile this file, because it exceeds 64K of code size. */ +#define TT_MAKE_OPTION_SINGLE_OBJECT + +/* first include common core components */ + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* then system-specific (or ANSI) components */ + +#ifdef TT_HUGE_PTR +#include "arch/msdos/hugefile.c" +#include "arch/msdos/hugemem.c" +#else +#include "ttfile.c" +#include "ttmemory.c" +#endif +#include "ttmutex.c" + +/* finally, add some extensions */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h new file mode 100644 index 000000000..8333bfbb1 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h @@ -0,0 +1,253 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for MSDOS */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H + +/* Define if you have the header file. */ +#if defined( __EMX__ ) || defined( __DJGPP__ ) || defined( __GO32__ ) +/* some compilers are known to have ; */ +/* add yours if needed, and report to us the update. */ +#define HAVE_UNISTD_H +#else +/* most MS-DOS compilers lack */ +#undef HAVE_UNISTD_H +#endif + +/* Define if you need for console I/O functions. */ +#ifdef __EMX__ +#define HAVE_CONIO_H +#endif + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the libintl library. */ +#undef HAVE_LIBINTL + +/* DJGPP v.2 may feature the GNU gettext package, with some subtleties. */ +/* The macro HAVE_GETTEXT has to be set in the makefile. */ +#ifdef HAVE_GETTEXT +#define HAVE_LOCALE_H +#define HAVE_LIBINTL_H +#define HAVE_LIBINTL +#define LOCALEDIR "/usr/djgpp/share/locale" +/* Due to a name conflict, gettext is renamed gettext__ in DJGPP */ +#define gettext( str ) gettext__( str ) +#endif + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + +/* The number of bytes in a int. We use the ANSI header file limits.h */ +/* for determining it since there is no easy way to guess. */ +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c new file mode 100644 index 000000000..ddf73ad75 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c @@ -0,0 +1,84 @@ +/******************************************************************* + * + * hugefile.c + * + * File I/O Component (body) for dealing with "huge" objects under + * MS-DOS. Relies on the "default" version, with a small hook. + * + * Written by Antoine Leca based on ideas from Dave Hoo. + * Copyright 1999 by Dave Hoo, 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. + * + * NOTE + * + * This file #includes the normal version, to avoid discrepancies + * between versions. It uses only ANSI-mandated "tricks", so + * any ANSI-compliant compiler should be able to compile this file. + * + ******************************************************************/ + +#include "ttconfig.h" +#include "tttypes.h" + +/* Here we include , to have the proper definition of fread */ +#include + +/* Then, we divert the use of fread to our version */ +#undef fread +#define fread(ptr, size, n, stream) huge_fread(ptr, size, n, stream) + + LOCAL_FUNC + Long huge_fread ( void *ptr, size_t size, Long n, FILE *stream ); + +/* Now, we include the "normal" version of ttfile.c */ +/* The ANSI/ISO standard mandates that the include of */ +/* there have no bad effects. */ +#include "ttfile.c" + +/* Then, we define our implementation of fread that makes use of */ +/* "huge"-allocated memory. */ + +/******************************************************************* + * + * Function : huge_fread + * + * Description : replacement version of fread that handles + * "huge"-allocated memory. + * + * Input : See the reference for the runtime library function fread + * + * Output : See the reference for the runtime library function fread + * + * Notes : + * + ******************************************************************/ + + LOCAL_DEF + Long huge_fread ( void *ptr, size_t size, Long n, FILE *stream ) + { + char TT_HUGE_PTR * p = (char TT_HUGE_PTR *) ptr; + ULong left = (ULong)n * size; + size_t toRead; + + while ( left ) + { + toRead = (left > 0x8000) ? 0x8000 : left; + if ( (fread)( p, 1, toRead, stream ) != toRead) + return -1; + else + { + left -= (ULong) toRead; + p += toRead; + } + } + return n * size; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c new file mode 100644 index 000000000..5083e49e2 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c @@ -0,0 +1,496 @@ +/******************************************************************* + * + * hugemem.c + * + * Memory management component (body) + * for dealing with "huge" objects with 16-bit MS-DOS. + * + * Written by Dave Hoo and Antoine Leca. + * Copyright 1999 by Dave Hoo, 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. + * + ******************************************************************/ + +#include + +#include "ttdebug.h" +#include "ttmemory.h" +#include "ttengine.h" + +#ifndef TT_HUGE_PTR +#error "This component needs TT_HUGE_PTR to be #defined." +#endif + +/* ---- Microsoft C compilers support ------------------------------------ */ + +#if defined( M_I86 ) || defined( _M_I86 ) + +#include +#define huge_alloc( size ) _halloc ( size, 1 ) +#define huge_free( block ) _hfree ( block ) + +#endif /* Microsoft compilers */ + +/* ---- Borland C compiler support --------------------------------------- */ + +#ifdef __TURBOC__ + +#include +#define huge_alloc( size ) farmalloc ( size ) +#define huge_free( block ) farfree ( block ) + +#endif + +#if !defined( huge_alloc ) || !defined( huge_free ) +#error "Your compiler is not (yet) supported. Check the source file!" +#endif + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE +#error "This component needs static allocation and is not re-entrant." +#endif + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_memory + + +#ifdef DEBUG_MEMORY + +#include + +#define MAX_TRACKED_BLOCKS 1024 + + struct TMemRec_ + { + void* base; + Long size; + }; + + typedef struct TMemRec_ TMemRec; + + static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; + + static Int num_alloc; + static Int num_free; + static Int num_realloc; /* counts only `real' reallocations + (i.e., an existing buffer will be resized + to a value larger than zero */ + + static Int fail_alloc; + static Int fail_realloc; + static Int fail_free; + +#else + + /* We need a tracing stack of the calls to big chunks of memory, */ + /* in order to call the matching version of free(). */ + +#define MAX_TRACKED_BIGCHUNKS 16 + + struct TMemRec_ + { + void* base; + Long size; + }; + + typedef struct TMemRec_ TMemRec; + + static TMemRec pointers[MAX_TRACKED_BIGCHUNKS + 1]; + +#endif /* DEBUG_MEMORY */ + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + Long TTMemory_Allocated; + Long TTMemory_MaxAllocated; +#endif + + +/******************************************************************* + * + * Function : TT_Alloc + * + * Description : Allocates memory from the heap buffer. + * + * Input : Size size of the memory to be allocated + * P pointer to a buffer pointer + * + * Output : Error code. + * + * NOTE : The newly allocated block should _always_ be zeroed + * on return. Many parts of the engine rely on this to + * work properly. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Alloc( ULong Size, void** P ) + { + Int i; + + + if ( !P ) + return TT_Err_Invalid_Argument; + /* Also see below for another case of "invalid argument". */ + + if ( Size > 0 ) + { + if ( Size > ( UINT_MAX & ~0xFu ) ) + *P = (void*)huge_alloc( Size ); + else + *P = (void*)malloc( Size ); + if ( !*P ) + return TT_Err_Out_Of_Memory; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated += Size; + TTMemory_MaxAllocated += Size; +#endif + +#ifdef DEBUG_MEMORY + + num_alloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_alloc++; + else + { + pointers[i].base = *P; + pointers[i].size = Size; + } + +#else + + if ( Size > ( UINT_MAX & ~0xFu ) ) + { + i = 0; + while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BIGCHUNKS ) + /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ + return TT_Err_Invalid_Argument; + else + { + pointers[i].base = *P; + pointers[i].size = Size; + } + } + +#endif /* DEBUG_MEMORY */ + + if ( Size > ( UINT_MAX & ~0xFu ) ) + { + char TT_HUGE_PTR * p = (char TT_HUGE_PTR *) *P; + ULong left = (ULong)Size; + size_t toClear; + + while ( left ) + { + toClear = (left > 0xFF00) ? 0xFF00 : left; + MEM_Set( p, 0, toClear ); + left -= (ULong) toClear; + p += toClear; + } + } + else + MEM_Set( *P, 0, Size ); + } + else + *P = NULL; + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + +/******************************************************************* + * + * Function : TT_Realloc + * + * Description : Reallocates memory from the heap buffer. + * + * Input : Size new size of the memory to be allocated; + * if zero, TT_Free() will be called + * P pointer to a buffer pointer; if *P == NULL, + * TT_Alloc() will be called + * + * Output : Error code. + * + * NOTES : It's not necessary to zero the memory in case the + * reallocated buffer is larger than before -- the + * application has to take care of this. + * + * If the memory request fails, TT_Free() will be + * called on *P, and TT_Err_Out_Of_Memory returned. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Realloc( ULong Size, void** P ) + { + void* Q; + +#ifdef DEBUG_MEMORY + Int i; +#endif + + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( !*P ) + return TT_Alloc( Size, P ); + + if ( Size == 0 ) + return TT_Free( P ); + + if ( Size > ( UINT_MAX & ~0xFu ) ) + Q = NULL; /* Do not even try to deal with big chunks of memory. */ + else + Q = (void*)realloc( *P, Size ); + if ( !Q ) + { + TT_Free( *P ); + return TT_Err_Out_Of_Memory; + } + +#ifdef DEBUG_MEMORY + + num_realloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_realloc++; + else + { +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated += Size - pointers[i].size; + if ( Size > pointers[i].size ) + TTMemory_MaxAllocated += Size - pointers[i].size; +#endif + + pointers[i].base = Q; + pointers[i].size = Size; + } +#endif /* DEBUG_MEMORY */ + + *P = Q; + + return TT_Err_Ok; + } + + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + +/******************************************************************* + * + * Function : TT_Free + * + * Description : Releases a previously allocated block of memory. + * + * Input : P pointer to memory block + * + * Output : Always SUCCESS. + * + * Note : The pointer must _always_ be set to NULL by this function. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Free( void** P ) + { + Int i; + Long Size = 0; + + + if ( !P || !*P ) + return TT_Err_Ok; + +#ifdef DEBUG_MEMORY + + num_free++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_free++; + else + { +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated -= pointers[i].size; +#endif + + Size = pointers[i].size; + pointers[i].base = NULL; + pointers[i].size = 0; + } + +#else + + i = 0; + while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != *P ) + i++; + + /* If we did not found the pointer, then this is a "small" chunk. */ + + if ( i < MAX_TRACKED_BIGCHUNKS ) + { + Size = pointers[i].size; + pointers[i].base = NULL; + pointers[i].base = NULL; + } + +#endif /* DEBUG_MEMORY */ + + if ( Size > ( UINT_MAX & ~0xFu ) ) + huge_free( *P ); + else + free( *P ); + + *P = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Init + * + * Description : Initializes the memory. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Init( void ) + { +#ifdef DEBUG_MEMORY + Int i; + + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + pointers[i].base = NULL; + pointers[i].size = 0; + } + + num_alloc = 0; + num_realloc = 0; + num_free = 0; + + fail_alloc = 0; + fail_realloc = 0; + fail_free = 0; +#else + Int i; + + for ( i = 0; i < MAX_TRACKED_BIGCHUNKS; i++ ) + { + pointers[i].base = NULL; + pointers[i].size = 0; + } +#endif + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated = 0; + TTMemory_MaxAllocated = 0; +#endif + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Done + * + * Description : Finalizes memory usage. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Done( void ) + { +#ifdef DEBUG_MEMORY + Int i, num_leaked, tot_leaked; + + + num_leaked = 0; + tot_leaked = 0; + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + num_leaked ++; + tot_leaked += pointers[i].size; + } + } + + fprintf( stderr, + "%d memory allocations, of which %d failed\n", + num_alloc, + fail_alloc ); + + fprintf( stderr, + "%d memory reallocations, of which %d failed\n", + num_realloc, + fail_realloc ); + + fprintf( stderr, + "%d memory frees, of which %d failed\n", + num_free, + fail_free ); + + if ( num_leaked > 0 ) + { + fprintf( stderr, + "There are %d leaked memory blocks, totalizing %d bytes\n", + num_leaked, tot_leaked ); + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + fprintf( stderr, + "index: %4d (base: $%08lx, size: %08ld)\n", + i, + (long)pointers[i].base, + pointers[i].size ); + } + } + } + else + fprintf( stderr, "No memory leaks !\n" ); + +#endif /* DEBUG_MEMORY */ + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep new file mode 100755 index 000000000..32b3a5f32 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep @@ -0,0 +1,26 @@ +# 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 -Iarch/msdos -I. *.c | \ + sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.dos + +(cd ../.. + gcc -MM -Iarch/msdos -I. -Iextend extend/*.c | \ + sed -e "s/^\(.*\)\.o:/extend\\\\\1.obj:/" -e "s:/:\\\\:g") >> depend.dos + +(cd ../.. + gcc -MM -Iarch/msdos -I. -Iextend \ + -DTT_HUGE_PTR -Dhuge_alloc -Dhuge_free arch/msdos/*.c | \ + sed -e "s/^\(.*\)\.o:/arch\\\\msdos\\\\\1.obj:/" \ + -e "s:/:\\\\:g") >> depend.dos + +# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm new file mode 100644 index 000000000..f4f02ecbd --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm @@ -0,0 +1,84 @@ +# 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 lib 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 + +CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend +# CFLAGS = -Wall -ansi -O2 -s -I$(ARCH) -I. -Iextend + +TTFILE = $(ARCH)/os2file.c +TTMEMORY = ./ttmemory.c +TTMUTEX = ./ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ + extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ + extend/ftxgsub.c extend/ftxgpos.c extend/ftxopen.c \ + extend/ftxgdef.c +OBJS_X = $(SRC_X:.c=.o) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttgload.c ttinterp.c ttload.c ttobjs.c \ + ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) + +SRC_S = $(ARCH)/freetype.c +OBJ_S = $(SRC_S:.c=.o) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: all debug clean distclean depend + + +all: + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a + +debug: + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a + + +$(OBJ_S): $(SRC_S) $(SRC_M) + $(CC) $(CFLAGS) -c -o $@ $(SRC_S) + + +libttf.a: $($(LIB_FILES)) + +-del $@ + ar src $@ @$(mktmp $(<:t"\n")\n) + +clean: + -+del $(subst,/,\ $($(LIB_FILES))) + +distclean: clean + -+del dep.end libttf.a + +# depend: $(SRC_S) $(SRC_M) $(SRC_X) +# $(CC) -E -M @$(mktmp $(<:t"\n")\n) > dep.end + +# ifeq (dep.end,$(wildcard dep.end)) +# include dep.end +# endif + +# end of Makefile.dm diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx new file mode 100644 index 000000000..fe40be192 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx @@ -0,0 +1,91 @@ +# 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 lib directory with the following statement: +# +# make -f arch/os2/Makefile.emx + +ARCH = arch/os2 +FT_MAKEFILE = $(ARCH)/Makefile.emx + +CC = gcc + +#CFLAGS = -W -Wall -O0 -g -ansi -pedantic -I$(ARCH) -I. -Iextend + +CFLAGS = -Wall -O3 -fno-inline -fomit-frame-pointer \ + -g -ansi -pedantic -I$(ARCH) -I. -Iextend + +#CFLAGS = -Wall -ansi -pedantic -O2 -s -I$(ARCH) -I. -Iextend + +TTFILE = $(ARCH)/os2file.c +TTMEMORY = ./ttmemory.c +TTMUTEX = ./ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ + extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ + extend/ftxgsub.c extend/ftxgpos.c extend/ftxopen.c \ + extend/ftxgdef.c +OBJS_X = $(SRC_X:.c=.o) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttgload.c ttinterp.c ttload.c ttobjs.c \ + ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) + +SRC_S = $(ARCH)/freetype.c +OBJ_S = $(SRC_S:.c=.o) +OBJS_S = $(OBJ_S) $(OBJS_X) + +SRCD_S = $(ARCH)/freetypd.c +OBJD_S = $(SRCD_S:.c=.o) +OBJDS_S = $(OBJD_S) $(OBJS_X) + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: all debug clean distclean depend + + +all: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a + +debug: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a + +debugger: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJDS_S libttfd.a + +$(OBJ_S): $(SRC_S) $(SRC_M) +$(OBJD_S): $(SRCD_S) $(SRC_M) + +libttf.a: $($(LIB_FILES)) + -del $@ + ar src $@ $^ + +libttfd.a: $(OBJDS) + +libttfd.a: $(OBJDS) + -del $@ + ar src $@ $^ + +clean: + -del $(subst /,\,$(OBJS_S)) + -del $(subst /,\,$(OBJS_M)) + +distclean: clean + -del dep.end + -del libttf.a + +depend: $(SRC_S) $(SRC_M) $(SRC_X) + $(CC) -E -M $^ > dep.end + +ifeq (dep.end,$(wildcard dep.end)) + include dep.end +endif + +# end of Makefile.emx diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc new file mode 100644 index 000000000..d774b5422 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc @@ -0,0 +1,73 @@ +# 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 lib 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 +CFLAGS = -O+ -Ti- -Tm- -Sa -W3 -Wpro- -Wcnd- -Q+ -Iarch\os2 -I. -Iextend + +# NOTE: Optimizations are discarded, as it seems that Visual Age +# is buggy when producing ttraster.obj. The resulting code +# crashes under some circumstances (performing vertical dropout +# control when rendering smoothed outlines)! + +TTFILE = $(ARCH)\os2file.c +TTMEMORY = .\ttmemory.c +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c \ + extend\ftxcmap.c extend\ftxwidth.c extend\ftxsbit.c \ + extend\ftxgsub.c extend\ftxgpos.c extend\ftxopen.c \ + extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c \ + ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +all: + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_S)" libttf.lib + +debug: + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_M)" libttf.lib + + +$(OBJ_S): $(SRC_S) $(SRC_M) + $(CC) -C $(CFLAGS) /Fo$@ $*.c + +$(OBJS_X): + $(CC) -C $(CFLAGS) /Fo$@ $*.c + +$(ARCH)\os2file.obj: + $(CC) -C $(CFLAGS) /Fo$@ $*.c + +libttf.lib: $(LIB_FILES) + !ilib /nologo /noignorecase /nobackup $@ +$?,, + +clean: + -del *.obj + -del extend\*.obj + -del arch\os2\*.obj + +distclean: clean + -del libttf.lib + +# end of Makefile.icc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat new file mode 100644 index 000000000..f6cbb1c0c --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat @@ -0,0 +1,88 @@ +# This file is part of the FreeType project. +# +# This builds the Watcom library with Watcom's wcc386 under OS/2. +# +# You'll need Watcom's wmake. +# +# +# Invoke by "wmake -f arch\os2\Makefile.wat" when in the "lib" directory +# +# This will build "freetype\lib\libttf.lib" + +ARCH = arch\os2 +FT_MAKEFILE = $(ARCH)\Makefile.wat +FT_MAKE = wmake -h + + +.EXTENSIONS: +.EXTENSIONS: .lib .obj .c .h +.obj:.;.\extend;.\$(ARCH) +.c:.;.\extend;.\$(ARCH) +.h:.;.\extend;.\$(ARCH) + +CC = wcc386 + +CCFLAGS = /otexanl+ /s /w5 /zq -Iarch\os2 -I. -Iextend + +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +TTMUTEX = .\ttmutex.c + +TTFILE_OBJ = ttfile.obj +TTMEMORY_OBJ = ttmemory.obj +TTMUTEX_OBJ = ttmutex.obj + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) +PORT_OBJS = $(TTFILE_OBJ) $(TTMEMORY_OBJ) $(TTMUTEX_OBJ) + +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c & + extend\ftxcmap.c extend\ftxwidth.c extend\ftxsbit.c & + extend\ftxgsub.c extend\ftxgpos.c extend\ftxopen.c & + extend\ftxgdef.c + +OBJS_X = extend\ftxgasp.obj extend\ftxkern.obj extend\ftxpost.obj & + extend\ftxcmap.obj extend\ftxwidth.obj extend\ftxsbit.obj & + extend\ftxgsub.obj extend\ftxgpos.obj extend\ftxopen.obj & + extend\ftxgdef.obj + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c & + ttgload.c ttinterp.c ttload.c ttobjs.c & + ttraster.c ttextend.c $(PORT) + +OBJS_M = ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj & + ttgload.obj ttinterp.obj ttload.obj ttobjs.obj & + ttraster.obj ttextend.obj $(PORT_OBJS) $(OBJS_X) + +SRC_S = freetype.c +OBJ_S = freetype.obj +OBJS_S = $(OBJ_S) $(OBJS_X) + + +.c.obj: + $(CC) $(CCFLAGS) $[* /fo=$[*.obj + +all: .symbolic + $(FT_MAKE) -f $(FT_MAKEFILE) libttf.lib + +debug: .symbolic + $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_M)" libttf.lib + + +libttf.lib: $(OBJS_M) + wlib -q -n libttf.lib $(OBJS_M) + +# is this correct? Know nothing about wmake and the Watcom compiler... +$(OBJ_S): $(SRC_S) $(SRC_M) + $(CC) $(CCFLAGS) $(SRC_S) /fo=$(OBJ_S) + +clean: .symbolic + @-erase $(OBJS_M) + @-erase *.err + +distclean: .symbolic clean + @-erase libttf.lib + +new: .symbolic + @-wtouch *.c + +# end of Makefile.wat diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c new file mode 100644 index 000000000..8fdcaa704 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c @@ -0,0 +1,32 @@ +/* This file is part of the FreeType project */ + +/* Single file library component for OS/2 */ +#define TT_MAKE_OPTION_SINGLE_OBJECT + +/* first include common core components */ + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* then system-specific (or ANSI) components */ + +#include "os2file.c" +#include "ttmemory.c" +#include "ttmutex.c" + +/* the extensions are compiled separately, but we need to */ +/* include the file ttextend.c if we want to support them */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h new file mode 100644 index 000000000..14905cba4 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h @@ -0,0 +1,239 @@ +/******************************************************************* + * + * ft_conf.h (OS/2 version) + * + * High-level interface specification. + * + * Copyright 1996-1998 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. + * + * + * This file is used to contain the definition of several + * configuration-specific macros. + * + ******************************************************************/ + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + + +/**********************************************************************/ +/* */ +/* We begin by a series of macros that are automatically set by the */ +/* 'configure' script on Unix. They must be set manually on OS/2, */ +/* so here they are : */ +/* */ +/**********************************************************************/ + +#define OS2 + +/* Define to empty if the keyword "const" does not work. */ +/* #undef const */ + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you need for console I/O functions. */ +#if defined(__EMX__) || defined(__IBMC__) +#define HAVE_CONIO_H +#endif + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c new file mode 100644 index 000000000..87545b1d6 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c @@ -0,0 +1,1237 @@ +/******************************************************************* + * + * os2file.c (OS2 version) 2.1 + * + * File I/O Component (body). + * + * 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. + * + * NOTES: + * + * This implementation relies on the OS/2 file API. It was provided + * by the PM FreeType DLL author, Michal Necasek. + * + ******************************************************************/ + +#include "ttconfig.h" + +#include /* !Mike! */ + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttmemory.h" +#include "ttfile.h" /* our prototypes */ + + +/* For now, we don't define additional error messages in the core library */ +/* to report open-on demand errors. Define these errors as standard ones. */ + +#define TT_Err_Could_Not_ReOpen_File TT_Err_Could_Not_Open_File +#define TT_Err_Could_Not_ReSeek_File TT_Err_Could_Not_Open_File + + + /* This definition is mandatory for each file component! */ + EXPORT_FUNC + const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; + + +/* It has proven useful to do some bounds checks during development phase. */ +/* They should probably be undefined for speed reasons in a later release. */ + +#if 0 +#define CHECK_FRAME( frame, n ) \ + do { \ + if ( frame.cursor + n > frame.address + frame.size ) \ + Panic( "Frame boundary error!\n" ); \ + } while ( 0 ) +#else +#define CHECK_FRAME( frame, n ) \ + do { \ + } while ( 0 ) +#endif + + + /* Because a stream can be flushed, i.e., its file handle can be */ + /* closed to save system resources, we must keep the stream's file */ + /* pathname to be able to re-open it on demand when it is flushed. */ + + struct _TStream_Rec + { + Bool opened; /* is the stream handle opened ? */ + String* name; /* the file's pathname */ + Long position; /* current pos. within the file */ + + HFILE file; /* file handle !Mike! */ + Long base; /* stream base in file */ + Long size; /* stream size in file */ + }; + + typedef struct _TStream_Rec TStream_Rec; + typedef TStream_Rec* PStream_Rec; + + + /* We support embedded TrueType files by allowing them to be */ + /* inside any file, at any location, hence the 'base' argument. */ + /* Note, however, that the current implementation does not allow you */ + /* to specify a 'base' index when opening a file. */ + /* (will come later) */ + /* I still don't know if this will turn out useful... - DavidT */ + +#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) + + static TT_Error Stream_Activate ( PStream_Rec stream ); + static TT_Error Stream_Deactivate( PStream_Rec stream ); + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /**** ****/ + /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ + /**** ****/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + + /* In non-reentrant builds, we allocate a single block where we'll */ + /* place all the frames smaller than FRAME_CACHE_SIZE, rather than */ + /* allocating a new block on each access. Bigger frames will be */ + /* malloced normally in the heap. */ + /* */ + /* See TT_Access_Frame() and TT_Forget_Frame() for details. */ + +#define FRAME_CACHE_SIZE 2048 + + /* The TFile_Component structure holds all the data that was */ + /* previously declared static or global in this component. */ + /* */ + /* It is accessible through the 'engine.file_component' */ + /* variable in re-entrant builds, or directly through the */ + /* static 'files' variable in other builds. */ + + struct _TFile_Component + { + TMutex lock; /* used by the thread-safe build only */ + Byte* frame_cache; /* frame cache */ + PStream_Rec stream; /* current stream */ + TFileFrame frame; /* current frame */ + }; + + typedef struct _TFile_Component TFile_Component; + + static TFile_Component files; + +#define CUR_Stream files.stream +#define CUR_Frame files.frame + +#define STREAM_VARS /* void */ +#define STREAM_VAR /* void */ + +/* The macro CUR_Stream denotes the current input stream. */ +/* Note that for the re-entrant version, the 'stream' name has been */ +/* chosen according to the macro STREAM_ARGS. */ + +/* The macro CUR_Frame denotes the current file frame. */ +/* Note that for the re-entrant version, the 'frame' name has been */ +/* chosen according to the macro FRAME_ARGS. */ + +/* The macro STREAM_VAR is used when calling public functions */ +/* that need an 'optional' stream argument. */ + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + TT_Error error; + + MUTEX_Create( files.lock ); + files.stream = NULL; + ZERO_Frame( files.frame ); + + if ( ALLOC( files.frame_cache, FRAME_CACHE_SIZE ) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + FREE( files.frame_cache ); + MUTEX_Destroy( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ) + { + MUTEX_Lock( files.lock ); /* lock file mutex */ + + *stream = org_stream; /* copy the stream */ + files.stream = STREAM2REC( org_stream ); /* set current stream */ + + Stream_Activate( files.stream ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream target stream + * + * Output : Error code. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + HANDLE_Set( *stream, NULL ); + MUTEX_Release( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( size <= FRAME_CACHE_SIZE ) + { + /* use the cache */ + CUR_Frame.address = files.frame_cache; + CUR_Frame.size = FRAME_CACHE_SIZE; + } + else + { + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + } + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + if ( size > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + CUR_Frame.address = NULL; + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * `size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function truncates `size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes, requested; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( size <= FRAME_CACHE_SIZE ) + { + /* use the cache */ + CUR_Frame.address = files.frame_cache; + CUR_Frame.size = FRAME_CACHE_SIZE; + } + else + { + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + } + + requested = size; + readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); + if ( size > readBytes ) + size = readBytes; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + if ( requested > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + CUR_Frame.address = NULL; + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + if ( CUR_Frame.size > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + + ZERO_Frame( CUR_Frame ); + + return TT_Err_Ok; + } + + +#else /* TT_CONFIG_OPTION_THREAD_SAFE */ + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /******** ********/ + /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ + /******** ********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/* a simple macro to access the file component's data */ +#define files ( *((TFile_Component*)engine.file_component) ) + +#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ +#define CUR_Frame (*frame) + +#define STREAM_VARS stream, +#define STREAM_VAR stream + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Duplicates a stream for a new usage. + * + * Input : input_stream source stream to duplicate + * copy address of target duplicate stream + * + * Output : error code. + * The target stream is set to NULL in case of failure. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream input_stream, + TT_Stream* copy ) + { + PStream_Rec rec = STREAM2REC( input_stream ); + + return TT_Open_Stream( rec->name, copy ); + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream target stream + * + * Output : + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + return TT_Close_Stream( stream ); + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS int size ) + { + TT_Error error; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + FREE( CUR_Frame.address ); + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * `size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function truncates `size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS int size ) + { + TT_Error error; + Long readBytes; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + + readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); + if ( size > readBytes ) + size = readBytes; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + FREE( CUR_Frame.address ); + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + FREE( CUR_Frame.address ); + ZERO_Frame( CUR_Frame ); + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /*********** ***********/ + /*********** C O M M O N I M P L E M E N T A T I O N ***********/ + /*********** ***********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/******************************************************************* + * + * Function : Stream_Activate + * + * Description : activates a stream, this will either: + * - open a new file handle if the stream is closed + * - move the stream to the head of the linked list + * + * Input : stream the stream to activate + * + * Output : error condition. + * + * Note : this function is also called with fresh new streams + * created by TT_Open_Stream(). They have their 'size' + * field set to -1. + * + ******************************************************************/ + + static TT_Error Stream_Activate( PStream_Rec stream ) + { + ULONG ulAction; /* !Mike! */ + + if ( !stream->opened ) + { +#if 0 + if ( !(stream->file = fopen( stream->name, "rb" )) ) /* !Mike! */ +#endif + +/* XXX : Strange. GCC/EMX wants an (Byte*) for the file name? */ +#ifdef __EMX__ + + if ( DosOpen( (Byte*)stream->name, &(stream->file), + &ulAction, 0, + 0, OPEN_ACTION_OPEN_IF_EXISTS, + OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) ) + return TT_Err_Could_Not_ReOpen_File; + +#else + + if ( DosOpen( stream->name, &(stream->file), + &ulAction, 0, + 0, OPEN_ACTION_OPEN_IF_EXISTS, + OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) ) + return TT_Err_Could_Not_ReOpen_File; + +#endif /* __EMX__ */ + + stream->opened = TRUE; + + /* A newly created stream has a size field of -1 */ + if ( stream->size < 0 ) + { +#if 0 + fseek( stream->file, 0, SEEK_END ); /* !Mike! */ + stream->size = ftell( stream->file ); +#endif + + DosSetFilePtr( stream->file, 0, FILE_END, (ULONG *)&(stream->size) ); +#if 0 + fseek( stream->file, 0, SEEK_SET ); +#endif + + DosSetFilePtr( stream->file, 0, FILE_BEGIN, &ulAction ); + } + + /* Reset cursor in file */ + if ( stream->position ) + { +#if 0 /* !Mike! */ + if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 ) +#endif + + if ( DosSetFilePtr( stream->file, stream->position, + FILE_BEGIN, &ulAction ) ) + { + /* error during seek */ +#if 0 + fclose( stream->file ); /* !Mike! */ +#endif + + DosClose( stream->file ); + stream->opened = FALSE; + return TT_Err_Could_Not_ReSeek_File; + } + } + } + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Stream_DeActivate + * + * Description : deactivates a stream, this will: + * - close its file handle if it was opened + * - remove it from the opened list if necessary + * + * Input : stream the stream to deactivate + * + * Output : Error condition + * + * Note : the function is called whenever a stream is deleted + * (_not_ when a stream handle's is closed due to an + * activation). However, the stream record isn't + * destroyed by it... + * + ******************************************************************/ + + static TT_Error Stream_Deactivate( PStream_Rec stream ) + { + if ( stream->opened ) + { + /* Save its current position within the file */ +#if 0 + stream->position = ftell( stream->file ); /* !Mike! */ +#endif + + DosSetFilePtr( stream->file, 0, FILE_CURRENT, + (ULONG *)&(stream->position) ); +#if 0 + fclose( stream->file ); /* !Mike! */ +#endif + + DosClose( stream->file ); + stream->file = 0; + stream->opened = FALSE; + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Stream_Size + * + * Description : Returns the length of a given stream, even if it + * is flushed. + * + * Input : stream the stream + * + * Output : length of stream in bytes. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Stream_Size( TT_Stream stream ) + { + PStream_Rec rec = STREAM2REC( stream ); + + + if ( rec ) + return rec->size; + else + return 0; /* invalid stream - return 0 */ + } + + +/******************************************************************* + * + * Function : TT_Open_Stream + * + * Description : Opens the font file and saves the total file size. + * + * Input : error address of stream's error variable + * (re-entrant build only) + * filepathname pathname of the file to open + * stream address of target TT_Stream structure + * + * Output : SUCCESS on sucess, FAILURE on error. + * The target stream is set to -1 in case of failure. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Open_Stream( const String* filepathname, + TT_Stream* stream ) + { + int len; + TT_Error error; + PStream_Rec stream_rec; + + + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) + return error; + + stream_rec = STREAM2REC( *stream ); + + stream_rec->file = NULLHANDLE; /* !Mike! */ + stream_rec->size = -1; + stream_rec->base = 0; + stream_rec->opened = FALSE; + stream_rec->position = 0; + + len = strlen( filepathname ) + 1; + if ( ALLOC( stream_rec->name, len ) ) + goto Fail; + + strncpy( (String*)stream_rec->name, filepathname, len ); + + error = Stream_Activate( stream_rec ); + if ( error ) + goto Fail_Activate; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + CUR_Stream = stream_rec; +#endif + + return TT_Err_Ok; + + Fail_Activate: + FREE( stream_rec->name ); + Fail: + FREE( stream_rec ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Close_Stream + * + * Description : Closes a stream. + * + * Input : stream address of target TT_Stream structure + * + * Output : SUCCESS (always). + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Close_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + Stream_Deactivate( rec ); + FREE( rec->name ); + FREE( rec ); + + HANDLE_Set( *stream, NULL ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Stream + * + * Description : Flushes a stream, i.e., closes its file handle. + * + * Input : stream address of target TT_Stream structure + * + * Output : Error code + * + * NOTE : Never flush the current opened stream. This means that + * you should _never_ call this function between a + * TT_Use_Stream() and a TT_Done_Stream()! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + if ( rec ) + { + Stream_Deactivate( rec ); + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + +/******************************************************************* + * + * Function : TT_Seek_File + * + * Description : Seeks the file cursor to a different position. + * + * Input : position new position in file + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Seek_File( STREAM_ARGS long position ) + { + ULONG ibActual; /* !Mike! */ + + + position += CUR_Stream->base; + +#if 0 + if ( fseek( CUR_Stream->file, position, SEEK_SET ) ) /* !Mike! */ +#endif + + if ( DosSetFilePtr( CUR_Stream->file, position, FILE_BEGIN , &ibActual ) ) + return TT_Err_Invalid_File_Offset; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Skip_File + * + * Description : Skips forward the file cursor. + * + * Input : distance number of bytes to skip + * + * Output : see TT_Seek_File() + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Skip_File( STREAM_ARGS long distance ) + { + ULONG ibActual; /* !Mike! */ + + +#if 0 + return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) - + CUR_Stream->base + distance ); /* !Mike! */ +#endif + + DosSetFilePtr( CUR_Stream->file, 0, FILE_CURRENT, &ibActual ); + return TT_Seek_File( STREAM_VARS ibActual - CUR_Stream->base + distance ); + } + + +/******************************************************************* + * + * Function : TT_Read_File + * + * Description : Reads a chunk of the file and copies it to memory. + * + * Input : buffer target buffer + * count length in bytes to read + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_File( STREAM_ARGS void* buffer, long count ) + { + ULONG cbActual; /* !Mike! */ + +#if 0 /* !Mike! */ + if ( fread( buffer, 1, count, CUR_Stream->file ) != (unsigned long)count ) +#endif + + DosRead( CUR_Stream->file, buffer, count, &cbActual ); + if ( cbActual != (unsigned long)count ) + return TT_Err_Invalid_File_Read; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Read_At_File + * + * Description : Reads file at a specified position. + * + * Input : position position to seek to before read + * buffer target buffer + * count number of bytes to read + * + * Output : SUCCESS on success. FAILURE if error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_At_File( STREAM_ARGS long position, + void* buffer, + long count ) + { + TT_Error error; + + + if ( ( error = TT_Seek_File( STREAM_VARS position ) ) || + ( error = TT_Read_File( STREAM_VARS buffer, count ) ) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_File_Pos + * + * Description : Returns current file seek pointer. + * + * Input : none + * + * Output : current file position + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_File_Pos( STREAM_ARG ) + { + ULONG ibActual; /* !Mike! */ + + +#if 0 + return ftell( CUR_Stream->file ) - CUR_Stream->base; /* !Mike! */ +#endif + + DosSetFilePtr( CUR_Stream->file, 0, FILE_CURRENT, &ibActual ); + return ibActual - CUR_Stream->base; + } + + +/******************************************************************* + * + * Function : GET_Byte + * + * Description : Extracts a byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted Byte. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + Byte TT_Get_Byte( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Byte)(*CUR_Frame.cursor++); + } +#endif + +/******************************************************************* + * + * Function : GET_Char + * + * Description : Extracts a signed byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted char. + * + ******************************************************************/ + + EXPORT_FUNC + Char TT_Get_Char( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Char)(*CUR_Frame.cursor++); + } + + +/******************************************************************* + * + * Function : GET_Short + * + * Description : Extracts a short from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted short. + * + ******************************************************************/ + + EXPORT_FUNC + short TT_Get_Short( FRAME_ARG ) + { + short getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = ((short)CUR_Frame.cursor[0] << 8) | + (short)CUR_Frame.cursor[1]; + + CUR_Frame.cursor += 2; + + return getshort; + } + + +/******************************************************************* + * + * Function : GET_UShort + * + * Description : Extracts an unsigned short from the frame. + * + * Input : None or current frame + * + * Output : Extracted ushort. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + unsigned short TT_Get_UShort( FRAME_ARG ) + { + unsigned short getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = ((unsigned short)CUR_Frame.cursor[0] << 8) | + (unsigned short)CUR_Frame.cursor[1]; + + CUR_Frame.cursor += 2; + + return getshort; + } +#endif + +/******************************************************************* + * + * Function : GET_Long + * + * Description : Extracts a long from the frame. + * + * Input : None or current frame + * + * Output : Extracted long. + * + ******************************************************************/ + + EXPORT_FUNC + long TT_Get_Long( FRAME_ARG ) + { + long getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ((long)CUR_Frame.cursor[0] << 24) | + ((long)CUR_Frame.cursor[1] << 16) | + ((long)CUR_Frame.cursor[2] << 8 ) | + (long)CUR_Frame.cursor[3]; + + CUR_Frame.cursor += 4; + + return getlong; + } + + +/******************************************************************* + * + * Function : GET_ULong + * + * Description : Extracts an unsigned long from the frame. + * + * Input : None + * + * Output : Extracted ulong. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + unsigned long TT_Get_ULong( FRAME_ARG ) + { + unsigned long getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ( ((unsigned long)CUR_Frame.cursor[0] << 24) | + ((unsigned long)CUR_Frame.cursor[1] << 16) | + ((unsigned long)CUR_Frame.cursor[2] << 8 ) | + (unsigned long)CUR_Frame.cursor[3] ); + + CUR_Frame.cursor += 4; + + return getlong; + } +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore new file mode 100644 index 000000000..a8f619d84 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in new file mode 100644 index 000000000..ce70fae7e --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in @@ -0,0 +1,244 @@ +# This file is part of the FreeType project. +# +# lib/arch/unix/Makefile.in + +ARCH = arch/unix +FT_MAKEFILE = $(ARCH)/Makefile + +RM = @RM@ +RMF = @RM@ -f +RMDIR = @RMDIR@ +LN_S = @LN_S@ + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +VPATH = @srcdir@/../.. +srcdir = @srcdir@/../.. + +top_builddir=.. + +CC = @CC@ +CPP = @CPP@ + +LIBTOOL = $(top_builddir)/libtool +MKINSTALLDIRS = $(srcdir)/../mkinstalldirs + +version_info = @version_info@ + +include $(top_builddir)/MakeSub + +############### PORTABILITY COMPONENTS ######################## + +# location of memory component +MEMSRC = ttmemory.c + +# location of file component +FILESRC = @TT_FILE_COMPONENT@ + +# location of mutex component +MUTEXSRC = ttmutex.c + +# location of default extensions +FTEXTDIR = $(srcdir)/extend + + +# default extensions sources +EXTSRC = $(FTEXTDIR)/ftxkern.c \ + $(FTEXTDIR)/ftxgasp.c \ + $(FTEXTDIR)/ftxpost.c \ + $(FTEXTDIR)/ftxcmap.c \ + $(FTEXTDIR)/ftxsbit.c \ + $(FTEXTDIR)/ftxwidth.c \ + $(FTEXTDIR)/ftxerr18.c \ + $(FTEXTDIR)/ftxgsub.c \ + $(FTEXTDIR)/ftxgpos.c \ + $(FTEXTDIR)/ftxgdef.c \ + $(FTEXTDIR)/ftxopen.c + +EXTOBJ = ftxkern.lo \ + ftxgasp.lo \ + ftxpost.lo \ + ftxcmap.lo \ + ftxsbit.lo \ + ftxwidth.lo \ + ftxerr18.lo \ + ftxgsub.lo \ + ftxgpos.lo \ + ftxgdef.lo \ + ftxopen.lo + +# all engine sources +SRC_M = $(srcdir)/ttapi.c \ + $(srcdir)/ttcache.c \ + $(srcdir)/ttcalc.c \ + $(srcdir)/ttcmap.c \ + $(srcdir)/ttdebug.c \ + $(srcdir)/ttextend.c \ + $(srcdir)/ttgload.c \ + $(srcdir)/ttinterp.c \ + $(srcdir)/ttload.c \ + $(srcdir)/ttobjs.c \ + $(srcdir)/ttraster.c \ + $(srcdir)/$(FILESRC) \ + $(srcdir)/$(MEMSRC) \ + $(srcdir)/$(MUTEXSRC) +SRC_S = $(srcdir)/$(ARCH)/freetype.c + +# all header files +HEADERS = $(srcdir)/freetype.h \ + $(srcdir)/fterrid.h \ + $(srcdir)/ftnameid.h \ + $(FTEXTDIR)/ftxkern.h \ + $(FTEXTDIR)/ftxgasp.h \ + $(FTEXTDIR)/ftxcmap.h \ + $(FTEXTDIR)/ftxsbit.h \ + $(FTEXTDIR)/ftxpost.h \ + $(FTEXTDIR)/ftxwidth.h \ + $(FTEXTDIR)/ftxerr18.h \ + $(FTEXTDIR)/ftxgsub.h \ + $(FTEXTDIR)/ftxgpos.h \ + $(FTEXTDIR)/ftxgdef.h \ + $(FTEXTDIR)/ftxopen.h + +# all engine objects +OBJ_M = ttapi.lo \ + ttcache.lo \ + ttcalc.lo \ + ttcmap.lo \ + ttdebug.lo \ + ttextend.lo \ + ttgload.lo \ + ttinterp.lo \ + ttload.lo \ + ttobjs.lo \ + ttraster.lo \ + file.lo \ + memory.lo \ + mutex.lo \ + $(EXTOBJ) +OBJ_S = freetype.lo $(EXTOBJ) + + +# include paths +INCLUDES = -I. -I$(top_builddir) -I$(srcdir) -I$(FTEXTDIR) + +# C flags +CFLAGS = @CFLAGS@ @XX_CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +FT_CFLAGS = $(CFLAGS) $(INCLUDES) + +# linker flags +FT_LIBS = @LIBS@ + +# i18n stuff +LOCALEDIR = @LOCALEDIR@ + + +all: do_link + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJ_S)" libttf.la + +debug: do_link + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJ_M)" libttf.la + + +do_link: + -$(RMF) memory.c file.c mutex.c + $(LN_S) $(srcdir)/$(MEMSRC) memory.c + $(LN_S) $(srcdir)/$(FILESRC) file.c + $(LN_S) $(srcdir)/$(MUTEXSRC) mutex.c + + +.SUFFIXES: .lo +.c.lo: + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $< + +ftxkern.lo: $(FTEXTDIR)/ftxkern.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxkern.c + +ftxgasp.lo: $(FTEXTDIR)/ftxgasp.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgasp.c + +ftxpost.lo: $(FTEXTDIR)/ftxpost.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxpost.c + +ftxcmap.lo: $(FTEXTDIR)/ftxcmap.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxcmap.c + +ftxsbit.lo: $(FTEXTDIR)/ftxsbit.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxsbit.c + +ftxwidth.lo: $(FTEXTDIR)/ftxwidth.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxwidth.c + +ftxerr18.lo: $(FTEXTDIR)/ftxerr18.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) \ + -DLOCALEDIR='"$(LOCALEDIR)"' \ + $(FTEXTDIR)/ftxerr18.c + +ftxgsub.lo: $(FTEXTDIR)/ftxgsub.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgsub.c + +ftxgpos.lo: $(FTEXTDIR)/ftxgpos.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgpos.c + +ftxgdef.lo: $(FTEXTDIR)/ftxgdef.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgdef.c + +ftxopen.lo: $(FTEXTDIR)/ftxopen.c + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxopen.c + +freetype.lo: $(SRC_S) $(SRC_M) + $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) \ + -DLOCALEDIR='"$(LOCALEDIR)"' \ + -DTT_MAKE_OPTION_SINGLE_OBJECT \ + $(SRC_S) + +libttf.la: $(LIB_FILES) + $(LIBTOOL) --mode=link $(CC) -o libttf.la $(LIB_FILES) \ + -rpath $(libdir) \ + -version-info $(version_info) $(FT_LIBS) + +install: libttf.la + $(MKINSTALLDIRS) $(libdir) $(includedir)/freetype + $(LIBTOOL) --mode=install $(INSTALL) libttf.la $(libdir) + -for P in $(HEADERS) ; do \ + $(INSTALL_DATA) $$P $(includedir)/freetype ; \ + done + +uninstall: + -$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/libttf.la + -$(RMF) $(includedir)/freetype/* + -$(RMDIR) $(includedir)/freetype + +clean: + -$(RMF) $(OBJ_S) $(OBJ_M) *.o + +distclean: clean + -$(RMF) file.c memory.c mutex.c + -$(RMF) libttf.la + -$(RMF) *.orig *~ core *.core + -$(RMF) $(ARCH)/Makefile + -$(RMF) .libs/* + -$(RMDIR) .libs + +depend: do_link + (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_S) $(SRC_M) $(EXTSRC) ; do \ + $(CPP) $(CPPFLAGS) $(INCLUDES) $$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`.lo: /" ; \ + 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 diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c new file mode 100644 index 000000000..5f41ff6aa --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c @@ -0,0 +1,27 @@ +/* This file is part of the FreeType project */ + +/* Single object library component for Unix */ + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* The Makefile creates proper links to following three files */ + +#include "file.c" +#include "memory.c" +#include "mutex.c" + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c new file mode 100644 index 000000000..0378dc2a2 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c @@ -0,0 +1,1027 @@ +/******************************************************************* + * + * ttmmap.c 2.0 + * + * Memory-Mapped file component ( replaces ttfile.c ). + * + * 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. + * + * Changes between 2.0 and 1.3 : + * + * - adopted new design/separation introduced in ttfile.c 2.0 + * + ******************************************************************/ + +#include "ttconfig.h" + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include +#ifndef MAP_FILE +#define MAP_FILE 0x00 +#endif + +/* + * The prototype for munmap() is not provided on SunOS. This needs to + * have a check added later to see if the GNU C library is being used. + * If so, then this prototype is not needed. + */ +#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4) + extern int munmap( caddr_t addr, int len ); +#endif + +#include +#ifdef HAVE_FCNTL_H +#include +#endif + + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttmemory.h" +#include "ttfile.h" /* our prototypes */ + + /* This definition is mandatory for each file component! */ + EXPORT_FUNC + const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; + + /* It has proven useful to do some bounds checks during */ + /* development phase. Define DEBUG_FILE when compiling */ + /* this component to enable them. */ + +#ifdef DEBUG_FILE +#define CHECK_FRAME( frame, n ) \ + do { \ + if ( frame.cursor + n > frame.address + frame.size ) \ + Panic( "Frame boundary error!\n" ); \ + } while ( 0 ) +#else +#define CHECK_FRAME( frame, n ) \ + do { \ + } while( 0 ) +#endif + + struct _TFileMap + { + String* base; /* base address of mapped file */ + Int refcount; /* reference count for mmaped region */ + Long size; /* stream size in file */ + Long offset; /* offset in file */ + }; + + typedef struct _TFileMap TFileMap; + +#define MAP_Address( map ) (Byte*)( (map)->base + (map)->offset ) + + /* The stream record structure */ + typedef struct _TStream_Rec + { + TFileMap* map; /* mapped file description */ + Long pos ; /* cursor in mapped file */ + } TStream_Rec; + + typedef TStream_Rec* PStream_Rec; + +#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /**** ****/ + /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ + /**** ****/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + + /* The TFile_Component structure holds all the data that was */ + /* previously declared static or global in this component. */ + /* */ + /* It is accessible through the 'engine.file_component' */ + /* variable in re-entrant builds, or directly through the */ + /* static 'files' variable in other builds. */ + + struct _TFile_Component + { + TMutex lock; /* used by the thread-safe build only */ + PStream_Rec stream; /* current stream */ + TFileFrame frame; /* current frame */ + }; + + typedef struct _TFile_Component TFile_Component; + +/* The macro CUR_Stream denotes the current input stream */ +/* Note that for the re-entrant version, the 'stream' name has been */ +/* chosen according to the macro STREAM_ARGS. */ + +/* The macro CUR_Frame denotes the current file frame */ +/* Note that for the re-entrant version, the 'frame' name has been */ +/* chosen according to the macro FRAME_ARGS. */ + +/* The macro STREAM_VAR is used when calling public functions */ +/* that need an 'optional' stream argument. */ + +#define CUR_Stream files.stream /* thread-safe macros */ +#define CUR_Frame files.frame + +#define STREAM_VARS /* void */ +#define STREAM_VAR /* void */ + + /* the 'files' variable is only defined in non-reentrant builds */ + + static TFile_Component files; + + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + MUTEX_Create( files.lock ); + files.stream = NULL; + ZERO_Frame( files.frame ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + MUTEX_Destroy( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ) + { + MUTEX_Lock( files.lock ); + *stream = org_stream; + files.stream = STREAM2REC( org_stream ); /* set current stream */ + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream + * + * Output : Error code + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + HANDLE_Set( *stream, NULL ); + MUTEX_Release( files.lock ); + + return TT_Err_Ok; + } + +#else /* TT_CONFIG_OPTION_THREAD_SAFE */ + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /******** ********/ + /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ + /******** ********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ +#define CUR_Frame (*frame) + +#define STREAM_VARS stream, +#define STREAM_VAR stream + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + engine.file_component = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code. The output stream is set to NULL in + * case of Failure. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream input_stream, + TT_Stream* copy ) + { + TT_Error error; + PStream_Rec stream_rec; + PStream_Rec copy_rec; + + + stream_rec = STREAM2REC( input_stream ); + + if ( ALLOC( copy_rec, sizeof ( TStream_Rec ) ) ) + goto Fail; + + HANDLE_Set( *copy, copy_rec ); + + copy_rec->map->refcount++; + copy_rec->pos = 0; + + return TT_Err_Ok; + + Fail: + HANDLE_Set( *copy, NULL ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream + * + * Output : error code + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + return TT_Close_Stream( stream ); + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /*********** ***********/ + /*********** C O M M O N I M P L E M E N T A T I O N ***********/ + /*********** ***********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/******************************************************************* + * + * Function : AllocateMap + * + * Description : Allocates a new map from the table. + * + * Output : Pointer to new stream rec. NULL in case of failure. + * + ******************************************************************/ + + static + TFileMap* Allocate_Map( void ) + { + TFileMap* result; + + + if ( MEM_Alloc( result, sizeof ( TFileMap ) ) ) + return NULL; + + result->refcount = 1; + return result; + } + + +/******************************************************************* + * + * Function : ReleaseMap + * + * Description : Releases a used map to the table if reference i + * counter reaches zero. + * + * Input : map + * + * Output : None. + * + * Note : Called by TT_Close_File() + * + ******************************************************************/ + + static + void Release_Map ( TFileMap* map ) + { + map->refcount--; + if ( map->refcount <= 0 ) + { + munmap ( (void*)map->base, map->size ); + FREE( map ); + } + } + + +/******************************************************************* + * + * Function : TT_Open_Stream + * + * Description : Opens the font file and saves the total file size. + * + * Input : error address of stream's error variable + * (re-entrant build only). + * filepathname pathname of the file to open + * stream address of target TT_Stream structure + * + * Output : SUCCESS on success, FAILURE on error. + * The target stream is set to -1 in case of failure. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Open_Stream( const String* filepathname, + TT_Stream* stream ) + { + TT_Error error; + Int file; + PStream_Rec stream_rec; + TFileMap* map; + struct stat stat_buf; + + + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) + return error; + + map = Allocate_Map(); + if ( !map ) + { + error = TT_Err_Out_Of_Memory; + goto Memory_Fail; + } + + stream_rec = STREAM2REC( *stream ); + + file = open( (String*)filepathname, O_RDONLY ); + if ( file < 0 ) + goto File_Fail; + + if ( fstat( file, &stat_buf ) < 0 ) + goto Map_Fail; + + map->offset = 0; + map->size = stat_buf.st_size + map->offset; + map->base = mmap( NULL, + map->size, + PROT_READ, + MAP_FILE | MAP_PRIVATE, + file, + 0 ); + + if ( (long)map->base == -1 ) + goto Map_Fail; + + close( file ); + + stream_rec->map = map; + stream_rec->pos = 0; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + CUR_Stream = stream_rec; +#endif + + return TT_Err_Ok; + + Map_Fail: + close( file ); + + File_Fail: + error = TT_Err_Could_Not_Open_File; + FREE( map ); + + Memory_Fail: + FREE( *stream ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Close_Stream + * + * Description : Closes a stream. + * + * Input : stream + * + * Output : SUCCESS (always) + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Close_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + Release_Map( rec->map ); + FREE( rec ); + + HANDLE_Set( *stream, NULL ); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Stream + * + * Description : Flushes a stream, i.e., closes its file handle. + * + * Input : stream address of target TT_Stream structure + * + * Output : Error code + * + * NOTE : Never flush the current opened stream. This means that + * you should _never_ call this function between a + * TT_Use_Stream() and a TT_Done_Stream()! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Stream( TT_Stream* stream ) + { + /* XXX - DUMMY IMPLEMENTATION */ + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Stream_Size + * + * Description : Returns the length of a given stream, even if it + * is flushed. + * + * Input : stream the stream + * + * Output : Length of stream in bytes. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Stream_Size( TT_Stream stream ) + { + PStream_Rec rec = STREAM2REC( stream ); + + + if ( rec ) + return rec->map->size; + else + return 0; /* invalid stream - return 0 */ + } + + +/******************************************************************* + * + * Function : TT_Seek_File + * + * Description : Seeks the file cursor to a different position. + * + * Input : position new position in file + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Seek_File( STREAM_ARGS Long position ) + { + if ( position > CUR_Stream->map->size ) + return TT_Err_Invalid_File_Offset; + + CUR_Stream->pos = position; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Skip_File + * + * Description : Skips forward the file cursor. + * + * Input : distance number of bytes to skip + * + * Output : see TT_Seek_File + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Skip_File( STREAM_ARGS Long distance ) + { + return TT_Seek_File( STREAM_VARS CUR_Stream->pos + distance ); + } + + +/******************************************************************* + * + * Function : TT_Read_File + * + * Description : Reads a chunk of the file and copies it to memory. + * + * Input : buffer target buffer + * count length in bytes to read + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) + { + if ( CUR_Stream->pos + count > CUR_Stream->map->size ) + return TT_Err_Invalid_File_Read; + + MEM_Copy( buffer, + MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, count ); + CUR_Stream->pos += count; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Read_At_File + * + * Description : Reads file at a specified position. + * + * Input : position position to seek to before read + * buffer target buffer + * count number of bytes to read + * + * Output : SUCCESS on success. FAILURE if error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ) + { + TT_Error error; + + + if ( (error = TT_Seek_File( STREAM_VARS position )) || + (error = TT_Read_File( STREAM_VARS buffer, count )) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_File_Pos + * + * Description : Returns current file seek pointer. + * + * Input : none + * + * Output : current file position + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_File_Pos( STREAM_ARG ) + { + return CUR_Stream->pos; + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : Error code + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that aSize is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( CUR_Stream->pos + size > CUR_Stream->map->size ) + return TT_Err_Invalid_Frame_Access; + + CUR_Frame.size = size; + CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; + CUR_Frame.cursor = CUR_Frame.address; + + CUR_Stream->pos += size; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx() + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : Error code + * + * Notes: The function truncates 'size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that aSize is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. The 'overflow' is set to zero. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + readBytes = CUR_Stream->map->size - CUR_Stream->pos; + if ( size > readBytes ) + { + /* There is overflow, we allocate a new block then */ + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + + CUR_Frame.size = size; + + /* copy the valid part */ + MEM_Copy( CUR_Frame.address, + MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, + readBytes ); + } + else + { + CUR_Frame.size = size; + CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; + } + + CUR_Frame.cursor = CUR_Frame.address; + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + /* If we were using a duplicate in case of overflow, free it now */ + if ( CUR_Frame.address < (Byte*)CUR_Stream->map->base || + CUR_Frame.address >= (Byte*)CUR_Stream->map->base + + CUR_Stream->map->size ) + FREE( CUR_Frame.address ); + + ZERO_Frame( files.frame ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : GET_Byte + * + * Description : Extracts a byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted Byte + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + +#if 0 + + EXPORT_FUNC + Byte TT_Get_Byte( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Byte)(*CUR_Frame.cursor++); + } + +#endif + + +/******************************************************************* + * + * Function : GET_Char + * + * Description : Extracts a signed byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted char + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + + EXPORT_FUNC + Char TT_Get_Char( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Char)(*CUR_Frame.cursor++); + } + + +/******************************************************************* + * + * Function : GET_Short + * + * Description : Extracts a short from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted short + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + + EXPORT_FUNC + Short TT_Get_Short( FRAME_ARG ) + { + Short getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = ((Short)CUR_Frame.cursor[0] << 8) | + (Short)CUR_Frame.cursor[1]; + + CUR_Frame.cursor += 2; + + return getshort; + } + + +/******************************************************************* + * + * Function : GET_UShort + * + * Description : Extracts an unsigned short from the frame. + * + * Input : None or current frame + * + * Output : Extracted ushort + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + +#if 0 + + EXPORT_FUNC + UShort TT_Get_UShort( FRAME_ARG ) + { + UShort getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = ((UShort)CUR_Frame.cursor[0] << 8) | + (UShort)CUR_Frame.cursor[1]; + + CUR_Frame.cursor += 2; + + return getshort; + } + +#endif + + +/******************************************************************* + * + * Function : GET_Long + * + * Description : Extracts a long from the frame. + * + * Input : None or current frame + * + * Output : Extracted long + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Get_Long( FRAME_ARG ) + { + Long getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ((Long)CUR_Frame.cursor[0] << 24) | + ((Long)CUR_Frame.cursor[1] << 16) | + ((Long)CUR_Frame.cursor[2] << 8 ) | + (Long)CUR_Frame.cursor[3]; + + CUR_Frame.cursor += 4; + + return getlong; + } + + +/******************************************************************* + * + * Function : GET_ULong + * + * Description : Extracts an unsigned long from the frame. + * + * Input : None + * + * Output : Extracted ulong + * + * NOTES : We consider that the programmer is intelligent enough + * not to try to get a byte that is out of the frame. Hence, + * we provide no bounds check here. (A misbehaving client + * could easily page fault using this call.) + * + ******************************************************************/ + +#if 0 + + EXPORT_FUNC + ULong TT_Get_ULong( FRAME_ARG ) + { + ULong getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | + ((ULong)CUR_Frame.cursor[1] << 16) | + ((ULong)CUR_Frame.cursor[2] << 8 ) | + (ULong)CUR_Frame.cursor[3] ); + + CUR_Frame.cursor += 4; + + return getlong; + } + +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README new file mode 100644 index 000000000..4d929652e --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README @@ -0,0 +1,20 @@ +This directory contains two files for compiling the FreeType library under +VMS: + + ft_conf.h the configuration file for the FreeType library + descrip.mms a makefile to be used with either MMS or MMK + +The files are such designed that after unpacking of freetype-1.2 one can +give the command + + MMS/DESCR=[.LIB.ARCH.VMS] + +to build the libraries. (Of course, for MMK use `MMK' on the command line +instead of `MMS'.) The makefile contains a `clean' target, but no `install' +target since I'm note sure where to install the library and the include +files. + +I did NOT do the test programs but I tested it with my own programs. + + + Jouk Jansen diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms new file mode 100644 index 000000000..2c087fd5c --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms @@ -0,0 +1,155 @@ +# This file is part of the FreeType project. +# +# DESCRIP.MMS: Make file for VMS using MMS or MMK +# Created by Jouk Jansen (joukj@hrem.stm.tudelft.nl) + +ARCH = arch.unix + +CC = cc + +############### PORTABILITY COMPONENTS ######################## + +# location of memory component +MEMSRC = ttmemory.c + +# location of file component +FILESRC = ttfile.c + +# location of mutex component +MUTEXSRC = ttmutex.c + +# location of default extensions +FTEXTDIR = [.lib.extend] + +# default extensions sources +EXTSRC = $(FTEXTDIR)ftxkern.c \ + $(FTEXTDIR)ftxgasp.c \ + $(FTEXTDIR)ftxpost.c \ + $(FTEXTDIR)ftxcmap.c \ + $(FTEXTDIR)ftxsbit.c \ + $(FTEXTDIR)ftxwidth.c \ + $(FTEXTDIR)ftxerr18.c \ + $(FTEXTDIR)ftxgsub.c \ + $(FTEXTDIR)ftxgpos.c \ + $(FTEXTDIR)ftxopen.c \ + $(FTEXTDIR)ftxgdef.c + +EXTOBJ = [.lib]ftxkern.obj, \ + [.lib]ftxgasp.obj, \ + [.lib]ftxpost.obj, \ + [.lib]ftxcmap.obj, \ + [.lib]ftxsbit.obj, \ + [.lib]ftxwidth.obj, \ + [.lib]ftxerr18.obj, \ + [.lib]ftxgsub.obj, \ + [.lib]ftxgpos.obj, \ + [.lib]ftxopen.obj, \ + [.lib]ftxgdef.obj + +# all engine sources +SRC_M = [.lib]ttapi.c \ + [.lib]ttcache.c \ + [.lib]ttcalc.c \ + [.lib]ttcmap.c \ + [.lib]ttdebug.c \ + [.lib]ttextend.c \ + [.lib]ttgload.c \ + [.lib]ttinterp.c \ + [.lib]ttload.c \ + [.lib]ttobjs.c \ + [.lib]ttraster.c \ + [.lib]$(FILESRC) \ + [.lib]$(MEMSRC) \ + [.lib]$(MUTEXSRC) +SRC_S = [.lib.$(ARCH)]freetype.c + +# all header files with path +HEADERS = [.lib]freetype.h \ + [.lib]fterrid.h \ + [.lib]ftnameid.h \ + $(FTEXTDIR)ftxkern.h \ + $(FTEXTDIR)ftxgasp.h \ + $(FTEXTDIR)ftxcmap.h \ + $(FTEXTDIR)ftxsbit.h \ + $(FTEXTDIR)ftxpost.h \ + $(FTEXTDIR)ftxwidth.h \ + $(FTEXTDIR)ftxerr18.h \ + $(FTEXTDIR)ftxgsub.h \ + $(FTEXTDIR)ftxgpos.h \ + $(FTEXTDIR)ftxgdef.h \ + $(FTEXTDIR)ftxopen.h + +# all engine objects +OBJ_M = [.lib]ttapi.obj, \ + [.lib]ttcache.obj, \ + [.lib]ttcalc.obj, \ + [.lib]ttcmap.obj, \ + [.lib]ttdebug.obj, \ + [.lib]ttextend.obj, \ + [.lib]ttgload.obj, \ + [.lib]ttinterp.obj, \ + [.lib]ttload.obj, \ + [.lib]ttobjs.obj, \ + [.lib]ttraster.obj, \ + [.lib]file.obj, \ + [.lib]memory.obj, \ + [.lib]mutex.obj, \ + $(EXTOBJ) +OBJ_S = [.lib]freetype.obj + + +# include paths +INCLUDES = /include=([.lib],[],$(FTEXTDIR)) + +# C flags +CFLAGS = $(INCLUDES)/obj=[.lib] + +all : do_link [.lib]libttf.olb + library/compress [.lib]libttf.olb + +do_link : + if f$search( "[.lib]memory.c" ) .nes. "" then set file/remove [.lib]memory.c; + if f$search( "[.lib]file.c" ) .nes. "" then set file/remove [.lib]file.c; + if f$search( "[.lib]mutex.c" ) .nes. "" then set file/remove [.lib]mutex.c; + if f$search( "[.lib]ft_conf.h" ) .nes. "" then set file/remove [.lib]ft_conf.h; + set file/enter=[.lib]memory.c [.lib]$(MEMSRC) + set file/enter=[.lib]file.c [.lib]$(FILESRC) + set file/enter=[.lib]mutex.c [.lib]$(MUTEXSRC) + set file/enter=[.lib]ft_conf.h [.lib.arch.vms]ft_conf.h + +[.lib]ftxkern.obj : $(FTEXTDIR)ftxkern.c + +[.lib]ftxgasp.obj : $(FTEXTDIR)ftxgasp.c + +[.lib]ftxpost.obj : $(FTEXTDIR)ftxpost.c + +[.lib]ftxcmap.obj : $(FTEXTDIR)ftxcmap.c + +[.lib]ftxsbit.obj : $(FTEXTDIR)ftxsbit.c + +[.lib]ftxwidth.obj : $(FTEXTDIR)ftxwidth.c + +[.lib]ftxerr18.obj : $(FTEXTDIR)ftxerr18.c + +[.lib]ftxgsub.obj : $(FTEXTDIR)ftxgsub.c + +[.lib]ftxgpos.obj : $(FTEXTDIR)ftxgpos.c + +[.lib]ftxgdef.obj : $(FTEXTDIR)ftxgdef.c + +[.lib]ftxopen.obj : $(FTEXTDIR)ftxopen.c + +[.lib]freetype.obj : $(SRC_S) $(SRC_M) + + +[.lib]libttf.olb : $(OBJ_M) + library/create [.lib]libttf.olb $(OBJ_M) + + +clean : + delete [.lib]*.obj;* + delete [.lib]*.olb;* + if f$search( "[.lib]memory.c" ) .nes. "" then set file/remove [.lib]memory.c; + if f$search( "[.lib]file.c" ) .nes. "" then set file/remove [.lib]file.c; + if f$search( "[.lib]mutex.c" ) .nes. "" then set file/remove [.lib]mutex.c; + if f$search( "[.lib]ft_conf.h" ) .nes. "" then set file/remove [.lib]ft_conf.h; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h new file mode 100644 index 000000000..a000e6233 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h @@ -0,0 +1,215 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for VMS using MMS or MMK */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +/* #undef HAVE_MMAP */ + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if the X Window System is missing or not being used. */ +/* #undef X_DISPLAY_MISSING */ + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the libintl library. */ +/* #undef HAVE_LIBINTL */ + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #undef HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +/* #undef TT_CONFIG_OPTION_THREAD_SAFE */ + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +/* #undef DEBUG_LEVEL_TRACE */ + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +/* #undef DEBUG_LEVEL_ERROR */ + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC new file mode 100644 index 000000000..e13c9ca18 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC @@ -0,0 +1,180 @@ +# This file is part of the FreeType project. +# +# It builds the library for Borland C++ for 16-bit Windows, large model. +# Due to size constraints, it does not try to pack all modules into one. +# +# You will need Borland MAKE. +# Tested with Borland C++ v.4.0 and 5.0. +# +# Use this file while in the lib directory with the following statement: +# +# make -farch/win16/Makefile.BC +# +# +# A DLL version of the library can be built with +# +# make -DDLL -farch/win16/Makefile.BC dll +# +# 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/win16/Makefile.BC + +ARCH = arch\win16 +FT_MAKEFILE = $(ARCH)\Makefile.BC +FT_DLL = ft13_16.dll + +CC = bcc +LIB = tlib /c /e +IMPLIB = implib -c -o + +SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig + +# Credits go to Dave Hoo for pointing out that modern +# Borland compilers (from BC++ 3.1 on) can increase the limit on +# the length of identifiers. +!if ! $d(DEBUG) +CFLAGS = -O2 -3 -ml -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) +DLLFLAGS = -ml -WD -lC +!else +CFLAGS = -v -N -ml -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) +DLLFLAGS = -v -ml -WD -lC +!endif + +CFLAGS = $(CFLAGS) -W + +FT_DEF = $(FT_DLL:.dll=.def) +!if $d(DLL) +CFLAGS = $(CFLAGS) -WD +!endif + + +!if $d(BIGFONTS) +CFLAGS = $(CFLAGS) -DTT_HUGE_PTR=__huge + +TTFILE = $(ARCH)\hugefile.c +TTMEMORY = $(ARCH)\hugemem.c +!else +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +!endif +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +# Do not insert spaces before the \ at end of line, +# otherwise the substitution for TLIB command line will fail. +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ + extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c\ + extend\ftxsbit.c extend\ftxgsub.c extend\ftxgpos.c\ + extend\ftxopen.c extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c\ + ttgload.c ttinterp.c ttload.c ttobjs.c\ + ttraster.c ttextend.c ttdebug.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +# Since Borland make does not handle $($(LIB_FILES)), and using +# -DLIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat +# by constructing TLIB's response file directly in the `all' target. +# +# Another solution, useful during debugging of part of the library, +# would be to include each .obj in the library as soon as it is compiled. +# See ../msdos/Makefile.TC for an application. +.c.obj: + @$(CC) -c -o$* @&&| + $(CFLAGS) $< +| + + +!if ! $d(DEBUG) +# Skipped if DEBUG build +# (but it changes nothing, since we always build in multiple parts). +all: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(OBJS_M: = + ) +| +!endif + +debug: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(OBJS_M: = + ) +| + +$(FT_DEF): $(ARCH)\ttf.def + -copy $(ARCH)\ttf.def $(FT_DEF) + +dll $(FT_DLL): $(OBJS_M) $(FT_DEF) +!if $d(DLL) + $(CC) -e$(FT_DLL) @&&| + $(DLLFLAGS) $(OBJS_M) +| + $(IMPLIB) libttf $(FT_DEF) +!else +# Re-invoke with flag set. Unfortunately, this discards the other flags. + make -DDLL -f$(ARCH)/Makefile.BC dll +!endif + +install: $(FT_DLL) +!if $d(INSTALL_DIR) + copy $(FT_DLL) $(INSTALL_DIR) +!else + copy $(FT_DLL) C:\WINDOWS +!endif + + +$(OBJ_S): $(SRC_S) $(SRC_M) + +# Not used here because it excesses the capacity of COMMAND.COM... +libttf.lib: $(LIB_FILES) + -del libttf.lib + echo -+$(**: =-+)> response + $(LIB) libttf.lib @&&| ++ $(**: = + ) +| + +!if $d(BIGFONTS) +$(TTMEMORY:.c=.obj): $(TTMEMORY) + $(CC) -c -o$* @&&| + $(CFLAGS) -A- $*.c +| + +$(TTFILE:.c=.obj): $(TTFILE) + $(CC) -c -o$* @&&| + $(CFLAGS) -A- $*.c +| +!endif + + +clean: + -del *.obj + -del extend\*.obj + -del $(ARCH)\*.obj + -del libttf.bak + -del response + -del *.def + +distclean: clean + -del libttf.lib + -del *.dll + -del $(FT_DEF) + -del C:\WINDOWS\$(FT_DLL) +!if $d(INSTALL_DIR) + -del $(INSTALL_DIR)\$(FT_DLL) +!endif + +!include "$(ARCH)\depend.win" + +# end of Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS new file mode 100644 index 000000000..847bdb916 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS @@ -0,0 +1,106 @@ +# This file is part of the FreeType project. +# +# It builds the library for Microsoft C for Windows, large model. +# It also works for Visual C++ 1.x 16-bit compilers, but you should +# instead use the Makefile customized for it, Makefile.VC. +# Due to size constraints, it does not try to pack all modules into one. +# +# You will need NMAKE. +# +# Use this file while in the lib 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 + +CC = cl /nologo +LIB = lib /noignorecase /nologo + +!ifndef DEBUG +CFLAGS = /Ox /AL /Za /W2 /G2 -I$(ARCH) -I. -Iextend +!else +CFLAGS = /Zi /AL /Za /W2 /G2 -I$(ARCH) -I. -Iextend +!endif + +# Use /Gw instead with Microsoft C version 6 +CFLAGS = $(CFLAGS) /GA + + +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +# Do not insert spaces between the file names or at end of line, otherwise +# the substitution for LIB command line will fail. Thank you. +# +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ +extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c extend\ftxsbit.c\ +extend\ftxopen.c extend\ftxgsub.c extend\ftxgpos.c extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ +ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +# Since Microsoft's NMAKE does not handle $($(LIB_FILES)), and using +# LIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat +# by constructing LIB's response file directly in the `all' target. +# +# Another solution, useful during debugging of part of the library, +# would be to include each .obj in the library as soon as it is compiled. +# See ..\msdos\Makefile.TC for an application. +.c.obj: + $(CC) /c /Fo$@ @<< + $(CFLAGS) $*.c +<< + + +!ifndef DEBUG +# Skipped if DEBUG build +# (but it changes nothing, since we always build in multiple parts). +all: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @< header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you need for console I/O functions. */ +#undef HAVE_CONIO_H + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the libintl library. */ +#undef HAVE_LIBINTL + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + +/* The number of bytes in a int. */ +#define SIZEOF_INT 2 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#undef LONG64 +#undef INT64 + +#endif /* FT_CONF_H */ + +/* End of ft_conf.h */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c new file mode 100644 index 000000000..fbc9bfc96 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c @@ -0,0 +1,51 @@ +/******************************************************************* + * + * hugefile.c + * + * File I/O Component (body) for dealing with "huge" objects + * under 16-bit Windows. Relies on the "default" version, with + * a small hook. Requires Windows 3.1+. + * + * Written by Antoine Leca based on ideas from Dave Hoo. + * Copyright 1999 by Dave Hoo, 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. + * + * NOTE + * + * This file #includes the normal version, to avoid discrepancies + * between versions. It uses only ANSI-mandated "tricks", so + * any ANSI-compliant compiler should be able to compile this file. + * + ******************************************************************/ + +#include "ttconfig.h" +#include "tttypes.h" + +#include + + /* Here we include , to have the proper definition of fread */ +#include + + /* Some compilers define fileno(), some define _fileno()... */ +#ifndef _fileno +#define _fileno(stream) fileno(stream) +#endif + + /* Then, we divert the use of fread to the Windows version */ +#undef fread +#define fread(ptr, size, n, stream) \ + _hread( _fileno(stream), (char TT_HUGE_PTR *) ptr, (ULong)n * size ) + + + /* Now, we include the "normal" version of `ttfile.c' */ + /* The ANSI/ISO standard mandates that the include of */ + /* there have no bad effects. */ +#include "ttfile.c" + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c new file mode 100644 index 000000000..ea2a342e8 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c @@ -0,0 +1,539 @@ +/******************************************************************* + * + * hugemem.c + * + * Memory management component (body) + * for dealing with "huge" objects with 16-bit Windows. + * + * Written by Antoine Leca based on ideas from Dave Hoo. + * Copyright 1999 by Dave Hoo, 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. + * + ******************************************************************/ + +#include +#include + +#include "ttdebug.h" +#include "ttmemory.h" +#include "ttengine.h" + +#ifndef TT_HUGE_PTR +#error "This component needs TT_HUGE_PTR to be #defined." +#endif + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE +#error "This component needs static allocation and is not re-entrant." +#endif + + /* If the memory reclaimed is abobve this limit, alloc directly from */ + /* global heap. Else, alloc using malloc (using suballocation). */ +#ifndef MEMORY_MIN_GLOBAL +#define MEMORY_MIN_GLOBAL 4096 +#endif + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_memory + + +#ifdef DEBUG_MEMORY + +#include + +#define MAX_TRACKED_BLOCKS 1024 + + struct TMemRec_ + { + void* base; + Long size; + }; + + typedef struct TMemRec_ TMemRec; + + static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; + + static Int num_alloc; + static Int num_free; + static Int num_realloc; /* counts only `real' reallocations + (i.e., an existing buffer will be resized + to a value larger than zero */ + + static Int fail_alloc; + static Int fail_realloc; + static Int fail_free; + +#else + + /* We need a tracing stack of the calls to big chunks of memory, */ + /* in order to call the matching version of free(). */ + +#define MAX_TRACKED_BIGCHUNKS 64 + + struct TMemRec_ + { + void* base; + }; + + typedef struct TMemRec_ TMemRec; + + static TMemRec pointers[MAX_TRACKED_BIGCHUNKS + 1]; + +#endif /* DEBUG_MEMORY */ + + +#ifndef TT_CONFIG_REENTRANT + Long TTMemory_Allocated; + Long TTMemory_MaxAllocated; +#endif + + +/******************************************************************* + * + * Function : TT_Alloc + * + * Description : Allocates memory from the heap buffer. + * + * Input : Size size of the memory to be allocated + * P pointer to a buffer pointer + * + * Output : Error code. + * + * NOTE : The newly allocated block should _always_ be zeroed + * on return. Many parts of the engine rely on this to + * work properly. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Alloc( ULong Size, void** P ) + { + Int i; + + + if ( !P ) + return TT_Err_Invalid_Argument; + /* Also see below for another case of "invalid argument". */ + + if ( Size > 0 ) + { + if ( Size >= MEMORY_MIN_GLOBAL ) + { + HANDLE hMem; + + hMem = GlobalAlloc( GMEM_ZEROINIT, Size ); + if ( !hMem ) + return TT_Err_Out_Of_Memory; + + *P = (void*)GlobalLock( hMem ); + } + else + *P = (void*)malloc( Size ); + + if ( !*P ) + return TT_Err_Out_Of_Memory; + +#ifndef TT_CONFIG_REENTRANT + TTMemory_MaxAllocated += Size; + TTMemory_Allocated += Size; +#endif + +#ifdef DEBUG_MEMORY + + num_alloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_alloc++; + else + { + pointers[i].base = *P; + pointers[i].size = Size; + } + +#else + + if ( Size >= MEMORY_MIN_GLOBAL ) + { + i = 0; + while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BIGCHUNKS ) + /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ + return TT_Err_Invalid_Argument; + else + pointers[i].base = *P; + } + +#endif /* DEBUG_MEMORY */ + + /* The nice thing about GlobalAlloc is that it zeroes the memory. */ + + if ( Size < MEMORY_MIN_GLOBAL ) + MEM_Set( *P, 0, Size ); + + } + else + *P = NULL; + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + +/******************************************************************* + * + * Function : TT_Realloc + * + * Description : Reallocates memory from the heap buffer. + * + * Input : Size new size of the memory to be allocated; + * if zero, TT_Free() will be called + * P pointer to a buffer pointer; if *P == NULL, + * TT_Alloc() will be called + * + * Output : Error code. + * + * NOTES : It's not necessary to zero the memory in case the + * reallocated buffer is larger than before -- the + * application has to take care of this. + * + * If the memory request fails, TT_Free() will be + * called on *P, and TT_Err_Out_Of_Memory returned. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Realloc( ULong Size, void** P ) + { + ULong oldSize; + void* Q; + Int i; + + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( !*P ) + return TT_Alloc( Size, P ); + + if ( Size == 0 ) + return TT_Free( P ); + +#ifdef DEBUG_MEMORY + + num_realloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_realloc++; + else + oldSize = pointers[i].size; + +#else + + i = 0; + while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != *P ) + i++; + + /* If we did not found the pointer, then this is a "small" chunk. */ + + if ( i < MAX_TRACKED_BIGCHUNKS ) + { + /* Signal we found a big one. Real size does not matter. */ + oldSize = MEMORY_MIN_GLOBAL; + } + +#endif /* DEBUG_MEMORY */ + + if ( oldSize >= MEMORY_MIN_GLOBAL ) + { + /* Deal with a big chunk. */ + HANDLE hMem, hNewMem; + + hMem = GlobalHandle ( (ULong)*P >> 16 ) & 0xFFFF; + if ( !hMem ) /* Bad call... */ + return TT_Err_Invalid_Argument; + + GlobalUnlock( hMem ); + hNewMem = GlobalReAlloc( hMem, Size, 0 ); + if ( hNewMem ) + *P = (void*)GlobalLock( hNewMem ); + } + if ( Size >= MEMORY_MIN_GLOBAL ) + { + /* A small chunk crosses the limit... */ + + if( TT_Alloc( Size, &Q ) != TT_Err_Ok ) + Q = NULL; /* Failed to create the new block. */ + else + MEM_Copy( Q, *P, oldSize ); + + /* We need to register the new entry. */ +#ifndef DEBUG_MEMORY + + i = 0; + while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BIGCHUNKS ) + /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ + return TT_Err_Invalid_Argument; +#endif /* DEBUG_MEMORY */ + } + else + Q = (void*)realloc( *P, Size ); + + if ( !Q ) + { + TT_Free( *P ); + return TT_Err_Out_Of_Memory; + } + +#ifdef DEBUG_MEMORY + + if ( i < MAX_TRACKED_BLOCKS ) + { +#ifndef TT_CONFIG_REENTRANT + TTMemory_Allocated += Size - pointers[i].size; + if ( Size > pointers[i].size ) + TTMemory_MaxAllocated += Size - pointers[i].size; +#endif + + pointers[i].base = Q; + pointers[i].size = Size; + } +#else + if ( i < MAX_TRACKED_BIGCHUNKS ) + { + pointers[i].base = Q; + } +#endif /* DEBUG_MEMORY */ + + *P = Q; + + return TT_Err_Ok; + } + + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + +/******************************************************************* + * + * Function : TT_Free + * + * Description : Releases a previously allocated block of memory. + * + * Input : P pointer to memory block + * + * Output : Always SUCCESS. + * + * Note : The pointer must _always_ be set to NULL by this function. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Free( void** P ) + { + Int i; + Long Size = 0; + + + if ( !P || !*P ) + return TT_Err_Ok; + +#ifdef DEBUG_MEMORY + + num_free++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_free++; + else + { +#ifndef TT_CONFIG_REENTRANT + TTMemory_Allocated -= pointers[i].size; +#endif + + Size = pointers[i].size; + pointers[i].base = NULL; + pointers[i].size = 0; + } + +#else + + i = 0; + while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != *P ) + i++; + + /* If we did not found the pointer, then this is a "small" chunk. */ + + if ( i < MAX_TRACKED_BIGCHUNKS ) + { + pointers[i].base = NULL; + /* Signal we found a big one. Real size does not matter. */ + Size = MEMORY_MIN_GLOBAL; + } + +#endif /* DEBUG_MEMORY */ + + if ( Size >= MEMORY_MIN_GLOBAL ) + { + HANDLE hMem; + + hMem = GlobalHandle ( (ULong)*P >> 16 ) & 0xFFFF; + if ( !hMem ) /* Bad call... */ + return TT_Err_Invalid_Argument; + + GlobalUnlock( hMem ); + GlobalFree ( hMem ); + } + else + free( *P ); + + *P = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Init + * + * Description : Initializes the memory. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Init( void ) + { +#ifdef DEBUG_MEMORY + Int i; + + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + pointers[i].base = NULL; + pointers[i].size = 0; + } + + num_alloc = 0; + num_realloc = 0; + num_free = 0; + + fail_alloc = 0; + fail_realloc = 0; + fail_free = 0; +#else + Int i; + + for ( i = 0; i < MAX_TRACKED_BIGCHUNKS; i++ ) + { + pointers[i].base = NULL; + } +#endif + + +#ifndef TT_CONFIG_REENTRANT + TTMemory_Allocated = 0; + TTMemory_MaxAllocated = 0; +#endif + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Done + * + * Description : Finalizes memory usage. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Done( void ) + { +#ifdef DEBUG_MEMORY + Int i, num_leaked, tot_leaked; + + + num_leaked = 0; + tot_leaked = 0; + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + num_leaked ++; + tot_leaked += pointers[i].size; + } + } + + fprintf( stderr, + "%d memory allocations, of which %d failed\n", + num_alloc, + fail_alloc ); + + fprintf( stderr, + "%d memory reallocations, of which %d failed\n", + num_realloc, + fail_realloc ); + + fprintf( stderr, + "%d memory frees, of which %d failed\n", + num_free, + fail_free ); + + if ( num_leaked > 0 ) + { + fprintf( stderr, + "There are %d leaked memory blocks, totalizing %d bytes\n", + num_leaked, tot_leaked ); + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + fprintf( stderr, + "index: %4d (base: $%08lx, size: %08ld)\n", + i, + (long)pointers[i].base, + pointers[i].size ); + } + } + } + else + fprintf( stderr, "No memory leaks !\n" ); + +#endif /* DEBUG_MEMORY */ + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef new file mode 100755 index 000000000..77feda125 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef @@ -0,0 +1,24 @@ +# makedef +# +# This shell script creates a .DEF file necessary for building as DLL +# on the Windows 16-bit platform. + +echo "\ +; This definition file to be used to built the library as DLL +; has been generated automatically with the script \`makedef' on +; `date +%d-%b-%Y`. + +LIBRARY ft13_16 +DESCRIPTION 'FreeType 1.3 16-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +EXPORTS +" > ttf.def + +(cd ../.. + sed -n -e "/^ *EXPORT_DEF/!d ; n ; s/(.*$//" \ + -e "s/;$//" -e "s/ const / /" -e "s/ *[a-zA-Z][a-zA-Z_\*]* //" \ + -e "s/ *//g" -e "s/^\(.*\)/ _\1/" -e "p" *.h extend/*.h) >> ttf.def + +# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep new file mode 100755 index 000000000..691a20e58 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep @@ -0,0 +1,32 @@ +# makedep +# +# This shell script creates a dependency file necessary for older compilers +# on the Windows 16-bit platform. + +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 -Iarch/win16 -I. \ + *.c | \ + sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.win + +(cd ../.. + gcc -MM -Iarch/win16 -I. -Iextend \ + extend/*.c | \ + sed -e "s/^\(.*\)\.o:/extend\\\\\1.obj:/" -e "s:/:\\\\:g") >> depend.win + +echo "!ifndef __MAKE__" >> depend.win + +(cd ../.. + gcc -MM -Iarch/win16 -I. -Iextend -DTT_HUGE_PTR \ + arch/win16/*.c | \ + sed -e "s/^\(.*\)\.o:/arch\\\\win16\\\\\1.obj:/" \ + -e "s:/:\\\\:g") >> depend.win + +echo "!endif" >> depend.win + +# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def new file mode 100644 index 000000000..b7651afc7 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def @@ -0,0 +1,127 @@ +; This definition file to be used to built the library as DLL +; has been generated automatically with the script `makedef' on +; 02-Sep-1999. + +LIBRARY ft13_16 +DESCRIPTION 'FreeType 1.3 16-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +EXPORTS + + _TT_FreeType_Version + _TT_Init_FreeType + _TT_Done_FreeType + _TT_Set_Raster_Gray_Palette + _TT_Open_Face + _TT_Open_Collection + _TT_Get_Face_Properties + _TT_Set_Face_Pointer + _TT_Get_Face_Pointer + _TT_Flush_Face + _TT_Get_Face_Metrics + _TT_Close_Face + _TT_Get_Font_Data + _TT_New_Instance + _TT_Set_Instance_Resolutions + _TT_Set_Instance_CharSize + _TT_Set_Instance_CharSizes + _TT_Set_Instance_PixelSizes + _TT_Set_Instance_Transform_Flags + _TT_Get_Instance_Metrics + _TT_Set_Instance_Pointer + _TT_Get_Instance_Pointer + _TT_Done_Instance + _TT_New_Glyph + _TT_Done_Glyph + _TT_Load_Glyph + _TT_Get_Glyph_Outline + _TT_Get_Glyph_Metrics + _TT_Get_Glyph_Big_Metrics + _TT_Get_Glyph_Bitmap + _TT_Get_Glyph_Pixmap + _TT_New_Outline + _TT_Done_Outline + _TT_Copy_Outline + _TT_Get_Outline_Bitmap + _TT_Get_Outline_Pixmap + _TT_Get_Outline_BBox + _TT_Transform_Outline + _TT_Translate_Outline + _TT_Transform_Vector + _TT_MulDiv + _TT_MulFix + _TT_Get_CharMap_Count + _TT_Get_CharMap_ID + _TT_Get_CharMap + _TT_Char_Index + _TT_Get_Name_Count + _TT_Get_Name_ID + _TT_Get_Name_String + _TT_Register_Extension + _TT_Extension_Get + _TT_Use_Stream + _TT_Done_Stream + _TT_Flush_Stream + _TT_Read_File + _TT_Seek_File + _TT_Skip_File + _TT_Read_At_File + _TT_File_Pos + _TT_Stream_Size + _TT_Null_FileFrame + _TT_Access_Frame + _TT_Check_And_Access_Frame + _TT_Forget_Frame + _TT_Get_Char + _TT_Get_Short + _TT_Get_Long + _TT_LookUp_Table + _TT_Alloc + _TT_Realloc + _TT_Free + _TT_CharMap_First + _TT_CharMap_Next + _TT_CharMap_Last + _TT_ErrToString18 + _TT_Get_Face_Gasp_Flags + _TT_Init_GDEF_Extension + _TT_Load_GDEF_Table + _TT_GDEF_Get_Glyph_Property + _TT_GDEF_Build_ClassDefinition + _TT_Init_GPOS_Extension + _TT_Load_GPOS_Table + _TT_GPOS_Select_Script + _TT_GPOS_Select_Language + _TT_GPOS_Select_Feature + _TT_GPOS_Query_Scripts + _TT_GPOS_Query_Languages + _TT_GPOS_Query_Features + _TT_GPOS_Add_Feature + _TT_GPOS_Clear_Features + _TT_Init_GSUB_Extension + _TT_Load_GSUB_Table + _TT_GSUB_Select_Script + _TT_GSUB_Select_Language + _TT_GSUB_Select_Feature + _TT_GSUB_Query_Scripts + _TT_GSUB_Query_Languages + _TT_GSUB_Query_Features + _TT_GSUB_Add_Feature + _TT_GSUB_Clear_Features + _TT_GSUB_Register_Alternate_Function + _TT_GSUB_Apply_String + _TT_GSUB_Add_String + _TT_Init_Kerning_Extension + _TT_Get_Kerning_Directory + _TT_Load_Kerning_Table + _TT_Init_Post_Extension + _TT_Load_PS_Names + _TT_Get_PS_Name + _TT_Init_SBit_Extension + _TT_Get_Face_Bitmaps + _TT_New_SBit_Image + _TT_Done_SBit_Image + _TT_Get_SBit_Strike + _TT_Load_Glyph_Bitmap + _TT_Get_Face_Widths diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC new file mode 100644 index 000000000..e72f23007 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC @@ -0,0 +1,161 @@ +# This file is part of the FreeType project. +# +# It builds the library for Borland C++ for Win32. +# +# You will need Borland MAKE. +# Tested with Borland C++ v.5.0 and Borland C++ builder 4.0. +# Does not work with Borland C++ 4.0, since it needs __declspec. +# +# Use this file while in the lib directory with the following statement: +# +# make -farch/win32/Makefile.BC +# +# +# A DLL version of the library can be built with +# +# make -DDLL -farch/win32/Makefile.BC dll +# +# 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 +LIB = tlib /c /e +IMPLIB = implib -c + +SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig + +!if ! $d(DEBUG) +CFLAGS = -O2 -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) +DLLFLAGS = -WD +!else +CFLAGS = -v -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) +DLLFLAGS = -v -WD +!endif + +FT_DEF = $(FT_DLL:.dll=.def) +!if $d(DLL) +CFLAGS = $(CFLAGS) \ + -DEXPORT_DEF=__declspec(dllexport) -DEXPORT_FUNC=__declspec(dllexport) +!endif + + +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +# Do not insert spaces before the \ at end of line, +# otherwise the substitution for TLIB command line will fail. +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ + extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c\ + extend\ftxsbit.c extend\ftxgsub.c extend\ftxgpos.c\ + extend\ftxopen.c extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c\ + ttgload.c ttinterp.c ttload.c ttobjs.c\ + ttraster.c ttextend.c ttdebug.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +# Since Borland make does not handle $($(LIB_FILES)), and using +# -DLIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat +# by constructing TLIB's response file directly in the `all' target. +# +# Another solution, useful during debugging of part of the library, +# would be to include each .obj in the library as soon as it is compiled. +# See ../msdos/Makefile.TC for an application. +.c.obj: + $(CC) -c -o$* @&&| + $(CFLAGS) $< +| + + +!if ! $d(DEBUG) +# Skipped if DEBUG build +all: $(OBJS_S) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(OBJS_S: = + ) +| + +dll $(FT_DLL): $(OBJS_S) $(FT_DEF) +!if $d(DLL) + $(CC) @&&| + $(DLLFLAGS) -e$(FT_DLL) $(OBJS_S) +| + $(IMPLIB) libttf $(FT_DLL) +!else + $(MAKE) -DDLL -f$(FT_MAKEFILE) dll # Re-invoke with flag set. +!endif +!endif + +debug: $(OBJS_M) + -del libttf.lib + $(LIB) libttf.lib @&&| ++ $(OBJS_M: = + ) +| + +!ifdef DEBUG +dll $(FT_DLL): $(OBJS_M) $(FT_DEF) +!if $d(DLL) + $(CC) @&&| + $(DLLFLAGS) -e$(FT_DLL) $(OBJS_M) +| + $(IMPLIB) libttf $(FT_DLL) +!else + $(MAKE) -DDEBUG -DDLL -f$(FT_MAKEFILE) dll +!endif +!endif + +install: $(FT_DLL) +!ifdef INSTALL_DIR + copy $(FT_DLL) $(INSTALL_DIR) +!else + copy $(FT_DLL) C:\WINDOWS +!endif + +$(OBJ_S): $(SRC_S) $(SRC_M) + +# Not used here because it excesses the capacity of COMMAND.COM... +libttf.lib: $(LIB_FILES) + -del libttf.lib + echo -+$(**: =-+)> response + $(LIB) libttf.lib @&&| ++ $(**: = + ) +| + +$(FT_DEF): $(ARCH)\ttf.def + -copy $(ARCH)\ttf.def $(FT_DEF) + +clean: + -del *.obj + -del extend\*.obj + -del $(ARCH)\*.obj + -del libttf.bak + -del response + -del *.def + -del *.tds + +distclean: clean + -del libttf.lib + -del *.dll + -del $(FT_DEF) + -del C:\WINDOWS\$(FT_DLL) +!if $d(INSTALL_DIR) + -del $(INSTALL_DIR)\$(FT_DLL) +!endif + +!include "$(ARCH)\depend.win" + +# end of Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL new file mode 100644 index 000000000..72c060a6b --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL @@ -0,0 +1,165 @@ +# This file is part of the FreeType project. +# +# It builds the library for Microsoft Visual C++ for 32-bit Windows. +# +# You will need NMAKE. +# +# Use this file while in the lib directory with the following statement: +# +# nmake /f arch\win32\Makefile.CL +# +# +# A DLL version of the library can be built with +# +# nmake DLL=1 /f arch\win32\Makefile.CL dll +# +# Debug versions can be obtained with +# +# nmake DEBUG=1 /f arch\win32\Makefile.CL + +ARCH = arch\win32 +FT_MAKEFILE = $(ARCH)\Makefile.CL +FT_DLL = ft13_32.dll + +CC = cl /nologo +LIB = lib /nologo +LINK = link /nologo + +CFLAGS = /Za /W2 -I$(ARCH) -I. -Iextend + +!ifndef DEBUG +CFLAGS = $(CFLAGS) /Ox +DLLFLAGS = /RELEASE +!else +CFLAGS = $(CFLAGS) /Zi /Ge +DLLFLAGS = /DEBUG +!endif + +!ifdef DLL +CFLAGS = $(CFLAGS) /GD \ + /DEXPORT_DEF=__declspec(dllexport) /DEXPORT_FUNC=__declspec(dllexport) +!else +CFLAGS = $(CFLAGS) /GA +!endif + + +TTFILE = .\ttfile.c +TTMEMORY = .\ttmemory.c +TTMUTEX = .\ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +# Do not insert spaces between the file names or at end of line, otherwise +# the substitution for LIB command line will fail. Thank you. +# +SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ +extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c extend\ftxsbit.c\ +extend\ftxopen.c extend\ftxgsub.c extend\ftxgpos.c extend\ftxgdef.c +OBJS_X = $(SRC_X:.c=.obj) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ +ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) + +SRC_S = $(ARCH)\freetype.c +OBJ_S = $(SRC_S:.c=.obj) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +# Since Microsoft's NMAKE does not handle $($(LIB_FILES)), and using +# LIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat +# by constructing LIB's response file directly in the `all' target. +# +# Another solution, useful during debugging of part of the library, +# would be to include each .obj in the library as soon as it is compiled. +# See ..\msdos\Makefile.TC for an application. +.c.obj: + @$(CC) /c /Fo$@ @<< + $(CFLAGS) $*.c +<< + + +!ifndef DEBUG +# Skipped if DEBUG build +all: $(OBJS_S) + -del libttf.lib + $(LIB) /OUT:libttf.lib @< dep.end + +ifeq (dep.end,$(wildcard dep.end)) + include dep.end +endif + +# end of Makefile.Min diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC new file mode 100644 index 000000000..f84fb23a1 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC @@ -0,0 +1,195 @@ +# Visual C++ 2.x, 4.x, 5.0 and 6.0 makefile for freetype +# adapted from suns example makefile (related to the TCL script language) + +# Does not depend on the presence of any environment variables in +# order to compile freetype; all needed information is derived from +# location of the compiler directories. + +# +# Project directories +# +# ROOT = top of source tree +# +# TMPDIR = location where .obj files should be stored during build +# +# TOOLS32 = location of VC++ 32-bit development tools. Note that the +# VC++ 2.0 header files are broken, so you need to use the +# ones that come with the developer network CD's, or later +# versions of VC++. +# + +ROOT = ..\.. +TMPDIR = . +#TOOLS32 = c:\msdev # VC++ 2.x,4.x +#TOOLS32 = c:\Program Files\devstudio\vc # VC++ 5.x +TOOLS32 = c:\Program Files\Microsoft Visual Studio\Vc98 # VC++ 6.x +INSTALLDIR = c:\WINNT\SYSTEM32 + +# Set this to the appropriate value of /MACHINE: for your platform +MACHINE = IX86 + +# Comment the following line to compile with symbols +NODEBUG=1 + + +###################################################################### +# Do not modify below this line +###################################################################### + +TTF = ttf +TTFLIB = $(TTF).lib +TTFDLL = $(TTF).dll + +TTFOBJS = \ + $(TMPDIR)\ttapi.obj \ + $(TMPDIR)\ttcache.obj \ + $(TMPDIR)\ttcalc.obj \ + $(TMPDIR)\ttcmap.obj \ + $(TMPDIR)\ttdebug.obj \ + $(TMPDIR)\ttfile.obj \ + $(TMPDIR)\ttgload.obj \ + $(TMPDIR)\ttinterp.obj \ + $(TMPDIR)\ttload.obj \ + $(TMPDIR)\ttmemory.obj \ + $(TMPDIR)\ttmutex.obj \ + $(TMPDIR)\ttobjs.obj \ + $(TMPDIR)\ttraster.obj \ + $(TMPDIR)\ttextend.obj \ + $(TMPDIR)\ftxcmap.obj \ + $(TMPDIR)\ftxgasp.obj \ + $(TMPDIR)\ftxkern.obj \ + $(TMPDIR)\ftxpost.obj \ + $(TMPDIR)\ftxwidth.obj \ + $(TMPDIR)\ftxerr18.obj + + +PATH=$(TOOLS32)\bin;$(PATH) + +cc32 = "$(TOOLS32)\bin\cl.exe" +link32 = "$(TOOLS32)\bin\link.exe" +include32 = "-I$(TOOLS32)\include" -I$(ROOT)\arch\win32 +CP = copy +RM = del + +TTF_INCLUDES = -I$(ROOT) +TTF_DEFINES = -nologo -D__WIN32__ -D__WIN32DLL__ + +TTF_CFLAGS = $(cdebug) $(cflags) $(cvarsdll) $(include32) \ + $(TTF_INCLUDES) $(TTF_DEFINES) +CON_CFLAGS = $(cdebug) $(cflags) $(cvars) $(include32) -DCONSOLE +DOS_CFLAGS = $(cdebug) $(cflags) $(include16) -AL + +###################################################################### +# Link flags +###################################################################### + +!IFDEF NODEBUG +ldebug = /RELEASE +!ELSE +ldebug = -debug:full -debugtype:cv +!ENDIF + +# declarations common to all linker options +lcommon = /NODEFAULTLIB /RELEASE /NOLOGO + +# declarations for use on Intel i386, i486, and Pentium systems +!IF "$(MACHINE)" == "IX86" +DLLENTRY = @12 +lflags = $(lcommon) /MACHINE:$(MACHINE) +!ELSE +lflags = $(lcommon) /MACHINE:$(MACHINE) +!ENDIF + +conlflags = $(lflags) -subsystem:console -entry:mainCRTStartup +guilflags = $(lflags) -subsystem:windows -entry:WinMainCRTStartup +dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll + +!IF "$(MACHINE)" == "PPC" +libc = libc.lib +libcdll = crtdll.lib +!ELSE +libc = libc.lib oldnames.lib +libcdll = msvcrt.lib oldnames.lib +!ENDIF + +baselibs = kernel32.lib $(optlibs) advapi32.lib +winlibs = $(baselibs) user32.lib gdi32.lib comdlg32.lib winspool.lib + +guilibs = $(libc) $(winlibs) +conlibs = $(libc) $(baselibs) +guilibsdll = $(libcdll) $(winlibs) +conlibsdll = $(libcdll) $(baselibs) + +###################################################################### +# Compile flags +###################################################################### + +!IFDEF NODEBUG +cdebug = -O2 -Gs -GD +!ELSE +cdebug = -Z7 -Od -WX +!ENDIF + +# declarations common to all compiler options +ccommon = -c -W3 -nologo -YX -Dtry=__try -Dexcept=__except + +# NEED BYTEORDER INFORMATION HERE !! +!IF "$(MACHINE)" == "IX86" +cflags = $(ccommon) -D_X86_=1 +!ELSE +!IF "$(MACHINE)" == "MIPS" +cflags = $(ccommon) -D_MIPS_=1 +!ELSE +!IF "$(MACHINE)" == "PPC" +cflags = $(ccommon) -D_PPC_=1 +!ELSE +!IF "$(MACHINE)" == "ALPHA" +cflags = $(ccommon) -D_ALPHA_=1 +!ENDIF +!ENDIF +!ENDIF +!ENDIF + +cvars = -DWIN32 -D_WIN32 +cvarsmt = $(cvars) -D_MT +cvarsdll = $(cvarsmt) -D_DLL + +###################################################################### +# Project specific targets +###################################################################### + +release: $(TTFDLL) +all: $(TTFDLL) + +install: $(TTFDLL) + -@md $(INSTALLDIR) + -@$(CP) $(TTFDLL) $(INSTALLDIR) + + + +$(TTFDLL): $(TTFOBJS) ttf.def + $(link32) $(ldebug) $(dlllflags) \ + $(guilibsdll) -out:$(TTFDLL) -def:ttf.def $(TTFOBJS) + +#ttf.def: $(TTFOBJS) +# ..\..\tcl8.0.4\win\release\dumpexts -o $@ ttf.dll $(TTFOBJS) + + +# +# Implicit rules +# + +{$(ROOT)\extend}.c{$(TMPDIR)}.obj: + $(cc32) $(TTF_CFLAGS) -Fo$(TMPDIR)\ $< + +{$(ROOT)}.c{$(TMPDIR)}.obj: + $(cc32) $(TTF_CFLAGS) -Fo$(TMPDIR)\ $< + + +clean: + -@del *.exp + -@del *.lib + -@del *.dll + -@del $(TMPDIR)\*.obj + -@del *.pch + -@del *.pdb diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc new file mode 100644 index 000000000..db4c715e6 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc @@ -0,0 +1,96 @@ +# This file is part of the FreeType project. +# +# It builds the library for gcc under Win32. +# This Makefile will fail with MinGW32 ports of gcc and make under +# bare-bones Windows 9X, because of the limitations of command.com. +# Use Makefile.min instead. +# +# You will need GNU make. +# +# Use this file while in the lib 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 + +ifndef GETTEXT +GETTEXT=NO_GETTEXT +endif + +ifdef DEBUG +CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend -D$(GETTEXT) +else +CFLAGS = -Wall -ansi -pedantic -O2 -s -I$(ARCH) -I. -Iextend -D$(GETTEXT) +endif + + +TTFILE = ./ttfile.c +TTMEMORY = ./ttmemory.c +TTMUTEX = ./ttmutex.c + +PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) + +SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ + extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ + extend/ftxgsub.c extend/ftxgpos.c extend/ftxgdef.c \ + extend/ftxopen.c extend/ftxerr18.c +OBJS_X = $(SRC_X:.c=.o) + +SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ + ttgload.c ttinterp.c ttload.c ttobjs.c \ + ttraster.c ttextend.c $(PORT) +OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) + +SRC_S = $(ARCH)/freetype.c +OBJ_S = $(SRC_S:.c=.o) +OBJS_S = $(OBJ_S) $(OBJS_X) + + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +.PHONY: all debug clean distclean depend + + +all: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a + +debug: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M DEBUG=1 libttf.a + +HAVE_GETTEXT: + $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S GETTEXT=HAVE_GETTEXT \ + libttf.a + +$(OBJ_S): $(SRC_S) $(SRC_M) + +libttf.a: $($(LIB_FILES)) + -del $@ + ar src $@ $^ + +clean: + -del *.o + -del extend\*.o + -del $(subst /,\,$(ARCH)/*.o) + -del response + +distclean: clean + -del dep.end + -del libttf.a + +depend: $(SRS_S) $(SRC_M) $(SRC_X) + $(CC) -E -M $^ > dep.end + +ifeq (dep.end,$(wildcard dep.end)) + include dep.end +endif + +# end of Makefile.gcc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win new file mode 100644 index 000000000..813a0eebc --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win @@ -0,0 +1,103 @@ +# This dependency file to be used with various Win32 compilers +# has been generated automatically with the script `makedep' on +# 03-Sep-1999. + +ttapi.obj: ttapi.c ttconfig.h arch\win32\ft_conf.h freetype.h fterrid.h \ + ftnameid.h ttengine.h tttypes.h ttmutex.h ttcalc.h ttmemory.h \ + ttcache.h ttfile.h ttdebug.h ttobjs.h tttables.h ttcmap.h ttload.h \ + ttgload.h ttraster.h ttextend.h +ttcache.obj: ttcache.c ttengine.h tttypes.h ttconfig.h \ + arch\win32\ft_conf.h freetype.h fterrid.h ftnameid.h ttmutex.h \ + ttmemory.h ttcache.h ttobjs.h tttables.h ttcmap.h ttdebug.h +ttcalc.obj: ttcalc.c ttcalc.h ttconfig.h arch\win32\ft_conf.h freetype.h \ + fterrid.h ftnameid.h ttdebug.h tttypes.h tttables.h +ttcmap.obj: ttcmap.c ttobjs.h ttconfig.h arch\win32\ft_conf.h ttengine.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ + tttables.h ttcmap.h ttdebug.h ttfile.h ttmemory.h ttload.h +ttdebug.obj: ttdebug.c ttdebug.h ttconfig.h arch\win32\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h tttables.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h ttcmap.h +ttextend.obj: ttextend.c ttextend.h ttconfig.h arch\win32\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttmemory.h +ttfile.obj: ttfile.c ttconfig.h arch\win32\ft_conf.h freetype.h \ + fterrid.h ftnameid.h tttypes.h ttdebug.h ttengine.h ttmutex.h \ + ttmemory.h ttfile.h +ttgload.obj: ttgload.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ + ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h ttgload.h \ + ttmemory.h tttags.h ttload.h +ttinterp.obj: ttinterp.c freetype.h fterrid.h ftnameid.h tttypes.h \ + ttconfig.h arch\win32\ft_conf.h ttdebug.h ttcalc.h ttmemory.h \ + ttinterp.h ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h \ + ttcmap.h +ttload.obj: ttload.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ + ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h \ + ttmemory.h tttags.h ttload.h +ttmemory.obj: ttmemory.c ttdebug.h ttconfig.h arch\win32\ft_conf.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttmemory.h ttengine.h \ + ttmutex.h +ttmutex.obj: ttmutex.c ttmutex.h ttconfig.h arch\win32\ft_conf.h +ttobjs.obj: ttobjs.c ttobjs.h ttconfig.h arch\win32\ft_conf.h ttengine.h \ + tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ + tttables.h ttcmap.h ttfile.h ttdebug.h ttcalc.h ttmemory.h ttload.h \ + ttinterp.h ttextend.h +ttraster.obj: ttraster.c ttraster.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttengine.h tttypes.h ttmutex.h \ + ttdebug.h ttcalc.h ttmemory.h +extend\ftxcmap.obj: extend\ftxcmap.c extend\ftxcmap.h freetype.h fterrid.h \ + ftnameid.h tttypes.h ttconfig.h arch\win32\ft_conf.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h +extend\ftxerr18.obj: extend\ftxerr18.c ttconfig.h arch\win32\ft_conf.h \ + extend\ftxerr18.h freetype.h fterrid.h ftnameid.h extend\ftxkern.h \ + extend\ftxpost.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h +extend\ftxgasp.obj: extend\ftxgasp.c extend\ftxgasp.h freetype.h fterrid.h \ + ftnameid.h tttypes.h ttconfig.h arch\win32\ft_conf.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h +extend\ftxgdef.obj: extend\ftxgdef.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxgpos.obj: extend\ftxgpos.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxgsub.obj: extend\ftxgsub.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxkern.obj: extend\ftxkern.c extend\ftxkern.h freetype.h fterrid.h \ + ftnameid.h ttextend.h ttconfig.h arch\win32\ft_conf.h tttypes.h \ + ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttdebug.h \ + ttmemory.h ttfile.h ttload.h tttags.h +extend\ftxopen.obj: extend\ftxopen.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ + freetype.h fterrid.h ftnameid.h ttload.h ttobjs.h ttengine.h \ + ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ + ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ + extend\ftxgpos.h extend\ftxopenf.h +extend\ftxpost.obj: extend\ftxpost.c extend\ftxpost.h freetype.h fterrid.h \ + ftnameid.h tttypes.h ttconfig.h arch\win32\ft_conf.h ttobjs.h \ + ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttload.h ttfile.h \ + ttdebug.h tttags.h ttmemory.h ttextend.h +extend\ftxsbit.obj: extend\ftxsbit.c extend\ftxsbit.h freetype.h fterrid.h \ + ftnameid.h ttobjs.h ttconfig.h arch\win32\ft_conf.h ttengine.h \ + tttypes.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h ttdebug.h \ + ttload.h ttmemory.h tttags.h ttextend.h +extend\ftxwidth.obj: extend\ftxwidth.c extend\ftxwidth.h freetype.h fterrid.h \ + ftnameid.h ttdebug.h ttconfig.h arch\win32\ft_conf.h tttypes.h \ + ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h \ + tttags.h ttload.h +!ifndef __MAKE__ +arch\win32\freetype.obj: arch\win32\freetype.c ttapi.c ttconfig.h \ + arch\win32\ft_conf.h freetype.h fterrid.h ftnameid.h ttengine.h \ + tttypes.h ttmutex.h ttcalc.h ttmemory.h ttcache.h ttfile.h ttdebug.h \ + ttobjs.h tttables.h ttcmap.h ttload.h ttgload.h ttraster.h ttextend.h \ + ttcache.c ttcalc.c ttcmap.c ttdebug.c ttgload.c tttags.h ttinterp.c \ + ttinterp.h ttload.c ttobjs.c ttraster.c ttfile.c ttmemory.c ttmutex.c \ + ttextend.c +!endif diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c new file mode 100644 index 000000000..f3bf03993 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c @@ -0,0 +1,42 @@ +/* This file is part of the FreeType project */ + +/* single object library component for Win32 */ +#define TT_MAKE_OPTION_SINGLE_OBJECT + +/* Note, you should define the EXPORT_DEF and EXPORT_FUNC macros */ +/* here if you want to build a Win32 DLL. If undefined, the */ +/* macros default to "extern"/"" (nothing), which is suitable */ +/* for static libraries. See `ttconfig.h' for details. */ + +/* The macro EXPORT_DEF is placed before each high-level API */ +/* function declaration, and EXPORT_FUNC before each definition */ +/* (body). You can then use it to take any compiler-specific */ +/* pragma for DLL-exported symbols */ + +/* first include common core components */ + +#include "ttapi.c" +#include "ttcache.c" +#include "ttcalc.c" +#include "ttcmap.c" +#include "ttdebug.c" +#include "ttgload.c" +#include "ttinterp.c" +#include "ttload.c" +#include "ttobjs.c" +#include "ttraster.c" + +/* then system-specific (or ANSI) components */ + +#include "ttfile.c" +#include "ttmemory.c" +#include "ttmutex.c" + +/* finally, add some extensions */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.c" +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp new file mode 100644 index 000000000..ecf6b1f6b --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp @@ -0,0 +1,104 @@ +# Microsoft Developer Studio Project File - Name="freetype" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=freetype - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "freetype.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "freetype.mak" CFG="freetype - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "freetype - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "freetype - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "freetype - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O1 /I "." /I "..\.." /I "..\..\extend" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /YX +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "freetype - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Zi /O1 /I "." /I "..\.." /I "..\..\extend" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c +# SUBTRACT CPP /YX +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "freetype - Win32 Release" +# Name "freetype - Win32 Debug" +# Begin Source File + +SOURCE=.\freetype.c +# End Source File +# Begin Source File + +SOURCE=..\..\Extend\Ftxcmap.c +# End Source File +# Begin Source File + +SOURCE=..\..\Extend\ftxerr18.c +# End Source File +# Begin Source File + +SOURCE=..\..\Extend\Ftxgasp.c +# End Source File +# Begin Source File + +SOURCE=..\..\Extend\Ftxkern.c +# End Source File +# Begin Source File + +SOURCE=..\..\Extend\ftxpost.c +# End Source File +# End Target +# End Project diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw new file mode 100644 index 000000000..0fb561d5d --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "freetype"=.\freetype.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.ide b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.ide new file mode 100644 index 0000000000000000000000000000000000000000..ee7c13cb0867765dcc3c81fe617a2f2f0aa76f17 GIT binary patch literal 35589 zcmeHwdtg=7neRF$C&>xqod5v>9Pkh$h8P|qDk^#MFoc){MMNMZAqj>gCI>`(AwI{d zAhnKtjAO0iOdaZ2YpG=z$J;s`+p*Sm9BZB4UdQqFdcEF`WgKVf*m{4zZ>?|dot@-p z|Cs;o2jBkA+Ut9*_u6aiy;3(cGSE5Lov1(a%tY(R(C(hDRHCVWpeJvNnPsBpDRbi4 z4_~_fHe>2CjVariZK{lkN6hhsuP^v{)Bs9v{|j?#=GXai4CH-3X69x@!24bNdkXX$ zz^8%V1Re)|3-}E1+rSgRzXYBH{uS_9;9mou1O7MQcYxmoJ`emG;P-%k3w#0iec%s( ze+PUK_(R}Jz#jo$2L2fM6X4$iUjhCD@KxYXfv*9727Dd(kHDV;|2yy(!2bb!1NcwC zH-Y~Qd<*zLfxiU)FW}q2{|$Tx_(5<-je#D}Y;pR|2;I zw*z+oJApfaUBGT&4{#T-7uW&p1NH-V1Fr%O0QUgDg1mYZ_$R=}fPV@kynU}RNvQ_f zYEW*bc6hk4V*hZ@NUFNJT6n5NgU?fHs;jr+f6x9@&tUh~U8()UL!&9HuSzVXz@NG1Vg}FOFT0LN2ONyS zogBL)1(E9;=~A8SsuZFo13LT6Iw!|2OhM%O2R%7)GF@(F-IYr3OYykSi?yfi!^SL$(6<|ZMngBj$@SqdUBKO zsBPaM8I_PR%#X`9$#olAo7dHu8^!i28Q=W)1t!_DvHh~z)8xR;i-N*0zlsT00W^hWfh`$@a$PmW>UK?I=I`pOAT=>Y}Y{ zMwc!1JEero5j7sOGPCiTfqL|+BPpquNtr)te3Tu`&@}^H`%&c zOwN5BtiaCRra`#pEDCRpOyYgs>83(>tVwEC|1K8(wKC!N`KwKU{nL18E)qTE^3dSx zLB}&Z;yU4^JWOaDDvoK}JJ{ZZfjz|sHK`9(^01*ioOM++4|R4UJGv9#PFQwZM$6@) z#OIxDJk}Agb|$(kcVZW{7mI((Yt^3db!%JrtI zGBvxFJj>;Y&gYqJ>PLDyQ$4JdoY>1;K+WQ*mof=?0#un&lZ6UC+SNJ8JJv3r4i!p} zNB!L!_ojyTrdm5weYQY5>l7SKXbd&Yhj3 znCX1QRY*RKDwN1fXL!H0S1C`a8pjc>t$sVJ;`YYw{?rf}?;S4B_#~^q@?|{IXZtZp zU!^?h`aA`~lc-RxQIw(02YDKHjBEtdh157@(XK)7(TGpc3hZ?1`crri z8SA&r^GbQz_IdNgmgScghbZe4pU4$7eTfRosXTmQSHL5>^&724o`OVAxjfPPJn(zx z9`}e;E>HSn;zl?hrTr>d0r2CBP5s`H(V>yCY5K9`U!|-R_`Ehvmfxo7doG{3nxNpP z$#QD>%W8wqRA>{083e4`ZbOun%Zh~0hlGJgm2jm(fzK-Ix`qbFxb7U{YKDS3L|$>* z@o=?6LFVpKJ1WR#%wb`wl;seg$>ucQE zva~ZMZr@JVYRhHGXG~nzu=mi!r62`K^Dg9^%UmuIDR7ZuT|?vc`Zdk#_6!fXxlNTU zA^AM0iRe_Se3wCU$Eo`OriTac)dB|Sf`*wnT+wVbCb zG92bs@>$yI;ZmT&RLt{JJ^RnL3qUop+vy9(CPQQNw%x?Y^Bk#$Jr$wrT2c|2`c>rt?Uz%@$+pFfpy#p#CEq^xWDd^u)U zYCBo5c%-W`m9p-sJei*D6c*`v@p!{^CTo*xqY9a*WY))2YR_I|A=w-s*H0BV#42A` z=RlXRIXQn z*WB2?m5&j%Ee%`i>d)SaC;8@04UJnzvCK5s3oT4zgRJ$cj!ZQ8Po-l!mhi+8tAlIB z3crUR-O%FvsFby4)e%f{S7%ori^R@tD`h=e`GR@93v(J~P24qFu30N&1j??PPupNT zLpq2CS=aXYK4tnxQ{DYTP~voOU0fma)0V?_^c>={t!rFYSI7v|AuKdXPXE@Wi)-%+ z!McknA!d#6$?_c===;b00)-%-T`TwbxTm1t+wJJ6udQF(h~DHGXP5g93Vu4s*IW-aQ|0)$ zH=!_wZ$oV>`4%`n?q4Vb?XGFwSla-`GRMa~4h3IdDwXQ&m2%5>eB1|7@YCDTv96_~ zv5l4;ANNWWe7;nwe-PQnl5+zf_fr&nyB!_QJq*USUUAPwA;`C}Zhbq`Tjcn-FQeew z?dWK$ZHI&4bbQ>qQ3&c|heLg~o;Jw-j?ee0`=)LTT}Y($o%=%yL7z4>ZrIp%xu0j; zLsAHq)rL(Sjhn&tGncpAXHp32Yuwz?*up|}eB6stScHDst(>>@?CQa?8F2Hw2j>DQn;O|KOUKV0 zCGd~*cUphAx2Av{#22!Rd~su23%Q>V9}}`a zsQg^mYwFluzp-4+QX%Ti z1v*e+r7k*Km9oF7d@--z?dV`GwZo-B@u^bwK$S1p1{xacHmw0)x8vhJsY1}MYg3+G z?xiY3z44=?L)tm=yVdFAeyc((z$g6+_?jFa_hc1<`lP=C-zvw)eOrYfUq|g4Cf6(# zz8cxvRX)FM`1N8am@V)X2WF z@<%7ApRF6)JLpHI)6YFP;4_skF{?WZV$$zcm=YF}uMEpb8yCnY}$IrcWg^Bn_vAjZlyR%y(`|v)$_9K3J zuj%hj^+8}$oR6mp>ofG%|EIrS4h&{|A>(@)r!wZo!gA|zXLsyS?4j6+*sHNqvHZ+M znN68HGjGiNLgsfef0bFCwLWWC)}gG2vQA{Zn)PAU^z8GpFU{VU{Z#f#+3#fMO^NS{ zABsN|e>VPl{DXLLPIbPu5+sHJFk(d|V~6}?{cyP}HXy5il%_ZB}@{Ce>R#dAy6mmDa0 zpya8NmrC9#$uB*xbXV!|(w~%mSUPvwh0}ITJ3j3v(|$K?*7Wt$2d5vM{+;RXOwXUO zV#c-^x6gQD#;Y@Cm2E3~r0fS}r^;r{+&1%(nLn6$YUZq2b+dNQIy&pbtT&OK*-K|{ znSE&XN%IrxqZ&@Ilr7UeQwj-opX=QJu&y4xp`CO zwahy@@5H<}=jBaFEKO`l97;T%_(>uxBhztS?1y-5GVoYl8iHO>clrEH% zjtupVbncP2_(r$Z+4uW`kL%{F$o%w-eCy!f3iA9tjxN0A;5?fOTi^FQ?aLl$~^m;4$U8%o+9wPI7VOb zB>J%GjF^PU*ZgpPKkfYeA?h4`vU*Fv`@=DMODEOKn2GgL!C1Z1!28k|z0)Vrn>36m z8{;qi8>?>ycz!fSU)d!3s_+0EHFM0e$V{_+yG&9qSbF~U?Reg-Zv?%pwylMVZ2D({ z_vJBqXNC2~v4@WamTPPbd#frl8(e$=5)Z1ve0WcX_$nFZryPV;2=Ya*HC zIGKf>41Y}|Q!!5FbWeuACX%TfCv%1;!(S80EE*@nalw}LnfS$*H2FdzUM-kD5Lt{n zVX(Yah&fGo$?*op8jd4jU>QD_MJ-QdedOBJOxNCi;o4iK3xCYM9+2U}zeSkkJr7~} zGu_<}wp*z#ExFW?NUqmnFkfU2$o1Q>!HhcL=wCW|(%Jsd(f@Qb z4oADepA9+_^mp$5$Br83YnDsUp{Uir&(Zyk?gb@W@96E0-s<9aI(pF2yBxjN(c2uo z3Y72}7rw{QI~~2k(LPW@j|=Z|wAazkx%e&@zR%I4j^6L+1CIWoquq{P>F72`4>)=a zDB)g5N8SDF9NpvYKj^|YIy&U&9WMSBM{jobZ*cT#cmF0A{;Z>e?*8W;{i35^a`AuU z=tGYFv7-+=`ejhUBaVK>-RDG!@T4nmP6!B`cn~Q6l zLl5a|F8tG}@B{FwqpyR)P4k)y|IE=ZIsPwFAO1h&=pT^+np}aUT=+UiuLfn0`++Oi zJKg=?xUkMOYA}A;g=w9iEW;f;4_Sg=W9KeQamUVG_-pJK%=@hoN;gDSV}F}_xo%Fju@p1L>5Pf7}}xFg9ey4RqGpO!G5+i0ZR3VWdK zaFSbHw8O0|@^PzbZT}rfZbk7vx0(tsKb+)N(!wo=liVtL2Ku=bls9G9;UxEZI*=gl zmM@>UY0^yRIx!QcnX8!-E)31waHjG57#0e@kqKtD7LH~**M)n$3vh>NA2$5ejkM>=H$8X#y7_QY zJ`@72`~-h?A%5|in?IEw<)&_&AN9CH9}XJ+O2LPG`QWMHhQrA&=xza>%m*z{Er?I5 z2wHKp6>%Y)mEIOu<2c`#E4H$(!7p1`7eeO8Xc(IA|7zc~a)m3O_7vfA*Gf29CDuly zjmM^a?YOkBb7?<_4~Dc{HX`k87+kn--Q50PUM_Z>Z9VMw!6IG{mM7PZcyj%WITRa| z&cynE@i_lkVphHxzql2k@|QvWZcpCwYyc0J|CMJucwEzn<(DEaM3zT)L|?%dTpbw)Gak)& zIpd>@%2-G2VC>P@%dwAQm6^*kcVu3ld4J}UnJ;9%mHAO-SyoL}b5?iO!K??fp3ZtP z>+P)4?A2Je1LT+Iugq`Ff4D$G?(%%WqlM35D6c8Pc2?0dMX!K%6dN;K+*&eF@@`3C zX;o=!X{z+W(vzikXGbtna<$Y<+gkdlXy7WWF)6HbP6ZtVjhW?}xJnuUAHSl-tn1^C zKNep}p}hdlMfSP(#W(O2j4y)l#f!&7UIKX(&cg2m0#VSW z$b5I3x&`97?hc978ADtRxUF4MLQv-t#3pc$I;$tp$=Q#B)tL#MOVjFH7SPEhO$)xC zGgKj{)tLpI%hT#STVnaFPT>VkgRgV8yF+4iWu7-8H^jFGY>k~OsaD&V%7n#61j;pbdkgbGc+GM*H5bRV#G89cc;;LW`)x#Ql9x&GRC}wN0wC z9WfoiooRH|h-$k`YSU5-o#@>F?6Aywre$d;EhXT&%;ymue&@0oF_!}`;eDx-?T&-G z1>#GD6iEHCc1sbr-P5^B>@E-4od%vxkH;zX@^B|&x`>Ei9-igpA$1GHm#Gk_wL2Yg z{hrR}#qK#~H}3GJt=luebCt)VD#*i+N3ktu_5kq>K&TB;w?O=CA+{b`yJd*OU;>bQ zzL@!Zt{K7|-n4dSf@j$05gkT&c(?+#-pmNF8~1H`wVhJ8KzyZ;VEN8M+;yJLBVu=z zxgK|T)7qU4o*O(Ks|ssYxWfY-ZUnsvIDm*qA={nWrEY=vc|ytp+SXH(@^P|>V5OXW=2qRFhv_m(Bx&`7FSt?hXmIUH%n^foRh`9rJA0;NySsT!4 z>&$%UywlUUY6H`)q3~xe#$jJ)Q4~-R6+p3h;c^<53l~ z8$3wlC?l3=EGcyh#4ol~uD0w>N8INo)X4)$@I+_+5GXo@OBMJ!H|Q-;n}?Oq`Jkt> zriEp6fI@O<9mQ5E_D?-vmBMc_Oa!SU1rbqmC0H_hF(Iu{}COB3qkp(@n* z&?o3@b^1uG&NHF&k0;d0I!2ve{sf(u1a#W`se;b0dOA~*Kkepm+~G}YcQJVW+~ZLd z8~wSW@a1h__iPS8KN#ao-S~AEAGEQtWofN6frw?Vbgmr#&83p@-3Y z6EVkuVmG0&q|`kgtlb*KeaqANuGrlqA2jo(wYvm7&v-nliHF}1z728$INmOGj|Xda zDdKo^jvaR@H?kgHCLcocp0&FSJUmus>;(Fsafb)(Jco#1g8KDP`(f%9h+itCFwhS# zN8ER)QpUS(v3t23*yGzhdkl}Lz=hv0^H87ff{_RNX!$Po#vSSwh;LRQP@CQri2EDQ z?!#jDijduN#_*^L+6^8eG~OLUzv|!=v)rSL-23&oKgH zlRv&ww?KTmrE;})S0RqaDp|Wn#O_Y{+?e-ly}AHAJaTDly*h%Wm zpl*S9r;y;h;zGm~Ql()&zbJOQL+QO}43DV5Me{ieHhJ*Vml=VbLLaDGAl~KQbmhAm zaZh-5&QY%GKI!MqH7n^X?AXy)I;T19*x( z9#x@sOAy0v!nZM^2y5poH38}ti0`vhuGVe~;>tXou}!plW617C@XYjhRE6rFg_zku zNQUfEw?O=QOXX_qwjyqhr}KKTd$W8=O1Eu?b;%eWRWTP*^MDE9eEw!cO)$OGEfBxS zQg^My2?)dHc~geB2cL_SMps7fj=m9Ho^fZ!&ogSU>iK6_@l0fd2e2KX1y5c)4_HYU+bi-kychG{%WKH*%Ria_M*i}G%>~B_UM@%$t}Xl$)ETkdwZmfK(T@{AJb%nhUxvjRJg+Ul7MFnp+JOnjCE*c%gk88#~( z?q=^xq+a6EOL+yvwQ5@t*bIY*zNr9cJRt!N>jW5>EW`bwZm?KhsTZ0SJ4nZO$h73-O)XK7h8qcj|5MZ3mA+q3r^QYH@hiRVS7WUV2cqEFJQ_PO zwK5#Iq@N$p6xYoMKg!B*pv&agFdpKvC~7znRG8{;!P9k%)$Z+DT zVC`_=4W81Xv7m7r_ygdaRl&+|pe~)n&Na&FQ7glNecB{4`#oO$VP!ZGm_CWjwaV&I zE5nJyj7ek;c)a?<%5b7lK8ef?!peE9f|cRKWWgjd2Zfb$P#?<8>v%iAF0wE3c;pw6 z;%HO!K=g^|o6+eR>oac5cq-$U8M9(7u|u)rv3Fu~Gutw6&pd&TxE5qxnsry!vstII zDzdj^-<$oN><_XR#ka+e#=jT;FkYRrGpDs5lP8o_CbkoH7&}?woUbAK>v&Ia>70QG z-`M8t?>x-@GSPMNe-7^P>l1$A!LKa%Wdy%s;1>t{N`P54V{E5fmUiN3y4gjC-& z{5}SKY(Qb~^-)6gQG)2}n~sp`qmGxMkBu=5zCKE*KGq6bGqk>x1@z6w?_;R2Y_?(W z^-)6gF^7o0f3px$|CkdmLm!)X7<_${P<<>xqOY$UA=Sr{dLR1O9fZNxM+wz82fvBF zzPSjgKGyWI$S}IUbowZv`sU#`(btziNcGXuD(GW369(TuN~k{OIMLU)03p>!OFN)X zJJq1hTfeXEjS_@P>#a70yk9~{{HZDQL%?h(LFdRL4_meU>Oh?}mH|%8D$5<#gPj>NR zSuDw6kXjLtVmybGS>VpWTkv+E;s6zvL#?_rQGsuE}$KoNLuwH?9M6J(X*lTxR5wAD7>_6y_~U!RKSgVGntgn2oW`;=-j<2CtUqC?nJCr^12#L{;wW4COx)*!sI76F?XVSuHOxwrUjCsM9HI^> zT@>LllbYVyX(VU6oU#kDVVmV?(u!jS@Q>{zEHx*TzpZiG3p0P`Nd8ia>yq4QQ)%^f zZkiT0S6WzjHJHm~_JwHbDmU7|=A~(1^Q3{Xg|mT$+ZNv}3im?X`;R{VFMaZnbc2 zRX2w;-?j7?n_Z}+<12j=if}OwBF&Rk=X6bq-IO*duF=*5!&a)p6~&bVuYYO`7hyM!IXRs)wbPq>)-8Qe5*_DfMz`Nb3C# zJB8&W4BZL-as6MV)Wc;VDaNx6P->Y-*_TgwALk^ysoV09)T&Lst>q$Rmk6ws+B!QV z#aOjiGqscEWgi&USKvYbRqT25RrZkUf*@KPFx% z_Bbwu?Ol|{-bG@MJrR2$l~jAHLy~KqJ$kxYB(?WZNljyINRsiI#@Y#Os$^Z7Ua!ve zdNy}BUhw&Zt$}rm<;@l^+p6K+bahZGLVY+Zor7%9^^%pW1Ys$husdm`!*V13O(fNr zMyhdAsirhp*d$p}kfYP1Av_b`KGrDkQ;imiTV3O0ti+{A4*$M~$WQM%kSkk8?j2=%2k zjW4aA+85P!Ng8dJ{NCEyLUloNm@TtS>O!z%*ZgP?N!85zmREz?MT(txI2SuYQu_l^ z9U^ts1X7zqQqKjXHi^`dfRyIar6H+cx-JzdmVem8%R*A|grBa}*r?PuR$nO4t-7CZ{pB2M)w}x8fdtb8y zBir*O(%jh=l6o%S<+gEBnmgM=QbAkWMT*=1 zVOu*wQpq>`zHx_01;+rj)ftis+UgXkiCWRlkkmlH)=rTMPJ`4|SEw&iTkMOvq%UIb z>*G#1ecd6OPX}yvi%mXssFd3536;3oWQq59{V*S|R8q@sSIFK+0eic|9v^U2O6~Qg zvDcf{USG&w!$0}u*C+OZk7a7FKaIV9vB%LtUat^W{k4+aA$yG08ogWW1=nyiSFQ?4 z-5v1qs&P{4dBO$5sH~l&?GEPc891TeYJscG&zOEAX zFqK9sB~lkp;NjkoRCmC`z2l_R!+mLH2K!`Yz}NqDE*XBKHSGB{As>S2y+(Wpt|Dul z*`G#g|D;marjfdKQmF%Jqz;Ue($c>!By}v1x7Ur6(!9MsO|N^s^t$?3#}{_Od3i&~ zW-u>r5Sv^$QYrQH#*oze0Z(rnC#9a=l*ZGW#(1jlF9%n{4~A?8Jv}HkgDb}B>CGXj zRsZa_sGG-0=|1eCP=EIBqHlY%`$Mjm&&I6U-x<}t*jqyOp5OCTuh+dr?D;PUl^Z<< z`8Kl(`@ptz_!;t-Ud=SLAVp2r3S!#sqGV6Qm0KNQx#|Dy3coGZxBL%M?D z)uC{0C|nl`^9-+`JkRn9h8sg+p6wNk=NVtY@Y+zAXMP3adG=Q@d~qnuv%rG!JQFM! z=J7$naBC=hNhr*7!Giqlp)k+P3dZy3tYDZ&W)ZYJd1MyBUUB|{3u}Aiky!){^Qfd? zn8!^Kv_IrIVg!3NhDR|0f1r5*@LJ-XPJdO)P?yHi$bg1aB>F_^qS9+dI>Kh?i}vnm=Os);fB~(UYL`D{l(E0Hxz=L3!f=N8bXa;#qiWpS0D{+Z{dW=qX1l z_u35J4NCrpUHDBGF571vX#-{aosK^1==+W?!W;jL-{I&3p!Dw*7sjWKR#5{e84tMd z(=Pmu3n%ePKjXJJdIXd?_5&9-2W z=zd3^aP%!lXWeS~S{=RJ(UXpza header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#define TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef new file mode 100755 index 000000000..92f5b2ac6 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef @@ -0,0 +1,24 @@ +# makedef +# +# This shell script creates a .DEF file necessary for building as DLL +# on the Windows 32-bit platform. + +echo "\ +; This definition file to be used to built the library as DLL +; has been generated automatically with the script \`makedef' on +; `date +%d-%b-%Y`. + +LIBRARY ft13_32 +DESCRIPTION 'FreeType 1.3 32-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +EXPORTS +" > ttf.def + +(cd ../.. + sed -n -e "/^ *EXPORT_DEF/!d ; n ; s/(.*$//" \ + -e "s/;$//" -e "s/ const / /" -e "s/ *[a-zA-Z][a-zA-Z_\*]* //" \ + -e "s/ *//g" -e "s/^/ /" -e "p" *.h extend/*.h) >> ttf.def + +# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep new file mode 100755 index 000000000..9fcae2490 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep @@ -0,0 +1,29 @@ +# makedep +# +# This shell script creates a dependency file necessary for some compilers +# on the Win32 platform. + +echo "\ +# This dependency file to be used with various Win32 compilers +# has been generated automatically with the script \`makedep' on +# `date +%d-%b-%Y`. +" > depend.win + +(cd ../.. + gcc -MM -Iarch/win32 -I. *.c | \ + sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.win + +(cd ../.. + gcc -MM -Iarch/win32 -I. -Iextend extend/*.c | \ + sed -e "s/^\(.*\)\.o:/extend\\\\\1.obj:/" -e "s:/:\\\\:g") >> depend.win + +echo "!ifndef __MAKE__" >> depend.win + +(cd ../.. + gcc -MM -Iarch/win32 -I. -Iextend arch/win32/*.c | \ + sed -e "s/^\(.*\)\.o:/arch\\\\win32\\\\\1.obj:/" \ + -e "s:/:\\\\:g") >> depend.win + +echo "!endif" >> depend.win + +# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def new file mode 100644 index 000000000..f34788659 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def @@ -0,0 +1,127 @@ +; This definition file to be used to built the library as DLL +; has been generated automatically with the script `makedef' on +; 03-Sep-1999. + +LIBRARY ft13_32 +DESCRIPTION 'FreeType 1.3 32-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +EXPORTS + + TT_FreeType_Version + TT_Init_FreeType + TT_Done_FreeType + TT_Set_Raster_Gray_Palette + TT_Open_Face + TT_Open_Collection + TT_Get_Face_Properties + TT_Set_Face_Pointer + TT_Get_Face_Pointer + TT_Flush_Face + TT_Get_Face_Metrics + TT_Close_Face + TT_Get_Font_Data + TT_New_Instance + TT_Set_Instance_Resolutions + TT_Set_Instance_CharSize + TT_Set_Instance_CharSizes + TT_Set_Instance_PixelSizes + TT_Set_Instance_Transform_Flags + TT_Get_Instance_Metrics + TT_Set_Instance_Pointer + TT_Get_Instance_Pointer + TT_Done_Instance + TT_New_Glyph + TT_Done_Glyph + TT_Load_Glyph + TT_Get_Glyph_Outline + TT_Get_Glyph_Metrics + TT_Get_Glyph_Big_Metrics + TT_Get_Glyph_Bitmap + TT_Get_Glyph_Pixmap + TT_New_Outline + TT_Done_Outline + TT_Copy_Outline + TT_Get_Outline_Bitmap + TT_Get_Outline_Pixmap + TT_Get_Outline_BBox + TT_Transform_Outline + TT_Translate_Outline + TT_Transform_Vector + TT_MulDiv + TT_MulFix + TT_Get_CharMap_Count + TT_Get_CharMap_ID + TT_Get_CharMap + TT_Char_Index + TT_Get_Name_Count + TT_Get_Name_ID + TT_Get_Name_String + TT_Register_Extension + TT_Extension_Get + TT_Use_Stream + TT_Done_Stream + TT_Flush_Stream + TT_Read_File + TT_Seek_File + TT_Skip_File + TT_Read_At_File + TT_File_Pos + TT_Stream_Size + TT_Null_FileFrame + TT_Access_Frame + TT_Check_And_Access_Frame + TT_Forget_Frame + TT_Get_Char + TT_Get_Short + TT_Get_Long + TT_LookUp_Table + TT_Alloc + TT_Realloc + TT_Free + TT_CharMap_First + TT_CharMap_Next + TT_CharMap_Last + TT_ErrToString18 + TT_Get_Face_Gasp_Flags + TT_Init_GDEF_Extension + TT_Load_GDEF_Table + TT_GDEF_Get_Glyph_Property + TT_GDEF_Build_ClassDefinition + TT_Init_GPOS_Extension + TT_Load_GPOS_Table + TT_GPOS_Select_Script + TT_GPOS_Select_Language + TT_GPOS_Select_Feature + TT_GPOS_Query_Scripts + TT_GPOS_Query_Languages + TT_GPOS_Query_Features + TT_GPOS_Add_Feature + TT_GPOS_Clear_Features + TT_Init_GSUB_Extension + TT_Load_GSUB_Table + TT_GSUB_Select_Script + TT_GSUB_Select_Language + TT_GSUB_Select_Feature + TT_GSUB_Query_Scripts + TT_GSUB_Query_Languages + TT_GSUB_Query_Features + TT_GSUB_Add_Feature + TT_GSUB_Clear_Features + TT_GSUB_Register_Alternate_Function + TT_GSUB_Apply_String + TT_GSUB_Add_String + TT_Init_Kerning_Extension + TT_Get_Kerning_Directory + TT_Load_Kerning_Table + TT_Init_Post_Extension + TT_Load_PS_Names + TT_Get_PS_Name + TT_Init_SBit_Extension + TT_Get_Face_Bitmaps + TT_New_SBit_Image + TT_Done_SBit_Image + TT_Get_SBit_Strike + TT_Load_Glyph_Bitmap + TT_Get_Face_Widths diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h new file mode 100644 index 000000000..91ee8e5f3 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -0,0 +1,1147 @@ +/******************************************************************* + * + * freetype.h + * + * High-level interface specification. + * + * 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. + * + * Note: + * + * This is the only file that should be included by client + * application sources. All other types and functions defined + * in the `tt*.h' files are library internals and should not be + * included. + * + ******************************************************************/ + +#ifndef FREETYPE_H +#define FREETYPE_H + + +#define TT_FREETYPE_MAJOR 1 +#define TT_FREETYPE_MINOR 3 + + +#include "fterrid.h" +#include "ftnameid.h" + +/* To make freetype.h independent from configuration files we check */ +/* whether EXPORT_DEF has been defined already. */ + +#ifndef EXPORT_DEF +#define EXPORT_DEF extern +#endif + +/* The same for TT_Text. If you define the HAVE_TT_TEXT macro, you */ +/* have to provide a typedef declaration for TT_Text before */ +/* including this file. */ + +#ifndef HAVE_TT_TEXT +#define HAVE_TT_TEXT + typedef char TT_Text; /* The data type to represent */ + /* file name string elements. */ +#endif + +#ifdef __cplusplus + extern "C" { +#endif + + + /*******************************************************************/ + /* */ + /* FreeType types definitions. */ + /* */ + /* All these begin with a 'TT_' prefix. */ + /* */ + /*******************************************************************/ + + typedef int TT_Bool; + + typedef signed long TT_Fixed; /* signed fixed 16.16 float */ + + typedef signed short TT_FWord; /* distance in FUnits */ + typedef unsigned short TT_UFWord; /* unsigned distance */ + + typedef char TT_String; + typedef signed char TT_Char; + typedef unsigned char TT_Byte; + typedef signed short TT_Short; + typedef unsigned short TT_UShort; + typedef int TT_Int; + typedef unsigned int TT_UInt; + typedef signed long TT_Long; + typedef unsigned long TT_ULong; + + typedef signed short TT_F2Dot14; /* Signed fixed float 2.14 used for */ + /* unit vectors, with layout */ + /* */ + /* s : 1 -- sign bit */ + /* m : 1 -- integer bit */ + /* f : 14 -- unsigned fractional */ + /* */ + /* `s:m' is the 2-bit signed int */ + /* value to which the positive */ + /* fractional part should be added. */ + + typedef signed long TT_F26Dot6; /* 26.6 fixed float, used for */ + /* glyph points pixel coordinates. */ + + typedef signed long TT_Pos; /* Point position, expressed either */ + /* in fractional pixels or notional */ + /* units, depending on context. */ + /* For example, glyph coordinates */ + /* returned by TT_Load_Glyph() are */ + /* expressed in font units if */ + /* scaling wasn't requested, and */ + /* in 26.6 fractional pixels if it */ + /* was. */ + + + struct TT_UnitVector_ /* guess what... */ + { + TT_F2Dot14 x; + TT_F2Dot14 y; + }; + + typedef struct TT_UnitVector_ TT_UnitVector; + + + struct TT_Vector_ /* simple vector type */ + { + TT_F26Dot6 x; + TT_F26Dot6 y; + }; + + typedef struct TT_Vector_ TT_Vector; + + + /* A simple 2x2 matrix used for transformations. */ + /* You should use 16.16 fixed floats. */ + /* */ + /* x' = xx*x + xy*y */ + /* y' = yx*x + yy*y */ + /* */ + + struct TT_Matrix_ + { + TT_Fixed xx, xy; + TT_Fixed yx, yy; + }; + + typedef struct TT_Matrix_ TT_Matrix; + + + /* A structure used to describe the source glyph to the renderer. */ + + struct TT_Outline_ + { + TT_Short n_contours; /* number of contours in glyph */ + TT_UShort n_points; /* number of points in the glyph */ + + TT_Vector* points; /* the outline's points */ + TT_Byte* flags; /* the points flags */ + TT_UShort* contours; /* the contour end points */ + + /* The following flag indicates that the outline owns the arrays it */ + /* refers to. Typically, this is true of outlines created from the */ + /* TT_New_Outline() API, while it isn't for those returned by */ + /* TT_Get_Glyph_Outline(). */ + + TT_Bool owner; /* The outline owns the coordinates, */ + /* flags and contours array it uses. */ + + /* The following flags are set automatically by */ + /* TT_Get_Glyph_Outline(). Their meaning is the following: */ + /* */ + /* high_precision If true, the scan-line converter will use a */ + /* higher precision to render bitmaps (i.e., a */ + /* 1/1024 pixel precision). This is important for */ + /* small ppem sizes. */ + /* */ + /* second_pass If true, the scan-line converter performs a */ + /* second sweep phase dedicated to find vertical */ + /* drop-outs. If false, only horizontal drop-outs */ + /* will be checked during the first vertical */ + /* sweep (yes, this is a bit confusing but it is */ + /* really the way it should work). This is */ + /* important for small ppems too. */ + /* */ + /* dropout_mode Specifies the TrueType drop-out mode to use for */ + /* continuity checking. Valid values are 0 (no */ + /* check), 1, 2, 4, and 5. */ + /* */ + /* Most of the engine's users will safely ignore these fields... */ + + TT_Bool high_precision; /* high precision rendering */ + TT_Bool second_pass; /* two sweeps rendering */ + TT_Char dropout_mode; /* dropout mode */ + }; + + typedef struct TT_Outline_ TT_Outline; + + + /* A structure used to describe a simple bounding box. */ + + struct TT_BBox_ + { + TT_Pos xMin; + TT_Pos yMin; + TT_Pos xMax; + TT_Pos yMax; + }; + + typedef struct TT_BBox_ TT_BBox; + + + /* A structure used to return glyph metrics. */ + /* */ + /* The `bearingX' isn't called `left-side bearing' anymore because */ + /* it has different meanings depending on the glyph's orientation. */ + /* */ + /* The same is true for `bearingY', which is the top-side bearing */ + /* defined by the TT_Spec, i.e., the distance from the baseline to */ + /* the top of the glyph's bbox. According to our current convention, */ + /* this is always the same as `bbox.yMax' but we make it appear for */ + /* consistency in its proper field. */ + /* */ + /* The `advance' field is the advance width for horizontal layout, */ + /* and advance height for vertical layouts. */ + + struct TT_Glyph_Metrics_ + { + TT_BBox bbox; /* glyph bounding box */ + + TT_Pos bearingX; /* left-side bearing */ + TT_Pos bearingY; /* top-side bearing, per se the TT spec */ + + TT_Pos advance; /* advance width (or height) */ + }; + + typedef struct TT_Glyph_Metrics_ TT_Glyph_Metrics; + + + /* A structure used to return horizontal _and_ vertical glyph */ + /* metrics. */ + /* */ + /* A glyph can be used either in a horizontal or vertical layout. */ + /* Its glyph metrics vary with orientation. The TT_Big_Glyph_Metrics */ + /* structure is used to return _all_ metrics in one call. */ + + struct TT_Big_Glyph_Metrics_ + { + TT_BBox bbox; /* glyph bounding box */ + + TT_Pos horiBearingX; /* left side bearing in horizontal layouts */ + TT_Pos horiBearingY; /* top side bearing in horizontal layouts */ + + TT_Pos vertBearingX; /* left side bearing in vertical layouts */ + TT_Pos vertBearingY; /* top side bearing in vertical layouts */ + + TT_Pos horiAdvance; /* advance width for horizontal layout */ + TT_Pos vertAdvance; /* advance height for vertical layout */ + + /* The following fields represent unhinted scaled metrics values. */ + /* They can be useful for applications needing to do some device */ + /* independent placement of glyphs. */ + /* */ + /* Applying these metrics to hinted glyphs will most surely ruin */ + /* the grid fitting performed by the bytecode interpreter. These */ + /* values are better used to compute accumulated positioning */ + /* distances. */ + + TT_Pos linearHoriBearingX; /* linearly scaled horizontal lsb */ + TT_Pos linearHoriAdvance; /* linearly scaled horizontal advance */ + + TT_Pos linearVertBearingY; /* linearly scaled vertical tsb */ + TT_Pos linearVertAdvance; /* linearly scaled vertical advance */ + }; + + typedef struct TT_Big_Glyph_Metrics_ TT_Big_Glyph_Metrics; + + + /* A structure used to return instance metrics. */ + + struct TT_Instance_Metrics_ + { + TT_F26Dot6 pointSize; /* char. size in points (1pt = 1/72 inch) */ + + TT_UShort x_ppem; /* horizontal pixels per EM square */ + TT_UShort y_ppem; /* vertical pixels per EM square */ + + TT_Fixed x_scale; /* 16.16 to convert from EM units to 26.6 pix */ + TT_Fixed y_scale; /* 16.16 to convert from EM units to 26.6 pix */ + + TT_UShort x_resolution; /* device horizontal resolution in dpi */ + TT_UShort y_resolution; /* device vertical resolution in dpi */ + }; + + typedef struct TT_Instance_Metrics_ TT_Instance_Metrics; + + + /* Flow constants: */ + /* */ + /* The flow of a bitmap refers to the way lines are oriented */ + /* within the bitmap data, i.e., the orientation of the Y */ + /* coordinate axis. */ + /* */ + /* For example, if the first bytes of the bitmap pertain to */ + /* its top-most line, then the flow is `down'. If these bytes */ + /* pertain to its lowest line, the the flow is `up'. */ + +#define TT_Flow_Down -1 /* bitmap is oriented from top to bottom */ +#define TT_Flow_Up 1 /* bitmap is oriented from bottom to top */ +#define TT_Flow_Error 0 /* an error occurred during rendering */ + + + /* A structure used to describe the target bitmap or pixmap to the */ + /* renderer. Note that there is nothing in this structure that */ + /* gives the nature of the buffer. */ + /* */ + /* IMPORTANT NOTE: */ + /* */ + /* In the case of a pixmap, the `width' and `cols' fields must */ + /* have the _same_ values, and _must_ be padded to 32-bits, i.e., */ + /* be a multiple of 4. Clipping problems will arise otherwise, */ + /* if not even page faults! */ + /* */ + /* The typical settings are: */ + /* */ + /* - for a WxH bitmap: */ + /* */ + /* rows = H */ + /* cols = (W+7) / 8 */ + /* width = W */ + /* flow = your_choice */ + /* */ + /* - for a WxH pixmap: */ + /* */ + /* rows = H */ + /* cols = (W+3) & ~3 */ + /* width = cols */ + /* flow = your_choice */ + + struct TT_Raster_Map_ + { + int rows; /* number of rows */ + int cols; /* number of columns (bytes) per row */ + int width; /* number of pixels per line */ + int flow; /* bitmap orientation */ + + void* bitmap; /* bit/pixmap buffer */ + long size; /* bit/pixmap size in bytes */ + }; + + typedef struct TT_Raster_Map_ TT_Raster_Map; + + + /* ------ The font header TrueType table structure ------ */ + + struct TT_Header_ + { + TT_Fixed Table_Version; + TT_Fixed Font_Revision; + + TT_Long CheckSum_Adjust; + TT_Long Magic_Number; + + TT_UShort Flags; + TT_UShort Units_Per_EM; + + TT_Long Created [2]; + TT_Long Modified[2]; + + TT_FWord xMin; + TT_FWord yMin; + TT_FWord xMax; + TT_FWord yMax; + + TT_UShort Mac_Style; + TT_UShort Lowest_Rec_PPEM; + + TT_Short Font_Direction; + TT_Short Index_To_Loc_Format; + TT_Short Glyph_Data_Format; + }; + + typedef struct TT_Header_ TT_Header; + + + /* ------ The horizontal header TrueType table structure ------ */ + + /*******************************************************/ + /* This structure is the one defined by the TrueType */ + /* specification, plus two fields used to link the */ + /* font-units metrics to the header. */ + + struct TT_Horizontal_Header_ + { + TT_Fixed Version; + TT_FWord Ascender; + TT_FWord Descender; + TT_FWord Line_Gap; + + TT_UFWord advance_Width_Max; /* advance width maximum */ + + TT_FWord min_Left_Side_Bearing; /* minimum left-sb */ + TT_FWord min_Right_Side_Bearing; /* minimum right-sb */ + TT_FWord xMax_Extent; /* xmax extents */ + TT_FWord caret_Slope_Rise; + TT_FWord caret_Slope_Run; + + TT_Short Reserved0, + Reserved1, + Reserved2, + Reserved3, + Reserved4; + + TT_Short metric_Data_Format; + TT_UShort number_Of_HMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + }; + + typedef struct TT_Horizontal_Header_ TT_Horizontal_Header; + + + /*******************************************************/ + /* This structure is the one defined by the TrueType */ + /* specification. Note that it has exactly the same */ + /* layout as the horizontal header (both are loaded */ + /* by the same function). */ + + struct TT_Vertical_Header_ + { + TT_Fixed Version; + TT_FWord Ascender; + TT_FWord Descender; + TT_FWord Line_Gap; + + TT_UFWord advance_Height_Max; /* advance height maximum */ + + TT_FWord min_Top_Side_Bearing; /* minimum left-sb or top-sb */ + TT_FWord min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ + TT_FWord yMax_Extent; /* xmax or ymax extents */ + TT_FWord caret_Slope_Rise; + TT_FWord caret_Slope_Run; + TT_FWord caret_Offset; + + TT_Short Reserved1, + Reserved2, + Reserved3, + Reserved4; + + TT_Short metric_Data_Format; + TT_UShort number_Of_VMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + }; + + typedef struct TT_Vertical_Header_ TT_Vertical_Header; + + + /* ------ The OS/2 table ------ */ + + /************************************************************************/ + /* Note that since FreeType 1.3, we support Mac fonts which do not have */ + /* an OS/2 table. In this case the `version' field will be set to */ + /* 0xFFFF by the table loader; all other fields should be 0. */ + + struct TT_OS2_ + { + TT_UShort version; /* 0x0001 */ + TT_FWord xAvgCharWidth; + TT_UShort usWeightClass; + TT_UShort usWidthClass; + TT_Short fsType; + TT_FWord ySubscriptXSize; + TT_FWord ySubscriptYSize; + TT_FWord ySubscriptXOffset; + TT_FWord ySubscriptYOffset; + TT_FWord ySuperscriptXSize; + TT_FWord ySuperscriptYSize; + TT_FWord ySuperscriptXOffset; + TT_FWord ySuperscriptYOffset; + TT_FWord yStrikeoutSize; + TT_FWord yStrikeoutPosition; + TT_Short sFamilyClass; + + TT_Byte panose[10]; + + TT_ULong ulUnicodeRange1; /* Bits 0-31 */ + TT_ULong ulUnicodeRange2; /* Bits 32-63 */ + TT_ULong ulUnicodeRange3; /* Bits 64-95 */ + TT_ULong ulUnicodeRange4; /* Bits 96-127 */ + + TT_Char achVendID[4]; + + TT_UShort fsSelection; + TT_UShort usFirstCharIndex; + TT_UShort usLastCharIndex; + TT_Short sTypoAscender; + TT_Short sTypoDescender; + TT_Short sTypoLineGap; + TT_UShort usWinAscent; + TT_UShort usWinDescent; + + /* only version 1 tables: */ + + TT_ULong ulCodePageRange1; /* Bits 0-31 */ + TT_ULong ulCodePageRange2; /* Bits 32-63 */ + }; + + typedef struct TT_OS2_ TT_OS2; + + + /* ------ The PostScript table ------ */ + + struct TT_Postscript_ + { + TT_Fixed FormatType; + TT_Fixed italicAngle; + TT_FWord underlinePosition; + TT_FWord underlineThickness; + TT_ULong isFixedPitch; + TT_ULong minMemType42; + TT_ULong maxMemType42; + TT_ULong minMemType1; + TT_ULong maxMemType1; + + /* Glyph names follow in the file, but we don't */ + /* load them by default. See the ftxpost.c extension. */ + }; + + typedef struct TT_Postscript_ TT_Postscript; + + + /* ------ The horizontal device metrics table (`hdmx') ------ */ + + struct TT_Hdmx_Record_ + { + TT_Byte ppem; + TT_Byte max_width; + TT_Byte* widths; + }; + + typedef struct TT_Hdmx_Record_ TT_Hdmx_Record; + + + struct TT_Hdmx_ + { + TT_UShort version; + TT_Short num_records; + TT_Hdmx_Record* records; + }; + + typedef struct TT_Hdmx_ TT_Hdmx; + + + /* A structure used to describe face properties. */ + + struct TT_Face_Properties_ + { + TT_UShort num_Glyphs; /* number of glyphs in face */ + TT_UShort max_Points; /* maximum number of points in a glyph */ + TT_UShort max_Contours; /* maximum number of contours in a glyph */ + + TT_UShort num_CharMaps; /* number of charmaps in the face */ + TT_UShort num_Names; /* number of name records in the face */ + + TT_ULong num_Faces; /* 1 for normal TrueType files, and the */ + /* number of embedded faces for TrueType */ + /* collections */ + + TT_Header* header; /* TrueType header table */ + TT_Horizontal_Header* horizontal; /* TrueType horizontal header */ + TT_OS2* os2; /* TrueType OS/2 table */ + TT_Postscript* postscript; /* TrueType Postscript table */ + TT_Hdmx* hdmx; /* TrueType hor. dev. metr. table */ + TT_Vertical_Header* vertical; /* TT Vertical header, if present */ + }; + + typedef struct TT_Face_Properties_ TT_Face_Properties; + + + /* Here are the definitions of the handle types used for FreeType's */ + /* most common objects accessed by the client application. We use */ + /* a simple trick: */ + /* */ + /* Each handle type is a structure that only contains one */ + /* pointer. The advantage of structures is that they are */ + /* mutually exclusive types. We could have defined the */ + /* following types: */ + /* */ + /* typedef void* TT_Stream; */ + /* typedef void* TT_Face; */ + /* typedef void* TT_Instance; */ + /* typedef void* TT_Glyph; */ + /* typedef void* TT_CharMap; */ + /* */ + /* but these would have allowed lines like: */ + /* */ + /* stream = instance; */ + /* */ + /* in the client code this would be a severe bug, unnoticed */ + /* by the compiler! */ + /* */ + /* Thus, we enforce type checking with a simple language */ + /* trick... */ + /* */ + /* NOTE: Some macros are defined in tttypes.h to perform */ + /* automatic type conversions for library hackers... */ + + struct TT_Engine_ { void* z; }; + struct TT_Stream_ { void* z; }; + struct TT_Face_ { void* z; }; + struct TT_Instance_ { void* z; }; + struct TT_Glyph_ { void* z; }; + struct TT_CharMap_ { void* z; }; + + typedef struct TT_Engine_ TT_Engine; /* engine instance */ + typedef struct TT_Stream_ TT_Stream; /* stream handle type */ + typedef struct TT_Face_ TT_Face; /* face handle type */ + typedef struct TT_Instance_ TT_Instance; /* instance handle type */ + typedef struct TT_Glyph_ TT_Glyph; /* glyph handle type */ + typedef struct TT_CharMap_ TT_CharMap; /* character map handle type */ + + + /* Almost all functions return an error code of this type. */ + + typedef long TT_Error; + + + /*******************************************************************/ + /* */ + /* FreeType API */ + /* */ + /* All these begin with a `TT_' prefix. */ + /* */ + /* Most of them are implemented in the `ttapi.c' source file. */ + /* */ + /*******************************************************************/ + + /* Get version information. */ + + EXPORT_DEF + TT_Error TT_FreeType_Version( int *major, + int *minor ); + + + /* Initialize the engine. */ + + EXPORT_DEF + TT_Error TT_Init_FreeType( TT_Engine* engine ); + + + /* Finalize the engine, and release all allocated objects. */ + + EXPORT_DEF + TT_Error TT_Done_FreeType( TT_Engine engine ); + + + /* Set the gray level palette. This is an array of 5 bytes used */ + /* to produce the font smoothed pixmaps. By convention: */ + /* */ + /* palette[0] = background (white) */ + /* palette[1] = light */ + /* palette[2] = medium */ + /* palette[3] = dark */ + /* palette[4] = foreground (black) */ + /* */ + + EXPORT_DEF + TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, + TT_Byte* palette ); + + + /* ----------------------- face management ----------------------- */ + + /* Open a new TrueType font file, and returns a handle for */ + /* it in variable '*face'. */ + /* */ + /* Note: The file can be either a TrueType file (*.ttf) or */ + /* a TrueType collection (*.ttc, in this case, only */ + /* the first face is opened). The number of faces in */ + /* the same collection can be obtained in the face's */ + /* properties, using TT_Get_Face_Properties() and the */ + /* `max_Faces' field. */ + + EXPORT_DEF + TT_Error TT_Open_Face( TT_Engine engine, + const TT_Text* fontPathName, + TT_Face* face ); + + + /* Open a TrueType font file located inside a collection. */ + /* The font is assigned by its index in `fontIndex'. */ + + EXPORT_DEF + TT_Error TT_Open_Collection( TT_Engine engine, + const TT_Text* collectionPathName, + TT_ULong fontIndex, + TT_Face* face ); + + + /* Return face properties in the `properties' structure. */ + /* */ + /* Note that since version 1.3, we support font files with no */ + /* OS/2 table (mainly old Mac fonts). In this case, the OS/2 */ + /* `version' field will be set to 0xFFFF, and all other fields */ + /* will be zeroed. */ + + EXPORT_DEF + TT_Error TT_Get_Face_Properties( TT_Face face, + TT_Face_Properties* properties ); + + + /* Set a face object's generic pointer */ + + EXPORT_DEF + TT_Error TT_Set_Face_Pointer( TT_Face face, + void* data ); + + + /* Get a face object's generic pointer */ + + EXPORT_DEF + void* TT_Get_Face_Pointer( TT_Face face ); + + + /* Close a face's file handle to save system resources. The file */ + /* will be re-opened automatically on the next disk access. */ + + EXPORT_DEF + TT_Error TT_Flush_Face( TT_Face face ); + + /* Get a face's glyph metrics expressed in font units. Returns any */ + /* number of arrays. Set the fields to NULL if you are not interested */ + /* by a given array. */ + + EXPORT_DEF + TT_Error TT_Get_Face_Metrics( TT_Face face, + TT_UShort firstGlyph, + TT_UShort lastGlyph, + TT_Short* leftBearings, + TT_UShort* widths, + TT_Short* topBearings, + TT_UShort* heights ); + + + /* Close a given font object, destroying all associated */ + /* instances. */ + + EXPORT_DEF + TT_Error TT_Close_Face( TT_Face face ); + + + /* Get font or table data. */ + + EXPORT_DEF + TT_Error TT_Get_Font_Data( TT_Face face, + TT_ULong tag, + TT_Long offset, + void* buffer, + TT_Long* length ); + + +/* A simple macro to build table tags from ASCII chars */ + +#define MAKE_TT_TAG( _x1, _x2, _x3, _x4 ) \ + (((TT_ULong)_x1 << 24) | \ + ((TT_ULong)_x2 << 16) | \ + ((TT_ULong)_x3 << 8) | \ + (TT_ULong)_x4) + + + + /* ----------------------- instance management -------------------- */ + + /* Open a new font instance and returns an instance handle */ + /* for it in `*instance'. */ + + EXPORT_DEF + TT_Error TT_New_Instance( TT_Face face, + TT_Instance* instance ); + + + /* Set device resolution for a given instance. The values are */ + /* given in dpi (Dots Per Inch). Default is 96 in both directions. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, + TT_UShort xResolution, + TT_UShort yResolution ); + + + /* Set the pointsize for a given instance. Default is 10pt. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_CharSize( TT_Instance instance, + TT_F26Dot6 charSize ); + + EXPORT_DEF + TT_Error TT_Set_Instance_CharSizes( TT_Instance instance, + TT_F26Dot6 charWidth, + TT_F26Dot6 charHeight ); + +#define TT_Set_Instance_PointSize( ins, ptsize ) \ + TT_Set_Instance_CharSize( ins, ptsize*64L ) + + EXPORT_DEF + TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, + TT_UShort pixelWidth, + TT_UShort pixelHeight, + TT_F26Dot6 pointSize ); + + + /* This function has been deprecated! Do not use it, as it */ + /* doesn't work reliably. You can perfectly control hinting */ + /* yourself when loading glyphs, then apply transforms as usual. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, + TT_Bool rotated, + TT_Bool stretched ); + + + /* Return instance metrics in `metrics'. */ + + EXPORT_DEF + TT_Error TT_Get_Instance_Metrics( TT_Instance instance, + TT_Instance_Metrics* metrics ); + + + /* Set an instance's generic pointer. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Pointer( TT_Instance instance, + void* data ); + + + /* Get an instance's generic pointer. */ + + EXPORT_DEF + void* TT_Get_Instance_Pointer( TT_Instance instance ); + + + /* Close a given instance object, destroying all associated data. */ + + EXPORT_DEF + TT_Error TT_Done_Instance( TT_Instance instance ); + + + + /* ----------------------- glyph management ----------------------- */ + + /* Create a new glyph object related to the given `face'. */ + + EXPORT_DEF + TT_Error TT_New_Glyph( TT_Face face, + TT_Glyph* glyph ); + + + /* Discard (and destroy) a given glyph object. */ + + EXPORT_DEF + TT_Error TT_Done_Glyph( TT_Glyph glyph ); + + +#define TTLOAD_SCALE_GLYPH 1 +#define TTLOAD_HINT_GLYPH 2 +#define TTLOAD_PEDANTIC 128 +#define TTLOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 256 + +#define TTLOAD_DEFAULT (TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH) + + + /* Load and process (scale/transform and hint) a glyph from the */ + /* given `instance'. The glyph and instance handles must be */ + /* related to the same face object. The glyph index can be */ + /* computed with a call to TT_Char_Index(). */ + /* */ + /* The 'load_flags' argument is a combination of the macros */ + /* TTLOAD_SCALE_GLYPH and TTLOAD_HINT_GLYPH. Hinting will be */ + /* applied only if the scaling is selected. */ + /* */ + /* If scaling is off (i.e., load_flags = 0), the returned */ + /* outlines are in EM square coordinates (also called FUnits), */ + /* extracted directly from the font with no hinting. Other */ + /* glyph metrics are also in FUnits. */ + /* */ + /* If scaling is on, the returned outlines are in fractional */ + /* pixel units (i.e. TT_F26Dot6 = 26.6 fixed floats). */ + /* */ + /* NOTE: The glyph index must be in the range 0..num_glyphs-1, */ + /* where `num_glyphs' is the total number of glyphs in */ + /* the font file (given in the face properties). */ + + EXPORT_DEF + TT_Error TT_Load_Glyph( TT_Instance instance, + TT_Glyph glyph, + TT_UShort glyphIndex, + TT_UShort loadFlags ); + + + /* Return glyph outline pointers in `outline'. Note that the returned */ + /* pointers are owned by the glyph object, and will be destroyed with */ + /* it. The client application should _not_ change the pointers. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Outline( TT_Glyph glyph, + TT_Outline* outline ); + + + /* Copy the glyph metrics into `metrics'. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Metrics( TT_Glyph glyph, + TT_Glyph_Metrics* metrics ); + + + /* Copy the glyph's big metrics into `metrics'. */ + /* Necessary to obtain vertical metrics. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, + TT_Big_Glyph_Metrics* metrics ); + + + /* Render the glyph into a bitmap, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Render the glyph into a pixmap, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + + /* ----------------------- outline support ------------------------ */ + + /* Allocate a new outline. Reserve space for `numPoints' and */ + /* `numContours'. */ + + EXPORT_DEF + TT_Error TT_New_Outline( TT_UShort numPoints, + TT_Short numContours, + TT_Outline* outline ); + + + /* Release an outline. */ + + EXPORT_DEF + TT_Error TT_Done_Outline( TT_Outline* outline ); + + + /* Copy an outline into another one. */ + + EXPORT_DEF + TT_Error TT_Copy_Outline( TT_Outline* source, + TT_Outline* target ); + + + /* Render an outline into a bitmap. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + + + /* Render an outline into a pixmap. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + + + /* Return an outline's bounding box -- this function is slow as it */ + /* performs a complete scan-line process, without drawing, to get */ + /* the most accurate values. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_BBox( TT_Outline* outline, + TT_BBox* bbox ); + + + /* Apply a transformation to a glyph outline. */ + + EXPORT_DEF + void TT_Transform_Outline( TT_Outline* outline, + TT_Matrix* matrix ); + + + /* Apply a translation to a glyph outline. */ + + EXPORT_DEF + void TT_Translate_Outline( TT_Outline* outline, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Apply a transformation to a vector. */ + + EXPORT_DEF + void TT_Transform_Vector( TT_F26Dot6* x, + TT_F26Dot6* y, + TT_Matrix* matrix ); + + + /* Compute A*B/C with 64 bits intermediate precision. */ + + EXPORT_DEF + TT_Long TT_MulDiv( TT_Long A, + TT_Long B, + TT_Long C ); + + + /* Compute A*B/0x10000 with 64 bits intermediate precision. */ + /* Useful to multiply by a 16.16 fixed float value. */ + + EXPORT_DEF + TT_Long TT_MulFix( TT_Long A, + TT_Long B ); + + + /* ----------------- character mapping support --------------- */ + + /* Return the number of character mappings found in this file. */ + /* Returns -1 in case of failure (invalid face handle). */ + /* */ + /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ + /* */ + /* It is retained for backwards compatibility only and will */ + /* fail on 16bit systems. */ + /* */ + /* You can now get the charmap count in the `num_CharMaps' */ + /* field of a face's properties. */ + /* */ + + EXPORT_DEF + int TT_Get_CharMap_Count( TT_Face face ); + + + /* Return the ID of charmap number `charmapIndex' of a given face */ + /* used to enumerate the charmaps present in a TrueType file. */ + + EXPORT_DEF + TT_Error TT_Get_CharMap_ID( TT_Face face, + TT_UShort charmapIndex, + TT_UShort* platformID, + TT_UShort* encodingID ); + + + /* Look up the character maps found in `face' and return a handle */ + /* for the one matching `platformID' and `platformEncodingID' */ + /* (see the TrueType specs relating to the `cmap' table for */ + /* information on these ID numbers). Returns an error code. */ + /* In case of failure, the handle is set to NULL and is invalid. */ + + EXPORT_DEF + TT_Error TT_Get_CharMap( TT_Face face, + TT_UShort charmapIndex, + TT_CharMap* charMap ); + + + /* Translate a character code through a given character map */ + /* and return the corresponding glyph index to be used in */ + /* a TT_Load_Glyph() call. This function returns 0 in case */ + /* of failure. */ + + EXPORT_DEF + TT_UShort TT_Char_Index( TT_CharMap charMap, + TT_UShort charCode ); + + + + /* --------------------- names table support ------------------- */ + + /* Return the number of name strings found in the name table. */ + /* Returns -1 in case of failure (invalid face handle). */ + /* */ + /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ + /* */ + /* It is retained for backwards compatibility only and will */ + /* fail on 16bit systems. */ + /* */ + /* You can now get the number of name strings in a face with */ + /* the `num_Names' field of its properties. */ + + EXPORT_DEF + int TT_Get_Name_Count( TT_Face face ); + + + /* Return the ID of the name number `nameIndex' of a given face */ + /* used to enumerate the charmaps present in a TrueType file. */ + + EXPORT_DEF + TT_Error TT_Get_Name_ID( TT_Face face, + TT_UShort nameIndex, + TT_UShort* platformID, + TT_UShort* encodingID, + TT_UShort* languageID, + TT_UShort* nameID ); + + + /* Return the address and length of the name number `nameIndex' */ + /* of a given face in the variables `stringPtr' resp. `length'. */ + /* The string is part of the face object and shouldn't be */ + /* written to or released. */ + /* */ + /* Note that for an invalid platform ID a null pointer will be */ + /* returned. */ + + EXPORT_DEF + TT_Error TT_Get_Name_String( TT_Face face, + TT_UShort nameIndex, + TT_String** stringPtr, + TT_UShort* length ); + + +#ifdef __cplusplus + } +#endif + +#endif /* FREETYPE_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h new file mode 100644 index 000000000..e0edc4697 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -0,0 +1,231 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for the FreeGEOS Build */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Under FreeGEOS we need this for the file operations. */ +#include +#include + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. Unix-specific */ +#undef HAVE_FCNTL_H + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + + +/* The number of bytes in a int. We use the ANSI header file limits.h */ +/* for determining it since there is no easy way to guess. */ +/* */ +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +/* We now try to guess the size of longs in the same way */ +/* */ +#if ULONG_MAX == 0xFFFFFFFF +#define SIZEOF_LONG 4 +#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF +#define SIZEOF_LONG 8 +#else +#error "Unsupported number of bytes in `long' type!" +#endif + + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#undef TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#undef TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#define TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/fterrid.h b/Appl/Breadbox/testapps/ttf2/FreeType/fterrid.h new file mode 100644 index 000000000..5606e5dc8 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/fterrid.h @@ -0,0 +1,161 @@ +/******************************************************************* + * + * fterrid.h + * + * TrueType Error ID definitions + * + * 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 FREETYPE_H +#error "Don't include this file! Use freetype.h instead." +#endif + +#ifndef FTERRID_H +#define FTERRID_H + + /************************ error codes declaration **************/ + + /* The error codes are grouped in 'classes' used to indicate the */ + /* 'level' at which the error happened. */ + /* The class is given by an error code's high byte. */ + + + /* ------------- Success is always 0 -------- */ + +#define TT_Err_Ok 0 + + + /* -------- High-level API error codes ------ */ + +#define TT_Err_Invalid_Face_Handle 0x001 +#define TT_Err_Invalid_Instance_Handle 0x002 +#define TT_Err_Invalid_Glyph_Handle 0x003 +#define TT_Err_Invalid_CharMap_Handle 0x004 +#define TT_Err_Invalid_Result_Address 0x005 +#define TT_Err_Invalid_Glyph_Index 0x006 +#define TT_Err_Invalid_Argument 0x007 +#define TT_Err_Could_Not_Open_File 0x008 +#define TT_Err_File_Is_Not_Collection 0x009 + +#define TT_Err_Table_Missing 0x00A +#define TT_Err_Invalid_Horiz_Metrics 0x00B +#define TT_Err_Invalid_CharMap_Format 0x00C +#define TT_Err_Invalid_PPem 0x00D +#define TT_Err_Invalid_Vert_Metrics 0x00E + +#define TT_Err_Invalid_File_Format 0x010 + +#define TT_Err_Invalid_Engine 0x020 +#define TT_Err_Too_Many_Extensions 0x021 +#define TT_Err_Extensions_Unsupported 0x022 +#define TT_Err_Invalid_Extension_Id 0x023 + +#define TT_Err_No_Vertical_Data 0x030 + +#define TT_Err_Max_Profile_Missing 0x080 +#define TT_Err_Header_Table_Missing 0x081 +#define TT_Err_Horiz_Header_Missing 0x082 +#define TT_Err_Locations_Missing 0x083 +#define TT_Err_Name_Table_Missing 0x084 +#define TT_Err_CMap_Table_Missing 0x085 +#define TT_Err_Hmtx_Table_Missing 0x086 +#define TT_Err_OS2_Table_Missing 0x087 +#define TT_Err_Post_Table_Missing 0x088 +#define TT_Err_Glyf_Table_Missing 0x089 + + + /* -------- Memory component error codes ---- */ + + /* this error indicates that an operation cannot */ + /* be performed due to memory exhaustion. */ + +#define TT_Err_Out_Of_Memory 0x100 + + + /* -------- File component error codes ------ */ + + /* these error codes indicate that the file could */ + /* not be accessed properly. Usually, this means */ + /* a broken font file! */ + +#define TT_Err_Invalid_File_Offset 0x200 +#define TT_Err_Invalid_File_Read 0x201 +#define TT_Err_Invalid_Frame_Access 0x202 + + + /* -------- Glyph loader error codes -------- */ + + /* Produced only by the glyph loader, these error */ + /* codes indicate a broken glyph in a font file. */ + +#define TT_Err_Too_Many_Points 0x300 +#define TT_Err_Too_Many_Contours 0x301 +#define TT_Err_Invalid_Composite 0x302 +#define TT_Err_Too_Many_Ins 0x303 + + + /* --- bytecode interpreter error codes ----- */ + + /* These error codes are produced by the TrueType */ + /* bytecode interpreter. They usually indicate a */ + /* broken font file, a broken glyph within a font */ + /* file, or a bug in the interpreter! */ + +#define TT_Err_Invalid_Opcode 0x400 +#define TT_Err_Too_Few_Arguments 0x401 +#define TT_Err_Stack_Overflow 0x402 +#define TT_Err_Code_Overflow 0x403 +#define TT_Err_Bad_Argument 0x404 +#define TT_Err_Divide_By_Zero 0x405 +#define TT_Err_Storage_Overflow 0x406 +#define TT_Err_Cvt_Overflow 0x407 +#define TT_Err_Invalid_Reference 0x408 +#define TT_Err_Invalid_Distance 0x409 +#define TT_Err_Interpolate_Twilight 0x40A +#define TT_Err_Debug_OpCode 0x40B +#define TT_Err_ENDF_In_Exec_Stream 0x40C +#define TT_Err_Out_Of_CodeRanges 0x40D +#define TT_Err_Nested_DEFS 0x40E +#define TT_Err_Invalid_CodeRange 0x40F +#define TT_Err_Invalid_Displacement 0x410 +#define TT_Err_Execution_Too_Long 0x411 + + + /* ------ internal failure error codes ----- */ + + /* These error codes are produced when an incoherent */ + /* library state has been detected. These reflect a */ + /* severe bug in the engine! (Or a major overwrite */ + /* of your application into the library's data.) */ + +#define TT_Err_Nested_Frame_Access 0x500 +#define TT_Err_Invalid_Cache_List 0x501 +#define TT_Err_Could_Not_Find_Context 0x502 +#define TT_Err_Unlisted_Object 0x503 + + + /* ---- scan-line converter error codes ----- */ + + /* These error codes are produced by the raster component. */ + /* They indicate that an outline structure was incoherently */ + /* setup, or that you're trying to render an horribly */ + /* complex glyph! */ + +#define TT_Err_Raster_Pool_Overflow 0x600 +#define TT_Err_Raster_Negative_Height 0x601 +#define TT_Err_Raster_Invalid_Value 0x602 +#define TT_Err_Raster_Not_Initialized 0x603 + +#endif /* FTERRID_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftnameid.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftnameid.h new file mode 100644 index 000000000..14c573230 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftnameid.h @@ -0,0 +1,628 @@ +/******************************************************************* + * + * ftnameid.h + * + * TrueType Name ID definitions + * + * 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 FREETYPE_H +#error "Don't include this file! Use freetype.h instead." +#endif + +#ifndef FTNAMEID_H +#define FTNAMEID_H + +/* + * possible values for the 'Platform' identifier code in the name + * records of the TTF "name" table + */ + +#define TT_PLATFORM_APPLE_UNICODE 0 +#define TT_PLATFORM_MACINTOSH 1 +#define TT_PLATFORM_ISO 2 +#define TT_PLATFORM_MICROSOFT 3 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_APPLE_UNICODE + */ + +#define TT_APPLE_ID_DEFAULT 0 +#define TT_APPLE_ID_UNICODE_1_1 1 +#define TT_APPLE_ID_ISO_10646 2 +#define TT_APPLE_ID_UNICODE_2_0 3 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_MACINTOSH + */ + +#define TT_MAC_ID_ROMAN 0 +#define TT_MAC_ID_JAPANESE 1 +#define TT_MAC_ID_TRADITIONAL_CHINESE 2 +#define TT_MAC_ID_KOREAN 3 +#define TT_MAC_ID_ARABIC 4 +#define TT_MAC_ID_HEBREW 5 +#define TT_MAC_ID_GREEK 6 +#define TT_MAC_ID_RUSSIAN 7 +#define TT_MAC_ID_RSYMBOL 8 +#define TT_MAC_ID_DEVANAGARI 9 +#define TT_MAC_ID_GURMUKHI 10 +#define TT_MAC_ID_GUJARATI 11 +#define TT_MAC_ID_ORIYA 12 +#define TT_MAC_ID_BENGALI 13 +#define TT_MAC_ID_TAMIL 14 +#define TT_MAC_ID_TELUGU 15 +#define TT_MAC_ID_KANNADA 16 +#define TT_MAC_ID_MALAYALAM 17 +#define TT_MAC_ID_SINHALESE 18 +#define TT_MAC_ID_BURMESE 19 +#define TT_MAC_ID_KHMER 20 +#define TT_MAC_ID_THAI 21 +#define TT_MAC_ID_LAOTIAN 22 +#define TT_MAC_ID_GEORGIAN 23 +#define TT_MAC_ID_ARMENIAN 24 +#define TT_MAC_ID_MALDIVIAN 25 +#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 +#define TT_MAC_ID_TIBETAN 26 +#define TT_MAC_ID_MONGOLIAN 27 +#define TT_MAC_ID_GEEZ 28 +#define TT_MAC_ID_SLAVIC 29 +#define TT_MAC_ID_VIETNAMESE 30 +#define TT_MAC_ID_SINDHI 31 +#define TT_MAC_ID_UNINTERP 32 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_ISO + */ + +#define TT_ISO_ID_7BIT_ASCII 0 +#define TT_ISO_ID_10646 1 +#define TT_ISO_ID_8859_1 2 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_MICROSOFT + */ + +#define TT_MS_ID_SYMBOL_CS 0 +#define TT_MS_ID_UNICODE_CS 1 +#define TT_MS_ID_SJIS 2 +#define TT_MS_ID_GB2312 3 +#define TT_MS_ID_BIG_5 4 +#define TT_MS_ID_WANSUNG 5 +#define TT_MS_ID_JOHAB 6 + + + +/* + * possible values of the language identifier field in the name records of + * the TTF "name" table when the 'Platform' identifier code is + * TT_PLATFORM_MACINTOSH + * + * the canonical source for the Apple assigned Language ID's is at + * http://fonts.apple.com/TTRefMan/RM06/Chap6name.html + */ + +#define TT_MAC_LANGID_ENGLISH 0 +#define TT_MAC_LANGID_FRENCH 1 +#define TT_MAC_LANGID_GERMAN 2 +#define TT_MAC_LANGID_ITALIAN 3 +#define TT_MAC_LANGID_DUTCH 4 +#define TT_MAC_LANGID_SWEDISH 5 +#define TT_MAC_LANGID_SPANISH 6 +#define TT_MAC_LANGID_DANISH 7 +#define TT_MAC_LANGID_PORTUGUESE 8 +#define TT_MAC_LANGID_NORWEGIAN 9 +#define TT_MAC_LANGID_HEBREW 10 +#define TT_MAC_LANGID_JAPANESE 11 +#define TT_MAC_LANGID_ARABIC 12 +#define TT_MAC_LANGID_FINNISH 13 +#define TT_MAC_LANGID_GREEK 14 +#define TT_MAC_LANGID_ICELANDIC 15 +#define TT_MAC_LANGID_MALTESE 16 +#define TT_MAC_LANGID_TURKISH 17 +#define TT_MAC_LANGID_CROATIAN 18 +#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 +#define TT_MAC_LANGID_URDU 20 +#define TT_MAC_LANGID_HINDI 21 +#define TT_MAC_LANGID_THAI 22 +#define TT_MAC_LANGID_KOREAN 23 +#define TT_MAC_LANGID_LITHUANIAN 24 +#define TT_MAC_LANGID_POLISH 25 +#define TT_MAC_LANGID_HUNGARIAN 26 +#define TT_MAC_LANGID_ESTONIAN 27 +#define TT_MAC_LANGID_LETTISH 28 +#define TT_MAC_LANGID_SAAMISK 29 +#define TT_MAC_LANGID_FAEROESE 30 +#define TT_MAC_LANGID_FARSI 31 +#define TT_MAC_LANGID_RUSSIAN 32 +#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 +#define TT_MAC_LANGID_FLEMISH 34 +#define TT_MAC_LANGID_IRISH 35 +#define TT_MAC_LANGID_ALBANIAN 36 +#define TT_MAC_LANGID_ROMANIAN 37 +#define TT_MAC_LANGID_CZECH 38 +#define TT_MAC_LANGID_SLOVAK 39 +#define TT_MAC_LANGID_SLOVENIAN 40 +#define TT_MAC_LANGID_YIDDISH 41 +#define TT_MAC_LANGID_SERBIAN 42 +#define TT_MAC_LANGID_MACEDONIAN 43 +#define TT_MAC_LANGID_BULGARIAN 44 +#define TT_MAC_LANGID_UKRAINIAN 45 +#define TT_MAC_LANGID_BYELORUSSIAN 46 +#define TT_MAC_LANGID_UZBEK 47 +#define TT_MAC_LANGID_KAZAKH 48 +#define TT_MAC_LANGID_AZERBAIJANI 49 +#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 +#define TT_MAC_LANGID_ARMENIAN 51 +#define TT_MAC_LANGID_GEORGIAN 52 +#define TT_MAC_LANGID_MOLDAVIAN 53 +#define TT_MAC_LANGID_KIRGHIZ 54 +#define TT_MAC_LANGID_TAJIKI 55 +#define TT_MAC_LANGID_TURKMEN 56 +#define TT_MAC_LANGID_MONGOLIAN 57 +#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 +#define TT_MAC_LANGID_PASHTO 59 +#define TT_MAC_LANGID_KURDISH 60 +#define TT_MAC_LANGID_KASHMIRI 61 +#define TT_MAC_LANGID_SINDHI 62 +#define TT_MAC_LANGID_TIBETAN 63 +#define TT_MAC_LANGID_NEPALI 64 +#define TT_MAC_LANGID_SANSKRIT 65 +#define TT_MAC_LANGID_MARATHI 66 +#define TT_MAC_LANGID_BENGALI 67 +#define TT_MAC_LANGID_ASSAMESE 68 +#define TT_MAC_LANGID_GUJARATI 69 +#define TT_MAC_LANGID_PUNJABI 70 +#define TT_MAC_LANGID_ORIYA 71 +#define TT_MAC_LANGID_MALAYALAM 72 +#define TT_MAC_LANGID_KANNADA 73 +#define TT_MAC_LANGID_TAMIL 74 +#define TT_MAC_LANGID_TELUGU 75 +#define TT_MAC_LANGID_SINHALESE 76 +#define TT_MAC_LANGID_BURMESE 77 +#define TT_MAC_LANGID_KHMER 78 +#define TT_MAC_LANGID_LAO 79 +#define TT_MAC_LANGID_VIETNAMESE 80 +#define TT_MAC_LANGID_INDONESIAN 81 +#define TT_MAC_LANGID_TAGALOG 82 +#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 +#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 +#define TT_MAC_LANGID_AMHARIC 85 +#define TT_MAC_LANGID_TIGRINYA 86 +#define TT_MAC_LANGID_GALLA 87 +#define TT_MAC_LANGID_SOMALI 88 +#define TT_MAC_LANGID_SWAHILI 89 +#define TT_MAC_LANGID_RUANDA 90 +#define TT_MAC_LANGID_RUNDI 91 +#define TT_MAC_LANGID_CHEWA 92 +#define TT_MAC_LANGID_MALAGASY 93 +#define TT_MAC_LANGID_ESPERANTO 94 +#define TT_MAC_LANGID_WELSH 128 +#define TT_MAC_LANGID_BASQUE 129 +#define TT_MAC_LANGID_CATALAN 130 +#define TT_MAC_LANGID_LATIN 131 +#define TT_MAC_LANGID_QUECHUA 132 +#define TT_MAC_LANGID_GUARANI 133 +#define TT_MAC_LANGID_AYMARA 134 +#define TT_MAC_LANGID_TATAR 135 +#define TT_MAC_LANGID_UIGHUR 136 +#define TT_MAC_LANGID_DZONGKHA 137 +#define TT_MAC_LANGID_JAVANESE 138 +#define TT_MAC_LANGID_SUNDANESE 139 +#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 +#define TT_MAC_LANGID_IRISH_GAELIC 141 +#define TT_MAC_LANGID_BRETON 142 +#define TT_MAC_LANGID_INUKTITUT 143 + + +/* + * possible values of the language identifier field in the name records of + * the TTF "name" table when the 'Platform' identifier code is + * TT_PLATFORM_MICROSOFT + * + * the canonical source for the MS assigned LCID's is at + * http://www.microsoft.com/typography/OTSPEC/lcid-cp.txt + */ + +#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 +#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 +#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01 +#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 +#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 +#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 +#define TT_MS_LANGID_ARABIC_TUNISIA 0x1c01 +#define TT_MS_LANGID_ARABIC_OMAN 0x2001 +#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 +#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 +#define TT_MS_LANGID_ARABIC_JORDAN 0x2c01 +#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 +#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 +#define TT_MS_LANGID_ARABIC_UAE 0x3801 +#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3c01 +#define TT_MS_LANGID_ARABIC_QATAR 0x4001 +#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 +#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 +#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 +#define TT_MS_LANGID_CHINESE_PRC 0x0804 +#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04 +#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 +#define TT_MS_LANGID_CHINESE_MACAU 0x1404 +#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 +#define TT_MS_LANGID_DANISH_DENMARK 0x0406 +#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 +#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 +#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0c07 +#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 +#define TT_MS_LANGID_GREEK_GREECE 0x0408 +#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 +#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 +#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09 +#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 +#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 +#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 +#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1c09 +#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 +#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 +#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 +#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09 +#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 +#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 +#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a +#define TT_MS_LANGID_SPANISH_MEXICO 0x080a +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a +#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100a +#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140a +#define TT_MS_LANGID_SPANISH_PANAMA 0x180a +#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1c0a +#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200a +#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240a +#define TT_MS_LANGID_SPANISH_PERU 0x280a +#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2c0a +#define TT_MS_LANGID_SPANISH_ECUADOR 0x300a +#define TT_MS_LANGID_SPANISH_CHILE 0x340a +#define TT_MS_LANGID_SPANISH_URUGUAY 0x380a +#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3c0a +#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400a +#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440a +#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a +#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a +#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a +#define TT_MS_LANGID_FINNISH_FINLAND 0x040b +#define TT_MS_LANGID_FRENCH_FRANCE 0x040c +#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c +#define TT_MS_LANGID_FRENCH_CANADA 0x0c0c +#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c +#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c +#define TT_MS_LANGID_FRENCH_MONACO 0x180c +#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d +#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e +#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f +#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 +#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 +#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 +#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 +#define TT_MS_LANGID_POLISH_POLAND 0x0415 +#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 +#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a +#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a +#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a +#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b +#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c +#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d +#define TT_MS_LANGID_SWEDISH_FINLAND 0x081d +#define TT_MS_LANGID_THAI_THAILAND 0x041e +#define TT_MS_LANGID_TURKISH_TURKEY 0x041f +#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 +#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 +#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 +#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 +#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 +#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 +#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 +#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0428 +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a +#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b +#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042c +#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082c +#define TT_MS_LANGID_BASQUE_SPAIN 0x042d +#define TT_MS_LANGID_SORBIAN_GERMANY 0x042e +#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042f +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 +#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 +#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 +#define TT_MS_LANGID_HINDI_INDIA 0x0439 +#define TT_MS_LANGID_MALTESE_MALTA 0x043a +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c +#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e +#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e +#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f +#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 +#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 +#define TT_MS_LANGID_BENGALI_INDIA 0x0445 +#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 +#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 +#define TT_MS_LANGID_ORIYA_INDIA 0x0448 +#define TT_MS_LANGID_TAMIL_INDIA 0x0449 +#define TT_MS_LANGID_TELUGU_INDIA 0x044a +#define TT_MS_LANGID_KANNADA_INDIA 0x044b +#define TT_MS_LANGID_MALAYALAM_INDIA 0x044c +#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d +#define TT_MS_LANGID_MARATHI_INDIA 0x044e +#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f +#define TT_MS_LANGID_KONKANI_INDIA 0x0457 + + +/* + * possible values of the 'Name' identifier field in the name records of + * the TTF "name" table. These values are platform independent. + */ + +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 +/* the following values are from the OpenType spec */ +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 +/* number 15 is reserved */ +#define TT_NAME_ID_PREFERRED_FAMILY 16 +#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 + + +/* + * Bit Mask values for the Unicode Ranges from the TTF "OS2 " table. + */ + +/* General Scripts Area */ + +/* Bit 0 C0 Controls and Basic Latin */ +#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0000-U+007F */ +/* Bit 1 C1 Controls and Latin-1 Supplement */ +#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ +/* Bit 2 Latin Extended-A */ +#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ +/* Bit 3 Latin Extended-B */ +#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ +/* Bit 4 IPA Extensions */ +#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ +/* Bit 5 Spacing Modifier Letters */ +#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ +/* Bit 6 Combining Diacritical Marks */ +#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ +/* Bit 7 Greek */ +#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ +/* Bit 8 is reserved (was: Greek Symbols and Coptic) */ +/* Bit 9 Cyrillic */ +#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ +/* Bit 10 Armenian */ +#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ +/* Bit 11 Hebrew */ +#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ +/* Bit 12 is reserved (was: Hebrew Extended) */ +/* Bit 13 Arabic */ +#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ +/* Bit 14 is reserved (was: Arabic Extended) */ +/* Bit 15 Devanagari */ +#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ +/* Bit 16 Bengali */ +#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ +/* Bit 17 Gurmukhi */ +#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ +/* Bit 18 Gujarati */ +#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ +/* Bit 19 Oriya */ +#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ +/* Bit 20 Tamil */ +#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ +/* Bit 21 Telugu */ +#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ +/* Bit 22 Kannada */ +#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ +/* Bit 23 Malayalam */ +#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ +/* Bit 24 Thai */ +#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ +/* Bit 25 Lao */ +#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ +/* Bit 26 Georgian */ +#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ +/* Bit 27 is reserved (was Georgian Extended) */ +/* Bit 28 Hangul Jamo */ +#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ +/* Bit 29 Latin Extended Additional */ +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ +/* Bit 30 Greek Extended */ +#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ + +/* Symbols Area */ + +/* Bit 31 General Punctuation */ +#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ +/* Bit 32 Superscripts And Subscripts */ +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ +/* Bit 33 Currency Symbols */ +#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ +/* Bit 34 Combining Diacritical Marks For Symbols */ +#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ +/* Bit 35 Letterlike Symbols */ +#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ +/* Bit 36 Number Forms */ +#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ +/* Bit 37 Arrows */ +#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ +/* Bit 38 Mathematical Operators */ +#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ +/* Bit 39 Miscellaneous Technical */ +#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ +/* Bit 40 Control Pictures */ +#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ +/* Bit 41 Optical Character Recognition */ +#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ +/* Bit 42 Enclosed Alphanumerics */ +#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ +/* Bit 43 Box Drawing */ +#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ +/* Bit 44 Block Elements */ +#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ +/* Bit 45 Geometric Shapes */ +#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ +/* Bit 46 Miscellaneous Symbols */ +#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ +/* Bit 47 Dingbats */ +#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ + +/* CJK Phonetics and Symbols Area */ + +/* Bit 48 CJK Symbols And Punctuation */ +#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ +/* Bit 49 Hiragana */ +#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ +/* Bit 50 Katakana */ +#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ +/* Bit 51 Bopomofo */ +#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ +/* Bit 52 Hangul Compatibility Jamo */ +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ +/* Bit 53 CJK Miscellaneous */ +#define TT_UCR_CJK_MISC (1L << 21) /* U+3190-U+319F */ +/* Bit 54 Enclosed CJK Letters And Months */ +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ +/* Bit 55 CJK Compatibility */ +#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ + +/* Hangul Syllables Area */ + +/* Bit 56 Hangul */ +#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ + +/* Surrogates Area */ + +/* Bit 57 Surrogates */ +#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DFFF */ +/* Bit 58 is reserved for Unicode SubRanges */ + +/* CJK Ideographs Area */ + +/* Bit 59 CJK Unified Ideographs */ +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ + +/* Private Use Area */ + +/* Bit 60 Private Use */ +#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ + +/* Compatibility Area and Specials */ + +/* Bit 61 CJK Compatibility Ideographs */ +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+F900-U+FAFF */ +/* Bit 62 Alphabetic Presentation Forms */ +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ +/* Bit 63 Arabic Presentation Forms-A */ +#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FSFF */ +/* Bit 64 Combining Half Marks */ +#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ +/* Bit 65 CJK Compatibility Forms */ +#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE30-U+FE4F */ +/* Bit 66 Small Form Variants */ +#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ +/* Bit 67 Arabic Presentation Forms-B */ +#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFF */ +/* Bit 68 Halfwidth And Fullwidth Forms */ +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ +/* Bit 69 Specials */ +#define TT_UCR_SPECIALS (1L << 5) /* U+FEFF, + U+FFF0-U+FFFF */ +/* Bit 70 Tibetan */ +#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FBF */ + + +/* Some compilers have a very limited length of identifiers. */ +#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) +#define HAVE_LIMIT_ON_IDENTS +#endif + +#ifndef HAVE_LIMIT_ON_IDENTS + +/* + * Here some alias #defines in order to be clearer. + * + * These are not always #defined to stay within the 31 character limit + * which some compilers have. + * + * Credits go to Dave Hoo for pointing out that modern + * Borland compilers (read: from BC++ 3.1 on) can increase this limit. + * If you get a warning with such a compiler, use the -i40 switch. + */ + +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ + TT_UCR_ARABIC_PRESENTATIONS_A +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ + TT_UCR_ARABIC_PRESENTATIONS_B + +#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ + TT_UCR_COMBINING_DIACRITICS +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + TT_UCR_COMBINING_DIACRITICS_SYMB + +#endif /* ndef HAVE_LIMIT_ON_IDENTS */ + +#endif /* FTNAMEID_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/header.h b/Appl/Breadbox/testapps/ttf2/FreeType/header.h new file mode 100644 index 000000000..a7a493192 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/header.h @@ -0,0 +1,49 @@ +/******************************************************************* + * + * Function : + * + * Description : + * + * Input : + * + * Output : + * + * Notes : + * + ******************************************************************/ + +/******************************************************************* + * + * Function : + * + * Description : + * + * Input : None + * + * Output : Error code. + * + ******************************************************************/ + +/******************************************************************* + * + * Function : + * + * Description : + * + ******************************************************************/ + +/******************************************************************* + * + * Component Name (e.g. TTRaster.C) + eventually a version number. + * + * Component Short Description (e.g. Rasterizer). + * + * Copyright 1996 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. + * + ******************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c new file mode 100644 index 000000000..b9ddf1c2a --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -0,0 +1,2219 @@ +/******************************************************************* + * + * ttapi.c + * + * High-level interface implementation + * + * 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. + * + * Notes: + * + * This file is used to implement most of the functions that are + * defined in the file "freetype.h". However, two functions are + * implemented elsewhere : + * + * TT_MulDiv and TT_MulFix are in ttcalc.h/ttcalc.c + * + ******************************************************************/ + +#include "ttconfig.h" + +#include "freetype.h" +#include "ttengine.h" +#include "ttcalc.h" +#include "ttmemory.h" +#include "ttcache.h" +#include "ttfile.h" +#include "ttobjs.h" +#include "ttload.h" +#include "ttgload.h" +#include "ttraster.h" +#include "ttextend.h" + + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_api + + +#ifdef TT_STATIC_RASTER +#define RAS_OPS /* void */ +#define RAS_OP /* void */ +#else +#define RAS_OPS ((TRaster_Instance*)_engine->raster_component), +#define RAS_OP ((TRaster_Instance*)_engine->raster_component) +#endif /* TT_STATIC_RASTER */ + + +#define RENDER_Glyph( glyph, target ) \ + Render_Glyph( RAS_OPS glyph, target ) + +#define RENDER_Gray_Glyph( glyph, target, palette ) \ + Render_Gray_Glyph( RAS_OPS glyph, target, palette ) + + + +/******************************************************************* + * + * Function : TT_FreeType_Version + * + * Description : Returns the major and minor version of the library. + * + * Input : major, minor addresses + * + * Output : Error code. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_FreeType_Version( int *major, int *minor ) + { + if ( !major || !minor ) + return TT_Err_Invalid_Argument; + + *major = TT_FREETYPE_MAJOR; + *minor = TT_FREETYPE_MINOR; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Init_FreeType + * + * Description : The library's engine initializer. This function + * must be called prior to any call. + * + * Input : engine pointer to a FreeType engine instance + * + * Output : Error code. + * + * MT-Note : This function should be called each time you want + * to create a TT_Engine. It is not necessarily thread + * safe depending on the implementations of ttmemory, + * ttfile and ttmutex, so take care. Their default + * implementations are safe, however. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Init_FreeType( TT_Engine* engine ) + { + PEngine_Instance _engine; + + TT_Error error; + int n; + + + /* first of all, initialize memory sub-system */ + error = TTMemory_Init(); + if ( error ) + return error; + + /* Allocate engine instance */ + if ( ALLOC( _engine, sizeof ( TEngine_Instance ) ) ) + return error; + +#undef TT_FAIL +#define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok + + /* Initalize components */ + if ( TT_FAIL( TTFile_Init ) || + TT_FAIL( TTCache_Init ) || +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + TT_FAIL( TTExtend_Init ) || +#endif + TT_FAIL( TTObjs_Init ) || + TT_FAIL( TTRaster_Init ) ) + goto Fail; + +#undef TT_FAIL + + /* set the gray palette defaults: 0 to 4 */ + for ( n = 0; n < 5; n++ ) + _engine->raster_palette[n] = (Byte)n; /* Conversion ok, some warn */ + + /* create the engine lock */ + MUTEX_Create( _engine->lock ); + + HANDLE_Set( *engine, _engine ); + return TT_Err_Ok; + + Fail: + TT_Done_FreeType( *engine ); + HANDLE_Set( *engine, NULL ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_FreeType + * + * Description : The library's engine finalizer. This function + * will discard all active face and glyph objects + * from the heap. + * + * Input : engine FreeType engine instance + * + * Output : Error code. + * + * MT-Note : Destroys an engine. Not necessarily thread-safe + * depending on the implementations of ttmemory, + * ttfile and ttmutex. The default implementations + * are safe, however. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_FreeType( TT_Engine engine ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + + if ( !_engine ) + return TT_Err_Ok; + + MUTEX_Destroy( _engine->lock ); + + TTRaster_Done( _engine ); + TTObjs_Done ( _engine ); +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + TTExtend_Done( _engine ); +#endif + TTCache_Done ( _engine ); + TTFile_Done ( _engine ); + FREE( _engine ); + + TTMemory_Done(); + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/******************************************************************* + * + * Function : TT_Set_Raster_Gray_Palette + * + * Description : Sets the gray-levels palette used for font + * smoothing. + * + * Input : engine FreeType engine instance + * palette address of palette (a 5 byte array) + * + * Output : Invalid argument if 'palette' is NULL. + * + * MT-Note: NO! Unprotected modification of an engine's palette. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, + Byte* palette ) + { + int i; + + + if ( !palette ) + return TT_Err_Invalid_Argument; + + for ( i = 0; i < 5; i++ ) + HANDLE_Engine( engine )->raster_palette[i] = (Byte)palette[i]; + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/******************************************************************* + * + * Function : TT_Open_Face + * + * Description : Creates a new face object from a given font file. + * + * Input : engine FreeType engine instance + * fontPathName the font file's pathname + * face adress of returned face handle + * + * Output : Error code. + * + * Note : The face handle is set to NULL in case of failure. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Open_Face( TT_Engine engine, + const TT_Text* fontPathName, + TT_Face* face ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + TFont_Input input; + TT_Error error; + TT_Stream stream; + PFace _face; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + /* open the file */ + error = TT_Open_Stream( fontPathName, &stream ); + if ( error ) + return error; + + input.stream = stream; + input.fontIndex = 0; + input.engine = _engine; + + /* Create and load the new face object - this is thread-safe */ + error = CACHE_New( _engine->objs_face_cache, + _face, + &input ); + + /* Set the handle */ + HANDLE_Set( *face, _face ); + + if ( error ) + goto Fail; + + return TT_Err_Ok; + + Fail: + TT_Close_Stream( &stream ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Open_Collection + * + * Description : Creates a new face object from a given font file. + * + * Input : engine FreeType engine instance + * collectionPathName the font file's pathname + * fontIndex index of font in TrueType collection + * face adress of returned face handle + * + * Output : Error code. + * + * Note : The face handle is set to NULL in case of failure. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Open_Collection( TT_Engine engine, + const TT_Text* collectionPathName, + TT_ULong fontIndex, + TT_Face* face ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + TFont_Input input; + TT_Error error; + TT_Stream stream; + PFace _face; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + /* open the file */ + error = TT_Open_Stream( collectionPathName, &stream ); + if ( error ) + return error; + + input.stream = stream; + input.fontIndex = fontIndex; + input.engine = _engine; + + /* Create and load the new face object - this is thread-safe */ + error = CACHE_New( _engine->objs_face_cache, + _face, + &input ); + + /* Set the handle */ + HANDLE_Set( *face, _face ); + + if ( error ) + goto Fail; + + return TT_Err_Ok; + + Fail: + TT_Close_Stream( &stream ); + + return error; + } + + +/******************************************************************* + * + * Function : TT_Get_Face_Properties + * + * Description : Returns face properties. + * + * Input : face the face handle + * properties address of target properties record + * + * Output : Error code. + * + * Note : Currently, max_Faces is always set to 0. + * + * MT-Note : YES! Reads only permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Face_Properties( TT_Face face, + TT_Face_Properties* properties ) + { + PFace _face = HANDLE_Face( face ); + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + properties->num_Glyphs = _face->numGlyphs; + properties->max_Points = _face->maxPoints; + properties->max_Contours = _face->maxContours; + properties->num_CharMaps = _face->numCMaps; + properties->num_Names = _face->nameTable.numNameRecords; + + if ( _face->ttcHeader.DirCount == 0 ) + properties->num_Faces = 1; + else + properties->num_Faces = _face->ttcHeader.DirCount; + + properties->header = &_face->fontHeader; + properties->horizontal = &_face->horizontalHeader; + + if ( _face->verticalInfo ) + properties->vertical = &_face->verticalHeader; + else + properties->vertical = NULL; + + properties->os2 = &_face->os2; + properties->postscript = &_face->postscript; + properties->hdmx = &_face->hdmx; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Set_Face_Pointer + * + * Description : Each face object has one pointer, which use is + * reserved to client applications. The TrueType + * engine never accesses or uses this field. + * + * This function is used to set the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Note : NO! But this function is reserved to "enlightened" + * developers, so it shouldn't be a problem. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Face_Pointer( TT_Face face, + void* data ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + else + faze->generic = data; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Face_Pointer + * + * Description : Each face object has one pointer, which use is + * reserved to client applications. The TrueType + * engine never access or use this field. + * + * This function is used to read the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Note : NO! But this function is reserved to "enlightened" + * developers, so it shouldn't be a problem. + * + ******************************************************************/ + + EXPORT_FUNC + void* TT_Get_Face_Pointer( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return NULL; + else + return faze->generic; + } + + +/******************************************************************* + * + * Function : TT_Get_Face_Metrics + * + * Description : This function returns the original horizontal AND + * vertical metrics as found in the "hmtx" and "vmtx" + * tables. These are the glyphs' left-side-bearings + * and advance widths (horizontal), as well as top + * side bearings and advance heights (vertical). + * + * All are expressed in FONT UNITS, a.k.a. EM + * units. + * + * Input : face The given face handle. + * first Index of first glyph in table. + * last Index of last glyph in table. + * + * leftBearings A pointer to an array of TT_Shorts where the + * left side bearings for the glyphs 'first' + * to 'last' will be returned. If these metrics + * don't interest you, simply set it to NULL. + * + * widths A pointer to an array of TT_UShorts + * where the advance widths for the glyphs + * 'first' to 'last' will be returned. If these + * metrics don't interest you, simply set it + * to NULL. + * + * topBearings A pointer to an array of TT_Shorts where the + * top side bearings for the glyphs 'first' + * to 'last' will be returned. If these metrics + * don't interest you, simply set it to NULL. + * + * heights A pointer to an array of TT_UShorts + * where the advance heights for the glyphs + * 'first' to 'last' will be returned. If these + * metrics don't interest you, simply set it + * to NULL. + * + * Output : Error code. + * + * IMPORTANT NOTE : + * + * As vertical metrics are optional in a TrueType font, this + * function will return an error ( TT_Err_No_Vertical_Data ) + * whenever this function is called on such a face with non-NULL + * 'topBearings' or 'heights' arguments. + * + * When a font has no vertical data, the 'vertical' field in its + * properties structure is set to NULL. + * + * MT-Note : YES! Reads only permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Face_Metrics( TT_Face face, + TT_UShort firstGlyph, + TT_UShort lastGlyph, + TT_Short* leftBearings, + TT_UShort* widths, + TT_Short* topBearings, + TT_UShort* heights ) + { + PFace _face = HANDLE_Face( face ); + UShort num; + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + /* Check the glyph range */ + if ( lastGlyph >= _face->numGlyphs || firstGlyph > lastGlyph ) + return TT_Err_Invalid_Argument; + + num = lastGlyph - firstGlyph; /* number of elements-1 in each array */ + + /* store the left side bearings and advance widths first */ + { + UShort n; + Short left_bearing; + UShort advance_width; + + + for ( n = 0; n <= num; n++ ) + { + TT_Get_Metrics( &_face->horizontalHeader, + firstGlyph + n, &left_bearing, &advance_width ); + + if ( leftBearings ) leftBearings[n] = left_bearing; + if ( widths ) widths[n] = advance_width; + } + } + + /* check for vertical data if topBearings or heights is non-NULL */ + if ( !topBearings && !heights ) + return TT_Err_Ok; + + if ( !_face->verticalInfo ) + return TT_Err_No_Vertical_Data; + + /* store the top side bearings */ + { + UShort n; + Short top_bearing; + UShort advance_height; + + for ( n = 0; n <= num; n++ ) + { + TT_Get_Metrics( (TT_Horizontal_Header*)&_face->verticalHeader, + firstGlyph + n, &top_bearing, &advance_height ); + + if ( topBearings ) topBearings[n] = top_bearing; + if ( heights ) heights[n] = advance_height; + } + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Face + * + * Description : This function is used to close an active face's + * file handle or descriptor. This is useful to save + * system resources, if your application uses tons + * of fonts. + * + * Input : face the given face handle + * + * Output : Error code. + * + * MT-Note : YES! (If ttfile is.) + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Face( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + else + return TT_Flush_Stream( &faze->stream ); + } + + +/******************************************************************* + * + * Function : TT_Close_Face + * + * Description : Closes an opened face object. This function + * will destroy all objects associated to the + * face, except the glyphs. + * + * Input : face the given face handle + * + * Output : Error code. + * + * NOTE : The handle is set to NULL on exit. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Close_Face( TT_Face face ) + { + PFace _face = HANDLE_Face( face ); + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + TT_Close_Stream( &_face->stream ); + + /* delete the face object -- this is thread-safe */ + return CACHE_Done( _face->engine->objs_face_cache, _face ); + } + + +/******************************************************************* + * + * Function : TT_New_Instance + * + * Description : Creates a new instance from a given face. + * + * Input : face parent face handle + * instance address of instance handle + * + * Output : Error code. + * + * Note : The handle is set to NULL in case of failure. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_New_Instance( TT_Face face, + TT_Instance* instance ) + { + TT_Error error; + PFace _face = HANDLE_Face( face ); + PInstance _ins; + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + /* get a new instance from the face's cache -- this is thread-safe */ + error = CACHE_New( &_face->instances, _ins, _face ); + + HANDLE_Set( *instance, _ins ); + + if ( !error ) + { + error = Instance_Init( _ins ); + if ( error ) + { + HANDLE_Set( *instance, NULL ); + CACHE_Done( &_face->instances, _ins ); + } + } + + return error; + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_Resolutions + * + * Description : Resets an instance to a new device resolution. + * + * Input : instance the instance handle + * xResolution new horizontal device resolution in dpi + * yResolution new vertical device resolution in dpi + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolutions must have reasonable values. + * + * MT-Note : You should set the charsize or pixel size immediately + * after this call in multi-threaded programs. This will + * force the instance data to be resetted. Otherwise, you + * may encounter corruption when loading two glyphs from + * the same instance concurrently! + * + * Happily, 99.99% will do just that :-) + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, + TT_UShort xResolution, + TT_UShort yResolution ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + ins->metrics.x_resolution = xResolution; + ins->metrics.y_resolution = yResolution; + ins->valid = FALSE; + + /* In the case of a thread-safe implementation, we immediately */ + /* call Instance_Reset in order to change the instance's variable */ + + /* In the case of a non-threaded build, we simply set the 'valid' */ + /* flag to FALSE, which will force the instance's resetting at */ + /* the next glyph loading */ + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_CharSizes + * + * Description : Resets an instance to new point size. + * + * Input : instance the instance handle + * charWidth the new width in 26.6 char points + * charHeight the new height in 26.6 char points + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolution must have reasonable values. + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_CharSizes( TT_Instance instance, + TT_F26Dot6 charWidth, + TT_F26Dot6 charHeight ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( charWidth < 1 * 64 ) + charWidth = 1 * 64; + + if ( charHeight < 1 * 64 ) + charHeight = 1 * 64; + + ins->metrics.x_scale1 = ( charWidth * ins->metrics.x_resolution ) / 72; + ins->metrics.x_scale2 = ins->owner->fontHeader.Units_Per_EM; + + ins->metrics.y_scale1 = ( charHeight * ins->metrics.y_resolution ) / 72; + ins->metrics.y_scale2 = ins->owner->fontHeader.Units_Per_EM; + + if ( ins->owner->fontHeader.Flags & 8 ) + { + ins->metrics.x_scale1 = (ins->metrics.x_scale1+32) & -64; + ins->metrics.y_scale1 = (ins->metrics.y_scale1+32) & -64; + } + + ins->metrics.x_ppem = ins->metrics.x_scale1 / 64; + ins->metrics.y_ppem = ins->metrics.y_scale1 / 64; + + if ( charWidth > charHeight ) + ins->metrics.pointSize = charWidth; + else + ins->metrics.pointSize = charHeight; + + ins->valid = FALSE; + + return Instance_Reset( ins ); + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_CharSize + * + * Description : Resets an instance to new point size. + * + * Input : instance the instance handle + * charSize the new character size in 26.6 char points + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolution must have reasonable values. + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_CharSize( TT_Instance instance, + TT_F26Dot6 charSize ) + { + return TT_Set_Instance_CharSizes( instance, charSize, charSize ); + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_PixelSizes + * + * Description : Resets an instance to new pixel sizes + * + * Input : instance the instance handle + * pixelWidth the new width in pixels + * pixelHeight the new height in pixels + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolution must have reasonable values. + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, + TT_UShort pixelWidth, + TT_UShort pixelHeight, + TT_F26Dot6 pointSize ) + { + PInstance ins = HANDLE_Instance( instance ); + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( pixelWidth < 1 ) pixelWidth = 1; + if ( pixelHeight < 1 ) pixelHeight = 1; + + ins->metrics.x_ppem = pixelWidth; + ins->metrics.y_ppem = pixelHeight; + ins->metrics.pointSize = pointSize; + + ins->metrics.x_scale1 = ins->metrics.x_ppem * 64L; + ins->metrics.x_scale2 = ins->owner->fontHeader.Units_Per_EM; + ins->metrics.y_scale1 = ins->metrics.y_ppem * 64L; + ins->metrics.y_scale2 = ins->owner->fontHeader.Units_Per_EM; + + ins->valid = FALSE; + + return Instance_Reset( ins ); + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_Transform_Flags + * + * Description : Informs the interpreter about the transformations + * that will be applied to the rendered glyphs. + * + * Input : instance the instance handle + * rotated set to TRUE if the glyph are rotated + * stretched set to TRUE if the glyph are stretched + * + * Output : Error code. + * + * Note : This function is deprecated! It's much better to + * control hinting manually when calling TT_Load_Glyph + * than relying on the font programs... + * + * Never use it, unless calling for trouble ;-) + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, + TT_Bool rotated, + TT_Bool stretched ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + ins->metrics.rotated = rotated; + ins->metrics.stretched = stretched; + ins->valid = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Instance_Metrics + * + * Description : Returns instance metrics. + * + * Input : instance the instance handle + * metrics address of target instance metrics record + * + * Output : Error code. + * + * MT-Note : YES! Reads only semi-permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Instance_Metrics( TT_Instance instance, + TT_Instance_Metrics* metrics ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( !ins->valid ) + Instance_Reset( ins ); + + metrics->pointSize = ins->metrics.pointSize; + + metrics->x_scale = TT_MulDiv( 0x10000, + ins->metrics.x_scale1, + ins->metrics.x_scale2 ); + + metrics->y_scale = TT_MulDiv( 0x10000, + ins->metrics.y_scale1, + ins->metrics.y_scale2 ); + + metrics->x_resolution = ins->metrics.x_resolution; + metrics->y_resolution = ins->metrics.y_resolution; + metrics->x_ppem = ins->metrics.x_ppem; + metrics->y_ppem = ins->metrics.y_ppem; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_Pointer + * + * Description : Each instance has one pointer, which use is + * reserved to client applications. The TrueType + * engine never accesses or uses this field. + * + * This function is used to set the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Note : NO! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_Pointer( TT_Instance instance, + void* data ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + else + ins->generic = data; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Instance_Pointer + * + * Description : Each instance has one pointer, which use is + * reserved to client applications. The TrueType + * engine never accesses or uses this field. + * + * This function is used to read the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Safe : NO! + * + ******************************************************************/ + + EXPORT_FUNC + void* TT_Get_Instance_Pointer( TT_Instance instance ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return NULL; + else + return ins->generic; + } + + +/******************************************************************* + * + * Function : TT_Done_Instance + * + * Description : Closes a given instance. + * + * Input : instance address of instance handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Instance( TT_Instance instance ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + /* delete the instance -- this is thread-safe */ + return CACHE_Done( &ins->owner->instances, ins ); + } + + +/******************************************************************* + * + * Function : TT_New_Glyph + * + * Description : Creates a new glyph object related to a given + * face. + * + * Input : face the face handle + * glyph address of target glyph handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_New_Glyph( TT_Face face, + TT_Glyph* glyph ) + { + TT_Error error; + PFace _face = HANDLE_Face( face ); + PGlyph _glyph; + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + /* get a new glyph from the face's cache -- this is thread-safe */ + error = CACHE_New( &_face->glyphs, _glyph, _face ); + + HANDLE_Set( *glyph, _glyph ); + + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_Glyph + * + * Description : Destroys a given glyph object. + * + * Input : glyph the glyph handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Glyph( TT_Glyph glyph ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + /* delete the engine -- this is thread-safe */ + return CACHE_Done( &_glyph->face->glyphs, _glyph ); + } + + +/******************************************************************* + * + * Function : TT_Load_Glyph + * + * Description : Loads a glyph. + * + * Input : instance the instance handle + * glyph the glyph handle + * glyphIndex the glyph index + * loadFlags flags controlling how to load the glyph + * (none, scaled, hinted, both) + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Load_Glyph( TT_Instance instance, + TT_Glyph glyph, + TT_UShort glyphIndex, + TT_UShort loadFlags ) + { + PInstance _ins; + PGlyph _glyph; + TT_Error error; + + + _ins = HANDLE_Instance( instance ); + + if ( !_ins ) + loadFlags &= ~(TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH); + + if ( (loadFlags & TTLOAD_SCALE_GLYPH) == 0 ) + _ins = 0; + + _glyph = HANDLE_Glyph( glyph ); + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + if ( _ins ) + { + if ( _ins->owner != _glyph->face ) + return TT_Err_Invalid_Face_Handle; + + if ( !_ins->valid ) + { + /* This code can only be called in non thread-safe builds */ + error = Instance_Reset( _ins ); + if ( error ) + return error; + } + } + + return Load_TrueType_Glyph( _ins, _glyph, glyphIndex, loadFlags ); + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Outline + * + * Description : Returns the glyph's outline data. + * + * Input : glyph the glyph handle + * outline address where the glyph outline will be returned + * + * Output : Error code. + * + * MT-Safe : YES! Reads only semi-permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Outline( TT_Glyph glyph, + TT_Outline* outline ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + *outline = _glyph->outline; + outline->owner = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Metrics + * + * Description : Extracts the glyph's horizontal metrics information. + * + * Input : glyph glyph object handle + * metrics address where metrics will be returned + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Metrics( TT_Glyph glyph, + TT_Glyph_Metrics* metrics ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + metrics->bbox = _glyph->metrics.bbox; + metrics->bearingX = _glyph->metrics.horiBearingX; + metrics->bearingY = _glyph->metrics.horiBearingY; + metrics->advance = _glyph->metrics.horiAdvance; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Big_Metrics + * + * Description : Extracts the glyph's big metrics information. + * + * Input : glyph glyph object handle + * metrics address where big metrics will be returned + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, + TT_Big_Glyph_Metrics* metrics ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + *metrics = _glyph->metrics; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Bitmap + * + * Description : Produces a bitmap from a glyph outline. + * + * Input : glyph the glyph container's handle + * map target pixmap description block + * xOffset x offset in fractional pixels (26.6 format) + * yOffset y offset in fractional pixels (26.6 format) + * + * Output : Error code. + * + * Note : Only use integer pixel offsets if you want to preserve + * the fine hints applied to the outline. This means that + * xOffset and yOffset must be multiples of 64! + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set( engine, _engine ); + + outline = _glyph->outline; + /* XXX : For now, use only dropout mode 2 */ + /* outline.dropout_mode = _glyph->scan_type; */ + outline.dropout_mode = 2; + + TT_Translate_Outline( &outline, xOffset, yOffset ); + error = TT_Get_Outline_Bitmap( engine, &outline, map ); + TT_Translate_Outline( &outline, -xOffset, -yOffset ); + + return error; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/******************************************************************* + * + * Function : TT_Get_Glyph_Pixmap + * + * Description : Produces a grayscaled pixmap from a glyph + * outline. + * + * Input : glyph the glyph container's handle + * map target pixmap description block + * xOffset x offset in fractional pixels (26.6 format) + * yOffset y offset in fractional pixels (26.6 format) + * + * Output : Error code. + * + * Note : Only use integer pixel offsets to preserve the fine + * hinting of the glyph and the 'correct' anti-aliasing + * (where vertical and horizontal stems aren't grayed). + * This means that xOffset and yOffset must be multiples + * of 64! + * + * You can experiment with offsets of +32 to get 'blurred' + * versions of the glyphs (a nice effect at large sizes that + * some graphic designers may appreciate :) + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + /* XXX : For now, use only dropout mode 2 */ + /* outline.dropout_mode = _glyph->scan_type; */ + outline.dropout_mode = 2; + + TT_Translate_Outline( &outline, xOffset, yOffset ); + error = TT_Get_Outline_Pixmap( engine, &outline, map ); + TT_Translate_Outline( &outline, -xOffset, -yOffset ); + + return error; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + + static const TT_Outline null_outline + = { 0, 0, NULL, NULL, NULL, 0, 0, 0, 0 }; + + +/******************************************************************* + * + * Function : TT_New_Outline + * + * Description : Creates a new TrueType outline, reserving + * array space for a given number of points and + * contours. + * + * Input : numPoints number of points + * numContours number of contours + * outline address of target outline structure + * + * Output : Error code + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_New_Outline( TT_UShort numPoints, + TT_Short numContours, + TT_Outline* outline ) + { + TT_Error error; + + + if ( !outline ) + return TT_Err_Invalid_Argument; + + *outline = null_outline; + + if ( ALLOC( outline->points, numPoints*2*sizeof ( TT_F26Dot6 ) ) || + ALLOC( outline->flags, numPoints *sizeof ( Byte ) ) || + ALLOC( outline->contours, numContours*sizeof ( UShort ) ) ) + goto Fail; + + outline->n_points = numPoints; + outline->n_contours = numContours; + outline->owner = TRUE; + return TT_Err_Ok; + + Fail: + outline->owner = TRUE; + TT_Done_Outline( outline ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_Outline + * + * Description : Deletes an outline created through TT_New_Outline(). + * Calling this function for outlines returned + * by TT_Get_Glyph_Outline() yields an error. + * + * Input : outline address of outline + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Outline( TT_Outline* outline ) + { + if ( outline ) + { + if ( outline->owner ) + { + FREE( outline->points ); + FREE( outline->flags ); + FREE( outline->contours ); + } + *outline = null_outline; + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + +/******************************************************************* + * + * Function : TT_Get_Outline_Bitmap + * + * Description : Render a TrueType outline into a bitmap. + * Note that the bitmap must be created by the caller. + * + * Input : outline the outline to render + * map the target bitmap + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + if ( !outline || !map ) + return TT_Err_Invalid_Argument; + + MUTEX_Lock( _engine->raster_lock ); + error = RENDER_Glyph( outline, map ); + MUTEX_Release( _engine->raster_lock ); + + return error; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/******************************************************************* + * + * Function : TT_Get_Outline_Pixmap + * + * Description : Render a TrueType outline into a pixmap. + * Note that the pixmap must be created by the caller. + * + * Input : outline the outline to render + * map the target bitmap + * + * Output : Error code + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + if ( !outline || !map ) + return TT_Err_Invalid_Argument; + + MUTEX_Lock( _engine->raster_lock ); + error = RENDER_Gray_Glyph( outline, map, _engine->raster_palette ); + MUTEX_Release( _engine->raster_lock ); + return error; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/******************************************************************* + * + * Function : TT_Copy_Outline + * + * Description : Copy an outline into another. The source and + * target outlines must have the same points and + * contours numbers. + * + * Input : source address of source outline + * target address of target outline + * + * Output : Error code + * + * Note : This function doesn't touch the target outline's 'owner' + * field. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Copy_Outline( TT_Outline* source, + TT_Outline* target ) + { + if ( !source || !target || + source->n_points != target->n_points || + source->n_contours != target->n_contours ) + return TT_Err_Invalid_Argument; + + MEM_Copy( target->points, source->points, + source->n_points * 2 * sizeof ( TT_F26Dot6 ) ); + + MEM_Copy( target->flags, source->flags, + source->n_points * sizeof ( Byte ) ); + + MEM_Copy( target->contours, source->contours, + source->n_contours * sizeof ( Short ) ); + + target->high_precision = source->high_precision; + target->second_pass = target->second_pass; + target->dropout_mode = source->dropout_mode; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Transform_Outline + * + * Description : Applies a simple transformation to an outline. + * + * Input : outline the glyph's outline. Can be extracted + * from a glyph container through + * TT_Get_Glyph_Outline(). + * + * matrix simple matrix with 16.16 fixed floats + * + * Output : Error code (always TT_Err_Ok). + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + void TT_Transform_Outline( TT_Outline* outline, + TT_Matrix* matrix ) + { + UShort n; + TT_F26Dot6 x, y; + TT_Vector* vec; + + + vec = outline->points; + for ( n = 0; n < outline->n_points; n++ ) + { + x = TT_MulFix( vec->x, matrix->xx ) + + TT_MulFix( vec->y, matrix->xy ); + + y = TT_MulFix( vec->x, matrix->yx ) + + TT_MulFix( vec->y, matrix->yy ); + + vec->x = x; + vec->y = y; + vec++; + } + } + + +/******************************************************************* + * + * Function : TT_Transform_Vector + * + * Description : Apply a simple transform to a vector + * + * Input : x, y the vector. + * + * matrix simple matrix with 16.16 fixed floats + * + * Output : None. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + void TT_Transform_Vector( TT_F26Dot6* x, + TT_F26Dot6* y, + TT_Matrix* matrix ) + { + TT_F26Dot6 xz, yz; + + + xz = TT_MulFix( *x, matrix->xx ) + + TT_MulFix( *y, matrix->xy ); + + yz = TT_MulFix( *x, matrix->yx ) + + TT_MulFix( *y, matrix->yy ); + + *x = xz; + *y = yz; + } + + +/******************************************************************* + * + * Function : TT_Translate_Outline + * + * Description : Applies a simple translation. + * + * Input : outline no comment :) + * xOffset + * yOffset + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + void TT_Translate_Outline( TT_Outline* outline, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + UShort n; + TT_Vector* vec = outline->points; + + + for ( n = 0; n < outline->n_points; n++ ) + { + vec->x += xOffset; + vec->y += yOffset; + vec++; + } + } + + +/******************************************************************* + * + * Function : TT_Get_Outline_BBox + * + * Description : Returns an outline's bounding box. + * + * Input : outline no comment :) + * bbox address where the bounding box is returned + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Outline_BBox( TT_Outline* outline, + TT_BBox* bbox ) + { + TT_F26Dot6 x, y; + UShort k; + + + if ( outline && bbox ) + { + if ( outline->n_points == 0 ) + { + bbox->xMin = 0; + bbox->yMin = 0; + bbox->xMax = 0; + bbox->yMax = 0; + } + else + { + TT_Vector* vec = outline->points; + + bbox->xMin = bbox->xMax = vec->x; + bbox->yMin = bbox->yMax = vec->y; + vec++; + + for ( k = 1; k < outline->n_points; k++ ) + { + x = vec->x; + if ( x < bbox->xMin ) bbox->xMin = x; + if ( x > bbox->xMax ) bbox->xMax = x; + y = vec->y; + if ( y < bbox->yMin ) bbox->yMin = y; + if ( y > bbox->yMax ) bbox->yMax = y; + vec++; + } + } + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + + + /* ----------------- character mappings support ------------- */ + +/******************************************************************* + * + * Function : TT_Get_CharMap_Count + * + * Description : Returns the number of charmaps in a given face. + * + * Input : face face object handle + * + * Output : Number of tables. -1 in case of error (bad handle). + * + * Note : DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! + * + * It is retained for backwards compatibility only and will + * fail on 16bit systems. + * + * MT-Safe : YES ! + * + ******************************************************************/ + + EXPORT_FUNC + int TT_Get_CharMap_Count( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + return ( faze ? faze->numCMaps : -1 ); + } + + +/******************************************************************* + * + * Function : TT_Get_CharMap_ID + * + * Description : Returns the ID of a given charmap. + * + * Input : face face object handle + * charmapIndex index of charmap in directory + * platformID address of returned platform ID + * encodingID address of returned encoding ID + * + * Output : error code + * + * MT-Safe : YES ! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_CharMap_ID( TT_Face face, + TT_UShort charmapIndex, + TT_UShort* platformID, + TT_UShort* encodingID ) + { + PCMapTable cmap; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( charmapIndex >= faze->numCMaps ) + return TT_Err_Invalid_Argument; + + cmap = faze->cMaps + charmapIndex; + + *platformID = cmap->platformID; + *encodingID = cmap->platformEncodingID; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_CharMap + * + * Description : Looks up a charmap. + * + * Input : face face object handle + * charmapIndex index of charmap in directory + * charMap address of returned charmap handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_CharMap( TT_Face face, + TT_UShort charmapIndex, + TT_CharMap* charMap ) + { + TT_Error error; + TT_Stream stream; + PCMapTable cmap; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( charmapIndex >= faze->numCMaps ) + return TT_Err_Invalid_Argument; + + cmap = faze->cMaps + charmapIndex; + + /* Load table if needed */ + error = TT_Err_Ok; + + /* MT-NOTE: We're modifying the face object, so protect it. */ + MUTEX_Lock( faze->lock ); + + if ( !cmap->loaded ) + { + (void)USE_Stream( faze->stream, stream ); + if ( !error ) + { + error = CharMap_Load( cmap, stream ); + DONE_Stream( stream ); + } + + if ( error ) + cmap = NULL; + else + cmap->loaded = TRUE; + } + MUTEX_Release( faze->lock ); + + HANDLE_Set( *charMap, cmap ); + + return error; + } + + +/******************************************************************* + * + * Function : TT_Char_Index + * + * Description : Returns the glyph index corresponding to + * a given character code defined for the 'charmap'. + * + * Input : charMap charmap handle + * charcode character code + * + * Output : glyph index. + * + * Notes : Character code 0 is the unknown glyph, which should never + * be displayed. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_UShort TT_Char_Index( TT_CharMap charMap, + TT_UShort charCode ) + { + PCMapTable cmap = HANDLE_CharMap( charMap ); + + + if ( !cmap ) + return 0; /* we return 0 in case of invalid char map */ + + return CharMap_Index( cmap, charCode ); + } + + +/******************************************************************* + * + * Function : TT_Get_Name_Count + * + * Description : Returns the number of strings found in the + * name table. + * + * Input : face face handle + * + * Output : number of strings. + * + * Notes : Returns -1 on error (invalid handle). + * + * DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! + * + * It is retained for backwards compatibility only and will + * fail on 16bit systems. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + int TT_Get_Name_Count( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return -1; + + return faze->nameTable.numNameRecords; + } + + +/******************************************************************* + * + * Function : TT_Get_Name_ID + * + * Description : Returns the IDs of the string number 'nameIndex' + * in the name table of a given face. + * + * Input : face face handle + * nameIndex index of string. First is 0 + * platformID addresses of returned IDs + * encodingID + * languageID + * nameID + * + * Output : Error code. + * + * Notes : Some files have a corrupt or unusual name table, with some + * entries having a platformID > 3. These can usually + * be ignored by a client application. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Name_ID( TT_Face face, + TT_UShort nameIndex, + TT_UShort* platformID, + TT_UShort* encodingID, + TT_UShort* languageID, + TT_UShort* nameID ) + { + TNameRec* namerec; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( nameIndex >= faze->nameTable.numNameRecords ) + return TT_Err_Invalid_Argument; + + namerec = faze->nameTable.names + nameIndex; + + *platformID = namerec->platformID; + *encodingID = namerec->encodingID; + *languageID = namerec->languageID; + *nameID = namerec->nameID; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Name_String + * + * Description : Returns the address and length of a given + * string found in the name table. + * + * Input : face face handle + * nameIndex string index + * stringPtr address of returned pointer to string + * length address of returned string length + * + * Output : Error code. + * + * Notes : If the string's platformID is invalid, + * stringPtr is NULL, and length is 0. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Name_String( TT_Face face, + TT_UShort nameIndex, + TT_String** stringPtr, + TT_UShort* length ) + { + TNameRec* namerec; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( nameIndex >= faze->nameTable.numNameRecords ) + return TT_Err_Invalid_Argument; + + namerec = faze->nameTable.names + nameIndex; + + *stringPtr = (String*)namerec->string; + *length = namerec->stringLength; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Font_Data + * + * Description : Loads any font table into client memory. + * + * Input : face Face object to look for. + * + * tag Tag of table to load. Use the value 0 if you + * want to access the whole font file, else set + * this parameter to a valid TrueType table tag + * that you can forge with the MAKE_TT_TAG + * macro. + * + * offset Starting offset in the table (or the file + * if tag == 0). + * + * buffer Address of target buffer + * + * length Address of decision variable: + * + * if length == NULL: + * Load the whole table. Returns an + * error if 'offset' != 0. + * + * if *length == 0 : + * Exit immediately, returning the + * length of the given table, or of + * the font file, depending on the + * value of 'tag'. + * + * if *length != 0 : + * Load the next 'length' bytes of + * table or font, starting at offset + * 'offset' (in table or font too). + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Font_Data( TT_Face face, + TT_ULong tag, + TT_Long offset, + void* buffer, + TT_Long* length ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + return Load_TrueType_Any( faze, tag, offset, buffer, length ); + } + + + /************************ callback definition ******************/ + + /* Register a new callback to the TrueType engine -- this should */ + /* only be used by higher-level libraries, not typical clients */ + /* */ + /* This is not part of the current FreeType release, thus */ + /* undefined... */ + +#if 0 + EXPORT_FUNC + TT_Error TT_Register_Callback( TT_Engine engine, + int callback_id, + void* callback_ptr ) + { + PEngine_Instance eng = HANDLE_Engine( engine ); + + + if ( !eng ) + return TT_Err_Invalid_Argument; + + /* currently, we only support one callback */ + if (callback_id != TT_Callback_Glyph_Outline_Load) + return TT_Err_Invalid_Argument; + + eng->glCallback = (TT_Glyph_Loader_Callback)callback_ptr; + return TT_Err_Ok; + } +#endif /* 0 */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c new file mode 100644 index 000000000..effa5c824 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -0,0 +1,463 @@ +/******************************************************************* + * + * ttcache.c 1.1 + * + * Generic object cache + * + * 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. + * + * Changes between 1.1 and 1.0: + * + * - introduced the refresher and finalizer in the cache class + * definition/implementation. + * + ******************************************************************/ + +#include "ttengine.h" +#include "ttmemory.h" +#include "ttcache.h" +#include "ttobjs.h" +#include "ttdebug.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_cache + +#define ZERO_List( list ) list = NULL + +/* The macro FREE_Elements aliases the current engine instance's */ +/* free list_elements recycle list. */ +#define FREE_Elements ( engine->list_free_elements ) + +/* Redefinition of LOCK and UNLOCK macros for New_Element and Done_Element */ +/* Note: The macros are redefined below for the cache functions */ + +#undef LOCK +#define LOCK() MUTEX_Lock ( engine->lock ) + +#undef UNLOCK +#define UNLOCK() MUTEX_Release( engine->lock ) + +/******************************************************************* + * + * Function : Element_New + * + * Description : Gets a new (either fresh or recycled) list + * element. The element is unlisted. + * + * Input : None + * + * Output : List element address. NULL if out of memory. + * + ******************************************************************/ + + static + PList_Element Element_New( PEngine_Instance engine ) + { + PList_Element element; + + + LOCK(); + if ( FREE_Elements ) + { + element = (PList_Element)FREE_Elements; + FREE_Elements = element->next; + } + else + { + if ( !MEM_Alloc( element, sizeof ( TList_Element ) ) ) + { + element->next = NULL; + element->data = NULL; + } + } + + /* Note: in case of failure, Alloc sets the pointer to NULL */ + UNLOCK(); + + return element; + } + + +/******************************************************************* + * + * Function : Element_Done + * + * Description : Recycles an unlinked list element. + * + * Input : The list element to recycle. It _must_ be unlisted. + * + * Output : none. + * + * Note : This function doesn't check the element. + * + ******************************************************************/ + + static + void Element_Done( PEngine_Instance engine, + PList_Element element ) + { + LOCK(); + /* Simply add the list element to the recycle list */ + element->next = (PList_Element)FREE_Elements; + FREE_Elements = element; + UNLOCK(); + } + + +/* Redefinition of LOCK and UNLOCK macros for the cache functions */ +/* Note: The macros are defined above for the list element functions */ + +#undef LOCK +#define LOCK() MUTEX_Lock( *cache->lock ) + +#undef UNLOCK +#define UNLOCK() MUTEX_Release( *cache->lock ) + + +/******************************************************************* + * + * Function : Cache_Create + * + * Description : Creates a new cache that will be used to list + * and recycle several objects of the same class. + * + * Input : clazz a pointer to the cache's class. This is + * a simple structure that describes the + * the cache's object types and recycling + * limits. + * + * cache address of cache to create + * + * lock address of the mutex to use for this + * cache. The mutex will be used to protect + * the cache's lists. Use NULL for unprotected + * cache. + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_Create( PEngine_Instance engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ) + { + cache->engine = engine; + cache->clazz = clazz; + cache->lock = lock; + cache->idle_count = 0; + + ZERO_List( cache->active ); + ZERO_List( cache->idle ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Cache_Destroy + * + * Description : Destroys a cache and all its idle and active + * objects. This will call each object's destructor + * before freeing it. + * + * Input : cache address of cache to destroy + * + * Output : error code. + * + * Note: This function is not MT-Safe, as we assume that a client + * isn't stupid enough to use an object while destroying it. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_Destroy( TCache* cache ) + { + PDestructor destroy; + PList_Element current; + PList_Element next; + + + /* now destroy all active and idle listed objects */ + + /* get the destructor function */ + destroy = cache->clazz->done; + + /* destroy all elements in active list */ + current = cache->active; + while ( current ) + { + next = current->next; + destroy( current->data ); + FREE( current->data ); + + Element_Done( cache->engine, current ); + current = next; + } + ZERO_List(cache->active); + + /* destroy all elements in idle list */ + current = cache->idle; + while ( current ) + { + next = current->next; + destroy( current->data ); + FREE( current->data ); + + Element_Done( cache->engine, current ); + current = next; + } + ZERO_List(cache->idle); + + cache->clazz = NULL; + cache->idle_count = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Cache_New + * + * Description : Extracts a new object from a cache. This will + * try to recycle an idle object, if any is found. + * Otherwise, a new object will be allocated and + * built (by calling its constructor). + * + * Input : cache address of cache to use + * new_object address of target pointer to the 'new' + * object + * parent_object this pointer is passed to a new object + * constructor (unused if object is + * recycled) + * + * Output : Error code. + * + * Notes: This function is thread-safe, each cache list is protected + * through the cache's mutex, if there is one... + * + * *new_object will be set to NULL in case of failure. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_New( TCache* cache, + void** new_object, + void* parent_object ) + { + TT_Error error; + PList_Element current; + PConstructor build; + PRefresher reset; + void* object; + + + LOCK(); + current = cache->idle; + if ( current ) + { + cache->idle = current->next; + cache->idle_count--; + } + UNLOCK(); + + if ( current ) + { + object = current->data; + reset = cache->clazz->reset; + if ( reset ) + { + error = reset( object, parent_object ); + if ( error ) + { + LOCK(); + current->next = cache->idle; + cache->idle = current; + cache->idle_count++; + UNLOCK(); + goto Exit; + } + } + } + else + { + /* if no object was found in the cache, create a new one */ + build = cache->clazz->init; + + if ( MEM_Alloc( object, cache->clazz->object_size ) ) + goto Memory_Fail; + + current = Element_New( cache->engine ); + if ( !current ) + goto Memory_Fail; + + current->data = object; + + error = build( object, parent_object ); + if ( error ) + { + Element_Done( cache->engine, current ); + goto Fail; + } + } + + LOCK(); + current->next = cache->active; + cache->active = current; + UNLOCK(); + + *new_object = current->data; + return TT_Err_Ok; + + Exit: + *new_object = NULL; + return error; + + Memory_Fail: + error = TT_Err_Out_Of_Memory; + + Fail: + FREE( object ); + goto Exit; + } + + +/******************************************************************* + * + * Function : Cache_Done + * + * Description : Releases an object to the cache. This will either + * recycle or destroy the object, based on the cache's + * class and state. + * + * Input : cache the cache to use + * data the object to recycle/discard + * + * Output : error code. + * + * Notes : The object's destructor is called only when + * the objectwill be effectively destroyed by this + * function. This will not happen during recycling. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_Done( TCache* cache, void* data ) + { + TT_Error error; + PList_Element element; + PList_Element prev; + PFinalizer finalize; + Long limit; + Bool destroy; + + + /* Look for object in active list */ + LOCK(); + + element = cache->active; + prev = NULL; + while ( element ) + { + if ( element->data == data ) + { + if ( prev ) + prev->next = element->next; + else + cache->active = element->next; + goto Suite; + } + prev = element; + element = element->next; + } + + UNLOCK(); + return TT_Err_Unlisted_Object; + + Suite: + + limit = cache->clazz->idle_limit; + destroy = (cache->idle_count >= limit); + UNLOCK(); + + if ( destroy ) + { + /* destroy the object when the cache is full */ + cache->clazz->done( element->data ); + FREE( element->data ); + Element_Done( cache->engine, element ); + } + else + { + /* Finalize the object before adding it to the */ + /* idle list. Return the error if any is found. */ + + finalize = cache->clazz->finalize; + if ( finalize ) + { + error = finalize( element->data ); + if ( error ) + goto Exit; + + /* Note: a failure at finalize time is a severe bug in */ + /* the engine, which is why we allow ourselves to */ + /* lose the object in this case. A finalizer should */ + /* have its own error codes to spot this kind of */ + /* problems easily. */ + } + + LOCK(); + element->next = cache->idle; + cache->idle = element; + cache->idle_count++; + UNLOCK(); + } + + error = TT_Err_Ok; + + Exit: + return error; + } + + + LOCAL_FUNC + TT_Error TTCache_Init( PEngine_Instance engine ) + { + /* Create list elements mutex */ + FREE_Elements = NULL; + return TT_Err_Ok; + } + + + LOCAL_FUNC + TT_Error TTCache_Done( PEngine_Instance engine ) + { + /* We don't protect this function, as this is the end of the engine's */ + /* execution.. */ + PList_Element element, next; + + + /* frees the recycled list elements */ + element = FREE_Elements; + while ( element ) + { + next = element->next; + FREE( element ); + element = next; + } + return TT_Err_Ok; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h new file mode 100644 index 000000000..66d84bab0 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h @@ -0,0 +1,216 @@ +/******************************************************************* + * + * ttcache.h 1.1 + * + * Generic object cache + * + * 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. + * + * + * This component defines and implements object caches. + * + * An object class is a structure layout that encapsulate one + * given type of data used by the FreeType engine. Each object + * class is completely described by: + * + * - a 'root' or 'leading' structure containing the first + * important fields of the class. The root structure is + * always of fixed size. + * + * It is implemented as a simple C structure, and may + * contain several pointers to sub-tables that can be + * sized and allocated dynamically. + * + * Examples: TFace, TInstance, TGlyph & TExecution_Context + * (defined in 'ttobjs.h') + * + * - we make a difference between 'child' pointers and 'peer' + * pointers. A 'child' pointer points to a sub-table that is + * owned by the object, while a 'peer' pointer points to any + * other kind of data the object isn't responsible for. + * + * An object class is thus usually a 'tree' of 'child' tables. + * + * - each object class needs a constructor and a destructor. + * + * A constructor is a function which receives the address of + * freshly allocated and zeroed object root structure and + * 'builds' all the valid child data that must be associated + * to the object before it becomes 'valid'. + * + * A destructor does the inverse job: given the address of + * a valid object, it must discard all its child data and + * zero its main fields (essentially the pointers and array + * sizes found in the root fields). + * + * + * Important notes: + * + * When the constructor fails to allocate an object, it must + * return immediately with an error code, and not try to release + * what it has previously allocated before the error. The cache + * manager detects the error and calls the destructor on the + * partial object, before returning the error to the caller (along + * with a NULL pointer for the "new" object). + * + * The destructor must thus be able to deal with "partial objects", + * i.e., objects where only part of the child tables are allocated, + * and only release these ones. As the TT_Free() function accepts + * a NULL parameter (and returns successfuly in this case), no check + * is really necessary when using the macro 'FREE()'. + * + * Currently, there is no check in the cache manager to see if a + * destructor fails (double error state!). + * + * This scheme is more compact and more maintanable than the one + * where de-allocation code is duplicated in the constructor + * _and_ the destructor. + * + * + * + * Changes between 1.1 and 1.0: + * + * - introduced the refreshed and finalizer class definition/implementation + * - inserted an engine instance pointer in the cache structure + * + ******************************************************************/ + +#ifndef TTCACHE_H +#define TTCACHE_H + +#include "tttypes.h" +#include "ttconfig.h" +#include "ttmutex.h" + +#ifdef __cplusplus + extern "C" { +#endif + + typedef TT_Error TConstructor( void* object, + void* parent ); + + typedef TT_Error TDestructor ( void* object ); + + typedef TConstructor TRefresher; + typedef TDestructor TFinalizer; + + typedef TConstructor* PConstructor; + typedef TDestructor* PDestructor; + typedef TRefresher* PRefresher; + typedef TFinalizer* PFinalizer; + + + /* A Cache class record holds the data necessary to define */ + /* a cache kind. */ + struct TCache_Class_ + { + ULong object_size; + Long idle_limit; + PConstructor init; + PDestructor done; + PRefresher reset; + PFinalizer finalize; + }; + + typedef struct TCache_Class_ TCache_Class; + typedef TCache_Class* PCache_Class; + + + + /* Simple list node record. A list element is said to be 'unlinked' */ + /* when it doesn't belong to any list. */ + struct TList_Element_; + + typedef struct TList_Element_ TList_Element; + typedef TList_Element* PList_Element; + + struct TList_Element_ + { + PList_Element next; + void* data; + }; + + + /* Simple singly-linked list record - LIFO style, no tail field */ + typedef PList_Element TSingle_List; + + struct TCache_ + { + PEngine_Instance engine; + PCache_Class clazz; /* 'class' is a reserved word in C++ */ + TMutex* lock; + TSingle_List active; + TSingle_List idle; + Long idle_count; + }; + + typedef struct TCache_ TCache; + typedef TCache* PCache; + + /* Returns a new list element, either fresh or recycled. */ + /* Note: the returned element is unlinked. */ + + /* An object cache holds two lists tracking the active and */ + /* idle objects that are currently created and used by the */ + /* engine. It can also be 'protected' by a mutex. */ + + /* Initializes a new cache, of class 'clazz', pointed by 'cache', */ + /* protected by the 'lock' mutex. Set 'lock' to NULL if the cache */ + /* doesn't need protection */ + + LOCAL_DEF + TT_Error Cache_Create( PEngine_Instance engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ); + + /* Destroys a cache and all its listed objects */ + + LOCAL_DEF + TT_Error Cache_Destroy( TCache* cache ); + + + /* Extracts a new object from the cache */ + + LOCAL_DEF + TT_Error Cache_New( TCache* cache, + void** new_object, + void* parent_object ); + + + /* Returns an object to the cache, or discards it depending */ + /* on the cache class' 'idle_limit' field */ + + LOCAL_DEF + TT_Error Cache_Done( TCache* cache, void* data ); + +#define CACHE_New( _cache, _newobj, _parent ) \ + Cache_New( (TCache*)_cache, (void**)&_newobj, (void*)_parent ) + +#define CACHE_Done( _cache, _obj ) \ + Cache_Done( (TCache*)_cache, (void*)_obj ) + + + + LOCAL_DEF + TT_Error TTCache_Init( PEngine_Instance engine ); + + LOCAL_DEF + TT_Error TTCache_Done( PEngine_Instance engine ); + + +#ifdef __cplusplus + } +#endif + +#endif /* TTCACHE_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.c new file mode 100644 index 000000000..0d7fcbc51 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.c @@ -0,0 +1,403 @@ +/******************************************************************* + * + * ttcalc.c + * + * Arithmetic Computations (body). + * + * 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 "ttcalc.h" +#include "ttdebug.h" +#include "tttables.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_calc + + +/* Support for 1-complement arithmetic has been totally dropped in this */ +/* release. You can still write your own code if you need it... */ + + static const Long Roots[63] = + { + 1, 1, 2, 3, 4, 5, 8, 11, + 16, 22, 32, 45, 64, 90, 128, 181, + 256, 362, 512, 724, 1024, 1448, 2048, 2896, + 4096, 5892, 8192, 11585, 16384, 23170, 32768, 46340, + + 65536, 92681, 131072, 185363, 262144, 370727, + 524288, 741455, 1048576, 1482910, 2097152, 2965820, + 4194304, 5931641, 8388608, 11863283, 16777216, 23726566, + + 33554432, 47453132, 67108864, 94906265, + 134217728, 189812531, 268435456, 379625062, + 536870912, 759250125, 1073741824, 1518500250, + 2147483647 + }; + + +#ifdef LONG64 + + EXPORT_FUNC + TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ) + { + Long s; + + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + s ^= c; c = ABS( c ); + + a = ((TT_Int64)a * b + c/2) / c; + return ( s < 0 ) ? -a : a; + } + + + EXPORT_FUNC + TT_Long TT_MulFix( TT_Long a, TT_Long b ) + { + Long s; + + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + + a = ((TT_Int64)a * b + 0x8000) / 0x10000; + return ( s < 0 ) ? -a : a; + } + + + LOCAL_FUNC + Int Order64( TT_Int64 z ) + { + Int j = 0; + + + while ( z ) + { + z = (unsigned INT64)z >> 1; + j++; + } + return j - 1; + } + + + LOCAL_FUNC + TT_Int32 Sqrt64( TT_Int64 l ) + { + TT_Int64 r, s; + + + if ( l <= 0 ) return 0; + if ( l == 1 ) return 1; + + r = Roots[Order64( l )]; + + do + { + s = r; + r = ( r + l/r ) >> 1; + } + while ( r > s || r*r > l ); + + return r; + } + +#else /* LONG64 */ + + + /* The TT_MulDiv function has been optimized thanks to ideas from */ + /* Graham Asher. The trick is to optimize computation when everything */ + /* fits within 32-bits (a rather common case). */ + /* */ + /* we compute 'a*b+c/2', then divide it by 'c'. (positive values) */ + /* */ + /* 46340 is FLOOR(SQRT(2^31-1)). */ + /* */ + /* if ( a <= 46340 && b <= 46340 ) then ( a*b <= 0x7FFEA810 ) */ + /* */ + /* 0x7FFFFFFF - 0x7FFEA810 = 0x157F0 */ + /* */ + /* if ( c < 0x157F0*2 ) then ( a*b+c/2 <= 0x7FFFFFFF ) */ + /* */ + /* and 2*0x157F0 = 176096 */ + /* */ + + EXPORT_FUNC + TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ) + { + long s; + + + if ( a == 0 || b == c ) + return a; + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + s ^= c; c = ABS( c ); + + if ( a <= 46340 && b <= 46340 && c <= 176095 ) + { + a = ( a*b + c/2 )/c; + } + else + { + TT_Int64 temp, temp2; + + MulTo64( a, b, &temp ); + temp2.hi = (TT_Int32)(c >> 31); + temp2.lo = (TT_Word32)(c / 2); + Add64( &temp, &temp2, &temp ); + a = Div64by32( &temp, c ); + } + + return ( s < 0 ) ? -a : a; + } + + /* The optimization for TT_MulFix is different. We could simply be */ + /* happy by applying the same principles than with TT_MulDiv, because */ + /* */ + /* c = 0x10000 < 176096 */ + /* */ + /* however, in most cases, we have a 'b' with a value around 0x10000 */ + /* which is greater than 46340. */ + /* */ + /* According to Graham's testing, most cases have 'a' < 100, so a good */ + /* idea is to use bounds like 1024 and 2097151 (= floor(2^31-1)/1024 ) */ + /* for 'a' and 'b' respectively.. */ + /* */ + + EXPORT_FUNC + TT_Long TT_MulFix( TT_Long a, TT_Long b ) + { + long s; + + if ( a == 0 || b == 0x10000 ) + return a; + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + + if ( a <= 1024 && b <= 2097151 ) + { + a = ( a*b + 0x8000 ) >> 16; + } + else + { + TT_Int64 temp, temp2; + + MulTo64( a, b, &temp ); + temp2.hi = 0; + temp2.lo = 0x8000; + Add64( &temp, &temp2, &temp ); + a = Div64by32( &temp, 0x10000 ); + } + + return ( s < 0 ) ? -a : a; + } + + + LOCAL_FUNC + void Neg64( TT_Int64* x ) + { + /* Remember that -(0x80000000) == 0x80000000 with 2-complement! */ + /* We take care of that here. */ + + x->hi ^= 0xFFFFFFFFUL; + x->lo ^= 0xFFFFFFFFUL; + x->lo++; + + if ( !x->lo ) + { + x->hi++; + if ( x->hi == 0x80000000UL ) /* Check -MaxInt32 - 1 */ + { + x->lo--; + x->hi--; /* We return 0x7FFFFFFF! */ + } + } + } + + + LOCAL_FUNC + void Add64( TT_Int64* x, TT_Int64* y, TT_Int64* z ) + { + register TT_Word32 lo, hi; + + + lo = x->lo + y->lo; + hi = x->hi + y->hi + ( lo < x->lo ); + + z->lo = lo; + z->hi = hi; + } + + + LOCAL_FUNC + void Sub64( TT_Int64* x, TT_Int64* y, TT_Int64* z ) + { + register TT_Word32 lo, hi; + + + lo = x->lo - y->lo; + hi = x->hi - y->hi - ( (TT_Int32)lo < 0 ); + + z->lo = lo; + z->hi = hi; + } + + + LOCAL_FUNC + void MulTo64( TT_Int32 x, TT_Int32 y, TT_Int64* z ) + { + TT_Int32 s; + TT_Word32 lo1, hi1, lo2, hi2, lo, hi, i1, i2; + + + s = x; x = ABS( x ); + s ^= y; y = ABS( y ); + + lo1 = x & 0x0000FFFF; hi1 = x >> 16; + lo2 = y & 0x0000FFFF; hi2 = y >> 16; + + lo = lo1*lo2; + i1 = lo1*hi2; + i2 = lo2*hi1; + hi = hi1*hi2; + + /* Check carry overflow of i1 + i2 */ + + if ( i2 ) + { + if ( i1 >= (TT_Word32)-(TT_Int32)i2 ) hi += 1L << 16; + i1 += i2; + } + + i2 = i1 >> 16; + i1 = i1 << 16; + + /* Check carry overflow of i1 + lo */ + if ( i1 ) + { + if ( lo >= (TT_Word32)-(TT_Int32)i1 ) hi++; + lo += i1; + } + + hi += i2; + + z->lo = lo; + z->hi = hi; + + if ( s < 0 ) Neg64( z ); + } + + + LOCAL_FUNC + TT_Int32 Div64by32( TT_Int64* x, TT_Int32 y ) + { + TT_Int32 s; + TT_Word32 q, r, i, lo; + + + s = x->hi; if ( s < 0 ) Neg64( x ); + s ^= y; y = ABS( y ); + + /* Shortcut */ + if ( x->hi == 0 ) + { + q = x->lo / y; + return ( s < 0 ) ? -(TT_Int32)q : (TT_Int32)q; + } + + r = x->hi; + lo = x->lo; + + if ( r >= (TT_Word32)y ) /* we know y is to be treated as unsigned here */ + return ( s < 0 ) ? 0x80000001UL : 0x7FFFFFFFUL; + /* Return Max/Min Int32 if divide overflow */ + /* This includes division by zero! */ + q = 0; + for ( i = 0; i < 32; i++ ) + { + r <<= 1; + q <<= 1; + r |= lo >> 31; + + if ( r >= (TT_Word32)y ) + { + r -= y; + q |= 1; + } + lo <<= 1; + } + + return ( s < 0 ) ? -(TT_Int32)q : (TT_Int32)q; + } + + + LOCAL_FUNC + Int Order64( TT_Int64* z ) + { + TT_Word32 i; + Int j; + + + if ( z->hi ) + { + i = z->hi; + j = 32; + } + else + { + i = z->lo; + j = 0; + } + + while ( i > 0 ) + { + i >>= 1; + j++; + } + return j-1; + } + + + LOCAL_FUNC + TT_Int32 Sqrt64( TT_Int64* l ) + { + TT_Int64 l2; + TT_Int32 r, s; + + + if ( (TT_Int32)l->hi < 0 || + (l->hi == 0 && l->lo == 0) ) return 0; + + s = Order64( l ); + if ( s == 0 ) return 1; + + r = Roots[s]; + do + { + s = r; + r = ( r + Div64by32(l,r) ) >> 1; + MulTo64( r, r, &l2 ); + Sub64 ( l, &l2, &l2 ); + } + while ( r > s || (TT_Int32)l2.hi < 0 ); + + return r; + } + +#endif /* LONG64 */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.h new file mode 100644 index 000000000..0aec33850 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcalc.h @@ -0,0 +1,97 @@ +/******************************************************************* + * + * ttcalc.h + * + * Arithmetic Computations (specification). + * + * 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 TTCALC_H +#define TTCALC_H + +#include "ttconfig.h" +#include "freetype.h" + + +#ifdef __cplusplus + extern "C" { +#endif + +#ifdef LONG64 + + typedef INT64 TT_Int64; + +#define ADD_64( x, y, z ) z = x + y +#define SUB_64( x, y, z ) z = x - y +#define MUL_64( x, y, z ) z = (TT_Int64)(x) * (y) + +#define DIV_64( x, y ) ( (x) / (y) ) + +#define SQRT_64( x ) Sqrt64( x ) +#define SQRT_32( x ) Sqrt32( x ) + + LOCAL_DEF TT_Int32 Sqrt64( TT_Int64 l ); + +#else /* LONG64 */ + + struct TT_Int64_ + { + TT_Word32 lo; + TT_Word32 hi; + }; + + typedef struct TT_Int64_ TT_Int64; + +#define ADD_64( x, y, z ) Add64( &x, &y, &z ) +#define SUB_64( x, y, z ) Sub64( &x, &y, &z ) +#define MUL_64( x, y, z ) MulTo64( x, y, &z ) + +#define DIV_64( x, y ) Div64by32( &x, y ) + +#define SQRT_64( x ) Sqrt64( &x ) +#define SQRT_32( x ) Sqrt32( x ) + + LOCAL_DEF void Add64( TT_Int64* x, TT_Int64* y, TT_Int64* z ); + LOCAL_DEF void Sub64( TT_Int64* x, TT_Int64* y, TT_Int64* z ); + + LOCAL_DEF void MulTo64( TT_Int32 x, TT_Int32 y, TT_Int64* z ); + + LOCAL_DEF TT_Int32 Div64by32( TT_Int64* x, TT_Int32 y ); + + LOCAL_DEF int Order64( TT_Int64* z ); + + LOCAL_DEF TT_Int32 Sqrt64( TT_Int64* l ); + +#endif /* LONG64 */ + + /* The two following functions are now part of the API! */ + + /* TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ); */ + /* TT_Long TT_MulFix( TT_Long a, TT_Long b ); */ + + +#define INT_TO_F26DOT6( x ) ( (Long)(x) << 6 ) +#define INT_TO_F2DOT14( x ) ( (Long)(x) << 14 ) +#define INT_TO_FIXED( x ) ( (Long)(x) << 16 ) +#define F2DOT14_TO_FIXED( x ) ( (Long)(x) << 2 ) +#define FLOAT_TO_FIXED( x ) ( (Long)(x * 65536.0) ) + +#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ((x) + 32) & -64) \ + : ( -((32 - (x)) & -64) ) ) + +#ifdef __cplusplus + } +#endif + +#endif /* TTCALC_H */ + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c new file mode 100644 index 000000000..13d06c679 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c @@ -0,0 +1,503 @@ +/******************************************************************* + * + * ttcmap.c 1.0 + * + * TrueType Character Mappings + * + * 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 "ttobjs.h" +#include "ttdebug.h" +#include "ttfile.h" +#include "ttmemory.h" +#include "ttload.h" +#include "ttcmap.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_cmap + + +/******************************************************************* + * + * Function : CharMap_Load + * + * Description : Loads a given charmap into memory. + * + * Input : cmap pointer to cmap table + * + * Output : Error code. + * + * Notes : - Assumes the the stream is already used (opened). + * + * - In case of error, releases all partially allocated + * tables. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error CharMap_Load( PCMapTable cmap, + TT_Stream input ) + { + DEFINE_LOAD_LOCALS( input ); + + UShort num_SH, num_Seg, i; + + UShort u, l; + + PCMap0 cmap0; + PCMap2 cmap2; + PCMap4 cmap4; + PCMap6 cmap6; + + PCMap2SubHeader cmap2sub; + PCMap4Segment segments; + + + if ( cmap->loaded ) + return TT_Err_Ok; + + if ( FILE_Seek( cmap->offset ) ) + return error; + + switch ( cmap->format ) + { + case 0: + cmap0 = &cmap->c.cmap0; + + if ( ALLOC( cmap0->glyphIdArray, 256L ) || + FILE_Read( (void*)cmap0->glyphIdArray, 256L ) ) + goto Fail; + + break; + + case 2: + num_SH = 0; + cmap2 = &cmap->c.cmap2; + + /* allocate subheader keys */ + + if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, UShort ) || + ACCESS_Frame( 512L ) ) + goto Fail; + + for ( i = 0; i < 256; i++ ) + { + u = GET_UShort() / 8; + cmap2->subHeaderKeys[i] = u; + + if ( num_SH < u ) + num_SH = u; + } + + FORGET_Frame(); + + /* load subheaders */ + + cmap2->numGlyphId = l = + ( ( cmap->length - 2L * (256 + 3) - num_SH * 8L ) & 0xffff) / 2; + + if ( ALLOC_ARRAY( cmap2->subHeaders, + num_SH + 1, + TCMap2SubHeader ) || + ACCESS_Frame( ( num_SH + 1 ) * 8L ) ) + goto Fail; + + cmap2sub = cmap2->subHeaders; + + for ( i = 0; i <= num_SH; i++ ) + { + cmap2sub->firstCode = GET_UShort(); + cmap2sub->entryCount = GET_UShort(); + cmap2sub->idDelta = GET_Short(); + /* we apply the location offset immediately */ + cmap2sub->idRangeOffset = GET_UShort() - ( num_SH - i ) * 8 - 2; + + cmap2sub++; + } + + FORGET_Frame(); + + /* load glyph ids */ + + if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, UShort ) || + ACCESS_Frame( l * 2L ) ) + goto Fail; + + for ( i = 0; i < l; i++ ) + cmap2->glyphIdArray[i] = GET_UShort(); + + FORGET_Frame(); + break; + + case 4: + cmap4 = &cmap->c.cmap4; + + /* load header */ + + if ( ACCESS_Frame( 8L ) ) + goto Fail; + + cmap4->segCountX2 = GET_UShort(); + cmap4->searchRange = GET_UShort(); + cmap4->entrySelector = GET_UShort(); + cmap4->rangeShift = GET_UShort(); + + num_Seg = cmap4->segCountX2 / 2; + + FORGET_Frame(); + + /* load segments */ + + if ( ALLOC_ARRAY( cmap4->segments, + num_Seg, + TCMap4Segment ) || + ACCESS_Frame( (num_Seg * 4 + 1) * 2L ) ) + goto Fail; + + segments = cmap4->segments; + + for ( i = 0; i < num_Seg; i++ ) + segments[i].endCount = GET_UShort(); + + (void)GET_UShort(); + + for ( i = 0; i < num_Seg; i++ ) + segments[i].startCount = GET_UShort(); + + for ( i = 0; i < num_Seg; i++ ) + segments[i].idDelta = GET_Short(); + + for ( i = 0; i < num_Seg; i++ ) + segments[i].idRangeOffset = GET_UShort(); + + FORGET_Frame(); + + cmap4->numGlyphId = l = + ( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xffff ) / 2; + + /* load ids */ + + if ( ALLOC_ARRAY( cmap4->glyphIdArray, l , UShort ) || + ACCESS_Frame( l * 2L ) ) + goto Fail; + + for ( i = 0; i < l; i++ ) + cmap4->glyphIdArray[i] = GET_UShort(); + + FORGET_Frame(); + break; + + case 6: + cmap6 = &cmap->c.cmap6; + + if ( ACCESS_Frame( 4L ) ) + goto Fail; + + cmap6->firstCode = GET_UShort(); + cmap6->entryCount = GET_UShort(); + + FORGET_Frame(); + + l = cmap6->entryCount; + + if ( ALLOC_ARRAY( cmap6->glyphIdArray, + cmap6->entryCount, + Short ) || + ACCESS_Frame( l * 2L ) ) + goto Fail; + + for ( i = 0; i < l; i++ ) + cmap6->glyphIdArray[i] = GET_UShort(); + + FORGET_Frame(); + break; + + default: /* corrupt character mapping table */ + return TT_Err_Invalid_CharMap_Format; + + } + return TT_Err_Ok; + + Fail: + CharMap_Free( cmap ); + return error; + } + + +/******************************************************************* + * + * Function : CharMap_Free + * + * Description : Releases a given charmap table. + * + * Input : cmap pointer to cmap table + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error CharMap_Free( PCMapTable cmap ) + { + if ( !cmap ) + return TT_Err_Ok; + + switch ( cmap->format ) + { + case 0: + FREE( cmap->c.cmap0.glyphIdArray ); + break; + + case 2: + FREE( cmap->c.cmap2.subHeaderKeys ); + FREE( cmap->c.cmap2.subHeaders ); + FREE( cmap->c.cmap2.glyphIdArray ); + break; + + case 4: + FREE( cmap->c.cmap4.segments ); + FREE( cmap->c.cmap4.glyphIdArray ); + cmap->c.cmap4.segCountX2 = 0; + break; + + case 6: + FREE( cmap->c.cmap6.glyphIdArray ); + cmap->c.cmap6.entryCount = 0; + break; + + default: + /* invalid table format, do nothing */ + ; + } + + cmap->loaded = FALSE; + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : CharMap_Index + * + * Description : Performs charcode->glyph index translation. + * + * Input : cmap pointer to cmap table + * + * Output : Glyph index, 0 in case of failure. + * + ******************************************************************/ + + static UShort code_to_index0( UShort charCode, PCMap0 cmap0 ); + static UShort code_to_index2( UShort charCode, PCMap2 cmap2 ); + static UShort code_to_index4( UShort charCode, PCMap4 cmap4 ); + static UShort code_to_index6( UShort charCode, PCMap6 cmap6 ); + + + LOCAL_FUNC + UShort CharMap_Index( PCMapTable cmap, + UShort charcode ) + { + switch ( cmap->format ) + { + case 0: + return code_to_index0( charcode, &cmap->c.cmap0 ); + case 2: + return code_to_index2( charcode, &cmap->c.cmap2 ); + case 4: + return code_to_index4( charcode, &cmap->c.cmap4 ); + case 6: + return code_to_index6( charcode, &cmap->c.cmap6 ); + default: + return 0; + } + } + + +/******************************************************************* + * + * Function : code_to_index0 + * + * Description : Converts the character code into a glyph index. + * Uses format 0. + * charCode will be masked to get a value in the range + * 0x00-0xFF. + * + * Input : charCode the wanted character code + * cmap0 a pointer to a cmap table in format 0 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist. + * + ******************************************************************/ + + static UShort code_to_index0( UShort charCode, + PCMap0 cmap0 ) + { + if ( charCode <= 0xFF ) + return cmap0->glyphIdArray[charCode]; + else + return 0; + } + + +/******************************************************************* + * + * Function : code_to_index2 + * + * Description : Converts the character code into a glyph index. + * Uses format 2. + * + * Input : charCode the wanted character code + * cmap2 a pointer to a cmap table in format 2 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist. + * + ******************************************************************/ + + static UShort code_to_index2( UShort charCode, + PCMap2 cmap2 ) + { + UShort index1, idx, offset; + TCMap2SubHeader sh2; + + + index1 = cmap2->subHeaderKeys[charCode <= 0xFF ? + charCode : (charCode >> 8)]; + + if ( index1 == 0 ) + { + if ( charCode <= 0xFF ) + return cmap2->glyphIdArray[charCode]; /* 8bit character code */ + else + return 0; + } + else /* 16bit character code */ + { + if ( charCode <= 0xFF ) + return 0; + + sh2 = cmap2->subHeaders[index1]; + + if ( (charCode & 0xFF) < sh2.firstCode ) + return 0; + + if ( (charCode & 0xFF) >= (sh2.firstCode + sh2.entryCount) ) + return 0; + + offset = sh2.idRangeOffset / 2 + (charCode & 0xFF) - sh2.firstCode; + if ( offset < cmap2->numGlyphId ) + idx = cmap2->glyphIdArray[offset]; + else + return 0; + + if ( idx ) + return (idx + sh2.idDelta) & 0xFFFF; + else + return 0; + } + } + + +/******************************************************************* + * + * Function : code_to_index4 + * + * Description : Converts the character code into a glyph index. + * Uses format 4. + * + * Input : charCode the wanted character code + * cmap4 a pointer to a cmap table in format 4 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist. + * + ******************************************************************/ + + static UShort code_to_index4( UShort charCode, + PCMap4 cmap4 ) + { + UShort index1, segCount; + UShort i; + TCMap4Segment seg4; + + + segCount = cmap4->segCountX2 / 2; + + for ( i = 0; i < segCount; i++ ) + if ( charCode <= cmap4->segments[i].endCount ) + break; + + /* Safety check - even though the last endCount should be 0xFFFF */ + if ( i >= segCount ) + return 0; + + seg4 = cmap4->segments[i]; + + if ( charCode < seg4.startCount ) + return 0; + + if ( seg4.idRangeOffset == 0 ) + return ( charCode + seg4.idDelta ) & 0xFFFF; + else + { + index1 = seg4.idRangeOffset / 2 + (charCode - seg4.startCount) - + (segCount - i); + + if ( index1 < cmap4->numGlyphId ) + { + if ( cmap4->glyphIdArray[index1] == 0 ) + return 0; + else + return ( cmap4->glyphIdArray[index1] + seg4.idDelta ) & 0xFFFF; + } + else + return 0; + } + } + + +/******************************************************************* + * + * Function : code_to_index6 + * + * Description : Converts the character code into a glyph index. + * Uses format 6. + * + * Input : charCode the wanted character code + * cmap6 a pointer to a cmap table in format 6 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist (`missing character glyph'). + * + ******************************************************************/ + + static UShort code_to_index6( UShort charCode, + PCMap6 cmap6 ) + { + UShort firstCode; + + + firstCode = cmap6->firstCode; + + if ( charCode < firstCode ) + return 0; + + if ( charCode >= (firstCode + cmap6->entryCount) ) + return 0; + + return cmap6->glyphIdArray[charCode - firstCode]; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h new file mode 100644 index 000000000..43ca7887c --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h @@ -0,0 +1,169 @@ +/******************************************************************* + * + * ttcmap.h 1.0 + * + * TrueType Character Mappings + * + * 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 TTCMAP_H +#define TTCMAP_H + +#include "ttconfig.h" +#include "tttypes.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* format 0 */ + + struct TCMap0_ + { + PByte glyphIdArray; + }; + + typedef struct TCMap0_ TCMap0; + typedef TCMap0* PCMap0; + + + /* format 2 */ + + struct TCMap2SubHeader_ + { + UShort firstCode; /* first valid low byte */ + UShort entryCount; /* number of valid low bytes */ + Short idDelta; /* delta value to glyphIndex */ + UShort idRangeOffset; /* offset from here to 1st code */ + }; + + typedef struct TCMap2SubHeader_ TCMap2SubHeader; + typedef TCMap2SubHeader* PCMap2SubHeader; + + struct TCMap2_ + { + PUShort subHeaderKeys; + /* high byte mapping table */ + /* value = subHeader index * 8 */ + + PCMap2SubHeader subHeaders; + PUShort glyphIdArray; + UShort numGlyphId; /* control value */ + }; + + typedef struct TCMap2_ TCMap2; + typedef TCMap2* PCMap2; + + + /* format 4 */ + + struct TCMap4Segment_ + { + UShort endCount; + UShort startCount; + Short idDelta; /* in the specs defined as UShort but the + example there gives negative values... */ + UShort idRangeOffset; + }; + + typedef struct TCMap4Segment_ TCMap4Segment; + typedef TCMap4Segment* PCMap4Segment; + + struct TCMap4_ + { + UShort segCountX2; /* number of segments * 2 */ + UShort searchRange; /* these parameters can be used */ + UShort entrySelector; /* for a binary search */ + UShort rangeShift; + + PCMap4Segment segments; + PUShort glyphIdArray; + UShort numGlyphId; /* control value */ + }; + + typedef struct TCMap4_ TCMap4; + typedef TCMap4* PCMap4; + + + /* format 6 */ + + struct TCMap6_ + { + UShort firstCode; /* first character code of subrange */ + UShort entryCount; /* number of character codes in subrange */ + + PUShort glyphIdArray; + }; + + typedef struct TCMap6_ TCMap6; + typedef TCMap6* PCMap6; + + + /* charmap table */ + + struct TCMapTable_ + { + UShort platformID; + UShort platformEncodingID; + UShort format; + UShort length; + UShort version; + + Bool loaded; + ULong offset; + + union + { + TCMap0 cmap0; + TCMap2 cmap2; + TCMap4 cmap4; + TCMap6 cmap6; + } c; + }; + + typedef struct TCMapTable_ TCMapTable; + typedef TCMapTable* PCMapTable; + + + + /* Load character mappings directory when face is loaded. */ + /* The mappings themselves are only loaded on demand. */ + + LOCAL_DEF + TT_Error CharMap_Load( PCMapTable table, + TT_Stream input ); + + + /* Destroy one character mapping table */ + + LOCAL_DEF + TT_Error CharMap_Free( PCMapTable table ); + + + /* Use character mapping table to perform mapping */ + + LOCAL_DEF + UShort CharMap_Index( PCMapTable cmap, + UShort charCode ); + + /* NOTE: The PFace type isn't defined at this point */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTCMAP_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h new file mode 100644 index 000000000..616a1a654 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h @@ -0,0 +1,279 @@ +/******************************************************************* + * + * ttconfig.h 1.0 + * + * Configuration settings header file (spec only). + * + * 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. + * + * Notes: + * + * All the configuration #define statements have been gathered in + * this file to allow easy check and modification. + * + ******************************************************************/ + +#ifndef TTCONFIG_H +#define TTCONFIG_H + + + +/* ------------ auto configuration ------------------------------------- */ + + +/*************************************************************************/ +/* Here we include the file ft_conf.h for system dependent stuff. */ +/* The specific makefile is responsible for providing the right path to */ +/* this file. */ + +#include "ft_conf.h" + + +/**************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#define TT_CONFIG_OPTION_THREAD_SAFE + + + +/* ------------ general debugging -------------------------------------- */ + + +/************************************************************************* + * + * There are now three debugging modes: + * + * - trace mode: + * + * Error and trace messages are sent to the log file + * (which can be the standard error output). Define + * DEBUG_LEVEL_TRACE to enable this mode. + * + * - error mode: + * + * Only error messages are generated. Define + * DEBUG_LEVEL_ERROR to enable this mode. + * + * - release mode: + * + * Error messages are neither sent nor generated. The code is + * free from any debugging parts. + * + * + * Note that you should link the engine with the 'ttdebug' component. + * in case either DEBUG_LEVEL_TRACE or DEBUG_LEVEL_ERROR is defined. + * + * Please consult ttdebug.h for more details. */ + +/* #define DEBUG_LEVEL_TRACE */ +/* #define DEBUG_LEVEL_ERROR */ + + + +/* ------------ special debugging -------------------------------------- */ + + +/*************************************************************************/ +/* Define this if you want to generate a special debug version of the */ +/* rasterizer. This will progressively draw the glyphs while the */ +/* computations are done directly on the graphics screen... (with */ +/* inverted glyphs). */ +/* */ +/* Use it at your own risk! It is not maintained currently. */ +/* */ +/* IMPORTANT: This is reserved to developers willing to debug the */ +/* rasterizer, which seems working very well in its */ +/* current state... */ + +/* #define DEBUG_RASTER */ + + +/*************************************************************************/ +/* Define this to have a simple debugger version of RunIns(). */ +/* */ +/* Use it at your own risk! It is not maintained currently. */ + +/* #define DEBUG_INTERPRETER */ + + +/*************************************************************************/ +/* Define this to have some housekeeping of allocation and deallocation. */ +/* */ +/* Please note that probably not all OS-specific versions of ttmemory.c */ +/* provide this functionality. */ + +/* #define DEBUG_MEMORY */ + + +/*************************************************************************/ +/* Define this to have bounds checking for file buffer frames. */ +/* */ +/* Please note that probably not all OS-specific versions of ttfile.c */ +/* provide this functionality. */ + +/* #define DEBUG_FILE */ + + + +/* ------------ arithmetic and processor support ----------------------- */ + + +/*************************************************************************/ +/* Define TT_USE_LONG_LONG if you want to enable the use of the */ +/* 'long long' 64-bit type provided by gcc and other compilers. Note */ +/* that : */ +/* */ +/* 1. The type isn't ANSI, and thus will produce many warnings */ +/* during library compilation. */ +/* */ +/* 2. Though the generated object files are slightly smaller, the */ +/* resulting executables are bigger of about 4Kb! gcc must be */ +/* linking some extra code in there! */ +/* */ +/* 3. There is really no speed gain in doing so (but it may help */ +/* debug the ttcalc component). */ +/* */ +/* IMPORTANT NOTE: You don't need to define it on 64-bits machines! */ +/* */ +/* NOTE 2 : This flag used to be _GNUC_LONG64_ */ + +/* #define TT_USE_LONG_LONG */ + + +/*************************************************************************/ +/* define ALIGNMENT to your processor/environment preferred alignment */ +/* size. A value of 8 should work on all current processors, even */ +/* 64-bits ones. */ + +#define ALIGNMENT 8 + + + +/* --------------- miscellaneous ----------------------------------- */ + + +/*********************************************************************/ +/* The number of extensions available. Don't change this value */ +/* except if you add new extensions to the engine. */ + +#define TT_MAX_EXTENSIONS 8 + + + +/* --------------- automatic setup -- don't touch ------------------ */ + + +/*********************************************************************/ +/* If HAVE_TT_TEXT is defined we don't provide a default typedef for */ +/* defining TT_Text. */ + +#ifndef HAVE_TT_TEXT +#define HAVE_TT_TEXT + typedef char TT_Text; +#endif + + +/*********************************************************************/ +/* We define NULL in case it's not defined yet. The default */ +/* location is stdlib.h. */ + +#ifdef HAVE_STDLIB_H +#include +#endif + + +/*********************************************************************/ +/* Some systems can't use vfprintf for error messages on stderr; if */ +/* HAVE_PRINT_FUNCTION is defined, the Print macro must be supplied */ +/* externally (having the same parameters). */ +/* */ +/* This is only used by the "ttdebug" component, which should be */ +/* linked to the engine only in debug mode. */ + +#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) +#ifndef HAVE_PRINT_FUNCTION +#define Print( format, ap ) vfprintf( stderr, (format), (ap) ) +#endif +#endif + + +/********************************************************************/ +/* */ +/* I have added the ability to compile the library into a single */ +/* object file. This gets rids of all the external symbols defined */ +/* in each component interface, and de-pollutes the name-space. */ +/* */ +/* I use two macros, namely LOCAL_FUNC and LOCAL_DEF, which only */ +/* apply to functions that are internal to the engine, and */ +/* should never be seen or linked by a client application. */ +/* */ +/* LOCAL_DEF used in header (.h) files, to define a function */ +/* that will be seen by other components. This */ +/* translates to "extern" in normal mode, and to */ +/* "static" in single-object mode. */ +/* */ +/* LOCAL_FUNC used in implementation (.c) files, just before */ +/* the function body. This translates to nothing */ +/* in normal mode, and to "static" in single-object */ +/* mode. */ +/* */ +/* Getting rid of un-necessary symbols makes the "ttcommon" */ +/* renaming macros hack unnecessary. Moreover, the stripped */ +/* single object file (freetype.o) is 52 Kb, instead of the */ +/* previous 57 Kb (size of all combined .o files), and gives */ +/* a better idea of the engine's real code size. */ +/* */ +/* It is called a "MAKE_OPTION" because the macro must be */ +/* defined in the Makefile, rather than this one. It allows */ +/* any developer to quickly switch from one mode to the other */ +/* without messing with "ttconfig.h" each time. */ +/* */ +//#ifndef TT_MAKE_OPTION_SINGLE_OBJECT +#define LOCAL_FUNC /* void */ +#define LOCAL_DEF extern +// #else +// #define LOCAL_FUNC static +// #define LOCAL_DEF static +// #endif + + +/*************************************************************************/ +/* Define EXPORT_DEF and EXPORT_FUNC as needed to build e.g. a DLL. All */ +/* variables and functions visible from outside have these prefixes. */ + +#ifndef EXPORT_DEF +#define EXPORT_DEF extern +#endif + +#ifndef EXPORT_FUNC +#define EXPORT_FUNC /* void */ +#endif + + + +/* -------------- internal (developer) configuration toggles ------------ */ + + +#undef TT_STATIC_INTERPRETER +/* Do not undefine this configuration macro. It is now a default that */ +/* must be kept in all release builds. */ + + +#undef TT_STATIC_RASTER +/* Define this if you want to generate a static raster. This makes */ +/* a non re-entrant version of the scan-line converter, which is */ +/* about 10% faster and 50% bigger than an indirect one! */ + + +#endif /* TTCONFIG_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.c new file mode 100644 index 000000000..6b65154a7 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.c @@ -0,0 +1,404 @@ +/* Simple debugging component. Temporary */ + +#include "ttdebug.h" +#include "tttables.h" +#include "ttobjs.h" + + +#ifdef DEBUG_LEVEL_TRACE + char tt_trace_levels[trace_max]; +#endif + +#if defined( DEBUG_LEVEL_ERROR ) || defined( DEBUG_LEVEL_TRACE ) + +#include +#include +#include + + + static String tempStr[128]; + + static const String* OpStr[256] = + { + "SVTCA y", /* Set vectors to coordinate axis y */ + "SVTCA x", /* Set vectors to coordinate axis x */ + "SPvTCA y", /* Set Proj. vec. to coord. axis y */ + "SPvTCA x", /* Set Proj. vec. to coord. axis x */ + "SFvTCA y", /* Set Free. vec. to coord. axis y */ + "SFvTCA x", /* Set Free. vec. to coord. axis x */ + "SPvTL //", /* Set Proj. vec. parallel to segment */ + "SPvTL +", /* Set Proj. vec. normal to segment */ + "SFvTL //", /* Set Free. vec. parallel to segment */ + "SFvTL +", /* Set Free. vec. normal to segment */ + "SPvFS", /* Set Proj. vec. from stack */ + "SFvFS", /* Set Free. vec. from stack */ + "GPV", /* Get projection vector */ + "GFV", /* Get freedom vector */ + "SFvTPv", /* Set free. vec. to proj. vec. */ + "ISECT", /* compute intersection */ + + "SRP0", /* Set reference point 0 */ + "SRP1", /* Set reference point 1 */ + "SRP2", /* Set reference point 2 */ + "SZP0", /* Set Zone Pointer 0 */ + "SZP1", /* Set Zone Pointer 1 */ + "SZP2", /* Set Zone Pointer 2 */ + "SZPS", /* Set all zone pointers */ + "SLOOP", /* Set loop counter */ + "RTG", /* Round to Grid */ + "RTHG", /* Round to Half-Grid */ + "SMD", /* Set Minimum Distance */ + "ELSE", /* Else */ + "JMPR", /* Jump Relative */ + "SCvTCi", /* Set CVT */ + "SSwCi", /* */ + "SSW", /* */ + + "DUP", + "POP", + "CLEAR", + "SWAP", + "DEPTH", + "CINDEX", + "MINDEX", + "AlignPTS", + "INS_$28", + "UTP", + "LOOPCALL", + "CALL", + "FDEF", + "ENDF", + "MDAP[-]", + "MDAP[r]", + + "IUP[y]", + "IUP[x]", + "SHP[0]", + "SHP[1]", + "SHC[0]", + "SHC[1]", + "SHZ[0]", + "SHZ[1]", + "SHPIX", + "IP", + "MSIRP[0]", + "MSIRP[1]", + "AlignRP", + "RTDG", + "MIAP[-]", + "MIAP[r]", + + "NPushB", + "NPushW", + "WS", + "RS", + "WCvtP", + "RCvt", + "GC[0]", + "GC[1]", + "SCFS", + "MD[0]", + "MD[1]", + "MPPEM", + "MPS", + "FlipON", + "FlipOFF", + "DEBUG", + + "LT", + "LTEQ", + "GT", + "GTEQ", + "EQ", + "NEQ", + "ODD", + "EVEN", + "IF", + "EIF", + "AND", + "OR", + "NOT", + "DeltaP1", + "SDB", + "SDS", + + "ADD", + "SUB", + "DIV", + "MUL", + "ABS", + "NEG", + "FLOOR", + "CEILING", + "ROUND[G]", + "ROUND[B]", + "ROUND[W]", + "ROUND[?]", + "NROUND[G]", + "NROUND[B]", + "NROUND[W]", + "NROUND[?]", + + "WCvtF", + "DeltaP2", + "DeltaP3", + "DeltaC1", + "DeltaC2", + "DeltaC3", + "SROUND", + "S45Round", + "JROT", + "JROF", + "ROFF", + "INS_$7B", + "RUTG", + "RDTG", + "SANGW", + "AA", + + "FlipPT", + "FlipRgON", + "FlipRgOFF", + "INS_$83", + "INS_$84", + "ScanCTRL", + "SDPVTL[0]", + "SDPVTL[1]", + "GetINFO", + "IDEF", + "ROLL", + "MAX", + "MIN", + "ScanTYPE", + "IntCTRL", + "INS_$8F", + + "INS_$90", + "INS_$91", + "INS_$92", + "INS_$93", + "INS_$94", + "INS_$95", + "INS_$96", + "INS_$97", + "INS_$98", + "INS_$99", + "INS_$9A", + "INS_$9B", + "INS_$9C", + "INS_$9D", + "INS_$9E", + "INS_$9F", + + "INS_$A0", + "INS_$A1", + "INS_$A2", + "INS_$A3", + "INS_$A4", + "INS_$A5", + "INS_$A6", + "INS_$A7", + "INS_$A8", + "INS_$A9", + "INS_$AA", + "INS_$AB", + "INS_$AC", + "INS_$AD", + "INS_$AE", + "INS_$AF", + + "PushB[0]", + "PushB[1]", + "PushB[2]", + "PushB[3]", + "PushB[4]", + "PushB[5]", + "PushB[6]", + "PushB[7]", + "PushW[0]", + "PushW[1]", + "PushW[2]", + "PushW[3]", + "PushW[4]", + "PushW[5]", + "PushW[6]", + "PushW[7]", + + "MDRP[G]", + "MDRP[B]", + "MDRP[W]", + "MDRP[?]", + "MDRP[rG]", + "MDRP[rB]", + "MDRP[rW]", + "MDRP[r?]", + "MDRP[mG]", + "MDRP[mB]", + "MDRP[mW]", + "MDRP[m?]", + "MDRP[mrG]", + "MDRP[mrB]", + "MDRP[mrW]", + "MDRP[mr?]", + "MDRP[pG]", + "MDRP[pB]", + + "MDRP[pW]", + "MDRP[p?]", + "MDRP[prG]", + "MDRP[prB]", + "MDRP[prW]", + "MDRP[pr?]", + "MDRP[pmG]", + "MDRP[pmB]", + "MDRP[pmW]", + "MDRP[pm?]", + "MDRP[pmrG]", + "MDRP[pmrB]", + "MDRP[pmrW]", + "MDRP[pmr?]", + + "MIRP[G]", + "MIRP[B]", + "MIRP[W]", + "MIRP[?]", + "MIRP[rG]", + "MIRP[rB]", + "MIRP[rW]", + "MIRP[r?]", + "MIRP[mG]", + "MIRP[mB]", + "MIRP[mW]", + "MIRP[m?]", + "MIRP[mrG]", + "MIRP[mrB]", + "MIRP[mrW]", + "MIRP[mr?]", + "MIRP[pG]", + "MIRP[pB]", + + "MIRP[pW]", + "MIRP[p?]", + "MIRP[prG]", + "MIRP[prB]", + "MIRP[prW]", + "MIRP[pr?]", + "MIRP[pmG]", + "MIRP[pmB]", + "MIRP[pmW]", + "MIRP[pm?]", + "MIRP[pmrG]", + "MIRP[pmrB]", + "MIRP[pmrW]", + "MIRP[pmr?]" + }; + + + const String* Cur_U_Line( void* _exec ) + { + String s[32]; + + Int op, i, n; + + PExecution_Context exec; + + + exec = _exec; + + op = exec->code[exec->IP]; + + sprintf( tempStr, "%s", OpStr[op] ); + + if ( op == 0x40 ) + { + n = exec->code[exec->IP + 1]; + sprintf( s, "(%d)", n ); + strncat( tempStr, s, 8 ); + + if ( n > 20 ) n = 20; /* limit output */ + + for ( i = 0; i < n; i++ ) + { + sprintf( s, " $%02hx", exec->code[exec->IP + i + 2] ); + strncat( tempStr, s, 8 ); + } + } + else if ( op == 0x41 ) + { + n = exec->code[exec->IP + 1]; + sprintf( s, "(%d)", n ); + strncat( tempStr, s, 8 ); + + if ( n > 20 ) n = 20; /* limit output */ + + for ( i = 0; i < n; i++ ) + { + sprintf( s, " $%02hx%02hx", exec->code[exec->IP + i*2 + 2], + exec->code[exec->IP + i*2 + 3] ); + strncat( tempStr, s, 8 ); + } + } + else if ( (op & 0xF8) == 0xB0 ) + { + n = op - 0xB0; + + for ( i = 0; i <= n; i++ ) + { + sprintf( s, " $%02hx", exec->code[exec->IP + i + 1] ); + strncat( tempStr, s, 8 ); + } + } + else if ( (op & 0xF8) == 0xB8 ) + { + n = op-0xB8; + + for ( i = 0; i <= n; i++ ) + { + sprintf( s, " $%02hx%02hx", exec->code[exec->IP + i*2 + 1], + exec->code[exec->IP + i*2 + 2] ); + strncat( tempStr, s, 8 ); + } + } + + return (String*)tempStr; + } + + + /* the Print() function is defined in ttconfig.h; */ + /* it defaults to vprintf on systems which have it */ + + void TT_Message( const String* fmt, ... ) + { + va_list ap; + + va_start( ap, fmt ); + Print( fmt, ap ); + va_end( ap ); + } + + + void TT_Panic( const String* fmt, ... ) + { + va_list ap; + + va_start( ap, fmt ); + Print( fmt, ap ); + va_end( ap ); + + exit( EXIT_FAILURE ); + } + +#endif /* defined( DEBUG_LEVEL_ERROR ) || defined( DEBUG_LEVEL_TRACE ) */ + +#if defined( DEBUG_LEVEL_TRACE ) + + /* use this function to set the values of tt_trace_levels */ + + void set_tt_trace_levels( int index, char value ) + { + tt_trace_levels[index] = value; + } + +#endif + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.h new file mode 100644 index 000000000..ac132512b --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttdebug.h @@ -0,0 +1,170 @@ +/******************************************************************* + * + * ttdebug.h + * + * Debugging and Logging component (specification) + * + * 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. + * + * + * This component contains various macros and functions used to + * ease the debugging of the FreeType engine. Its main purpose + * is in assertion checking, tracing, and error detection. + * + * There are now three debugging modes: + * + * - trace mode: + * + * Error and trace messages are sent to the log file + * (which can be the standard error output). Define + * DEBUG_LEVEL_TRACE to enable this mode. + * + * - error mode: + * + * Only error messages are generated. Define + * DEBUG_LEVEL_ERROR to enable this mode. + * + * - release mode: + * + * Error messages are neither sent nor generated. The code is + * free from any debugging parts. + * + ******************************************************************/ + +#ifndef TTDEBUG_H +#define TTDEBUG_H + +#include "ttconfig.h" +#include "tttypes.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + +#if defined( DEBUG_LEVEL_TRACE ) + + typedef enum Trace_Component_ + { + trace_any = 0, + trace_api, + trace_interp, + trace_load, + trace_gload, + trace_memory, + trace_file, + trace_mutex, + trace_cache, + trace_calc, + trace_cmap, + trace_extend, + trace_objs, + trace_raster, + + trace_bitmap, + trace_max + + } Trace_Component; + + + /* Here we define an array to hold the trace levels per component. */ + /* Since it is globally defined, all array members are set to 0. */ + /* You should set the values in this array either in your program */ + /* or with your debugger. */ + /* */ + /* Currently, up to eight levels (PTRACE0-PTRACE7, see below) are */ + /* used in some parts of the engine. */ + /* */ + /* For example, to have all tracing messages in the raster */ + /* component, say */ + /* */ + /* #define DEBUG_LEVEL_TRACE */ + /* #include "ttdebug.h" */ + /* */ + /* ... */ + /* set_tt_trace_levels( trace_raster, 7 ) */ + /* */ + /* in your code before initializing the FreeType engine. */ + /* */ + /* Maybe it is better to define DEBUG_LEVEL_TRACE in ttconfig.h... */ + + extern char tt_trace_levels[trace_max]; + + /* IMPORTANT: */ + /* */ + /* Each component must define the macro TT_COMPONENT */ + /* to a valid Trace_Component value before using any */ + /* PTRACEx macro. */ + /* */ + +#define PTRACE( level, varformat ) \ + if ( tt_trace_levels[TT_COMPONENT] >= level ) TT_Message##varformat + +#elif defined( DEBUG_LEVEL_ERROR ) + +#define PTRACE( level, varformat ) /* nothing */ + +#else /* RELEASE MODE */ + +#define TT_Assert( condition, action ) /* nothing */ + +#define PTRACE( level, varformat ) /* nothing */ +#define PERROR( varformat ) /* nothing */ +#define PANIC( varformat ) /* nothing */ + +#endif + + +/************************************************************************/ +/* */ +/* Define macros and fuctions that are common to the debug and trace */ +/* modes. */ +/* */ + +#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) + + +#define TT_Assert( condition, action ) if ( !(condition) ) ( action ) + + void TT_Message( const String* fmt, ... ); + void TT_Panic ( const String* fmt, ... ); + /* print a message and exit */ + + const String* Cur_U_Line( void* exec ); + +#define PERROR( varformat ) TT_Message##varformat +#define PANIC( varformat ) TT_Panic##varformat + +#endif + +#if defined( DEBUG_LEVEL_TRACE ) + + void set_tt_trace_levels( int index, char value ); + +#endif + + +#define PTRACE0( varformat ) PTRACE( 0, varformat ) +#define PTRACE1( varformat ) PTRACE( 1, varformat ) +#define PTRACE2( varformat ) PTRACE( 2, varformat ) +#define PTRACE3( varformat ) PTRACE( 3, varformat ) +#define PTRACE4( varformat ) PTRACE( 4, varformat ) +#define PTRACE5( varformat ) PTRACE( 5, varformat ) +#define PTRACE6( varformat ) PTRACE( 6, varformat ) +#define PTRACE7( varformat ) PTRACE( 7, varformat ) + + +#ifdef __cplusplus + } +#endif + + +#endif /* TTDEBUG_H */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h new file mode 100644 index 000000000..c4945839f --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h @@ -0,0 +1,115 @@ +/******************************************************************* + * + * ttengine.h 1.1 + * + * Engine instance structure definition. + * + * 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. + * + * New in 1.1 : + * + * - added the 'raster_lock' mutex field to synchronize + * scan-line conversion in thread-safe and re-entrant builds. + * + ******************************************************************/ + +#ifndef TTENGINE_H +#define TTENGINE_H + +#include "tttypes.h" +#include "ttconfig.h" +#include "freetype.h" +#include "ttmutex.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /********************************************************************/ + /* */ + /* The freetype engine instance structure. */ + /* */ + /* This structure holds all the data that is necessary to run */ + /* one instance of the freetype engine. It is needed to get a */ + /* completely re-entrant version of the library. */ + /* */ + /* The goal is to move _all_ component-specific variables, either */ + /* static or global in the structure; the component initializers */ + /* and finalizers will all be called with the address of a valid */ + /* TEngine_Instance. */ + /* */ + /********************************************************************/ + + struct TEngine_Instance_ + { + TMutex lock; /* engine lock */ + + void* list_free_elements; + + void* objs_face_class; /* the face cache class */ + void* objs_instance_class; /* the instance cache class */ + void* objs_execution_class; /* the context cache class */ + void* objs_glyph_class; /* the glyph cache class */ + + void* objs_face_cache; /* these caches are used to track */ + void* objs_exec_cache; /* the current face and execution */ + /* context objects */ + + void* file_component; /* ttfile implementation dependent */ + + TMutex raster_lock; /* mutex for this engine's render pool */ + void* raster_component; /* ttraster implementation depedent */ + Byte raster_palette[5]; /* gray-levels palette for anti-aliasing */ + + void* extension_component; /* extensions dependent */ + +#if 0 + TT_Glyph_Loader_Callback glCallback; /* glyph loader callback, if any */ +#endif + }; + + /* NOTE : The raster's lock is only acquired by the Render_Glyph and */ + /* Render_Gray_Glyph functions, which always release it on exit */ + /* They do not lock the engine mutex. This means you shouldn't */ + /* be concerned about deadlocks between the two mutexes, as these */ + /* should never appear.. */ + + typedef struct TEngine_Instance_ TEngine_Instance; + typedef TEngine_Instance* PEngine_Instance; + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* for re-entrant builds */ + +#define ENGINE_ARG TEngine_Instance* _engine +#define ENGINE_ARGS TEngine_Instance* _engine, + +#define ENGINE_VAR _engine +#define ENGINE_VARS _engine, + +#define ENGINE _engine + +#else /* for thread-safe builds */ + +#define ENGINE_ARG /* void */ +#define ENGINE_ARGS + +#define ENGINE_VAR +#define ENGINE_VARS + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTENGINE_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c new file mode 100644 index 000000000..d0a1d384d --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -0,0 +1,212 @@ +/******************************************************************* + * + * ttextend.h 2.0 + * + * Extensions Interface + * + * 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. + * + * This is an updated version of the extension component, now + * located in the main library's source directory. It allows + * the dynamic registration/use of various face object extensions + * through a simple API. + * + ******************************************************************/ + +#include "ttextend.h" +#include "ttengine.h" +#include "ttmemory.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_extend + + + struct TExtension_Registry_ + { + Int num_extensions; + Long cur_offset; + TExtension_Class classes[TT_MAX_EXTENSIONS]; + }; + + typedef struct TExtension_Registry_ TExtension_Registry; + typedef TExtension_Registry* PExtension_Registry; + + + + /* Initialize the extension component */ + + LOCAL_FUNC + TT_Error TTExtend_Init( PEngine_Instance engine ) + { + TT_Error error; + PExtension_Registry exts; + + + if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) + return error; + + exts->num_extensions = 0; + exts->cur_offset = 0; + engine->extension_component = (void*)exts; + + return TT_Err_Ok; + } + + + /* Finalize the extension component */ + + LOCAL_FUNC + TT_Error TTExtend_Done( PEngine_Instance engine ) + { + FREE( engine->extension_component ); + return TT_Err_Ok; + } + + + /* Register a new extension */ + + EXPORT_FUNC + TT_Error TT_Register_Extension( PEngine_Instance engine, + Long id, + Long size, + PExt_Constructor create, + PExt_Destructor destroy ) + { + PExtension_Registry exts; + PExtension_Class clazz; + Int p; + + + exts = (PExtension_Registry)engine->extension_component; + if ( !exts ) + return TT_Err_Ok; + + p = exts->num_extensions; + + if ( p >= TT_MAX_EXTENSIONS ) + return TT_Err_Too_Many_Extensions; + + clazz = exts->classes + p; + clazz->id = id; + clazz->size = size; + clazz->build = create; + clazz->destroy = destroy; + + clazz->offset = exts->cur_offset; + + exts->num_extensions++; + exts->cur_offset += ( size + ALIGNMENT-1 ) & -ALIGNMENT; + + return TT_Err_Ok; + } + + + /* Query an extension block by extension_ID */ + + EXPORT_FUNC + TT_Error TT_Extension_Get( PFace face, + Long extension_id, + void** extension_block ) + { + PExtension_Registry registry; + PExtension_Class clazz; + Int n; + + + if ( !face->extension ) + return TT_Err_Extensions_Unsupported; + + registry = (PExtension_Registry)face->engine->extension_component; + + for ( n = 0; n < face->n_extensions; n++ ) + { + clazz = registry->classes + n; + if ( clazz->id == extension_id ) + { + *extension_block = (PByte)face->extension + clazz->offset; + return TT_Err_Ok; + } + } + + return TT_Err_Invalid_Extension_Id; + } + + + /* Destroy all extensions within a face object. Called by the */ + /* face object destructor. */ + + LOCAL_FUNC + TT_Error Extension_Destroy( PFace face ) + { + PEngine_Instance engine = face->engine; + PExtension_Registry registry; + PExtension_Class clazz; + Int n; + PByte ext; + + + registry = (PExtension_Registry)engine->extension_component; + + for ( n = 0; n < face->n_extensions; n++ ) + { + clazz = registry->classes + n; + ext = (PByte)face->extension + clazz->offset; + + /* the destructor is optional */ + if ( clazz->destroy ) + clazz->destroy( (void*)ext, face ); + } + + /* destroy the face's extension block too */ + FREE( face->extension ); + face->n_extensions = 0; + + return TT_Err_Ok; + } + + + /* Create an extension within a face object. Called by the */ + /* face object constructor. */ + + LOCAL_FUNC + TT_Error Extension_Create( PFace face ) + { + PEngine_Instance engine = face->engine; + PExtension_Registry registry; + PExtension_Class clazz; + TT_Error error; + Int n; + PByte ext; + + + registry = (PExtension_Registry)engine->extension_component; + + face->n_extensions = registry->num_extensions; + if ( ALLOC( face->extension, registry->cur_offset ) ) + return error; + + for ( n = 0; n < face->n_extensions; n++ ) + { + clazz = registry->classes + n; + ext = (PByte)face->extension + clazz->offset; + error = clazz->build( (void*)ext, face ); + if ( error ) + goto Fail; + } + return TT_Err_Ok; + + Fail: + Extension_Destroy( face ); + return error; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h new file mode 100644 index 000000000..c922efed3 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h @@ -0,0 +1,168 @@ +/******************************************************************* + * + * ttextend.h 2.0 + * + * Extensions Interface. + * + * 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. + * + * This is an updated version of the extension component, now + * located in the main library's source directory. It allows + * the dynamic registration/use of various face object extensions + * through a simple API. + * + ******************************************************************/ + +#ifndef TTEXTEND_H +#define TTEXTEND_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* The extensions don't need to be integrated at compile time into */ + /* the engine, only at link time. */ + + + /* When a new face object is created, the face constructor calls */ + /* the extension constructor with the following arguments: */ + /* */ + /* ext : typeless pointer to the face's extension block. */ + /* Its size is the one given at registration time */ + /* in the extension class's 'size' field. */ + /* */ + /* face : the parent face object. Note that the extension */ + /* constructor is called when the face object is */ + /* built. */ + + typedef TT_Error TExt_Constructor( void* ext, PFace face ); + + + /* When a face object is destroyed, the face destructor calls */ + /* the extension destructor with the following arguments. */ + /* */ + /* ext : typeless pointer to the face's extension block. */ + /* Its size is the one given at registration time */ + /* in the extension class's 'size' field. */ + /* */ + /* face : the parent face object. Note that the extension */ + /* destructor is called before the actual face object */ + /* is destroyed. */ + + typedef TT_Error TExt_Destructor ( void* ext, PFace face ); + + typedef TExt_Constructor* PExt_Constructor; + typedef TExt_Destructor* PExt_Destructor; + + + struct TExtension_Class_ + { + Long id; /* extension id */ + Long size; /* size in bytes of extension record */ + PExt_Constructor build; /* the extension's class constructor */ + PExt_Destructor destroy; /* the extension's class destructor */ + + Long offset; /* offset of ext. record in face obj */ + /* (set by the engine) */ + }; + + typedef struct TExtension_Class_ TExtension_Class; + typedef TExtension_Class* PExtension_Class; + + +#define Build_Extension_ID( a, b, c, d ) \ + ( ((ULong)(a) << 24) | \ + ((ULong)(b) << 16) | \ + ((ULong)(c) << 8 ) | \ + (ULong)(d) ) + + /* A note regarding extensions and the single-object compilation */ + /* mode : */ + /* */ + /* When the engine is compiled as a single object file, extensions */ + /* must remain linkable *after* compile time. In order to do this, */ + /* we need to export the functions that an extension may need. */ + /* Fortunately, we can limit ourselves to : */ + /* */ + /* o TT_Register_Extension (previously called Extension_Register) */ + /* which is to be called by each extension on within */ + /* it TT_Init_XXXX_Extension initializer. */ + /* */ + /* o File and frame access functions. Fortunately, these already */ + /* have their names prefixed by "TT_", so no change was needed */ + /* except replacing the LOCAL_DEF keyword with EXPORT_DEF */ + /* */ + /* o Memory access functions, i.e. TT_Alloc and TT_Free. Again, */ + /* the change is minimal */ + /* */ + /* o the table-lookup function : TT_LookUp_Table, formerly known */ + /* as Load_TrueType_Table in ttload.c. */ + /* */ + /* */ + /* Other than that, an extension should be able to #include all */ + /* relevant header files to get access to internal types, but */ + /* should not call engine internal functions.. */ + /* */ + /* If there is a need for a specific internal function call, let */ + /* me known to see if we need to export it by default.. */ + /* - DavidT */ + /* */ + + /* Register a new extension. Called by extension */ + /* service initializers. */ + EXPORT_DEF + TT_Error TT_Register_Extension( PEngine_Instance engine, + Long id, + Long size, + PExt_Constructor create, + PExt_Destructor destroy ); + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + /* Initialize the extension component */ + LOCAL_DEF + TT_Error TTExtend_Init( PEngine_Instance engine ); + + /* Finalize the extension component */ + LOCAL_DEF + TT_Error TTExtend_Done( PEngine_Instance engine ); + + /* Create an extension within a face object. Called by the */ + /* face object constructor. */ + LOCAL_DEF + TT_Error Extension_Create( PFace face ); + + /* Destroy all extensions within a face object. Called by the */ + /* face object destructor. */ + LOCAL_DEF + TT_Error Extension_Destroy( PFace face ); +#endif + + /* Query an extension block by extension_ID. Called by extension */ + /* service routines. */ + EXPORT_DEF + TT_Error TT_Extension_Get( PFace face, + Long extension_id, + void** extension_block ); + +#ifdef __cplusplus + } +#endif + + +#endif /* TTEXTEND_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c new file mode 100644 index 000000000..0a9092de0 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c @@ -0,0 +1,1222 @@ +/******************************************************************* + * + * ttfile.c (extended version) 2.1 + * + * File I/O Component (body). + * + * 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. + * + * NOTES: + * + * This implementation relies on the ANSI libc. You may wish to + * modify it to get rid of libc and go straight to the your + * platform's stream routines. + * + * The same source code can be used for thread-safe and re-entrant + * builds of the library. + * + * Changes between 2.0 and 2.1 : + * + * - it is now possible to close a stream's file handle explicitely + * through the new API "TT_Flush_Stream". This will simply close + * a stream's file handle (useful to save system resources when + * dealing with lots of opened fonts). Of course, the function + * "TT_Use_Stream" will automatically re-open a stream's handle if + * necessary. + * + * - added "TT_Stream_Size" to replace "TT_File_Size" which wasn't + * used anyway. This one returns the size of any stream, even + * flushed one (when the previous TT_File_Size could only return + * the size of the current working stream). This is used by the + * new "Load_TrueType_Any" function in the tables loader. + * + ******************************************************************/ + +#include "ttconfig.h" + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttmemory.h" +#include "ttfile.h" /* our prototypes */ + +#ifdef __GEOS__ +#include +#include +#endif /* ifdef __GEOS__ */ + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_file + + +/* For now, we don't define additional error messages in the core library */ +/* to report open-on demand errors. Define these error as standard ones */ + +#define TT_Err_Could_Not_ReOpen_File TT_Err_Could_Not_Open_File +#define TT_Err_Could_Not_ReSeek_File TT_Err_Could_Not_Open_File + + /* This definition is mandatory for each file component! */ + EXPORT_FUNC + const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; + +/* It has proven useful to do some bounds checks during development phase. */ +/* They should probably be undefined for speed reasons in a later release. */ + +#if DEBUG_FILE +#define CHECK_FRAME( frame, n ) \ + do { \ + if ( frame.cursor + n > frame.address + frame.size ) \ + Panic( "Frame boundary error!\n" ); \ + } while ( 0 ) +#else +#define CHECK_FRAME( frame, n ) /* nothing */ +#endif + + /* Because a stream can be flushed, i.e. its file handle can be */ + /* closed to save system resources, we must keep the stream's file */ + /* pathname to be able to re-open it on demand when it is flushed */ + + struct TStream_Rec_; + typedef struct TStream_Rec_ TStream_Rec; + typedef TStream_Rec* PStream_Rec; + + struct TStream_Rec_ + { + Bool opened; /* is the stream handle opened ? */ + TT_Text* name; /* the file's pathname */ + Long position; /* current position within the file */ + +#ifdef __GEOS__ + FileHandle file; /* FreeGEOS file handle */ +#else + FILE* file; /* file handle */ +#endif /* ifdef __GEOS__ */ + Long base; /* stream base in file */ + Long size; /* stream size in file */ + }; + + /* We support embedded TrueType files by allowing them to be */ + /* inside any file, at any location, hence the 'base' argument. */ + /* Note however that the current implementation does not allow you */ + /* to specify a 'base' index when opening a file. */ + /* (will come later) */ + /* I still don't know if this will turn out useful ?? - DavidT */ + +#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) + + static TT_Error Stream_Activate ( PStream_Rec stream ); + static TT_Error Stream_Deactivate( PStream_Rec stream ); + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /**** ****/ + /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ + /**** ****/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + + /* in non-rentrant builds, we allocate a single block where we'll */ + /* place all the frames smaller than FRAME_CACHE_SIZE, rather than */ + /* allocating a new block on each access. Bigger frames will be */ + /* malloced normally in the heap. */ + /* */ + /* See TT_Access_Frame() and TT_Forget_Frame() for details. */ + +#define FRAME_CACHE_SIZE 2048 + + /* The TFile_Component structure holds all the data that was */ + /* previously declared static or global in this component. */ + /* */ + /* It is accessible through the 'engine.file_component' */ + /* variable in re-entrant builds, or directly through the */ + /* static 'files' variable in other builds. */ + + struct TFile_Component_ + { + TMutex lock; /* used by the thread-safe build only */ + Byte* frame_cache; /* frame cache */ + PStream_Rec stream; /* current stream */ + TFileFrame frame; /* current frame */ + }; + + typedef struct TFile_Component_ TFile_Component; + + static TFile_Component files; + +#define CUR_Stream files.stream +#define CUR_Frame files.frame + +#define STREAM_VARS /* void */ +#define STREAM_VAR /* void */ + +/* The macro CUR_Stream denotes the current input stream. */ +/* Note that for the re-entrant version, the 'stream' name has been */ +/* chosen according to the macro STREAM_ARGS. */ + +/* The macro CUR_Frame denotes the current file frame. */ +/* Note that for the re-entrant version, the 'frame' name has been */ +/* chosen according to the macro FRAME_ARGS. */ + +/* The macro STREAM_VAR is used when calling public functions */ +/* that need an 'optional' stream argument. */ + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + TT_Error error; + + + MUTEX_Create( files.lock ); + files.stream = NULL; + ZERO_Frame( files.frame ); + + if ( ALLOC( files.frame_cache, FRAME_CACHE_SIZE ) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + FREE( files.frame_cache ); + MUTEX_Destroy( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ) + { + MUTEX_Lock( files.lock ); /* lock file mutex */ + + *stream = org_stream; /* copy the stream */ + files.stream = STREAM2REC(org_stream); /* set current stream */ + + Stream_Activate( files.stream ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream target stream + * + * Output : Error code. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + HANDLE_Set( *stream, NULL ); + MUTEX_Release( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( size <= FRAME_CACHE_SIZE ) + { + /* use the cache */ + CUR_Frame.address = files.frame_cache; + CUR_Frame.size = FRAME_CACHE_SIZE; + } + else + { + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + } + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if (error) + { + if ( size > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + CUR_Frame.address = NULL; + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * `size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function truncates `size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes, requested; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( size <= FRAME_CACHE_SIZE ) + { + /* use the cache */ + CUR_Frame.address = files.frame_cache; + CUR_Frame.size = FRAME_CACHE_SIZE; + } + else + { + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + } + + requested = size; + readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); + if ( size > readBytes ) + size = readBytes; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if (error) + { + if ( requested > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + CUR_Frame.address = NULL; + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + if ( CUR_Frame.size > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + + ZERO_Frame( CUR_Frame ); + + return TT_Err_Ok; + } + + +#else /* TT_CONFIG_OPTION_THREAD_SAFE */ + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /******** ********/ + /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ + /******** ********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/* a simple macro to access the file component's data */ +#define files ( *((TFile_Component*)engine.file_component) ) + +#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ +#define CUR_Frame (*frame) + +#define STREAM_VARS stream, +#define STREAM_VAR stream + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Duplicates a stream for a new usage. + * + * Input : input_stream source stream to duplicate + * copy address of target duplicate stream + * + * Output : error code. + * The target stream is set to NULL in case of failure. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream input_stream, + TT_Stream* copy ) + { + PStream_Rec rec = STREAM2REC( input_stream ); + + return TT_Open_Stream( rec->name, copy ); + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream target stream + * + * Output : + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + return TT_Close_Stream( stream ); + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + FREE( CUR_Frame.address ); + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * `size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function truncates `size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + + readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); + if ( size > readBytes ) + size = readBytes; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + FREE( CUR_Frame.address ); + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + FREE( CUR_Frame.address ); + ZERO_Frame( CUR_Frame ); + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /*********** ***********/ + /*********** C O M M O N I M P L E M E N T A T I O N ***********/ + /*********** ***********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/******************************************************************* + * + * Function : Stream_Activate + * + * Description : activates a stream, this will either: + * - open a new file handle if the stream is closed + * - move the stream to the head of the linked list + * + * Input : stream the stream to activate + * + * Output : error condition. + * + * Note : This function is also called with fresh new streams + * created by TT_Open_Stream(). They have their 'size' + * field set to -1. + * + ******************************************************************/ + + TT_Error Stream_Activate( PStream_Rec stream ) + { + if ( !stream->opened ) + { +#ifdef __GEOS__ + if ( (stream->file = FileOpen( (TT_Text*)stream->name, FILE_ACCESS_R | FILE_DENY_W)) == NullHandle ) +#else + if ( (stream->file = fopen( (TT_Text*)stream->name, "rb" )) == 0 ) +#endif /* ifdef __GEOS__ */ + return TT_Err_Could_Not_ReOpen_File; + + stream->opened = TRUE; + + /* A newly created stream has a size field of -1 */ + if ( stream->size < 0 ) + { +#ifdef __GEOS__ + stream->size = FileSize( stream->file ); +#else + fseek( stream->file, 0, SEEK_END ); + stream->size = ftell( stream->file ); + fseek( stream->file, 0, SEEK_SET ); +#endif /* ifdef __GEOS__ */ + } + + /* Reset cursor in file */ + if ( stream->position ) + { +#ifdef __GEOS__ + FilePos( stream->file, stream->position, FILE_POS_START); + if ( ThreadGetError() != NO_ERROR_RETURNED ) + { + /* error during seek */ + FileClose( stream->file, FALSE ); +#else + if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 ) + { + /* error during seek */ + fclose( stream->file ); +#endif /* ifdef __GEOS__ */ + stream->opened = FALSE; + return TT_Err_Could_Not_ReSeek_File; + } + } + } + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Stream_DeActivate + * + * Description : deactivates a stream, this will : + * - close its file handle if it was opened + * - remove it from the opened list if necessary + * + * Input : stream the stream to deactivate + * + * Output : Error condition + * + * Note : the function is called whenever a stream is deleted + * (_not_ when a stream handle's is closed due to an + * activation). However, the stream record isn't + * destroyed by it.. + * + ******************************************************************/ + + static TT_Error Stream_Deactivate( PStream_Rec stream ) + { + if ( stream->opened ) + { + /* Save its current position within the file */ +#ifdef __GEOS__ + stream->position = FilePos( stream->file, 0, FILE_POS_RELATIVE ); + FileClose( stream->file, FALSE ); +#else + stream->position = ftell( stream->file ); + fclose( stream->file ); +#endif /* ifdef __GEOS__ */ + stream->file = 0; + stream->opened = FALSE; + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Stream_Size + * + * Description : Returns the length of a given stream, even if it + * is flushed. + * + * Input : stream the stream + * + * Output : Length of stream in bytes. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Stream_Size( TT_Stream stream ) + { + PStream_Rec rec = STREAM2REC( stream ); + + + if ( rec ) + return rec->size; + else + return 0; /* invalid stream - return 0 */ + } + + +/******************************************************************* + * + * Function : TT_Open_Stream + * + * Description : Opens the font file and saves the total file size. + * + * Input : error address of stream's error variable + * (re-entrant build only) + * filepathname pathname of the file to open + * stream address of target TT_Stream structure + * + * Output : SUCCESS on sucess, FAILURE on error. + * The target stream is set to -1 in case of failure. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Open_Stream( const TT_Text* filepathname, + TT_Stream* stream ) + { + Int len; + TT_Error error; + PStream_Rec stream_rec; + + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) + return error; + + stream_rec = STREAM2REC( *stream ); + +#ifdef __GEOS__ + stream_rec->file = NullHandle; +#else + stream_rec->file = NULL; +#endif /* ifdef __GEOS__ */ + stream_rec->size = -1L; + stream_rec->base = 0; + stream_rec->opened = FALSE; + stream_rec->position = 0; + + len = strlen( filepathname ) + 1; + if ( ALLOC( stream_rec->name, len ) ) + goto Fail; + + strncpy( stream_rec->name, filepathname, len ); + + error = Stream_Activate( stream_rec ); + if ( error ) + goto Fail_Activate; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + CUR_Stream = stream_rec; +#endif + + return TT_Err_Ok; + + Fail_Activate: + FREE( stream_rec->name ); + Fail: + FREE( stream_rec ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Close_Stream + * + * Description : Closes a stream. + * + * Input : stream address of target TT_Stream structure + * + * Output : SUCCESS (always). + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Close_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + Stream_Deactivate( rec ); + FREE( rec->name ); + FREE( rec ); + + HANDLE_Set( *stream, NULL ); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Stream + * + * Description : Flushes a stream, i.e., closes its file handle. + * + * Input : stream address of target TT_Stream structure + * + * Output : Error code + * + * NOTE : Never flush the current opened stream. This means that + * you should _never_ call this function between a + * TT_Use_Stream() and a TT_Done_Stream()! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + if ( rec ) + { + Stream_Deactivate( rec ); + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + +/******************************************************************* + * + * Function : TT_Seek_File + * + * Description : Seeks the file cursor to a different position. + * + * Input : position new position in file + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Seek_File( STREAM_ARGS Long position ) + { + position += CUR_Stream->base; + +#ifdef __GEOS__ + FilePos( CUR_Stream->file, position, FILE_POS_START ); + if ( ThreadGetError() != NO_ERROR_RETURNED ) +#else + if ( fseek( CUR_Stream->file, position, SEEK_SET ) ) +#endif /* ifdef __GEOS__ */ + return TT_Err_Invalid_File_Offset; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Skip_File + * + * Description : Skips forward the file cursor. + * + * Input : distance number of bytes to skip + * + * Output : see TT_Seek_File() + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Skip_File( STREAM_ARGS Long distance ) + { + return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) - + CUR_Stream->base + distance ); + } + + +/******************************************************************* + * + * Function : TT_Read_File + * + * Description : Reads a chunk of the file and copies it to memory. + * + * Input : buffer target buffer + * count length in bytes to read + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) + { + #ifdef __GEOS__ + if ( FileRead( CUR_Stream->file, buffer, count, FALSE ) != (ULong)count ) + #else + if ( fread( buffer, 1, count, CUR_Stream->file ) != (ULong)count ) + #endif /* ifdef __GEOS__ */ + return TT_Err_Invalid_File_Read; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Read_At_File + * + * Description : Reads file at a specified position. + * + * Input : position position to seek to before read + * buffer target buffer + * count number of bytes to read + * + * Output : SUCCESS on success. FAILURE if error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ) + { + TT_Error error; + + + if ( (error = TT_Seek_File( STREAM_VARS position )) != TT_Err_Ok || + (error = TT_Read_File( STREAM_VARS buffer, count )) != TT_Err_Ok ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_File_Pos + * + * Description : Returns current file seek pointer. + * + * Input : none + * + * Output : Current file position. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_File_Pos( STREAM_ARG ) + { + #ifdef __GEOS__ + return FilePos( CUR_Stream->file, 0, FILE_POS_RELATIVE ) - CUR_Stream->base; + #else + return ftell( CUR_Stream->file ) - CUR_Stream->base; + #endif /* ifdef __GEOS__ */ + } + + +/******************************************************************* + * + * Function : GET_Byte + * + * Description : Extracts a byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted Byte. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + Byte TT_Get_Byte( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Byte)(*CUR_Frame.cursor++); + } +#endif + + +/******************************************************************* + * + * Function : GET_Char + * + * Description : Extracts a signed byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted char. + * + ******************************************************************/ + EXPORT_FUNC + Char TT_Get_Char( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Char)(*CUR_Frame.cursor++); + } + + +/******************************************************************* + * + * Function : GET_Short + * + * Description : Extracts a short from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted short. + * + ******************************************************************/ + + EXPORT_FUNC + Short TT_Get_Short( FRAME_ARG ) + { + Short getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = (Short)((CUR_Frame.cursor[0] << 8) | + CUR_Frame.cursor[1]); + + CUR_Frame.cursor += 2; + + return getshort; + } + + +/******************************************************************* + * + * Function : GET_UShort + * + * Description : Extracts an unsigned short from the frame. + * + * Input : None or current frame + * + * Output : Extracted ushort. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + UShort TT_Get_UShort( FRAME_ARG ) + { + UShort getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = (UShort)((CUR_Frame.cursor[0] << 8) | + CUR_Frame.cursor[1]); + + CUR_Frame.cursor += 2; + + return getshort; + } +#endif + + +/******************************************************************* + * + * Function : GET_Long + * + * Description : Extracts a long from the frame. + * + * Input : None or current frame + * + * Output : Extracted long. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Get_Long( FRAME_ARG ) + { + Long getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ((Long)CUR_Frame.cursor[0] << 24) | + ((Long)CUR_Frame.cursor[1] << 16) | + ((Long)CUR_Frame.cursor[2] << 8 ) | + (Long)CUR_Frame.cursor[3]; + + CUR_Frame.cursor += 4; + + return getlong; + } + + +/******************************************************************* + * + * Function : GET_ULong + * + * Description : Extracts an unsigned long from the frame. + * + * Input : None or current frame + * + * Output : Extracted ulong. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + ULong TT_Get_ULong( FRAME_ARG ) + { + ULong getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | + ((ULong)CUR_Frame.cursor[1] << 16) | + ((ULong)CUR_Frame.cursor[2] << 8 ) | + (ULong)CUR_Frame.cursor[3] ); + + CUR_Frame.cursor += 4; + + return getlong; + } +#endif + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h new file mode 100644 index 000000000..64fb233c1 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h @@ -0,0 +1,271 @@ +/******************************************************************* + * + * ttfile.h 1.3 + * + * File I/O Component (specification). + * + * 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. + * + * Changes between 1.3 and 1.2: + * + * - all functions report error values now + * + * - the stream semantics have also changed + * + * Changes between 1.2 and 1.1: + * + * - added macros to support re-entrant builds + * + * - added the TT_Duplicate_File function to duplicate streams + * (re-entrant builds only) + * + ******************************************************************/ + +#ifndef TTFILE_H +#define TTFILE_H + +#include "ttconfig.h" +#include "freetype.h" +#include "ttengine.h" +#include "ttdebug.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /* Initialize file component */ + LOCAL_DEF + TT_Error TTFile_Init( PEngine_Instance engine ); + + /* Done with file component */ + LOCAL_DEF + TT_Error TTFile_Done( PEngine_Instance engine ); + + + /**********************************************************************/ + /* */ + /* Stream functions. */ + /* */ + /**********************************************************************/ + + /* Open a file and return a stream handle for it. */ + /* Should only be used for a new face object's main stream. */ + + LOCAL_DEF + TT_Error TT_Open_Stream( const TT_Text* name, + TT_Stream* stream ); + + + /* Closes, then discards, a stream when it's no longer needed. */ + /* Should only be used for a stream opend with TT_Open_Stream(). */ + + LOCAL_DEF + TT_Error TT_Close_Stream( TT_Stream* stream ); + + + /* Informs the component that we're going to use the file */ + /* opened in 'org_stream', and report errors to the 'error' */ + /* variable. */ + + /* in non re-entrant builds, 'org_stream' is simply copied */ + /* to 'stream'. Otherwise, the latter is a duplicate handle */ + /* for the file opened with 'org_stream' */ + + EXPORT_DEF + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ); + + /* Informs the component that we don't need to perform file */ + /* operations on the stream 'stream' anymore. This must be */ + /* used with streams "opened" with TT_Use_Stream() only! */ + + /* in re-entrant builds, this will really discard the stream */ + + EXPORT_DEF + TT_Error TT_Done_Stream( TT_Stream* stream ); + + /* Closes the stream's file handle to release system resources */ + /* The function TT_Use_Stream automatically re-activates a */ + /* flushed stream when it uses one */ + + EXPORT_DEF + TT_Error TT_Flush_Stream( TT_Stream* stream ); + +/* The macros STREAM_ARGS and STREAM_ARG let us build a thread-safe */ +/* or re-entrant implementation depending on a single configuration */ +/*define. */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define STREAM_ARGS TT_Stream stream, +#define STREAM_ARG TT_Stream stream + +#else + +#define STREAM_ARGS /* void */ +#define STREAM_ARG void + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /****************************************************************/ + /* */ + /* File Functions. */ + /* */ + /* The following functions perform file operations on the */ + /* currently 'used' stream. In thread-safe builds, only one */ + /* stream can be used at a time. Synchronisation is performed */ + /* through the Use_Stream()/Done_Stream() functions. */ + /* */ + /****************************************************************/ + + /* Read 'count' bytes from file into 'buffer' */ + + EXPORT_DEF + TT_Error TT_Read_File( STREAM_ARGS void* buffer, + Long count ); + + + /* Seek file cursor to a given position */ + + EXPORT_DEF + TT_Error TT_Seek_File( STREAM_ARGS Long position ); + + + /* Skip the next 'distance' bytes in file */ + + EXPORT_DEF + TT_Error TT_Skip_File( STREAM_ARGS Long distance ); + + + /* Read the 'count' bytes at 'position' into 'buffer' */ + + EXPORT_DEF + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ); + + /* Return current file position */ + + EXPORT_DEF + Long TT_File_Pos( STREAM_ARG ); + + /* Return length of a given stream, even if it is flushed */ + + EXPORT_DEF + Long TT_Stream_Size( TT_Stream stream ); + + + /********************************************************************/ + /* */ + /* Frame operations. */ + /* */ + /* For a comprehensive explanation of frames, please refer to the */ + /* documentation files. */ + /* */ + /********************************************************************/ + + /* Frame type declaration.*/ + + struct TFileFrame_ + { + Byte* address; /* frame buffer */ + Byte* cursor; /* current cursor position in frame */ + Long size; /* frame size */ + }; + + typedef struct TFileFrame_ TFileFrame; + + EXPORT_DEF + const TFileFrame TT_Null_FileFrame; + + +/* The macro ZERO_Frame is used to define and init a frame. */ +/* It is important to have a default frame of { NULL, NULL, 0 } */ +/* before a call to TT_Access_Frame(). Otherwise, the call will */ +/* fail with a TT_Err_Nested_Frame_Accesses error. */ + +#define ZERO_Frame( frame ) \ + { \ + (frame).address = NULL; \ + (frame).cursor = NULL; \ + (frame).size = 0; \ + } + + +/* The macros FRAME_ARGS and FRAME_ARG let us build a thread-safe */ +/* or re-entrant implementation depending on a single configuration */ +/* define */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define FRAME_ARGS TFileFrame* frame, +#define FRAME_ARG TFileFrame* frame + +#else + +#define FRAME_ARGS /* void */ +#define FRAME_ARG void + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /* Access the next 'size' bytes from current position. */ + /* Fails if all bytes cannot be read/accessed. */ + + EXPORT_DEF + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ); + + + /* Access the bytes located in the next 'size' bytes of the file. */ + /* Doesn't fail if less than 'size' bytes are accessible (like */ + /* at the end of the file). */ + + EXPORT_DEF + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ); + + /* Forget frame */ + + EXPORT_DEF + TT_Error TT_Forget_Frame( FRAME_ARG ); + + + /* primitive routines for data accessing */ + + EXPORT_DEF + Char TT_Get_Char ( FRAME_ARG ); + EXPORT_DEF + Short TT_Get_Short( FRAME_ARG ); + EXPORT_DEF + Long TT_Get_Long ( FRAME_ARG ); + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define TT_Get_Byte( frame ) ( (Byte )TT_Get_Char ( frame ) ) +#define TT_Get_UShort( frame ) ( (UShort)TT_Get_Short( frame ) ) +#define TT_Get_ULong( frame ) ( (ULong )TT_Get_Long ( frame ) ) + +#else + +#define TT_Get_Byte() ( (Byte )TT_Get_Char () ) +#define TT_Get_UShort() ( (UShort)TT_Get_Short() ) +#define TT_Get_ULong() ( (ULong )TT_Get_Long () ) + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + +#ifdef __cplusplus + } +#endif + +#endif /* TTFILE_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttgload.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttgload.c new file mode 100644 index 000000000..a10418e51 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttgload.c @@ -0,0 +1,1351 @@ +/******************************************************************* + * + * ttgload.c 1.0 + * + * TrueType Glyph Loader. + * + * 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 "tttypes.h" +#include "ttdebug.h" +#include "ttcalc.h" +#include "ttfile.h" + +#include "tttables.h" +#include "ttobjs.h" +#include "ttgload.h" + +#include "ttmemory.h" +#include "tttags.h" +#include "ttload.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_gload + + +/* composite font flags */ + +#define ARGS_ARE_WORDS 0x001 +#define ARGS_ARE_XY_VALUES 0x002 +#define ROUND_XY_TO_GRID 0x004 +#define WE_HAVE_A_SCALE 0x008 +/* reserved 0x010 */ +#define MORE_COMPONENTS 0x020 +#define WE_HAVE_AN_XY_SCALE 0x040 +#define WE_HAVE_A_2X2 0x080 +#define WE_HAVE_INSTR 0x100 +#define USE_MY_METRICS 0x200 + + +/********************************************************/ +/* Return horizontal or vertical metrics in font units */ +/* for a given glyph. The metrics are the left side */ +/* bearing (resp. top side bearing) and advance width */ +/* (resp. advance height). */ +/* */ +/* This function will much probably move to another */ +/* component in the short future, but I haven't decided */ +/* which yet... */ + + LOCAL_FUNC + void TT_Get_Metrics( TT_Horizontal_Header* header, + UShort index, + Short* bearing, + UShort* advance ) + { + PLongMetrics longs_m; + + UShort k = header->number_Of_HMetrics; + + + if ( index < k ) + { + longs_m = (PLongMetrics)header->long_metrics + index; + *bearing = longs_m->bearing; + *advance = longs_m->advance; + } + else + { + *bearing = ((PShortMetrics)header->short_metrics)[index - k]; + *advance = ((PLongMetrics)header->long_metrics)[k - 1].advance; + } + } + + +/********************************************************/ +/* Return horizontal metrics in font units for a given */ +/* glyph. If `check' is true, take care of mono-spaced */ +/* fonts by returning the advance width max. */ + + static void Get_HMetrics( PFace face, + UShort index, + Bool check, + Short* lsb, + UShort* aw ) + { + TT_Get_Metrics( &face->horizontalHeader, index, lsb, aw ); + + if ( check && face->postscript.isFixedPitch ) + *aw = face->horizontalHeader.advance_Width_Max; + } + + +/********************************************************/ +/* Return advance width table for a given pixel size */ +/* if it is found in the font's `hdmx' table (if any). */ + + static PByte Get_Advance_Widths( PFace face, + UShort ppem ) + { + UShort n; + + + for ( n = 0; n < face->hdmx.num_records; n++ ) + if ( face->hdmx.records[n].ppem == ppem ) + return face->hdmx.records[n].widths; + + return NULL; + } + + +/********************************************************/ +/* Copy current glyph into original one. */ + +#define cur_to_org( n, zone ) \ + MEM_Copy( (zone)->org, (zone)->cur, (n) * sizeof ( TT_Vector ) ) + +/********************************************************/ +/* copy original glyph into current one */ + +#define org_to_cur( n, zone ) \ + MEM_Copy( (zone)->cur, (zone)->org, (n) * sizeof ( TT_Vector ) ) + +/********************************************************/ +/* translate an array of coordinates */ + + static void translate_array( UShort n, + TT_Vector* coords, + TT_Pos delta_x, + TT_Pos delta_y ) + { + UShort k; + + + if ( delta_x ) + for ( k = 0; k < n; k++ ) + coords[k].x += delta_x; + + if ( delta_y ) + for ( k = 0; k < n; k++ ) + coords[k].y += delta_y; + } + + +/********************************************************/ +/* mount one zone on top of another */ + + static void mount_zone( PGlyph_Zone source, + PGlyph_Zone target ) + { + UShort np; + Short nc; + + np = source->n_points; + nc = source->n_contours; + + target->org = source->org + np; + target->cur = source->cur + np; + target->touch = source->touch + np; + + target->contours = source->contours + nc; + + target->n_points = 0; + target->n_contours = 0; + } + + +/******************************************************************* + * + * Function: Load_Simple_Glyph + * + ******************************************************************/ + + static TT_Error Load_Simple_Glyph( PExecution_Context exec, + TT_Stream input, + Short n_contours, + Short left_contours, + UShort left_points, + UShort load_flags, + PSubglyph_Record subg ) + { + DEFINE_LOAD_LOCALS( input ); + + PGlyph_Zone pts; + Short k; + UShort j; + UShort n_points, n_ins; + PFace face; + Byte* flag; + TT_Vector* vec; + TT_F26Dot6 x, y; + + + face = exec->face; + + /* simple check */ + if ( n_contours > left_contours ) + { + PTRACE0(( "ERROR: Glyph index %ld has %d contours > left %d\n", + subg->index, n_contours, left_contours )); + return TT_Err_Too_Many_Contours; + } + + + /* preparing the execution context */ + mount_zone( &subg->zone, &exec->pts ); + + /* reading the contours endpoints */ + if ( ACCESS_Frame( (n_contours + 1) * 2L ) ) + return error; + + PTRACE4(( " Contour endpoints:" )); + + for ( k = 0; k < n_contours; k++ ) + { + exec->pts.contours[k] = GET_UShort(); + PTRACE4(( " %d", exec->pts.contours[k] )); + } + PTRACE4(( "\n" )); + + if ( n_contours > 0 ) + n_points = exec->pts.contours[n_contours - 1] + 1; + else + n_points = 0; + + n_ins = GET_UShort(); + + FORGET_Frame(); + + if ( n_points > left_points ) + { + PTRACE0(( "ERROR: Too many points in glyph %ld\n", subg->index )); + return TT_Err_Too_Many_Points; + } + + /* loading instructions */ + + PTRACE4(( " Instructions size: %d\n", n_ins )); + + if ( n_ins > face->maxProfile.maxSizeOfInstructions ) + { + PTRACE0(( "ERROR: Too many instructions!\n" )); + return TT_Err_Too_Many_Ins; + } + + if ( FILE_Read( exec->glyphIns, n_ins ) ) + return error; + + if ( (error = Set_CodeRange( exec, + TT_CodeRange_Glyph, + exec->glyphIns, + n_ins )) != TT_Err_Ok ) + return error; + + + /* read the flags */ + + if ( CHECK_ACCESS_Frame( n_points * 5L ) ) + return error; + + j = 0; + flag = exec->pts.touch; + + while ( j < n_points ) + { + Byte c, cnt; + + flag[j] = c = GET_Byte(); + j++; + + if ( c & 8 ) + { + cnt = GET_Byte(); + while( cnt > 0 ) + { + flag[j++] = c; + cnt--; + } + } + } + + /* read the X */ + + x = 0; + vec = exec->pts.org; + + for ( j = 0; j < n_points; j++ ) + { + if ( flag[j] & 2 ) + { + if ( flag[j] & 16 ) + x += GET_Byte(); + else + x -= GET_Byte(); + } + else + { + if ( (flag[j] & 16) == 0 ) + x += GET_Short(); + } + + vec[j].x = x; + } + + + /* read the Y */ + + y = 0; + + for ( j = 0; j < n_points; j++ ) + { + if ( flag[j] & 4 ) + { + if ( flag[j] & 32 ) + y += GET_Byte(); + else + y -= GET_Byte(); + } + else + { + if ( (flag[j] & 32) == 0 ) + y += GET_Short(); + } + + vec[j].y = y; + } + + FORGET_Frame(); + + /* Now add the two shadow points at n and n + 1. */ + /* We need the left side bearing and advance width. */ + + /* pp1 = xMin - lsb */ + vec[n_points].x = subg->metrics.bbox.xMin - subg->metrics.horiBearingX; + vec[n_points].y = 0; + + /* pp2 = pp1 + aw */ + vec[n_points+1].x = vec[n_points].x + subg->metrics.horiAdvance; + vec[n_points+1].y = 0; + + /* clear the touch flags */ + + for ( j = 0; j < n_points; j++ ) + exec->pts.touch[j] &= TT_Flag_On_Curve; + + exec->pts.touch[n_points ] = 0; + exec->pts.touch[n_points + 1] = 0; + + /* Note that we return two more points that are not */ + /* part of the glyph outline. */ + + n_points += 2; + + /* now eventually scale and hint the glyph */ + + pts = &exec->pts; + pts->n_points = n_points; + pts->n_contours = n_contours; + + if ( (load_flags & TTLOAD_SCALE_GLYPH) == 0 ) + { + /* no scaling, just copy the orig arrays into the cur ones */ + org_to_cur( n_points, pts ); + } + else + { + /* first scale the glyph points */ + + for ( j = 0; j < n_points; j++ ) + { + pts->org[j].x = Scale_X( &exec->metrics, pts->org[j].x ); + pts->org[j].y = Scale_Y( &exec->metrics, pts->org[j].y ); + } + + /* if hinting, round pp1, and shift the glyph accordingly */ + if ( subg->is_hinted ) + { + x = pts->org[n_points - 2].x; + x = ((x+32) & -64) - x; + translate_array( n_points, pts->org, x, 0 ); + + org_to_cur( n_points, pts ); + + pts->cur[n_points - 1].x = (pts->cur[n_points - 1].x + 32) & -64; + + /* now consider hinting */ + if ( n_ins > 0 ) + { + exec->is_composite = FALSE; + exec->pedantic_hinting = load_flags & TTLOAD_PEDANTIC; + + error = Context_Run( exec, FALSE ); + if (error && exec->pedantic_hinting) + return error; + } + } + else + org_to_cur( n_points, pts ); + } + + /* save glyph phantom points */ + if (!subg->preserve_pps) + { + subg->pp1 = pts->cur[n_points - 2]; + subg->pp2 = pts->cur[n_points - 1]; + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_Composite_End + * + ******************************************************************/ + + static + TT_Error Load_Composite_End( UShort n_points, + Short n_contours, + PExecution_Context exec, + PSubglyph_Record subg, + UShort load_flags, + TT_Stream input ) + { + DEFINE_LOAD_LOCALS( input ); + + UShort k, n_ins; + PGlyph_Zone pts; + + + if ( subg->is_hinted && + subg->element_flag & WE_HAVE_INSTR ) + { + if ( ACCESS_Frame( 2L ) ) + return error; + + n_ins = GET_UShort(); /* read size of instructions */ + FORGET_Frame(); + + PTRACE4(( " Instructions size: %d\n", n_ins )); + + if ( n_ins > exec->face->maxProfile.maxSizeOfInstructions ) + { + PTRACE0(( "ERROR: Too many instructions in composite glyph %ld\n", + subg->index )); + return TT_Err_Too_Many_Ins; + } + + if ( FILE_Read( exec->glyphIns, n_ins ) ) + return error; + + error = Set_CodeRange( exec, + TT_CodeRange_Glyph, + exec->glyphIns, + n_ins ); + + if ( error ) + return error; + } + else + n_ins = 0; + + + /* prepare the execution context */ + n_points += 2; + exec->pts = subg->zone; + pts = &exec->pts; + + pts->n_points = n_points; + pts->n_contours = n_contours; + + /* add phantom points */ + pts->cur[n_points - 2] = subg->pp1; + pts->cur[n_points - 1] = subg->pp2; + + pts->touch[n_points - 1] = 0; + pts->touch[n_points - 2] = 0; + + /* if hinting, round the phantom points */ + if ( subg->is_hinted ) + { + pts->cur[n_points - 2].x = (subg->pp1.x + 32) & -64; + pts->cur[n_points - 1].x = (subg->pp2.x + 32) & -64; + } + + for ( k = 0; k < n_points; k++ ) + pts->touch[k] &= TT_Flag_On_Curve; + + cur_to_org( n_points, pts ); + + /* now consider hinting */ + if ( subg->is_hinted && n_ins > 0 ) + { + exec->is_composite = TRUE; + exec->pedantic_hinting = load_flags & TTLOAD_PEDANTIC; + + error = Context_Run( exec, FALSE ); + if (error && exec->pedantic_hinting) + return error; + } + + /* save glyph origin and advance points */ + subg->pp1 = pts->cur[n_points - 2]; + subg->pp2 = pts->cur[n_points - 1]; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Init_Glyph_Component + * + ******************************************************************/ + + static + void Init_Glyph_Component( PSubglyph_Record element, + PSubglyph_Record original, + PExecution_Context exec ) + { + element->index = -1; + element->is_scaled = FALSE; + element->is_hinted = FALSE; + + if ( original ) + mount_zone( &original->zone, &element->zone ); + else + element->zone = exec->pts; + + element->zone.n_contours = 0; + element->zone.n_points = 0; + + element->arg1 = 0; + element->arg2 = 0; + + element->element_flag = 0; + element->preserve_pps = FALSE; + + element->transform.xx = 1L << 16; + element->transform.xy = 0; + element->transform.yx = 0; + element->transform.yy = 1L << 16; + + element->transform.ox = 0; + element->transform.oy = 0; + + element->metrics.horiBearingX = 0; + element->metrics.horiAdvance = 0; + } + + + + LOCAL_FUNC + TT_Error Load_TrueType_Glyph( PInstance instance, + PGlyph glyph, + UShort glyph_index, + UShort load_flags ) + { + enum TPhases_ + { + Load_Exit, + Load_Glyph, + Load_Header, + Load_Simple, + Load_Composite, + Load_End + }; + + typedef enum TPhases_ TPhases; + + DEFINE_ALL_LOCALS; + + PFace face; + + UShort num_points; + Short num_contours; + UShort left_points; + Short left_contours; + UShort num_elem_points; + + Long table; + UShort load_top; + Long k, l; + UShort new_flags; + Long index; + UShort u, v; + + Long glyph_offset, offset; + + TT_F26Dot6 x, y, nx, ny; + + Fixed xx, xy, yx, yy; + + PExecution_Context exec; + + PSubglyph_Record subglyph, subglyph2; + + TGlyph_Zone base_pts; + + TPhases phase; + PByte widths; + +/* TT_Glyph_Loader_Callback cacheCb; */ +/* TT_Outline cached_outline; */ + + + /* first of all, check arguments */ + if ( !glyph ) + return TT_Err_Invalid_Glyph_Handle; + + face = glyph->face; + if ( !face ) + return TT_Err_Invalid_Glyph_Handle; + + if ( glyph_index >= face->numGlyphs ) + return TT_Err_Invalid_Glyph_Index; + + if ( instance && (load_flags & TTLOAD_SCALE_GLYPH) == 0 ) + { + instance = 0; + load_flags &= ~( TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH ); + } + + table = TT_LookUp_Table( face, TTAG_glyf ); + if ( table < 0 ) + { + PTRACE0(( "ERROR: There is no glyph table in this font file!\n" )); + return TT_Err_Glyf_Table_Missing; + } + + glyph_offset = face->dirTables[table].Offset; + + /* query new execution context */ + + if ( instance && instance->debug ) + exec = instance->context; + else + exec = New_Context( face ); + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + Context_Load( exec, face, instance ); + + if ( instance ) + { + if ( instance->GS.instruct_control & 2 ) + exec->GS = Default_GraphicsState; + else + exec->GS = instance->GS; + /* load default graphics state */ + + glyph->outline.high_precision = ( instance->metrics.y_ppem < 24 ); + } + + /* save its critical pointers, as they'll be modified during load */ + base_pts = exec->pts; + + /* init variables */ + left_points = face->maxPoints; + left_contours = face->maxContours; + + num_points = 0; + num_contours = 0; + + load_top = 0; + subglyph = exec->loadStack; + + Init_Glyph_Component( subglyph, NULL, exec ); + + subglyph->index = glyph_index; + subglyph->is_hinted = load_flags & TTLOAD_HINT_GLYPH; + + /* when the cvt program has disabled hinting, the argument */ + /* is ignored. */ + if ( instance && instance->GS.instruct_control & 1 ) + subglyph->is_hinted = FALSE; + + + /* now access stream */ + + if ( USE_Stream( face->stream, stream ) ) + goto Fin; + + /* Main loading loop */ + + phase = Load_Glyph; + index = 0; + + while ( phase != Load_Exit ) + { + subglyph = exec->loadStack + load_top; + + switch ( phase ) + { + /************************************************************/ + /* */ + /* Load_Glyph state */ + /* */ + /* reading a glyph's generic header to determine */ + /* whether it's simple or composite */ + /* */ + /* exit states: Load_Header and Load_End */ + + case Load_Glyph: + /* check glyph index and table */ + + index = subglyph->index; + if ( index < 0 || index >= face->numGlyphs ) + { + error = TT_Err_Invalid_Glyph_Index; + goto Fail; + } + + /* get horizontal metrics */ + + { + Short left_bearing; + UShort advance_width; + + + Get_HMetrics( face, (UShort)index, + !(load_flags & TTLOAD_IGNORE_GLOBAL_ADVANCE_WIDTH), + &left_bearing, + &advance_width ); + + subglyph->metrics.horiBearingX = left_bearing; + subglyph->metrics.horiAdvance = advance_width; + } + + phase = Load_Header; + + + /* The cache callback isn't part of the FreeType release yet */ + /* It is discarded for the moment.. */ + /* */ +#if 0 + if ( instance ) + { + /* is the glyph in an outline cache ? */ + cacheCb = instance->owner->engine->glCallback; + if ( cacheCb && 0 ) /* disabled */ + { + /* we have a callback */ + error = cacheCb( instance->generic, + index, &cached_outline, &x, &y ); + if ( !error ) + { + /* no error, then append the outline to the current subglyph */ + /* error = Append_Outline( subglyph, + &left_points, + &left_contours, + &cached_outline ); */ + phase = Load_End; + } + } + } +#endif + break; + + + /************************************************************/ + /* */ + /* Load_Header state */ + /* */ + /* reading a glyph's generic header to determine */ + /* wether it's simple or composite */ + /* */ + /* exit states: Load_Simple and Load_Composite */ + /* */ + + case Load_Header: /* load glyph */ + + if ( index + 1 < face->numLocations && + face->glyphLocations[index] == face->glyphLocations[index + 1] ) + { + /* as described by Frederic Loyer, these are spaces, and */ + /* not the unknown glyph. */ + + num_contours = 0; + num_points = 0; + + subglyph->metrics.bbox.xMin = 0; + subglyph->metrics.bbox.xMax = 0; + subglyph->metrics.bbox.yMin = 0; + subglyph->metrics.bbox.yMax = 0; + + subglyph->pp1.x = 0; + subglyph->pp2.x = subglyph->metrics.horiAdvance; + if (load_flags & TTLOAD_SCALE_GLYPH) + subglyph->pp2.x = Scale_X( &exec->metrics, subglyph->pp2.x ); + + exec->glyphSize = 0; + phase = Load_End; + break; + } + + offset = glyph_offset + face->glyphLocations[index]; + + /* read first glyph header */ + if ( FILE_Seek( offset ) || + ACCESS_Frame( 10L ) ) + goto Fail_File; + + num_contours = GET_Short(); + + subglyph->metrics.bbox.xMin = GET_Short(); + subglyph->metrics.bbox.yMin = GET_Short(); + subglyph->metrics.bbox.xMax = GET_Short(); + subglyph->metrics.bbox.yMax = GET_Short(); + + FORGET_Frame(); + + PTRACE6(( "Glyph %ld:\n", index )); + PTRACE6(( " # of contours: %d\n", num_contours )); + PTRACE6(( " xMin: %4d xMax: %4d\n", + subglyph->metrics.bbox.xMin, + subglyph->metrics.bbox.xMax )); + PTRACE6(( " yMin: %4d yMax: %4d\n", + subglyph->metrics.bbox.yMin, + subglyph->metrics.bbox.yMax )); + + if ( num_contours > left_contours ) + { + PTRACE0(( "ERROR: Too many contours for glyph %ld\n", index )); + error = TT_Err_Too_Many_Contours; + goto Fail; + } + + subglyph->pp1.x = subglyph->metrics.bbox.xMin - + subglyph->metrics.horiBearingX; + subglyph->pp1.y = 0; + subglyph->pp2.x = subglyph->pp1.x + subglyph->metrics.horiAdvance; + if (load_flags & TTLOAD_SCALE_GLYPH) + { + subglyph->pp1.x = Scale_X( &exec->metrics, subglyph->pp1.x ); + subglyph->pp2.x = Scale_X( &exec->metrics, subglyph->pp2.x ); + } + + /* is it a simple glyph ? */ + if ( num_contours > 0 ) + phase = Load_Simple; + else + phase = Load_Composite; + + break; + + + /************************************************************/ + /* */ + /* Load_Simple state */ + /* */ + /* reading a simple glyph (num_contours must be set to */ + /* the glyph's number of contours.) */ + /* */ + /* exit states : Load_End */ + /* */ + + case Load_Simple: + new_flags = load_flags; + + /* disable hinting when scaling */ + if ( !subglyph->is_hinted ) + new_flags &= ~TTLOAD_HINT_GLYPH; + + error = Load_Simple_Glyph( exec, + stream, + num_contours, + left_contours, + left_points, + new_flags, + subglyph ); + if ( error ) + goto Fail; + + /* Note: We could have put the simple loader source there */ + /* but the code is fat enough already :-) */ + + num_points = exec->pts.n_points - 2; + + phase = Load_End; + + break; + + + /************************************************************/ + /* */ + /* Load_Composite state */ + /* */ + /* reading a composite glyph header a pushing a new */ + /* load element on the stack. */ + /* */ + /* exit states: Load_Glyph */ + /* */ + + case Load_Composite: + + /* create a new element on the stack */ + load_top++; + + if ( load_top > face->maxComponents ) + { + error = TT_Err_Invalid_Composite; + goto Fail; + } + + subglyph2 = exec->loadStack + load_top; + + Init_Glyph_Component( subglyph2, subglyph, NULL ); + subglyph2->is_hinted = subglyph->is_hinted; + + /* now read composite header */ + + if ( ACCESS_Frame( 4L ) ) + goto Fail_File; + + subglyph->element_flag = new_flags = GET_UShort(); + + subglyph2->index = GET_UShort(); + + FORGET_Frame(); + + k = 1 + 1; + + if ( new_flags & ARGS_ARE_WORDS ) + k *= 2; + + if ( new_flags & WE_HAVE_A_SCALE ) + k += 2; + + else if ( new_flags & WE_HAVE_AN_XY_SCALE ) + k += 4; + + else if ( new_flags & WE_HAVE_A_2X2 ) + k += 8; + + if ( ACCESS_Frame( k ) ) + goto Fail_File; + + if ( new_flags & ARGS_ARE_WORDS ) + { + k = GET_Short(); + l = GET_Short(); + } + else + { + k = GET_Char(); + l = GET_Char(); + } + + subglyph->arg1 = k; + subglyph->arg2 = l; + + if ( new_flags & ARGS_ARE_XY_VALUES ) + { + subglyph->transform.ox = k; + subglyph->transform.oy = l; + } + + xx = 1L << 16; + xy = 0; + yx = 0; + yy = 1L << 16; + + if ( new_flags & WE_HAVE_A_SCALE ) + { + xx = (Fixed)GET_Short() << 2; + yy = xx; + subglyph2->is_scaled = TRUE; + } + else if ( new_flags & WE_HAVE_AN_XY_SCALE ) + { + xx = (Fixed)GET_Short() << 2; + yy = (Fixed)GET_Short() << 2; + subglyph2->is_scaled = TRUE; + } + else if ( new_flags & WE_HAVE_A_2X2 ) + { + xx = (Fixed)GET_Short() << 2; + xy = (Fixed)GET_Short() << 2; + yx = (Fixed)GET_Short() << 2; + yy = (Fixed)GET_Short() << 2; + subglyph2->is_scaled = TRUE; + } + + FORGET_Frame(); + + subglyph->transform.xx = xx; + subglyph->transform.xy = xy; + subglyph->transform.yx = yx; + subglyph->transform.yy = yy; + + k = TT_MulFix( xx, yy ) - TT_MulFix( xy, yx ); + + /* disable hinting in case of scaling/slanting */ + if ( ABS( k ) != (1L << 16) ) + subglyph2->is_hinted = FALSE; + + subglyph->file_offset = FILE_Pos(); + + phase = Load_Glyph; + + break; + + + /************************************************************/ + /* */ + /* Load_End state */ + /* */ + /* after loading a glyph, apply transformation and offset */ + /* where necessary, pops element and continue or */ + /* stop process. */ + /* */ + /* exit states : Load_Composite and Load_Exit */ + /* */ + + case Load_End: + if ( load_top > 0 ) + { + subglyph2 = subglyph; + + load_top--; + subglyph = exec->loadStack + load_top; + + /* check advance width and left side bearing */ + + if ( !subglyph->preserve_pps && + subglyph->element_flag & USE_MY_METRICS ) + { + subglyph->metrics.horiBearingX = subglyph2->metrics.horiBearingX; + subglyph->metrics.horiAdvance = subglyph2->metrics.horiAdvance; + + subglyph->pp1 = subglyph2->pp1; + subglyph->pp2 = subglyph2->pp2; + + subglyph->preserve_pps = TRUE; + } + + /* apply scale */ + + if ( subglyph2->is_scaled ) + { + TT_Vector* cur = subglyph2->zone.cur; + TT_Vector* org = subglyph2->zone.org; + + for ( u = 0; u < num_points; u++ ) + { + nx = TT_MulFix( cur->x, subglyph->transform.xx ) + + TT_MulFix( cur->y, subglyph->transform.yx ); + + ny = TT_MulFix( cur->x, subglyph->transform.xy ) + + TT_MulFix( cur->y, subglyph->transform.yy ); + + cur->x = nx; + cur->y = ny; + + nx = TT_MulFix( org->x, subglyph->transform.xx ) + + TT_MulFix( org->y, subglyph->transform.yx ); + + ny = TT_MulFix( org->x, subglyph->transform.xy ) + + TT_MulFix( org->y, subglyph->transform.yy ); + + org->x = nx; + org->y = ny; + + cur++; + org++; + } + } + + /* adjust counts */ + + num_elem_points = subglyph->zone.n_points; + + for ( k = 0; k < num_contours; k++ ) + subglyph2->zone.contours[k] += num_elem_points; + + subglyph->zone.n_points += num_points; + subglyph->zone.n_contours += num_contours; + + left_points -= num_points; + left_contours -= num_contours; + + if ( !(subglyph->element_flag & ARGS_ARE_XY_VALUES) ) + { + /* move second glyph according to control points */ + /* the attach points are relative to the specific component */ + + u = (UShort)subglyph->arg1; + v = (UShort)subglyph->arg2; + + if ( u >= num_elem_points || + v >= num_points ) + { + error = TT_Err_Invalid_Composite; + goto Fail; + } + + /* adjust count */ + v += num_elem_points; + + x = subglyph->zone.cur[u].x - subglyph->zone.cur[v].x; + y = subglyph->zone.cur[u].y - subglyph->zone.cur[v].y; + } + else + { + /* apply offset */ + + x = subglyph->transform.ox; + y = subglyph->transform.oy; + + if ( load_flags & TTLOAD_SCALE_GLYPH ) + { + x = Scale_X( &exec->metrics, x ); + y = Scale_Y( &exec->metrics, y ); + + if ( subglyph->element_flag & ROUND_XY_TO_GRID ) + { + x = (x+32) & -64; + y = (y+32) & -64; + } + } + } + + translate_array( num_points, subglyph2->zone.cur, x, y ); + + cur_to_org( num_points, &subglyph2->zone ); + + num_points = subglyph->zone.n_points; + num_contours = subglyph->zone.n_contours; + + /* check for last component */ + + if ( FILE_Seek( subglyph->file_offset ) ) + goto Fail_File; + + if ( subglyph->element_flag & MORE_COMPONENTS ) + phase = Load_Composite; + else + { + error = Load_Composite_End( num_points, + num_contours, + exec, + subglyph, + load_flags, + stream ); + if ( error ) + goto Fail; + + phase = Load_End; + } + } + else + phase = Load_Exit; + + break; + + + case Load_Exit: + break; + } + } + + /* finally, copy the points arrays to the glyph object */ + + exec->pts = base_pts; + + for ( u = 0; u < num_points + 2; u++ ) + { + glyph->outline.points[u] = exec->pts.cur[u]; + glyph->outline.flags [u] = exec->pts.touch[u]; + } + + for ( k = 0; k < num_contours; k++ ) + glyph->outline.contours[k] = exec->pts.contours[k]; + + glyph->outline.n_points = num_points; + glyph->outline.n_contours = num_contours; + glyph->outline.second_pass = TRUE; + + /* translate array so that (0,0) is the glyph's origin */ + translate_array( num_points + 2, + glyph->outline.points, + -subglyph->pp1.x, + 0 ); + + TT_Get_Outline_BBox( &glyph->outline, &glyph->metrics.bbox ); + + if ( subglyph->is_hinted ) + { + /* grid-fit the bounding box */ + glyph->metrics.bbox.xMin &= -64; + glyph->metrics.bbox.yMin &= -64; + glyph->metrics.bbox.xMax = (glyph->metrics.bbox.xMax+63) & -64; + glyph->metrics.bbox.yMax = (glyph->metrics.bbox.yMax+63) & -64; + } + + /* get the device-independent scaled horizontal metrics */ + /* take care of fixed-pitch fonts... */ + { + TT_Pos left_bearing; + TT_Pos advance; + + + left_bearing = subglyph->metrics.horiBearingX; + advance = subglyph->metrics.horiAdvance; + + if ( face->postscript.isFixedPitch ) + advance = face->horizontalHeader.advance_Width_Max; + + if ( load_flags & TTLOAD_SCALE_GLYPH ) + { + left_bearing = Scale_X( &exec->metrics, left_bearing ); + advance = Scale_X( &exec->metrics, advance ); + } + + glyph->metrics.linearHoriBearingX = left_bearing; + glyph->metrics.linearHoriAdvance = advance; + } + + glyph->metrics.horiBearingX = glyph->metrics.bbox.xMin; + glyph->metrics.horiBearingY = glyph->metrics.bbox.yMax; + glyph->metrics.horiAdvance = subglyph->pp2.x - subglyph->pp1.x; + + /* Now take care of vertical metrics. In the case where there is */ + /* no vertical information within the font (relatively common), make */ + /* up some metrics `by hand' ... */ + + { + Short top_bearing; /* vertical top side bearing (EM units) */ + UShort advance_height; /* vertical advance height (EM units) */ + + TT_Pos left; /* scaled vertical left side bearing */ + TT_Pos Top; /* scaled original vertical top side bearing */ + TT_Pos top; /* scaled vertical top side bearing */ + TT_Pos advance; /* scaled vertical advance height */ + + + /* Get the unscaled `tsb' and `ah' values */ + if ( face->verticalInfo && + face->verticalHeader.number_Of_VMetrics > 0 ) + { + /* Don't assume that both the vertical header and vertical */ + /* metrics are present in the same font :-) */ + + TT_Get_Metrics( (TT_Horizontal_Header*)&face->verticalHeader, + glyph_index, + &top_bearing, + &advance_height ); + } + else + { + /* Make up the distances from the horizontal header.. */ + + /* NOTE: The OS/2 values are the only `portable' ones, */ + /* which is why we use them... */ + /* */ + /* NOTE2: The sTypoDescender is negative, which is why */ + /* we compute the baseline-to-baseline distance */ + /* here with : */ + /* ascender - descender + linegap */ + /* */ + top_bearing = (Short) (face->os2.sTypoLineGap / 2); + advance_height = (UShort)(face->os2.sTypoAscender - + face->os2.sTypoDescender + + face->os2.sTypoLineGap); + } + + /* We must adjust the top_bearing value from the bounding box given + in the glyph header to te bounding box calculated with + TT_Get_Outline_BBox() */ + + /* scale the metrics */ + if ( load_flags & TTLOAD_SCALE_GLYPH ) + { + Top = Scale_Y( &exec->metrics, top_bearing ); + top = Scale_Y( &exec->metrics, + top_bearing + subglyph->metrics.bbox.yMax ) - + glyph->metrics.bbox.yMax; + advance = Scale_Y( &exec->metrics, advance_height ); + } + else + { + Top = top_bearing; + top = top_bearing + subglyph->metrics.bbox.yMax - + glyph->metrics.bbox.yMax; + advance = advance_height; + } + + glyph->metrics.linearVertBearingY = Top; + glyph->metrics.linearVertAdvance = advance; + + /* XXX : for now, we have no better algo for the lsb, but it should */ + /* work ok.. */ + /* */ + left = ( glyph->metrics.bbox.xMin - glyph->metrics.bbox.xMax ) / 2; + + /* grid-fit them if necessary */ + if ( subglyph->is_hinted ) + { + left &= -64; + top = (top + 63) & -64; + advance = (advance + 32) & -64; + } + + glyph->metrics.vertBearingX = left; + glyph->metrics.vertBearingY = top; + glyph->metrics.vertAdvance = advance; + } + + /* Adjust advance width to the value contained in the hdmx table. */ + if ( !exec->face->postscript.isFixedPitch && instance && + subglyph->is_hinted ) + { + widths = Get_Advance_Widths( exec->face, + exec->instance->metrics.x_ppem ); + if ( widths ) + glyph->metrics.horiAdvance = widths[glyph_index] << 6; + } + + glyph->outline.dropout_mode = (Char)exec->GS.scan_type; + + error = TT_Err_Ok; + + Fail_File: + Fail: + DONE_Stream( stream ); + + Fin: + + /* reset the execution context */ + exec->pts = base_pts; + + if ( !instance || !instance->debug ) + Done_Context( exec ); + + return error; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttgload.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttgload.h new file mode 100644 index 000000000..10759abf6 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttgload.h @@ -0,0 +1,51 @@ +/******************************************************************* + * + * ttgload.h 1.0 + * + * TrueType Glyph Loader. + * + * 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 TTGLOAD_H +#define TTGLOAD_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + +#ifdef __cplusplus + extern "C" { +#endif + + + LOCAL_DEF + void TT_Get_Metrics( TT_Horizontal_Header* header, + UShort index, + Short* bearing, + UShort* advance ); + + + LOCAL_DEF + TT_Error Load_TrueType_Glyph( PInstance instance, + PGlyph glyph, + UShort glyph_index, + UShort load_flags ); + +#ifdef __cplusplus + } +#endif + + +#endif /* TTGLOAD_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c new file mode 100644 index 000000000..fbe2fbe74 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c @@ -0,0 +1,6654 @@ +/******************************************************************* + * + * ttinterp.c 3.1 + * + * TrueType bytecode intepreter. + * + * 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. + * + * + * Changes between 3.1 and 3.0: + * + * - A more relaxed version of the interpreter. It is now able to + * ignore errors like out-of-bound array access and writes in order + * to silently support broken glyphs (even if the results are not + * always pretty). + * + * Note that one can use the flag TTLOAD_PEDANTIC to force + * TrueType-compliant interpretation. + * + * - A big #if used to completely disable the interpreter, which + * is due to the Apple patents issues which emerged recently. + * + ******************************************************************/ + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttcalc.h" +#include "ttmemory.h" +#include "ttinterp.h" + + +#ifdef TT_CONFIG_OPTION_NO_INTERPRETER + + LOCAL_FUNC + TT_Error RunIns( PExecution_Context exc ) + { + /* do nothing - always successful */ + (void)exc; + return TT_Err_Ok; + } + +#else + + +#ifdef DEBUG_INTERPRETER +#include +#include "ttdebug.h" + +/* Define the `getch()' function. On Unix systems, it is an alias */ +/* for `getchar()', and the debugger front end must ensure that the */ +/* `stdin' file descriptor is not in line-by-line input mode. */ +#ifdef OS2 +#include +#else +#define getch getchar +#endif + +#endif /* DEBUG_INTEPRETER */ + + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_interp + + +/* In order to detect infinite loops in the code, we set-up */ +/* a counter within the run loop. a singly stroke of interpretation */ +/* is now limited to a maximum number of opcodes defined below.. */ +/* */ +#define MAX_RUNNABLE_OPCODES 1000000 + + +/* There are two kinds of implementations there: */ +/* */ +/* a. static implementation: */ +/* */ +/* The current execution context is a static variable, */ +/* which fields are accessed directly by the interpreter */ +/* during execution. The context is named 'cur'. */ +/* */ +/* This version is non-reentrant, of course. */ +/* */ +/* */ +/* b. indirect implementation: */ +/* */ +/* The current execution context is passed to _each_ */ +/* function as its first argument, and each field is */ +/* thus accessed indirectly. */ +/* */ +/* This version is, however, fully re-entrant. */ +/* */ +/* */ +/* The idea is that an indirect implementation may be */ +/* slower to execute on the low-end processors that are */ +/* used in some systems (like 386s or even 486s). */ +/* */ +/* When the interpreter started, we had no idea of the */ +/* time that glyph hinting (i.e. executing instructions) */ +/* could take in the whole process of rendering a glyph, */ +/* and a 10 to 30% performance penalty on low-end systems */ +/* didn't seem much of a good idea. This question led us */ +/* to provide two distinct builds of the C version from */ +/* a single source, with the use of macros (again). */ +/* */ +/* Now that the engine is working (and working really */ +/* well!), it seems that the greatest time-consuming */ +/* factors are: file i/o, glyph loading, rasterizing and */ +/* _then_ glyph hinting! */ +/* */ +/* Tests performed with two versions of the 'fttimer' */ +/* program seem to indicate that hinting takes less than 5% */ +/* of the rendering process, which is dominated by glyph */ +/* loading and scan-line conversion by an high order of */ +/* magnitude. */ +/* */ +/* As a consequence, the indirect implementation is now the */ +/* default, as its performance costs can be considered */ +/* negligible in our context. Note, however, that we */ +/* kept the same source with macros because: */ +/* */ +/* - the code is kept very close in design to the */ +/* Pascal one used for development. */ +/* */ +/* - it's much more readable that way! */ +/* */ +/* - it's still open to later experimentation and tuning */ + + + +#ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */ + +#define CUR (*exc) /* see ttobjs.h */ + +#else /* static implementation */ + +#define CUR cur + + static TExecution_Context cur; /* static exec. context variable */ + + /* apparently, we have a _lot_ of direct indexing when accessing */ + /* the static 'cur', which makes the code bigger (due to all the */ + /* four bytes addresses). */ + +#endif /* !TT_CONFIG_OPTION_STATIC_INTERPRETER */ + + +#define INS_ARG EXEC_OPS PStorage args /* see ttobjs.h */ + +#define SKIP_Code() SkipCode( EXEC_ARG ) + +#define GET_ShortIns() GetShortIns( EXEC_ARG ) + +#define COMPUTE_Funcs() Compute_Funcs( EXEC_ARG ) + +#define NORMalize( x, y, v ) Normalize( EXEC_ARGS x, y, v ) + +#define SET_SuperRound( scale, flags ) \ + SetSuperRound( EXEC_ARGS scale, flags ) + +#define INS_Goto_CodeRange( range, ip ) \ + Ins_Goto_CodeRange( EXEC_ARGS range, ip ) + +#define CUR_Func_project( x, y ) CUR.func_project( EXEC_ARGS x, y ) +#define CUR_Func_move( z, p, d ) CUR.func_move( EXEC_ARGS z, p, d ) +#define CUR_Func_dualproj( x, y ) CUR.func_dualproj( EXEC_ARGS x, y ) +#define CUR_Func_freeProj( x, y ) CUR.func_freeProj( EXEC_ARGS x, y ) +#define CUR_Func_round( d, c ) CUR.func_round( EXEC_ARGS d, c ) + +#define CUR_Func_read_cvt( index ) \ + CUR.func_read_cvt( EXEC_ARGS index ) + +#define CUR_Func_write_cvt( index, val ) \ + CUR.func_write_cvt( EXEC_ARGS index, val ) + +#define CUR_Func_move_cvt( index, val ) \ + CUR.func_move_cvt( EXEC_ARGS index, val ) + +#define CURRENT_Ratio() Current_Ratio( EXEC_ARG ) +#define CURRENT_Ppem() Current_Ppem( EXEC_ARG ) + +#define CALC_Length() Calc_Length( EXEC_ARG ) + +#define INS_SxVTL( a, b, c, d ) Ins_SxVTL( EXEC_ARGS a, b, c, d ) + +#define COMPUTE_Point_Displacement( a, b, c, d ) \ + Compute_Point_Displacement( EXEC_ARGS a, b, c, d ) + +#define MOVE_Zp2_Point( a, b, c, t ) Move_Zp2_Point( EXEC_ARGS a, b, c, t ) + +#define CUR_Ppem() Cur_PPEM( EXEC_ARG ) + + /* Instruction dispatch function, as used by the interpreter */ + typedef void (*TInstruction_Function)( INS_ARG ); + +#define BOUNDS( x, n ) ( (x) >= (n) ) + + + +/*********************************************************************/ +/* */ +/* Before an opcode is executed, the interpreter verifies that */ +/* there are enough arguments on the stack, with the help of */ +/* the Pop_Push_Count table. */ +/* */ +/* For each opcode, the first column gives the number of arguments */ +/* that are popped from the stack; the second one gives the number */ +/* of those that are pushed in result. */ +/* */ +/* Note that for opcodes with a varying number of parameters, */ +/* either 0 or 1 arg is verified before execution, depending */ +/* on the nature of the instruction: */ +/* */ +/* - if the number of arguments is given by the bytecode */ +/* stream or the loop variable, 0 is chosen. */ +/* */ +/* - if the first argument is a count n that is followed */ +/* by arguments a1..an, then 1 is chosen. */ +/* */ +/*********************************************************************/ + +#undef PACK +#define PACK( x, y ) ((x << 4) | y) + + static const Byte Pop_Push_Count[256] = + { + /* opcodes are gathered in groups of 16 */ + /* please keep the spaces as they are */ + + /* SVTCA y */ PACK( 0, 0 ), + /* SVTCA x */ PACK( 0, 0 ), + /* SPvTCA y */ PACK( 0, 0 ), + /* SPvTCA x */ PACK( 0, 0 ), + /* SFvTCA y */ PACK( 0, 0 ), + /* SFvTCA x */ PACK( 0, 0 ), + /* SPvTL // */ PACK( 2, 0 ), + /* SPvTL + */ PACK( 2, 0 ), + /* SFvTL // */ PACK( 2, 0 ), + /* SFvTL + */ PACK( 2, 0 ), + /* SPvFS */ PACK( 2, 0 ), + /* SFvFS */ PACK( 2, 0 ), + /* GPV */ PACK( 0, 2 ), + /* GFV */ PACK( 0, 2 ), + /* SFvTPv */ PACK( 0, 0 ), + /* ISECT */ PACK( 5, 0 ), + + /* SRP0 */ PACK( 1, 0 ), + /* SRP1 */ PACK( 1, 0 ), + /* SRP2 */ PACK( 1, 0 ), + /* SZP0 */ PACK( 1, 0 ), + /* SZP1 */ PACK( 1, 0 ), + /* SZP2 */ PACK( 1, 0 ), + /* SZPS */ PACK( 1, 0 ), + /* SLOOP */ PACK( 1, 0 ), + /* RTG */ PACK( 0, 0 ), + /* RTHG */ PACK( 0, 0 ), + /* SMD */ PACK( 1, 0 ), + /* ELSE */ PACK( 0, 0 ), + /* JMPR */ PACK( 1, 0 ), + /* SCvTCi */ PACK( 1, 0 ), + /* SSwCi */ PACK( 1, 0 ), + /* SSW */ PACK( 1, 0 ), + + /* DUP */ PACK( 1, 2 ), + /* POP */ PACK( 1, 0 ), + /* CLEAR */ PACK( 0, 0 ), + /* SWAP */ PACK( 2, 2 ), + /* DEPTH */ PACK( 0, 1 ), + /* CINDEX */ PACK( 1, 1 ), + /* MINDEX */ PACK( 1, 0 ), + /* AlignPTS */ PACK( 2, 0 ), + /* INS_$28 */ PACK( 0, 0 ), + /* UTP */ PACK( 1, 0 ), + /* LOOPCALL */ PACK( 2, 0 ), + /* CALL */ PACK( 1, 0 ), + /* FDEF */ PACK( 1, 0 ), + /* ENDF */ PACK( 0, 0 ), + /* MDAP[0] */ PACK( 1, 0 ), + /* MDAP[1] */ PACK( 1, 0 ), + + /* IUP[0] */ PACK( 0, 0 ), + /* IUP[1] */ PACK( 0, 0 ), + /* SHP[0] */ PACK( 0, 0 ), + /* SHP[1] */ PACK( 0, 0 ), + /* SHC[0] */ PACK( 1, 0 ), + /* SHC[1] */ PACK( 1, 0 ), + /* SHZ[0] */ PACK( 1, 0 ), + /* SHZ[1] */ PACK( 1, 0 ), + /* SHPIX */ PACK( 1, 0 ), + /* IP */ PACK( 0, 0 ), + /* MSIRP[0] */ PACK( 2, 0 ), + /* MSIRP[1] */ PACK( 2, 0 ), + /* AlignRP */ PACK( 0, 0 ), + /* RTDG */ PACK( 0, 0 ), + /* MIAP[0] */ PACK( 2, 0 ), + /* MIAP[1] */ PACK( 2, 0 ), + + /* NPushB */ PACK( 0, 0 ), + /* NPushW */ PACK( 0, 0 ), + /* WS */ PACK( 2, 0 ), + /* RS */ PACK( 1, 1 ), + /* WCvtP */ PACK( 2, 0 ), + /* RCvt */ PACK( 1, 1 ), + /* GC[0] */ PACK( 1, 1 ), + /* GC[1] */ PACK( 1, 1 ), + /* SCFS */ PACK( 2, 0 ), + /* MD[0] */ PACK( 2, 1 ), + /* MD[1] */ PACK( 2, 1 ), + /* MPPEM */ PACK( 0, 1 ), + /* MPS */ PACK( 0, 1 ), + /* FlipON */ PACK( 0, 0 ), + /* FlipOFF */ PACK( 0, 0 ), + /* DEBUG */ PACK( 1, 0 ), + + /* LT */ PACK( 2, 1 ), + /* LTEQ */ PACK( 2, 1 ), + /* GT */ PACK( 2, 1 ), + /* GTEQ */ PACK( 2, 1 ), + /* EQ */ PACK( 2, 1 ), + /* NEQ */ PACK( 2, 1 ), + /* ODD */ PACK( 1, 1 ), + /* EVEN */ PACK( 1, 1 ), + /* IF */ PACK( 1, 0 ), + /* EIF */ PACK( 0, 0 ), + /* AND */ PACK( 2, 1 ), + /* OR */ PACK( 2, 1 ), + /* NOT */ PACK( 1, 1 ), + /* DeltaP1 */ PACK( 1, 0 ), + /* SDB */ PACK( 1, 0 ), + /* SDS */ PACK( 1, 0 ), + + /* ADD */ PACK( 2, 1 ), + /* SUB */ PACK( 2, 1 ), + /* DIV */ PACK( 2, 1 ), + /* MUL */ PACK( 2, 1 ), + /* ABS */ PACK( 1, 1 ), + /* NEG */ PACK( 1, 1 ), + /* FLOOR */ PACK( 1, 1 ), + /* CEILING */ PACK( 1, 1 ), + /* ROUND[0] */ PACK( 1, 1 ), + /* ROUND[1] */ PACK( 1, 1 ), + /* ROUND[2] */ PACK( 1, 1 ), + /* ROUND[3] */ PACK( 1, 1 ), + /* NROUND[0] */ PACK( 1, 1 ), + /* NROUND[1] */ PACK( 1, 1 ), + /* NROUND[2] */ PACK( 1, 1 ), + /* NROUND[3] */ PACK( 1, 1 ), + + /* WCvtF */ PACK( 2, 0 ), + /* DeltaP2 */ PACK( 1, 0 ), + /* DeltaP3 */ PACK( 1, 0 ), + /* DeltaCn[0] */ PACK( 1, 0 ), + /* DeltaCn[1] */ PACK( 1, 0 ), + /* DeltaCn[2] */ PACK( 1, 0 ), + /* SROUND */ PACK( 1, 0 ), + /* S45Round */ PACK( 1, 0 ), + /* JROT */ PACK( 2, 0 ), + /* JROF */ PACK( 2, 0 ), + /* ROFF */ PACK( 0, 0 ), + /* INS_$7B */ PACK( 0, 0 ), + /* RUTG */ PACK( 0, 0 ), + /* RDTG */ PACK( 0, 0 ), + /* SANGW */ PACK( 1, 0 ), + /* AA */ PACK( 1, 0 ), + + /* FlipPT */ PACK( 0, 0 ), + /* FlipRgON */ PACK( 2, 0 ), + /* FlipRgOFF */ PACK( 2, 0 ), + /* INS_$83 */ PACK( 0, 0 ), + /* INS_$84 */ PACK( 0, 0 ), + /* ScanCTRL */ PACK( 1, 0 ), + /* SDVPTL[0] */ PACK( 2, 0 ), + /* SDVPTL[1] */ PACK( 2, 0 ), + /* GetINFO */ PACK( 1, 1 ), + /* IDEF */ PACK( 1, 0 ), + /* ROLL */ PACK( 3, 3 ), + /* MAX */ PACK( 2, 1 ), + /* MIN */ PACK( 2, 1 ), + /* ScanTYPE */ PACK( 1, 0 ), + /* InstCTRL */ PACK( 2, 0 ), + /* INS_$8F */ PACK( 0, 0 ), + + /* INS_$90 */ PACK( 0, 0 ), + /* INS_$91 */ PACK( 0, 0 ), + /* INS_$92 */ PACK( 0, 0 ), + /* INS_$93 */ PACK( 0, 0 ), + /* INS_$94 */ PACK( 0, 0 ), + /* INS_$95 */ PACK( 0, 0 ), + /* INS_$96 */ PACK( 0, 0 ), + /* INS_$97 */ PACK( 0, 0 ), + /* INS_$98 */ PACK( 0, 0 ), + /* INS_$99 */ PACK( 0, 0 ), + /* INS_$9A */ PACK( 0, 0 ), + /* INS_$9B */ PACK( 0, 0 ), + /* INS_$9C */ PACK( 0, 0 ), + /* INS_$9D */ PACK( 0, 0 ), + /* INS_$9E */ PACK( 0, 0 ), + /* INS_$9F */ PACK( 0, 0 ), + + /* INS_$A0 */ PACK( 0, 0 ), + /* INS_$A1 */ PACK( 0, 0 ), + /* INS_$A2 */ PACK( 0, 0 ), + /* INS_$A3 */ PACK( 0, 0 ), + /* INS_$A4 */ PACK( 0, 0 ), + /* INS_$A5 */ PACK( 0, 0 ), + /* INS_$A6 */ PACK( 0, 0 ), + /* INS_$A7 */ PACK( 0, 0 ), + /* INS_$A8 */ PACK( 0, 0 ), + /* INS_$A9 */ PACK( 0, 0 ), + /* INS_$AA */ PACK( 0, 0 ), + /* INS_$AB */ PACK( 0, 0 ), + /* INS_$AC */ PACK( 0, 0 ), + /* INS_$AD */ PACK( 0, 0 ), + /* INS_$AE */ PACK( 0, 0 ), + /* INS_$AF */ PACK( 0, 0 ), + + /* PushB[0] */ PACK( 0, 1 ), + /* PushB[1] */ PACK( 0, 2 ), + /* PushB[2] */ PACK( 0, 3 ), + /* PushB[3] */ PACK( 0, 4 ), + /* PushB[4] */ PACK( 0, 5 ), + /* PushB[5] */ PACK( 0, 6 ), + /* PushB[6] */ PACK( 0, 7 ), + /* PushB[7] */ PACK( 0, 8 ), + /* PushW[0] */ PACK( 0, 1 ), + /* PushW[1] */ PACK( 0, 2 ), + /* PushW[2] */ PACK( 0, 3 ), + /* PushW[3] */ PACK( 0, 4 ), + /* PushW[4] */ PACK( 0, 5 ), + /* PushW[5] */ PACK( 0, 6 ), + /* PushW[6] */ PACK( 0, 7 ), + /* PushW[7] */ PACK( 0, 8 ), + + /* MDRP[00] */ PACK( 1, 0 ), + /* MDRP[01] */ PACK( 1, 0 ), + /* MDRP[02] */ PACK( 1, 0 ), + /* MDRP[03] */ PACK( 1, 0 ), + /* MDRP[04] */ PACK( 1, 0 ), + /* MDRP[05] */ PACK( 1, 0 ), + /* MDRP[06] */ PACK( 1, 0 ), + /* MDRP[07] */ PACK( 1, 0 ), + /* MDRP[08] */ PACK( 1, 0 ), + /* MDRP[09] */ PACK( 1, 0 ), + /* MDRP[10] */ PACK( 1, 0 ), + /* MDRP[11] */ PACK( 1, 0 ), + /* MDRP[12] */ PACK( 1, 0 ), + /* MDRP[13] */ PACK( 1, 0 ), + /* MDRP[14] */ PACK( 1, 0 ), + /* MDRP[15] */ PACK( 1, 0 ), + + /* MDRP[16] */ PACK( 1, 0 ), + /* MDRP[17] */ PACK( 1, 0 ), + /* MDRP[18] */ PACK( 1, 0 ), + /* MDRP[19] */ PACK( 1, 0 ), + /* MDRP[20] */ PACK( 1, 0 ), + /* MDRP[21] */ PACK( 1, 0 ), + /* MDRP[22] */ PACK( 1, 0 ), + /* MDRP[23] */ PACK( 1, 0 ), + /* MDRP[24] */ PACK( 1, 0 ), + /* MDRP[25] */ PACK( 1, 0 ), + /* MDRP[26] */ PACK( 1, 0 ), + /* MDRP[27] */ PACK( 1, 0 ), + /* MDRP[28] */ PACK( 1, 0 ), + /* MDRP[29] */ PACK( 1, 0 ), + /* MDRP[30] */ PACK( 1, 0 ), + /* MDRP[31] */ PACK( 1, 0 ), + + /* MIRP[00] */ PACK( 2, 0 ), + /* MIRP[01] */ PACK( 2, 0 ), + /* MIRP[02] */ PACK( 2, 0 ), + /* MIRP[03] */ PACK( 2, 0 ), + /* MIRP[04] */ PACK( 2, 0 ), + /* MIRP[05] */ PACK( 2, 0 ), + /* MIRP[06] */ PACK( 2, 0 ), + /* MIRP[07] */ PACK( 2, 0 ), + /* MIRP[08] */ PACK( 2, 0 ), + /* MIRP[09] */ PACK( 2, 0 ), + /* MIRP[10] */ PACK( 2, 0 ), + /* MIRP[11] */ PACK( 2, 0 ), + /* MIRP[12] */ PACK( 2, 0 ), + /* MIRP[13] */ PACK( 2, 0 ), + /* MIRP[14] */ PACK( 2, 0 ), + /* MIRP[15] */ PACK( 2, 0 ), + + /* MIRP[16] */ PACK( 2, 0 ), + /* MIRP[17] */ PACK( 2, 0 ), + /* MIRP[18] */ PACK( 2, 0 ), + /* MIRP[19] */ PACK( 2, 0 ), + /* MIRP[20] */ PACK( 2, 0 ), + /* MIRP[21] */ PACK( 2, 0 ), + /* MIRP[22] */ PACK( 2, 0 ), + /* MIRP[23] */ PACK( 2, 0 ), + /* MIRP[24] */ PACK( 2, 0 ), + /* MIRP[25] */ PACK( 2, 0 ), + /* MIRP[26] */ PACK( 2, 0 ), + /* MIRP[27] */ PACK( 2, 0 ), + /* MIRP[28] */ PACK( 2, 0 ), + /* MIRP[29] */ PACK( 2, 0 ), + /* MIRP[30] */ PACK( 2, 0 ), + /* MIRP[31] */ PACK( 2, 0 ) + }; + + static const TT_Vector Null_Vector = {0,0}; + +#undef NULL_Vector +#define NULL_Vector (TT_Vector*)&Null_Vector + +/******************************************************************* + * + * Function : Norm + * + * Description : Returns the norm (length) of a vector. + * + * Input : X, Y vector + * + * Output : Returns length in F26dot6. + * + *****************************************************************/ + + static TT_F26Dot6 Norm( TT_F26Dot6 X, TT_F26Dot6 Y ) + { + TT_Int64 T1, T2; + + + MUL_64( X, X, T1 ); + MUL_64( Y, Y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)SQRT_64( T1 ); + } + + +/******************************************************************* + * + * Function : FUnits_To_Pixels + * + * Description : Scale a distance in FUnits to pixel coordinates. + * + * Input : Distance in FUnits + * + * Output : Distance in 26.6 format. + * + *****************************************************************/ + + static TT_F26Dot6 FUnits_To_Pixels( EXEC_OPS Short distance ) + { + return TT_MulDiv( distance, + CUR.metrics.scale1, + CUR.metrics.scale2 ); + } + + +/******************************************************************* + * + * Function : Current_Ratio + * + * Description : Return the current aspect ratio scaling factor + * depending on the projection vector's state and + * device resolutions. + * + * Input : None + * + * Output : Aspect ratio in 16.16 format, always <= 1.0 . + * + *****************************************************************/ + + static Long Current_Ratio( EXEC_OP ) + { + if ( CUR.metrics.ratio ) + return CUR.metrics.ratio; + + if ( CUR.GS.projVector.y == 0 ) + CUR.metrics.ratio = CUR.metrics.x_ratio; + + else if ( CUR.GS.projVector.x == 0 ) + CUR.metrics.ratio = CUR.metrics.y_ratio; + + else + { + Long x, y; + + + x = TT_MulDiv( CUR.GS.projVector.x, CUR.metrics.x_ratio, 0x4000 ); + y = TT_MulDiv( CUR.GS.projVector.y, CUR.metrics.y_ratio, 0x4000 ); + CUR.metrics.ratio = Norm( x, y ); + } + + return CUR.metrics.ratio; + } + + + static Long Current_Ppem( EXEC_OP ) + { + return TT_MulFix( CUR.metrics.ppem, CURRENT_Ratio() ); + } + + + static TT_F26Dot6 Read_CVT( EXEC_OPS ULong index ) + { + return CUR.cvt[index]; + } + + + static TT_F26Dot6 Read_CVT_Stretched( EXEC_OPS ULong index ) + { + return TT_MulFix( CUR.cvt[index], CURRENT_Ratio() ); + } + + + static void Write_CVT( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] = value; + } + + static void Write_CVT_Stretched( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] = TT_MulDiv( value, 0x10000, CURRENT_Ratio() ); + } + + + static void Move_CVT( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] += value; + } + + static void Move_CVT_Stretched( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] += TT_MulDiv( value, 0x10000, CURRENT_Ratio() ); + } + + +/****************************************************************** + * + * Function : Calc_Length + * + * Description : Computes the length in bytes of current opcode. + * + *****************************************************************/ + + static Bool Calc_Length( EXEC_OP ) + { + CUR.opcode = CUR.code[CUR.IP]; + + switch ( CUR.opcode ) + { + case 0x40: + if ( CUR.IP + 1 >= CUR.codeSize ) + return FAILURE; + + CUR.length = CUR.code[CUR.IP + 1] + 2; + break; + + case 0x41: + if ( CUR.IP + 1 >= CUR.codeSize ) + return FAILURE; + + CUR.length = CUR.code[CUR.IP + 1] * 2 + 2; + break; + + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + CUR.length = CUR.opcode - 0xB0 + 2; + break; + + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + CUR.length = (CUR.opcode - 0xB8) * 2 + 3; + break; + + default: + CUR.length = 1; + break; + } + + /* make sure result is in range */ + + if ( CUR.IP + CUR.length > CUR.codeSize ) + return FAILURE; + + return SUCCESS; + } + + +/******************************************************************* + * + * Function : GetShortIns + * + * Description : Returns a short integer taken from the instruction + * stream at address IP. + * + * Input : None + * + * Output : Short read at Code^[IP..IP+1] + * + * Notes : This one could become a Macro in the C version. + * + *****************************************************************/ + + static Short GetShortIns( EXEC_OP ) + { + /* Reading a byte stream so there is no endianess (DaveP) */ + CUR.IP += 2; + return (Short)((CUR.code[CUR.IP - 2] << 8) + CUR.code[CUR.IP - 1]); + } + + +/******************************************************************* + * + * Function : Ins_Goto_CodeRange + * + * Description : Goes to a certain code range in the instruction + * stream. + * + * + * Input : aRange + * aIP + * + * Output : SUCCESS or FAILURE. + * + *****************************************************************/ + + static Bool Ins_Goto_CodeRange( EXEC_OPS Int aRange, ULong aIP ) + { + TCodeRange* WITH; + + + if ( aRange < 1 || aRange > 3 ) + { + CUR.error = TT_Err_Bad_Argument; + return FAILURE; + } + + WITH = &CUR.codeRangeTable[aRange - 1]; + + if ( WITH->Base == NULL ) /* invalid coderange */ + { + CUR.error = TT_Err_Invalid_CodeRange; + return FAILURE; + } + + /* NOTE: Because the last instruction of a program may be a CALL */ + /* which will return to the first byte *after* the code */ + /* range, we test for aIP <= Size, instead of aIP < Size. */ + + if ( aIP > WITH->Size ) + { + CUR.error = TT_Err_Code_Overflow; + return FAILURE; + } + + CUR.code = WITH->Base; + CUR.codeSize = WITH->Size; + CUR.IP = aIP; + CUR.curRange = aRange; + + return SUCCESS; + } + + +/******************************************************************* + * + * Function : Direct_Move + * + * Description : Moves a point by a given distance along the + * freedom vector. The point will be touched. + * + * Input : point index of point to move + * distance distance to apply + * zone affected glyph zone + * + * Output : None + * + *****************************************************************/ + + static void Direct_Move( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ) + { + TT_F26Dot6 v; + + + v = CUR.GS.freeVector.x; + + if ( v != 0 ) + { + zone->cur[point].x += TT_MulDiv( distance, + v * 0x10000L, + CUR.F_dot_P ); + + zone->touch[point] |= TT_Flag_Touched_X; + } + + v = CUR.GS.freeVector.y; + + if ( v != 0 ) + { + zone->cur[point].y += TT_MulDiv( distance, + v * 0x10000L, + CUR.F_dot_P ); + + zone->touch[point] |= TT_Flag_Touched_Y; + } + } + + +/******************************************************************/ +/* */ +/* The following versions are used whenever both vectors are both */ +/* along one of the coordinate unit vectors, i.e. in 90% cases. */ +/* */ +/******************************************************************/ + +/******************************************************************* + * Direct_Move_X + * + *******************************************************************/ + + static void Direct_Move_X( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ) + { + zone->cur[point].x += distance; + zone->touch[point] |= TT_Flag_Touched_X; + } + + +/******************************************************************* + * Direct_Move_Y + * + *******************************************************************/ + + static void Direct_Move_Y( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ) + { + zone->cur[point].y += distance; + zone->touch[point] |= TT_Flag_Touched_Y; + } + + +/******************************************************************* + * + * Function : Round_None + * + * Description : Does not round, but adds engine compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : rounded distance. + * + * NOTE : The spec says very few about the relationship between + * rounding and engine compensation. However, it seems + * from the description of super round that we should + * should add the compensation before rounding. + * + ******************************************************************/ + + static TT_F26Dot6 Round_None( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation; + if ( val < 0 ) + val = 0; + } + else { + val = distance - compensation; + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_To_Grid + * + * Description : Rounds value to grid after adding engine + * compensation + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_To_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation + 32; + if ( val > 0 ) + val &= ~63; + else + val = 0; + } + else + { + val = -( (compensation - distance + 32) & (-64) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_To_Half_Grid + * + * Description : Rounds value to half grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_To_Half_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = ((distance + compensation) & (-64)) + 32; + if ( val < 0 ) + val = 0; + } + else + { + val = -( ((compensation - distance) & (-64)) + 32 ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Down_To_Grid + * + * Description : Rounds value down to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Down_To_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation; + if ( val > 0 ) + val &= ~63; + else + val = 0; + } + else + { + val = -( (compensation - distance) & (-64) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Up_To_Grid + * + * Description : Rounds value up to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Up_To_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation + 63; + if ( val > 0 ) + val &= ~63; + else + val = 0; + } + else + { + val = -( (compensation - distance + 63) & (-64) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_To_Double_Grid + * + * Description : Rounds value to double grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_To_Double_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation + 16; + if ( val > 0 ) + val &= ~31; + else + val = 0; + } + else + { + val = -( (compensation - distance + 16) & (-32) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Super + * + * Description : Super-rounds value to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + * NOTE : The spec says very few about the relationship between + * rounding and engine compensation. However, it seems + * from the description of super round that we should + * should add the compensation before rounding. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Super( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = (distance - CUR.phase + CUR.threshold + compensation) & + (-CUR.period); + if ( val < 0 ) + val = 0; + val += CUR.phase; + } + else + { + val = -( (CUR.threshold - CUR.phase - distance + compensation) & + (-CUR.period) ); + if ( val > 0 ) + val = 0; + val -= CUR.phase; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Super_45 + * + * Description : Super-rounds value to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + * NOTE : There is a separate function for Round_Super_45 as we + * may need a greater precision. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Super_45( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = ( (distance - CUR.phase + CUR.threshold + compensation) / + CUR.period ) * CUR.period; + if ( val < 0 ) + val = 0; + val += CUR.phase; + } + else + { + val = -( ( (CUR.threshold - CUR.phase - distance + compensation) / + CUR.period ) * CUR.period ); + if ( val > 0 ) + val = 0; + val -= CUR.phase; + } + + return val; + } + + +/******************************************************************* + * Compute_Round + * + *****************************************************************/ + + static void Compute_Round( EXEC_OPS Byte round_mode ) + { + switch ( round_mode ) + { + case TT_Round_Off: + CUR.func_round = (TRound_Function)Round_None; + break; + + case TT_Round_To_Grid: + CUR.func_round = (TRound_Function)Round_To_Grid; + break; + + case TT_Round_Up_To_Grid: + CUR.func_round = (TRound_Function)Round_Up_To_Grid; + break; + + case TT_Round_Down_To_Grid: + CUR.func_round = (TRound_Function)Round_Down_To_Grid; + break; + + case TT_Round_To_Half_Grid: + CUR.func_round = (TRound_Function)Round_To_Half_Grid; + break; + + case TT_Round_To_Double_Grid: + CUR.func_round = (TRound_Function)Round_To_Double_Grid; + break; + + case TT_Round_Super: + CUR.func_round = (TRound_Function)Round_Super; + break; + + case TT_Round_Super_45: + CUR.func_round = (TRound_Function)Round_Super_45; + break; + } + } + + +/******************************************************************* + * + * Function : SetSuperRound + * + * Description : Sets Super Round parameters. + * + * Input : GridPeriod Grid period + * selector SROUND opcode + * + * Output : None. + * + *****************************************************************/ + + static void SetSuperRound( EXEC_OPS TT_F26Dot6 GridPeriod, + Long selector ) + { + switch ( (Int)(selector & 0xC0) ) + { + case 0: + CUR.period = GridPeriod / 2; + break; + + case 0x40: + CUR.period = GridPeriod; + break; + + case 0x80: + CUR.period = GridPeriod * 2; + break; + + /* This opcode is reserved, but... */ + + case 0xC0: + CUR.period = GridPeriod; + break; + } + + switch ( (Int)(selector & 0x30) ) + { + case 0: + CUR.phase = 0; + break; + + case 0x10: + CUR.phase = CUR.period / 4; + break; + + case 0x20: + CUR.phase = CUR.period / 2; + break; + + case 0x30: + CUR.phase = GridPeriod * 3 / 4; + break; + } + + if ( (selector & 0x0F) == 0 ) + CUR.threshold = CUR.period - 1; + else + CUR.threshold = ( (Int)(selector & 0x0F) - 4 ) * CUR.period / 8; + + CUR.period /= 256; + CUR.phase /= 256; + CUR.threshold /= 256; + } + + +/******************************************************************* + * + * Function : Project + * + * Description : Computes the projection of vector given by (v2-v1) + * along the current projection vector. + * + * Input : v1, v2 input vector + * + * Output : Returns distance in F26dot6 format. + * + *****************************************************************/ + + static TT_F26Dot6 Project( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + TT_Int64 T1, T2; + + + MUL_64( v1->x - v2->x, CUR.GS.projVector.x, T1 ); + MUL_64( v1->y - v2->y, CUR.GS.projVector.y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)DIV_64( T1, 0x4000L ); + } + + +/******************************************************************* + * + * Function : Dual_Project + * + * Description : Computes the projection of the vector given by + * (v2-v1) along the current dual vector. + * + * Input : v1, v2 input vector + * + * Output : Returns distance in F26dot6 format. + * + *****************************************************************/ + + static TT_F26Dot6 Dual_Project( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + TT_Int64 T1, T2; + + + MUL_64( v1->x - v2->x, CUR.GS.dualVector.x, T1 ); + MUL_64( v1->y - v2->y, CUR.GS.dualVector.y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)DIV_64( T1, 0x4000L ); + } + + +/******************************************************************* + * + * Function : Free_Project + * + * Description : Computes the projection of the vector given by + * (v2-v1) along the current freedom vector. + * + * Input : v1, v2 input vector + * + * Output : Returns distance in F26dot6 format. + * + *****************************************************************/ + + static TT_F26Dot6 Free_Project( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + TT_Int64 T1, T2; + + + MUL_64( v1->x - v2->x, CUR.GS.freeVector.x, T1 ); + MUL_64( v1->y - v2->y, CUR.GS.freeVector.y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)DIV_64( T1, 0x4000L ); + } + + +/******************************************************************* + * + * Function : Project_x + * + * Input : Vx, Vy input vector + * + * Output : Returns Vx. + * + * Note : Used as a dummy function. + * + *****************************************************************/ + + static TT_F26Dot6 Project_x( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + return (v1->x - v2->x); + } + + +/******************************************************************* + * + * Function : Project_y + * + * Input : Vx, Vy input vector + * + * Output : Returns Vy. + * + * Note : Used as a dummy function. + * + *****************************************************************/ + + static TT_F26Dot6 Project_y( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + return (v1->y - v2->y); + } + + +/******************************************************************* + * + * Function : Compute_Funcs + * + * Description : Computes the projections and movement function + * pointers according to the current graphics state. + * + * Input : None + * + *****************************************************************/ + + static void Compute_Funcs( EXEC_OP ) + { + if ( CUR.GS.freeVector.x == 0x4000 ) + { + CUR.func_freeProj = (TProject_Function)Project_x; + CUR.F_dot_P = CUR.GS.projVector.x * 0x10000L; + } + else + { + if ( CUR.GS.freeVector.y == 0x4000 ) + { + CUR.func_freeProj = (TProject_Function)Project_y; + CUR.F_dot_P = CUR.GS.projVector.y * 0x10000L; + } + else + { + CUR.func_freeProj = (TProject_Function)Free_Project; + CUR.F_dot_P = (Long)CUR.GS.projVector.x * CUR.GS.freeVector.x * 4 + + (Long)CUR.GS.projVector.y * CUR.GS.freeVector.y * 4; + } + } + + CUR.cached_metrics = FALSE; + + if ( CUR.GS.projVector.x == 0x4000 ) + CUR.func_project = (TProject_Function)Project_x; + else + { + if ( CUR.GS.projVector.y == 0x4000 ) + CUR.func_project = (TProject_Function)Project_y; + else + CUR.func_project = (TProject_Function)Project; + } + + if ( CUR.GS.dualVector.x == 0x4000 ) + CUR.func_dualproj = (TProject_Function)Project_x; + else + { + if ( CUR.GS.dualVector.y == 0x4000 ) + CUR.func_dualproj = (TProject_Function)Project_y; + else + CUR.func_dualproj = (TProject_Function)Dual_Project; + } + + CUR.func_move = (TMove_Function)Direct_Move; + + if ( CUR.F_dot_P == 0x40000000L ) + { + if ( CUR.GS.freeVector.x == 0x4000 ) + CUR.func_move = (TMove_Function)Direct_Move_X; + else + { + if ( CUR.GS.freeVector.y == 0x4000 ) + CUR.func_move = (TMove_Function)Direct_Move_Y; + } + } + + /* at small sizes, F_dot_P can become too small, resulting */ + /* in overflows and 'spikes' in a number of glyphs like 'w'. */ + + if ( ABS( CUR.F_dot_P ) < 0x4000000L ) + CUR.F_dot_P = 0x40000000L; + + /* Disable cached aspect ratio */ + CUR.metrics.ratio = 0; + } + + +/******************************************************************* + * + * Function : Normalize + * + * Description : Norms a vector + * + * Input : Vx, Vy input vector + * R normed unit vector + * + * Output : Returns FAILURE if a vector parameter is zero. + * + *****************************************************************/ + + static Bool Normalize( EXEC_OPS TT_F26Dot6 Vx, + TT_F26Dot6 Vy, + TT_UnitVector* R ) + { + TT_F26Dot6 W; + Bool S1, S2; + + + if ( ABS( Vx ) < 0x10000L && ABS( Vy ) < 0x10000L ) + { + Vx *= 0x100; + Vy *= 0x100; + + W = Norm( Vx, Vy ); + + if ( W == 0 ) + { + /* XXX : UNDOCUMENTED! It seems that it's possible to try */ + /* to normalize the vector (0,0). Return immediately */ + return SUCCESS; + } + + R->x = (TT_F2Dot14)TT_MulDiv( Vx, 0x4000L, W ); + R->y = (TT_F2Dot14)TT_MulDiv( Vy, 0x4000L, W ); + + return SUCCESS; + } + + W = Norm( Vx, Vy ); + + Vx = TT_MulDiv( Vx, 0x4000L, W ); + Vy = TT_MulDiv( Vy, 0x4000L, W ); + + W = Vx * Vx + Vy * Vy; + + /* Now, we want that Sqrt( W ) = 0x4000 */ + /* Or 0x1000000 <= W < 0x1004000 */ + + if ( Vx < 0 ) + { + Vx = -Vx; + S1 = TRUE; + } + else + S1 = FALSE; + + if ( Vy < 0 ) + { + Vy = -Vy; + S2 = TRUE; + } + else + S2 = FALSE; + + while ( W < 0x1000000L ) + { + /* We need to increase W, by a minimal amount */ + if ( Vx < Vy ) + Vx++; + else + Vy++; + + W = Vx * Vx + Vy * Vy; + } + + while ( W >= 0x1004000L ) + { + /* We need to decrease W, by a minimal amount */ + if ( Vx < Vy ) + Vx--; + else + Vy--; + + W = Vx * Vx + Vy * Vy; + } + + /* Note that in various cases, we can only */ + /* compute a Sqrt(W) of 0x3FFF, eg. Vx = Vy */ + + if ( S1 ) + Vx = -Vx; + + if ( S2 ) + Vy = -Vy; + + R->x = (TT_F2Dot14)Vx; /* Type conversion */ + R->y = (TT_F2Dot14)Vy; /* Type conversion */ + + return SUCCESS; + } + + +/**************************************************************** + * + * Opcodes + * + ****************************************************************/ + + + static Bool Ins_SxVTL( EXEC_OPS UShort aIdx1, + UShort aIdx2, + Int aOpc, + TT_UnitVector* Vec ) + { + Long A, B, C; + TT_Vector* p1; + TT_Vector* p2; + + + if ( BOUNDS( aIdx1, CUR.zp2.n_points ) || + BOUNDS( aIdx2, CUR.zp1.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return FAILURE; + } + + p1 = CUR.zp1.cur + aIdx2; + p2 = CUR.zp2.cur + aIdx1; + + A = p1->x - p2->x; + B = p1->y - p2->y; + + if ( (aOpc & 1) != 0 ) + { + C = B; /* CounterClockwise rotation */ + B = A; + A = -C; + } + + NORMalize( A, B, Vec ); + return SUCCESS; + } + + +/* When not using the big switch statements, the interpreter uses a */ +/* call table defined later below in this source. Each opcode must */ +/* thus have a corresponding function, even trivial ones. */ +/* */ +/* They're all defined there. */ + +#define DO_SVTCA \ + { \ + Short A, B; \ + \ + \ + A = (Short)(CUR.opcode & 1) << 14; \ + B = A ^ (Short)0x4000; \ + \ + CUR.GS.freeVector.x = A; \ + CUR.GS.projVector.x = A; \ + CUR.GS.dualVector.x = A; \ + \ + CUR.GS.freeVector.y = B; \ + CUR.GS.projVector.y = B; \ + CUR.GS.dualVector.y = B; \ + \ + COMPUTE_Funcs(); \ + } + + +#define DO_SPVTCA \ + { \ + Short A, B; \ + \ + \ + A = (Short)(CUR.opcode & 1) << 14; \ + B = A ^ (Short)0x4000; \ + \ + CUR.GS.projVector.x = A; \ + CUR.GS.dualVector.x = A; \ + \ + CUR.GS.projVector.y = B; \ + CUR.GS.dualVector.y = B; \ + \ + COMPUTE_Funcs(); \ + } + + +#define DO_SFVTCA \ + { \ + Short A, B; \ + \ + \ + A = (Short)(CUR.opcode & 1) << 14; \ + B = A ^ (Short)0x4000; \ + \ + CUR.GS.freeVector.x = A; \ + CUR.GS.freeVector.y = B; \ + \ + COMPUTE_Funcs(); \ + } + + +#define DO_SPVTL \ + if ( INS_SxVTL( (UShort)args[1], \ + (UShort)args[0], \ + CUR.opcode, \ + &CUR.GS.projVector) == SUCCESS ) \ + { \ + CUR.GS.dualVector = CUR.GS.projVector; \ + COMPUTE_Funcs(); \ + } + + +#define DO_SFVTL \ + if ( INS_SxVTL( (UShort)args[1], \ + (UShort)args[0], \ + CUR.opcode, \ + &CUR.GS.freeVector) == SUCCESS ) \ + COMPUTE_Funcs(); + + +#define DO_SFVTPV \ + CUR.GS.freeVector = CUR.GS.projVector; \ + COMPUTE_Funcs(); + + +#define DO_SPVFS \ + { \ + Short S; \ + Long X, Y; \ + \ + \ + /* Only use low 16bits, then sign extend */ \ + S = (Short)args[1]; \ + Y = (Long)S; \ + S = (Short)args[0]; \ + X = (Long)S; \ + \ + NORMalize( X, Y, &CUR.GS.projVector ); \ + \ + CUR.GS.dualVector = CUR.GS.projVector; \ + COMPUTE_Funcs(); \ + } + + +#define DO_SFVFS \ + { \ + Short S; \ + Long X, Y; \ + \ + \ + /* Only use low 16bits, then sign extend */ \ + S = (Short)args[1]; \ + Y = (Long)S; \ + S = (Short)args[0]; \ + X = S; \ + \ + NORMalize( X, Y, &CUR.GS.freeVector ); \ + COMPUTE_Funcs(); \ + } + + +#define DO_GPV \ + args[0] = CUR.GS.projVector.x; \ + args[1] = CUR.GS.projVector.y; + + +#define DO_GFV \ + args[0] = CUR.GS.freeVector.x; \ + args[1] = CUR.GS.freeVector.y; + + +#define DO_SRP0 \ + CUR.GS.rp0 = (UShort)args[0]; + + +#define DO_SRP1 \ + CUR.GS.rp1 = (UShort)args[0]; + + +#define DO_SRP2 \ + CUR.GS.rp2 = (UShort)args[0]; + + +#define DO_RTHG \ + CUR.GS.round_state = TT_Round_To_Half_Grid; \ + CUR.func_round = (TRound_Function)Round_To_Half_Grid; + + +#define DO_RTG \ + CUR.GS.round_state = TT_Round_To_Grid; \ + CUR.func_round = (TRound_Function)Round_To_Grid; + + +#define DO_RTDG \ + CUR.GS.round_state = TT_Round_To_Double_Grid; \ + CUR.func_round = (TRound_Function)Round_To_Double_Grid; + + +#define DO_RUTG \ + CUR.GS.round_state = TT_Round_Up_To_Grid; \ + CUR.func_round = (TRound_Function)Round_Up_To_Grid; + + +#define DO_RDTG \ + CUR.GS.round_state = TT_Round_Down_To_Grid; \ + CUR.func_round = (TRound_Function)Round_Down_To_Grid; + + +#define DO_ROFF \ + CUR.GS.round_state = TT_Round_Off; \ + CUR.func_round = (TRound_Function)Round_None; + + +#define DO_SROUND \ + SET_SuperRound( 0x4000L, args[0] ); \ + CUR.GS.round_state = TT_Round_Super; \ + CUR.func_round = (TRound_Function)Round_Super; + + +#define DO_S45ROUND \ + SET_SuperRound( 0x2D41L, args[0] ); \ + CUR.GS.round_state = TT_Round_Super_45; \ + CUR.func_round = (TRound_Function)Round_Super_45; + + +#define DO_SLOOP \ + if ( args[0] < 0 ) \ + CUR.error = TT_Err_Bad_Argument; \ + else \ + CUR.GS.loop = args[0]; + + +#define DO_SMD \ + CUR.GS.minimum_distance = (TT_F26Dot6)args[0]; + + +#define DO_SCVTCI \ + CUR.GS.control_value_cutin = (TT_F26Dot6)args[0]; + + +#define DO_SSWCI \ + CUR.GS.single_width_cutin = (TT_F26Dot6)args[0]; + + + /* XXX : UNDOCUMENTED! or bug in the Windows engine? */ + /* */ + /* It seems that the value that is read here is */ + /* expressed in 16.16 format, rather than in */ + /* font units.. */ + /* */ +#define DO_SSW \ + CUR.GS.single_width_value = (TT_F26Dot6)(args[0] >> 10); + + +#define DO_FLIPON \ + CUR.GS.auto_flip = TRUE; + + +#define DO_FLIPOFF \ + CUR.GS.auto_flip = FALSE; + + +#define DO_SDB \ + CUR.GS.delta_base = (Short)args[0]; + + +#define DO_SDS \ + CUR.GS.delta_shift = (Short)args[0]; + + +#define DO_MD /* nothing */ + + +#define DO_MPPEM \ + args[0] = CURRENT_Ppem(); + + +#define DO_MPS \ + args[0] = CUR.metrics.pointSize; + + +#define DO_DUP \ + args[1] = args[0]; + + +#define DO_CLEAR \ + CUR.new_top = 0; + + +#define DO_SWAP \ + { \ + Long L; \ + \ + L = args[0]; \ + args[0] = args[1]; \ + args[1] = L; \ + } + + +#define DO_DEPTH \ + args[0] = CUR.top; + + +#define DO_CINDEX \ + { \ + Long L; \ + \ + \ + L = args[0]; \ + \ + if ( L <= 0 || L > CUR.args ) \ + CUR.error = TT_Err_Invalid_Reference; \ + else \ + args[0] = CUR.stack[CUR.args - L]; \ + } + + +#define DO_JROT \ + if ( args[1] != 0 ) \ + { \ + CUR.IP += args[0]; \ + CUR.step_ins = FALSE; \ + } + + +#define DO_JMPR \ + CUR.IP += args[0]; \ + CUR.step_ins = FALSE; + + +#define DO_JROF \ + if ( args[1] == 0 ) \ + { \ + CUR.IP += args[0]; \ + CUR.step_ins = FALSE; \ + } + + +#define DO_LT \ + args[0] = (args[0] < args[1]); + + +#define DO_LTEQ \ + args[0] = (args[0] <= args[1]); + + +#define DO_GT \ + args[0] = (args[0] > args[1]); + + +#define DO_GTEQ \ + args[0] = (args[0] >= args[1]); + + +#define DO_EQ \ + args[0] = (args[0] == args[1]); + + +#define DO_NEQ \ + args[0] = (args[0] != args[1]); + + +#define DO_ODD \ + args[0] = ( (CUR_Func_round( args[0], 0 ) & 127) == 64 ); + + +#define DO_EVEN \ + args[0] = ( (CUR_Func_round( args[0], 0 ) & 127) == 0 ); + + +#define DO_AND \ + args[0] = ( args[0] && args[1] ); + + +#define DO_OR \ + args[0] = ( args[0] || args[1] ); + + +#define DO_NOT \ + args[0] = !args[0]; + + +#define DO_ADD \ + args[0] += args[1]; + + +#define DO_SUB \ + args[0] -= args[1]; + + +#define DO_DIV \ + if ( args[1] == 0 ) \ + CUR.error = TT_Err_Divide_By_Zero; \ + else \ + args[0] = TT_MulDiv( args[0], 64L, args[1] ); + + +#define DO_MUL \ + args[0] = TT_MulDiv( args[0], args[1], 64L ); + + +#define DO_ABS \ + args[0] = ABS( args[0] ); + + +#define DO_NEG \ + args[0] = -args[0]; + + +#define DO_FLOOR \ + args[0] &= -64; + + +#define DO_CEILING \ + args[0] = (args[0] + 63) & (-64); + + +#define DO_RS \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.storeSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + else \ + args[0] = 0; \ + } \ + else \ + args[0] = CUR.storage[I]; \ + } + + +#define DO_WS \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.storeSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + } \ + else \ + CUR.storage[I] = args[1]; \ + } + + + +#define DO_RCVT \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.cvtSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + else \ + args[0] = 0; \ + } \ + else \ + args[0] = CUR_Func_read_cvt(I); \ + } + + +#define DO_WCVTP \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.cvtSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + } \ + else \ + CUR_Func_write_cvt( I, args[1] ); \ + } + + +#define DO_WCVTF \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.cvtSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + } \ + else \ + CUR.cvt[I] = FUnits_To_Pixels( EXEC_ARGS (Short)args[1] ); \ + } + + +#define DO_DEBUG \ + CUR.error = TT_Err_Debug_OpCode; + + +#define DO_ROUND \ + args[0] = CUR_Func_round( args[0], \ + CUR.metrics.compensations[CUR.opcode-0x68] ); + + +#define DO_NROUND \ + args[0] = Round_None( EXEC_ARGS \ + args[0], \ + CUR.metrics.compensations[CUR.opcode - 0x6C] ); + + +#define DO_MAX \ + if ( args[1] > args[0] ) \ + args[0] = args[1]; + + +#define DO_MIN \ + if ( args[1] < args[0] ) \ + args[0] = args[1]; + + +#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +#undef ARRAY_BOUND_ERROR +#define ARRAY_BOUND_ERROR \ + { \ + CUR.error = TT_Err_Invalid_Reference; \ + return; \ + } + + +/*******************************************/ +/* SVTCA[a] : Set F and P vectors to axis */ +/* CodeRange : $00-$01 */ +/* Stack : --> */ + + static void Ins_SVTCA( INS_ARG ) + { + DO_SVTCA + } + + +/*******************************************/ +/* SPVTCA[a] : Set PVector to Axis */ +/* CodeRange : $02-$03 */ +/* Stack : --> */ + + static void Ins_SPVTCA( INS_ARG ) + { + DO_SPVTCA + } + + +/*******************************************/ +/* SFVTCA[a] : Set FVector to Axis */ +/* CodeRange : $04-$05 */ +/* Stack : --> */ + + static void Ins_SFVTCA( INS_ARG ) + { + DO_SFVTCA + } + +/*******************************************/ +/* SPVTL[a] : Set PVector to Line */ +/* CodeRange : $06-$07 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_SPVTL( INS_ARG ) + { + DO_SPVTL + } + + +/*******************************************/ +/* SFVTL[a] : Set FVector to Line */ +/* CodeRange : $08-$09 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_SFVTL( INS_ARG ) + { + DO_SFVTL + } + + +/*******************************************/ +/* SFVTPV[] : Set FVector to PVector */ +/* CodeRange : $0E */ +/* Stack : --> */ + + static void Ins_SFVTPV( INS_ARG ) + { + DO_SFVTPV + } + + +/*******************************************/ +/* SPVFS[] : Set PVector From Stack */ +/* CodeRange : $0A */ +/* Stack : f2.14 f2.14 --> */ + + static void Ins_SPVFS( INS_ARG ) + { + DO_SPVFS + } + + +/*******************************************/ +/* SFVFS[] : Set FVector From Stack */ +/* CodeRange : $0B */ +/* Stack : f2.14 f2.14 --> */ + + static void Ins_SFVFS( INS_ARG ) + { + DO_SFVFS + } + + +/*******************************************/ +/* GPV[] : Get Projection Vector */ +/* CodeRange : $0C */ +/* Stack : ef2.14 --> ef2.14 */ + + static void Ins_GPV( INS_ARG ) + { + DO_GPV + } + + +/*******************************************/ +/* GFV[] : Get Freedom Vector */ +/* CodeRange : $0D */ +/* Stack : ef2.14 --> ef2.14 */ + + static void Ins_GFV( INS_ARG ) + { + DO_GFV + } + + +/*******************************************/ +/* SRP0[] : Set Reference Point 0 */ +/* CodeRange : $10 */ +/* Stack : uint32 --> */ + + static void Ins_SRP0( INS_ARG ) + { + DO_SRP0 + } + + +/*******************************************/ +/* SRP1[] : Set Reference Point 1 */ +/* CodeRange : $11 */ +/* Stack : uint32 --> */ + + static void Ins_SRP1( INS_ARG ) + { + DO_SRP1 + } + + +/*******************************************/ +/* SRP2[] : Set Reference Point 2 */ +/* CodeRange : $12 */ +/* Stack : uint32 --> */ + + static void Ins_SRP2( INS_ARG ) + { + DO_SRP2 + } + + +/*******************************************/ +/* RTHG[] : Round To Half Grid */ +/* CodeRange : $19 */ +/* Stack : --> */ + + static void Ins_RTHG( INS_ARG ) + { + DO_RTHG + } + + +/*******************************************/ +/* RTG[] : Round To Grid */ +/* CodeRange : $18 */ +/* Stack : --> */ + + static void Ins_RTG( INS_ARG ) + { + DO_RTG + } + + +/*******************************************/ +/* RTDG[] : Round To Double Grid */ +/* CodeRange : $3D */ +/* Stack : --> */ + + static void Ins_RTDG( INS_ARG ) + { + DO_RTDG + } + + +/*******************************************/ +/* RUTG[] : Round Up To Grid */ +/* CodeRange : $7C */ +/* Stack : --> */ + + static void Ins_RUTG( INS_ARG ) + { + DO_RUTG + } + + +/*******************************************/ +/* RDTG[] : Round Down To Grid */ +/* CodeRange : $7D */ +/* Stack : --> */ + + static void Ins_RDTG( INS_ARG ) + { + DO_RDTG + } + + +/*******************************************/ +/* ROFF[] : Round OFF */ +/* CodeRange : $7A */ +/* Stack : --> */ + + static void Ins_ROFF( INS_ARG ) + { + DO_ROFF + } + + +/*******************************************/ +/* SROUND[] : Super ROUND */ +/* CodeRange : $76 */ +/* Stack : Eint8 --> */ + + static void Ins_SROUND( INS_ARG ) + { + DO_SROUND + } + + +/*******************************************/ +/* S45ROUND[]: Super ROUND 45 degrees */ +/* CodeRange : $77 */ +/* Stack : uint32 --> */ + + static void Ins_S45ROUND( INS_ARG ) + { + DO_S45ROUND + } + + +/*******************************************/ +/* SLOOP[] : Set LOOP variable */ +/* CodeRange : $17 */ +/* Stack : int32? --> */ + + static void Ins_SLOOP( INS_ARG ) + { + DO_SLOOP + } + + +/*******************************************/ +/* SMD[] : Set Minimum Distance */ +/* CodeRange : $1A */ +/* Stack : f26.6 --> */ + + static void Ins_SMD( INS_ARG ) + { + DO_SMD + } + + +/**********************************************/ +/* SCVTCI[] : Set Control Value Table Cut In */ +/* CodeRange : $1D */ +/* Stack : f26.6 --> */ + + static void Ins_SCVTCI( INS_ARG ) + { + DO_SCVTCI + } + + +/**********************************************/ +/* SSWCI[] : Set Single Width Cut In */ +/* CodeRange : $1E */ +/* Stack : f26.6 --> */ + + static void Ins_SSWCI( INS_ARG ) + { + DO_SSWCI + } + + +/**********************************************/ +/* SSW[] : Set Single Width */ +/* CodeRange : $1F */ +/* Stack : int32? --> */ + + static void Ins_SSW( INS_ARG ) + { + DO_SSW + } + + +/**********************************************/ +/* FLIPON[] : Set Auto_flip to On */ +/* CodeRange : $4D */ +/* Stack : --> */ + + static void Ins_FLIPON( INS_ARG ) + { + DO_FLIPON + } + + +/**********************************************/ +/* FLIPOFF[] : Set Auto_flip to Off */ +/* CodeRange : $4E */ +/* Stack : --> */ + + static void Ins_FLIPOFF( INS_ARG ) + { + DO_FLIPOFF + } + + +/**********************************************/ +/* SANGW[] : Set Angle Weight */ +/* CodeRange : $7E */ +/* Stack : uint32 --> */ + + static void Ins_SANGW( INS_ARG ) + { + /* instruction not supported anymore */ + } + + +/**********************************************/ +/* SDB[] : Set Delta Base */ +/* CodeRange : $5E */ +/* Stack : uint32 --> */ + + static void Ins_SDB( INS_ARG ) + { + DO_SDB + } + + +/**********************************************/ +/* SDS[] : Set Delta Shift */ +/* CodeRange : $5F */ +/* Stack : uint32 --> */ + + static void Ins_SDS( INS_ARG ) + { + DO_SDS + } + + +/**********************************************/ +/* MPPEM[] : Measure Pixel Per EM */ +/* CodeRange : $4B */ +/* Stack : --> Euint16 */ + + static void Ins_MPPEM( INS_ARG ) + { + DO_MPPEM + } + + +/**********************************************/ +/* MPS[] : Measure PointSize */ +/* CodeRange : $4C */ +/* Stack : --> Euint16 */ + + static void Ins_MPS( INS_ARG ) + { + DO_MPS + } + +/*******************************************/ +/* DUP[] : Duplicate top stack element */ +/* CodeRange : $20 */ +/* Stack : StkElt --> StkElt StkElt */ + + static void Ins_DUP( INS_ARG ) + { + DO_DUP + } + + +/*******************************************/ +/* POP[] : POPs the stack's top elt. */ +/* CodeRange : $21 */ +/* Stack : StkElt --> */ + + static void Ins_POP( INS_ARG ) + { + /* nothing to do */ + } + + +/*******************************************/ +/* CLEAR[] : Clear the entire stack */ +/* CodeRange : $22 */ +/* Stack : StkElt... --> */ + + static void Ins_CLEAR( INS_ARG ) + { + DO_CLEAR + } + + +/*******************************************/ +/* SWAP[] : Swap the top two elements */ +/* CodeRange : $23 */ +/* Stack : 2 * StkElt --> 2 * StkElt */ + + static void Ins_SWAP( INS_ARG ) + { + DO_SWAP + } + + +/*******************************************/ +/* DEPTH[] : return the stack depth */ +/* CodeRange : $24 */ +/* Stack : --> uint32 */ + + static void Ins_DEPTH( INS_ARG ) + { + DO_DEPTH + } + + +/*******************************************/ +/* CINDEX[] : copy indexed element */ +/* CodeRange : $25 */ +/* Stack : int32 --> StkElt */ + + static void Ins_CINDEX( INS_ARG ) + { + DO_CINDEX + } + + +/*******************************************/ +/* EIF[] : End IF */ +/* CodeRange : $59 */ +/* Stack : --> */ + + static void Ins_EIF( INS_ARG ) + { + /* nothing to do */ + } + + +/*******************************************/ +/* JROT[] : Jump Relative On True */ +/* CodeRange : $78 */ +/* Stack : StkElt int32 --> */ + + static void Ins_JROT( INS_ARG ) + { + DO_JROT + } + + +/*******************************************/ +/* JMPR[] : JuMP Relative */ +/* CodeRange : $1C */ +/* Stack : int32 --> */ + + static void Ins_JMPR( INS_ARG ) + { + DO_JMPR + } + + +/*******************************************/ +/* JROF[] : Jump Relative On False */ +/* CodeRange : $79 */ +/* Stack : StkElt int32 --> */ + + static void Ins_JROF( INS_ARG ) + { + DO_JROF + } + + +/*******************************************/ +/* LT[] : Less Than */ +/* CodeRange : $50 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_LT( INS_ARG ) + { + DO_LT + } + + +/*******************************************/ +/* LTEQ[] : Less Than or EQual */ +/* CodeRange : $51 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_LTEQ( INS_ARG ) + { + DO_LTEQ + } + + +/*******************************************/ +/* GT[] : Greater Than */ +/* CodeRange : $52 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_GT( INS_ARG ) + { + DO_GT + } + + +/*******************************************/ +/* GTEQ[] : Greater Than or EQual */ +/* CodeRange : $53 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_GTEQ( INS_ARG ) + { + DO_GTEQ + } + + +/*******************************************/ +/* EQ[] : EQual */ +/* CodeRange : $54 */ +/* Stack : StkElt StkElt --> bool */ + + static void Ins_EQ( INS_ARG ) + { + DO_EQ + } + + +/*******************************************/ +/* NEQ[] : Not EQual */ +/* CodeRange : $55 */ +/* Stack : StkElt StkElt --> bool */ + + static void Ins_NEQ( INS_ARG ) + { + DO_NEQ + } + + +/*******************************************/ +/* ODD[] : Odd */ +/* CodeRange : $56 */ +/* Stack : f26.6 --> bool */ + + static void Ins_ODD( INS_ARG ) + { + DO_ODD + } + + +/*******************************************/ +/* EVEN[] : Even */ +/* CodeRange : $57 */ +/* Stack : f26.6 --> bool */ + + static void Ins_EVEN( INS_ARG ) + { + DO_EVEN + } + + +/*******************************************/ +/* AND[] : logical AND */ +/* CodeRange : $5A */ +/* Stack : uint32 uint32 --> uint32 */ + + static void Ins_AND( INS_ARG ) + { + DO_AND + } + + +/*******************************************/ +/* OR[] : logical OR */ +/* CodeRange : $5B */ +/* Stack : uint32 uint32 --> uint32 */ + + static void Ins_OR( INS_ARG ) + { + DO_OR + } + + +/*******************************************/ +/* NOT[] : logical NOT */ +/* CodeRange : $5C */ +/* Stack : StkElt --> uint32 */ + + static void Ins_NOT( INS_ARG ) + { + DO_NOT + } + + +/*******************************************/ +/* ADD[] : ADD */ +/* CodeRange : $60 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_ADD( INS_ARG ) + { + DO_ADD + } + + +/*******************************************/ +/* SUB[] : SUBstract */ +/* CodeRange : $61 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_SUB( INS_ARG ) + { + DO_SUB + } + + +/*******************************************/ +/* DIV[] : DIVide */ +/* CodeRange : $62 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_DIV( INS_ARG ) + { + DO_DIV + } + + +/*******************************************/ +/* MUL[] : MULtiply */ +/* CodeRange : $63 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_MUL( INS_ARG ) + { + DO_MUL + } + + +/*******************************************/ +/* ABS[] : ABSolute value */ +/* CodeRange : $64 */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_ABS( INS_ARG ) + { + DO_ABS + } + + +/*******************************************/ +/* NEG[] : NEGate */ +/* CodeRange : $65 */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_NEG( INS_ARG ) + { + DO_NEG + } + + +/*******************************************/ +/* FLOOR[] : FLOOR */ +/* CodeRange : $66 */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_FLOOR( INS_ARG ) + { + DO_FLOOR + } + + +/*******************************************/ +/* CEILING[] : CEILING */ +/* CodeRange : $67 */ +/* f26.6 --> f26.6 */ + + static void Ins_CEILING( INS_ARG ) + { + DO_CEILING + } + +/*******************************************/ +/* RS[] : Read Store */ +/* CodeRange : $43 */ +/* Stack : uint32 --> uint32 */ + + static void Ins_RS( INS_ARG ) + { + DO_RS + } + + +/*******************************************/ +/* WS[] : Write Store */ +/* CodeRange : $42 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_WS( INS_ARG ) + { + DO_WS + } + + +/*******************************************/ +/* WCVTP[] : Write CVT in Pixel units */ +/* CodeRange : $44 */ +/* Stack : f26.6 uint32 --> */ + + static void Ins_WCVTP( INS_ARG ) + { + DO_WCVTP + } + + +/*******************************************/ +/* WCVTF[] : Write CVT in FUnits */ +/* CodeRange : $70 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_WCVTF( INS_ARG ) + { + DO_WCVTF + } + + +/*******************************************/ +/* RCVT[] : Read CVT */ +/* CodeRange : $45 */ +/* Stack : uint32 --> f26.6 */ + + static void Ins_RCVT( INS_ARG ) + { + DO_RCVT + } + + +/********************************************/ +/* AA[] : Adjust Angle */ +/* CodeRange : $7F */ +/* Stack : uint32 --> */ + + static void Ins_AA( INS_ARG ) + { + /* Intentional - no longer supported */ + } + + +/********************************************/ +/* DEBUG[] : DEBUG. Unsupported */ +/* CodeRange : $4F */ +/* Stack : uint32 --> */ + +/* NOTE : The original instruction pops a value from the stack */ + + static void Ins_DEBUG( INS_ARG ) + { + DO_DEBUG + } + +/*******************************************/ +/* ROUND[ab] : ROUND value */ +/* CodeRange : $68-$6B */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_ROUND( INS_ARG ) + { + DO_ROUND + } + +/*******************************************/ +/* NROUND[ab]: No ROUNDing of value */ +/* CodeRange : $6C-$6F */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_NROUND( INS_ARG ) + { + DO_NROUND + } + + + +/*******************************************/ +/* MAX[] : MAXimum */ +/* CodeRange : $68 */ +/* Stack : int32? int32? --> int32 */ + + static void Ins_MAX( INS_ARG ) + { + DO_MAX + } + + +/*******************************************/ +/* MIN[] : MINimum */ +/* CodeRange : $69 */ +/* Stack : int32? int32? --> int32 */ + + static void Ins_MIN( INS_ARG ) + { + DO_MIN + } + + +#endif /* !TT_CONFIG_OPTION_INTERPRETER_SWITCH */ + + +/* The following functions are called as is within the switch statement */ + +/*******************************************/ +/* MINDEX[] : move indexed element */ +/* CodeRange : $26 */ +/* Stack : int32? --> StkElt */ + + static void Ins_MINDEX( INS_ARG ) + { + Long L, K; + + + L = args[0]; + + if ( L <= 0 || L > CUR.args ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + K = CUR.stack[CUR.args - L]; + + MEM_Move( (&CUR.stack[CUR.args - L ]), + (&CUR.stack[CUR.args - L + 1]), + (L - 1) * sizeof ( Long ) ); + + CUR.stack[CUR.args - 1] = K; + } + + +/*******************************************/ +/* ROLL[] : roll top three elements */ +/* CodeRange : $8A */ +/* Stack : 3 * StkElt --> 3 * StkElt */ + + static void Ins_ROLL( INS_ARG ) + { + Long A, B, C; + + + A = args[2]; + B = args[1]; + C = args[0]; + + args[2] = C; + args[1] = A; + args[0] = B; + } + + + +/****************************************************************/ +/* */ +/* MANAGING THE FLOW OF CONTROL */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + + static Bool SkipCode( EXEC_OP ) + { + CUR.IP += CUR.length; + + if ( CUR.IP < CUR.codeSize ) + if ( CALC_Length() == SUCCESS ) + return SUCCESS; + + CUR.error = TT_Err_Code_Overflow; + return FAILURE; + } + + +/*******************************************/ +/* IF[] : IF test */ +/* CodeRange : $58 */ +/* Stack : StkElt --> */ + + static void Ins_IF( INS_ARG ) + { + Int nIfs; + Bool Out; + + + if ( args[0] != 0 ) + return; + + nIfs = 1; + Out = 0; + + do + { + if ( SKIP_Code() == FAILURE ) + return; + + switch ( CUR.opcode ) + { + case 0x58: /* IF */ + nIfs++; + break; + + case 0x1b: /* ELSE */ + Out = (nIfs == 1); + break; + + case 0x59: /* EIF */ + nIfs--; + Out = (nIfs == 0); + break; + } + } while ( Out == 0 ); + } + + +/*******************************************/ +/* ELSE[] : ELSE */ +/* CodeRange : $1B */ +/* Stack : --> */ + + static void Ins_ELSE( INS_ARG ) + { + Int nIfs; + + + nIfs = 1; + + do + { + if ( SKIP_Code() == FAILURE ) + return; + + switch ( CUR.opcode ) + { + case 0x58: /* IF */ + nIfs++; + break; + + case 0x59: /* EIF */ + nIfs--; + break; + } + } while ( nIfs != 0 ); + } + + +/****************************************************************/ +/* */ +/* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + + static PDefRecord Locate_FDef( EXEC_OPS Int n, Bool new_def ) + { + PDefRecord def; + UShort hash; + UShort cnt; + + /* The function table is interpreted as a simple hash table */ + /* with indexes computed modulo maxFDefs and the linear search */ + /* of free cells in the case of a collision. */ + /* Except for some old Apple fonts, all functions in a TrueType */ + /* font fit into 0..maxFDefs - 1 range and the lookup is */ + /* reduced to a single step. */ + + /* Minor optimization. */ + if ( !new_def && ( n < 0 || n > CUR.maxFunc ) ) + return NULL; + + for ( cnt = 0; cnt < CUR.maxFDefs; ++cnt ) + { + hash = ( (UShort)n + cnt ) % CUR.maxFDefs; + def = &CUR.FDefs[ hash ]; + if ( !def->Active ) + return new_def ? def : NULL; + if ( def->Opc == n ) + return def; + } + + /* The table is full and the entry has not been found. */ + return NULL; + } + + +/*******************************************/ +/* FDEF[] : Function DEFinition */ +/* CodeRange : $2C */ +/* Stack : uint32 --> */ + + static void Ins_FDEF( INS_ARG ) + { + Int n; + PDefRecord def; + + + /* check that there is enough room */ + if ( CUR.numFDefs >= CUR.maxFDefs ) + { + /* We could introduce a new error message, but we're too close */ + /* from the release to change all the 'po' files again.. */ + CUR.error = TT_Err_Too_Many_Ins; + return; + } + + n = (Int)args[0]; + if ( n < 0 || (ULong)n != args[0] ) + { + /* Gotcha. Function index is uint32 according to the specs */ + /* but TDefRecord.Opc is defined as Int. We cannot store */ + /* the definition of this function. */ + CUR.error = TT_Err_Bad_Argument; + return; + } + + def = Locate_FDef( EXEC_ARGS n, TRUE ); + if ( !def ) + { + /* Oh, oh. Something is wrong. Locate_FDef should never fail here. */ + CUR.error = TT_Err_Too_Many_Ins; + return; + } + + /* Some font programs are broken enough to redefine functions! */ + if ( !def->Active ) + CUR.numFDefs++; + + def->Range = CUR.curRange; + def->Opc = n; + def->Start = CUR.IP + 1; + def->Active = TRUE; + + if ( n > CUR.maxFunc ) + CUR.maxFunc = n; + + /* Now skip the whole function definition. */ + /* We don't allow nested IDEFS & FDEFs. */ + + while ( SKIP_Code() == SUCCESS ) + { + switch ( CUR.opcode ) + { + case 0x89: /* IDEF */ + case 0x2c: /* FDEF */ + CUR.error = TT_Err_Nested_DEFS; + return; + case 0x2d: /* ENDF */ + return; + } + } + } + + +/*******************************************/ +/* ENDF[] : END Function definition */ +/* CodeRange : $2D */ +/* Stack : --> */ + + static void Ins_ENDF( INS_ARG ) + { + PCallRecord pRec; + + + if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */ + { + CUR.error = TT_Err_ENDF_In_Exec_Stream; + return; + } + + CUR.callTop--; + + pRec = &CUR.callStack[CUR.callTop]; + + pRec->Cur_Count--; + + CUR.step_ins = FALSE; + + if ( pRec->Cur_Count > 0 ) + { + CUR.callTop++; + CUR.IP = pRec->Cur_Restart; + } + else + /* Loop through the current function */ + INS_Goto_CodeRange( pRec->Caller_Range, + pRec->Caller_IP ); + + /* Exit the current call frame. */ + + /* NOTE: When the last intruction of a program */ + /* is a CALL or LOOPCALL, the return address */ + /* is always out of the code range. This is */ + /* a valid address, and it's why we do not test */ + /* the result of Ins_Goto_CodeRange() here! */ + } + + +/*******************************************/ +/* CALL[] : CALL function */ +/* CodeRange : $2B */ +/* Stack : uint32? --> */ + + static void Ins_CALL( INS_ARG ) + { + Int n; + PDefRecord def; + PCallRecord pCrec; + + + n = (Int)args[0]; + def = Locate_FDef( EXEC_ARGS n, FALSE ); + if ( !def ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* check call stack */ + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + pCrec = CUR.callStack + CUR.callTop; + + pCrec->Caller_Range = CUR.curRange; + pCrec->Caller_IP = CUR.IP + 1; + pCrec->Cur_Count = 1; + pCrec->Cur_Restart = def->Start; + + CUR.callTop++; + + INS_Goto_CodeRange( def->Range, + def->Start ); + + CUR.step_ins = FALSE; + } + + +/*******************************************/ +/* LOOPCALL[]: LOOP and CALL function */ +/* CodeRange : $2A */ +/* Stack : uint32? Eint16? --> */ + + static void Ins_LOOPCALL( INS_ARG ) + { + Int n; + Long count; + PDefRecord def; + PCallRecord pTCR; + + + n = (Int)args[1]; + def = Locate_FDef( EXEC_ARGS n, FALSE ); + if ( !def ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + count = (Long)args[0]; + if ( count <= 0 ) + return; + + pTCR = &CUR.callStack[CUR.callTop]; + + pTCR->Caller_Range = CUR.curRange; + pTCR->Caller_IP = CUR.IP + 1; + pTCR->Cur_Count = count; + pTCR->Cur_Restart = def->Start; + + CUR.callTop++; + + INS_Goto_CodeRange( def->Range, + def->Start ); + + CUR.step_ins = FALSE; + } + + +/*******************************************/ +/* IDEF[] : Instruction DEFinition */ +/* CodeRange : $89 */ +/* Stack : Eint8 --> */ + + static void Ins_IDEF( INS_ARG ) + { + Byte opcode; + PDefRecord def; + PDefRecord limit; + + + opcode = (Byte)args[0]; + + /* First of all, look for the same instruction in our table */ + def = CUR.IDefs; + limit = def + CUR.numIDefs; + for ( ; def < limit; def++ ) + if ( def->Opc == opcode ) + break; + + if ( def == limit ) + { + /* check that there is enough room for a new instruction */ + if ( CUR.numIDefs >= CUR.maxIDefs ) + { + /* XXX Bad error code. See FDEF[]. */ + CUR.error = TT_Err_Too_Many_Ins; + return; + } + CUR.numIDefs++; + } + + def->Opc = opcode; + def->Start = CUR.IP + 1; + def->Range = CUR.curRange; + def->Active = TRUE; + + if ( opcode > CUR.maxIns ) + CUR.maxIns = opcode; + + /* Now skip the whole function definition */ + /* We don't allow nested IDEFs & FDEFs. */ + + while ( SKIP_Code() == SUCCESS ) + { + switch ( CUR.opcode ) + { + case 0x89: /* IDEF */ + case 0x2c: /* FDEF */ + CUR.error = TT_Err_Nested_DEFS; + return; + case 0x2d: /* ENDF */ + return; + } + } + } + + +/****************************************************************/ +/* */ +/* PUSHING DATA ONTO THE INTERPRETER STACK */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + +/*******************************************/ +/* NPUSHB[] : PUSH N Bytes */ +/* CodeRange : $40 */ +/* Stack : --> uint32... */ + + static void Ins_NPUSHB( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.code[CUR.IP + 1]; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + for ( K = 1; K <= L; K++ ) + args[K - 1] = CUR.code[CUR.IP + K + 1]; + + CUR.new_top += L; + } + + +/*******************************************/ +/* NPUSHW[] : PUSH N Words */ +/* CodeRange : $41 */ +/* Stack : --> int32... */ + + static void Ins_NPUSHW( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.code[CUR.IP + 1]; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + CUR.IP += 2; + + for ( K = 0; K < L; K++ ) + args[K] = GET_ShortIns(); + + CUR.step_ins = FALSE; + CUR.new_top += L; + } + + +/*******************************************/ +/* PUSHB[abc]: PUSH Bytes */ +/* CodeRange : $B0-$B7 */ +/* Stack : --> uint32... */ + + static void Ins_PUSHB( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.opcode - 0xB0 + 1; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + for ( K = 1; K <= L; K++ ) + args[K - 1] = CUR.code[CUR.IP + K]; + } + + +/*******************************************/ +/* PUSHW[abc]: PUSH Words */ +/* CodeRange : $B8-$BF */ +/* Stack : --> int32... */ + + static void Ins_PUSHW( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.opcode - 0xB8 + 1; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + CUR.IP++; + + for ( K = 0; K < L; K++ ) + args[K] = GET_ShortIns(); + + CUR.step_ins = FALSE; + } + + + +/****************************************************************/ +/* */ +/* MANAGING THE GRAPHICS STATE */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + +/**********************************************/ +/* GC[a] : Get Coordinate projected onto */ +/* CodeRange : $46-$47 */ +/* Stack : uint32 --> f26.6 */ + +/* BULLSHIT: Measures from the original glyph must be taken */ +/* along the dual projection vector! */ + + static void Ins_GC( INS_ARG ) + { + ULong L; + TT_F26Dot6 R; + + + L = (ULong)args[0]; + + if ( BOUNDS( L, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + else + R = 0; + } + else + { + if ( CUR.opcode & 1 ) + R = CUR_Func_dualproj( CUR.zp2.org + L, NULL_Vector ); + else + R = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector ); + } + + args[0] = R; + } + + +/**********************************************/ +/* SCFS[] : Set Coordinate From Stack */ +/* CodeRange : $48 */ +/* Stack : f26.6 uint32 --> */ +/* */ +/* Formula: */ +/* */ +/* OA := OA + ( value - OA.p )/( f.p ) * f */ +/* */ + + static void Ins_SCFS( INS_ARG ) + { + Long K; + UShort L; + + + L = (UShort)args[0]; + + if ( BOUNDS( L, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + K = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector ); + + CUR_Func_move( &CUR.zp2, L, args[1] - K ); + + /* not part of the specs, but here for safety */ + + if ( CUR.GS.gep2 == 0 ) + CUR.zp2.org[L] = CUR.zp2.cur[L]; + } + + +/**********************************************/ +/* MD[a] : Measure Distance */ +/* CodeRange : $49-$4A */ +/* Stack : uint32 uint32 --> f26.6 */ + +/* BULLSHIT: Measure taken in the original glyph must be along */ +/* the dual projection vector. */ + +/* Second BULLSHIT: Flag attributes are inverted! */ +/* 0 => measure distance in original outline */ +/* 1 => measure distance in grid-fitted outline */ + +/* Third one !! : zp0 - zp1, and not "zp2 - zp1" !!! */ +/* */ + + static void Ins_MD( INS_ARG ) + { + UShort K, L; + TT_F26Dot6 D; + + + K = (UShort)args[1]; + L = (UShort)args[0]; + + if( BOUNDS( L, CUR.zp0.n_points ) || + BOUNDS( K, CUR.zp1.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + else + D = 0; + } + else + { + if ( CUR.opcode & 1 ) + D = CUR_Func_project( CUR.zp0.cur + L, CUR.zp1.cur + K ); + else + D = CUR_Func_dualproj( CUR.zp0.org + L, CUR.zp1.org + K ); + } + + args[0] = D; + } + + +/*******************************************/ +/* SDPVTL[a] : Set Dual PVector to Line */ +/* CodeRange : $86-$87 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_SDPVTL( INS_ARG ) + { + Long A, B, C; + UShort p1, p2; /* was Int in pas type ERROR */ + + + p1 = (UShort)args[1]; + p2 = (UShort)args[0]; + + if ( BOUNDS( p2, CUR.zp1.n_points ) || + BOUNDS( p1, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + { + TT_Vector* v1 = CUR.zp1.org + p2; + TT_Vector* v2 = CUR.zp2.org + p1; + + + A = v1->x - v2->x; + B = v1->y - v2->y; + } + + if ( (CUR.opcode & 1) != 0 ) + { + C = B; /* CounterClockwise rotation */ + B = A; + A = -C; + } + + NORMalize( A, B, &CUR.GS.dualVector ); + + { + TT_Vector* v1 = CUR.zp1.cur + p2; + TT_Vector* v2 = CUR.zp2.cur + p1; + + + A = v1->x - v2->x; + B = v1->y - v2->y; + } + + if ( (CUR.opcode & 1) != 0 ) + { + C = B; /* CounterClockwise rotation */ + B = A; + A = -C; + } + + NORMalize( A, B, &CUR.GS.projVector ); + + COMPUTE_Funcs(); + } + + +/*******************************************/ +/* SZP0[] : Set Zone Pointer 0 */ +/* CodeRange : $13 */ +/* Stack : uint32 --> */ + + static void Ins_SZP0( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp0 = CUR.twilight; + break; + + case 1: + CUR.zp0 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.GS.gep0 = (UShort)args[0]; + } + + +/*******************************************/ +/* SZP1[] : Set Zone Pointer 1 */ +/* CodeRange : $14 */ +/* Stack : uint32 --> */ + + static void Ins_SZP1( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp1 = CUR.twilight; + break; + + case 1: + CUR.zp1 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.GS.gep1 = (UShort)args[0]; + } + + +/*******************************************/ +/* SZP2[] : Set Zone Pointer 2 */ +/* CodeRange : $15 */ +/* Stack : uint32 --> */ + + static void Ins_SZP2( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp2 = CUR.twilight; + break; + + case 1: + CUR.zp2 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.GS.gep2 = (UShort)args[0]; + } + + +/*******************************************/ +/* SZPS[] : Set Zone Pointers */ +/* CodeRange : $16 */ +/* Stack : uint32 --> */ + + static void Ins_SZPS( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp0 = CUR.twilight; + break; + + case 1: + CUR.zp0 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.zp1 = CUR.zp0; + CUR.zp2 = CUR.zp0; + + CUR.GS.gep0 = (UShort)args[0]; + CUR.GS.gep1 = (UShort)args[0]; + CUR.GS.gep2 = (UShort)args[0]; + } + + +/*******************************************/ +/* INSTCTRL[]: INSTruction ConTRol */ +/* CodeRange : $8e */ +/* Stack : int32 int32 --> */ + + static void Ins_INSTCTRL( INS_ARG ) + { + Long K, L; + + + K = args[1]; + L = args[0]; + + if ( K < 1 || K > 2 ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( L != 0 ) + L = K; + + CUR.GS.instruct_control = + (Byte)( CUR.GS.instruct_control & ~(Byte)K ) | (Byte)L; + } + + +/*******************************************/ +/* SCANCTRL[]: SCAN ConTRol */ +/* CodeRange : $85 */ +/* Stack : uint32? --> */ + + static void Ins_SCANCTRL( INS_ARG ) + { + Int A; + + + /* Get Threshold */ + A = (Int)(args[0] & 0xFF); + + if ( A == 0xFF ) + { + CUR.GS.scan_control = TRUE; + return; + } + else if ( A == 0 ) + { + CUR.GS.scan_control = FALSE; + return; + } + + A *= 64; + + if ( (args[0] & 0x100) != 0 && CUR.metrics.pointSize <= A ) + CUR.GS.scan_control = TRUE; + + if ( (args[0] & 0x200) != 0 && CUR.metrics.rotated ) + CUR.GS.scan_control = TRUE; + + if ( (args[0] & 0x400) != 0 && CUR.metrics.stretched ) + CUR.GS.scan_control = TRUE; + + if ( (args[0] & 0x800) != 0 && CUR.metrics.pointSize > A ) + CUR.GS.scan_control = FALSE; + + if ( (args[0] & 0x1000) != 0 && CUR.metrics.rotated ) + CUR.GS.scan_control = FALSE; + + if ( (args[0] & 0x2000) != 0 && CUR.metrics.stretched ) + CUR.GS.scan_control = FALSE; +} + + +/*******************************************/ +/* SCANTYPE[]: SCAN TYPE */ +/* CodeRange : $8D */ +/* Stack : uint32? --> */ + + static void Ins_SCANTYPE( INS_ARG ) + { + /* For compatibility with future enhancements, */ + /* we must ignore new modes */ + + if ( args[0] >= 0 && args[0] <= 5 ) + { + if ( args[0] == 3 ) + args[0] = 2; + + CUR.GS.scan_type = (Int)args[0]; + } + } + + + +/****************************************************************/ +/* */ +/* MANAGING OUTLINES */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + +/**********************************************/ +/* FLIPPT[] : FLIP PoinT */ +/* CodeRange : $80 */ +/* Stack : uint32... --> */ + + static void Ins_FLIPPT( INS_ARG ) + { + UShort point; + + + if ( CUR.top < CUR.GS.loop ) + { + CUR.error = TT_Err_Too_Few_Arguments; + return; + } + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.pts.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + CUR.pts.touch[point] ^= TT_Flag_On_Curve; + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* FLIPRGON[]: FLIP RanGe ON */ +/* CodeRange : $81 */ +/* Stack : uint32 uint32 --> */ +/* (but UShorts are sufficient) */ + + static void Ins_FLIPRGON( INS_ARG ) + { + UShort I, K, L; + + + K = (UShort)args[1]; + L = (UShort)args[0]; + + if ( BOUNDS( K, CUR.pts.n_points ) || + BOUNDS( L, CUR.pts.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + for ( I = L; I <= K; I++ ) + CUR.pts.touch[I] |= TT_Flag_On_Curve; + } + + +/**********************************************/ +/* FLIPRGOFF : FLIP RanGe OFF */ +/* CodeRange : $82 */ +/* Stack : uint32 uint32 --> */ +/* (but UShorts are sufficient) */ + + static void Ins_FLIPRGOFF( INS_ARG ) + { + UShort I, K, L; + + + K = (UShort)args[1]; + L = (UShort)args[0]; + + if ( BOUNDS( K, CUR.pts.n_points ) || + BOUNDS( L, CUR.pts.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + for ( I = L; I <= K; I++ ) + CUR.pts.touch[I] &= ~TT_Flag_On_Curve; + } + + + static Bool Compute_Point_Displacement( EXEC_OPS + PCoordinates x, + PCoordinates y, + PGlyph_Zone zone, + UShort* refp ) + { + TGlyph_Zone zp; + UShort p; + TT_F26Dot6 d; + + + if ( CUR.opcode & 1 ) + { + zp = CUR.zp0; + p = CUR.GS.rp1; + } + else + { + zp = CUR.zp1; + p = CUR.GS.rp2; + } + + if ( BOUNDS( p, zp.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Displacement; + return FAILURE; + } + + *zone = zp; + *refp = p; + + d = CUR_Func_project( zp.cur + p, zp.org + p ); + + *x = TT_MulDiv(d, (Long)CUR.GS.freeVector.x * 0x10000L, CUR.F_dot_P ); + *y = TT_MulDiv(d, (Long)CUR.GS.freeVector.y * 0x10000L, CUR.F_dot_P ); + + return SUCCESS; + } + + + static void Move_Zp2_Point( EXEC_OPS + UShort point, + TT_F26Dot6 dx, + TT_F26Dot6 dy, + Bool touch ) + { + if ( CUR.GS.freeVector.x != 0 ) + { + CUR.zp2.cur[point].x += dx; + if ( touch ) + CUR.zp2.touch[point] |= TT_Flag_Touched_X; + } + + if ( CUR.GS.freeVector.y != 0 ) + { + CUR.zp2.cur[point].y += dy; + if ( touch ) + CUR.zp2.touch[point] |= TT_Flag_Touched_Y; + } + } + + +/**********************************************/ +/* SHP[a] : SHift Point by the last point */ +/* CodeRange : $32-33 */ +/* Stack : uint32... --> */ + + static void Ins_SHP( INS_ARG ) + { + TGlyph_Zone zp; + UShort refp; + + TT_F26Dot6 dx, + dy; + UShort point; + + + if ( CUR.top < CUR.GS.loop ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) + return; + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + /* UNDOCUMENTED! SHP touches the points */ + MOVE_Zp2_Point( point, dx, dy, TRUE ); + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* SHC[a] : SHift Contour */ +/* CodeRange : $34-35 */ +/* Stack : uint32 --> */ + + static void Ins_SHC( INS_ARG ) + { + TGlyph_Zone zp; + UShort refp; + TT_F26Dot6 dx, + dy; + + Short contour; + UShort first_point, last_point, i; + + + contour = (UShort)args[0]; + + if ( BOUNDS( contour, CUR.pts.n_contours ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) + return; + + if ( contour == 0 ) + first_point = 0; + else + first_point = CUR.pts.contours[contour - 1] + 1; + + last_point = CUR.pts.contours[contour]; + + /* XXX: this is probably wrong... at least it prevents memory */ + /* corruption when zp2 is the twilight zone */ + if ( last_point > CUR.zp2.n_points ) + { + if ( CUR.zp2.n_points > 0 ) + last_point = CUR.zp2.n_points - 1; + else + last_point = 0; + } + + /* UNDOCUMENTED! SHC doesn't touch the points */ + for ( i = first_point; i <= last_point; i++ ) + { + if ( zp.cur != CUR.zp2.cur || refp != i ) + MOVE_Zp2_Point( i, dx, dy, FALSE ); + } + } + + +/**********************************************/ +/* SHZ[a] : SHift Zone */ +/* CodeRange : $36-37 */ +/* Stack : uint32 --> */ + + static void Ins_SHZ( INS_ARG ) + { + TGlyph_Zone zp; + UShort refp; + TT_F26Dot6 dx, + dy; + + UShort last_point, i; + + + if ( BOUNDS( args[0], 2 ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) + return; + + if ( CUR.zp2.n_points > 0 ) + last_point = CUR.zp2.n_points - 1; + else + last_point = 0; + + /* UNDOCUMENTED! SHZ doesn't touch the points */ + for ( i = 0; i <= last_point; i++ ) + { + if ( zp.cur != CUR.zp2.cur || refp != i ) + MOVE_Zp2_Point( i, dx, dy, FALSE ); + } + } + + +/**********************************************/ +/* SHPIX[] : SHift points by a PIXel amount */ +/* CodeRange : $38 */ +/* Stack : f26.6 uint32... --> */ + + static void Ins_SHPIX( INS_ARG ) + { + TT_F26Dot6 dx, dy; + UShort point; + + + if ( CUR.top < CUR.GS.loop + 1 ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + dx = TT_MulDiv( args[0], + (Long)CUR.GS.freeVector.x, + 0x4000 ); + dy = TT_MulDiv( args[0], + (Long)CUR.GS.freeVector.y, + 0x4000 ); + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + MOVE_Zp2_Point( point, dx, dy, TRUE ); + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* MSIRP[a] : Move Stack Indirect Relative */ +/* CodeRange : $3A-$3B */ +/* Stack : f26.6 uint32 --> */ + + static void Ins_MSIRP( INS_ARG ) + { + UShort point; + TT_F26Dot6 distance; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp1.n_points ) || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: UNDOCUMENTED! behaviour */ + if ( CUR.GS.gep0 == 0 ) /* if in twilight zone */ + { + CUR.zp1.org[point] = CUR.zp0.org[CUR.GS.rp0]; + CUR.zp1.cur[point] = CUR.zp1.org[point]; + } + + distance = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + CUR_Func_move( &CUR.zp1, point, args[1] - distance ); + + CUR.GS.rp1 = CUR.GS.rp0; + CUR.GS.rp2 = point; + + if ( (CUR.opcode & 1) != 0 ) + CUR.GS.rp0 = point; + } + + +/**********************************************/ +/* MDAP[a] : Move Direct Absolute Point */ +/* CodeRange : $2E-$2F */ +/* Stack : uint32 --> */ + + static void Ins_MDAP( INS_ARG ) + { + UShort point; + TT_F26Dot6 cur_dist, + distance; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: Is there some undocumented feature while in the */ + /* twilight zone? ? */ + if ( (CUR.opcode & 1) != 0 ) + { + cur_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector ); + distance = CUR_Func_round( cur_dist, + CUR.metrics.compensations[0] ) - cur_dist; + } + else + distance = 0; + + CUR_Func_move( &CUR.zp0, point, distance ); + + CUR.GS.rp0 = point; + CUR.GS.rp1 = point; + } + + +/**********************************************/ +/* MIAP[a] : Move Indirect Absolute Point */ +/* CodeRange : $3E-$3F */ +/* Stack : uint32 uint32 --> */ + + static void Ins_MIAP( INS_ARG ) + { + ULong cvtEntry; + UShort point; + TT_F26Dot6 distance, + org_dist; + + + cvtEntry = (ULong)args[1]; + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp0.n_points ) || + BOUNDS( cvtEntry, CUR.cvtSize ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* UNDOCUMENTED! */ + /* */ + /* The behaviour of an MIAP instruction is quite */ + /* different when used in the twilight zone. */ + /* */ + /* First, no control value cutin test is performed */ + /* as it would fail anyway. Second, the original */ + /* point, i.e. (org_x,org_y) of zp0.point, is set */ + /* to the absolute, unrounded distance found in */ + /* the CVT. */ + /* */ + /* This is used in the CVT programs of the Microsoft */ + /* fonts Arial, Times, etc., in order to re-adjust */ + /* some key font heights. It allows the use of the */ + /* IP instruction in the twilight zone, which */ + /* otherwise would be "illegal" according to the */ + /* specs :) */ + /* */ + /* We implement it with a special sequence for the */ + /* twilight zone. This is a bad hack, but it seems */ + /* to work. */ + + distance = CUR_Func_read_cvt( cvtEntry ); + + if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */ + { + CUR.zp0.org[point].x = TT_MulDiv( CUR.GS.freeVector.x, + distance, 0x4000L ); + CUR.zp0.org[point].y = TT_MulDiv( CUR.GS.freeVector.y, + distance, 0x4000L ); + CUR.zp0.cur[point] = CUR.zp0.org[point]; + } + + org_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector ); + + if ( (CUR.opcode & 1) != 0 ) /* rounding and control cutin flag */ + { + if ( ABS( distance - org_dist ) > CUR.GS.control_value_cutin ) + distance = org_dist; + + distance = CUR_Func_round( distance, CUR.metrics.compensations[0] ); + } + + CUR_Func_move( &CUR.zp0, point, distance - org_dist ); + + CUR.GS.rp0 = point; + CUR.GS.rp1 = point; + } + + +/**********************************************/ +/* MDRP[abcde] : Move Direct Relative Point */ +/* CodeRange : $C0-$DF */ +/* Stack : uint32 --> */ + + static void Ins_MDRP( INS_ARG ) + { + UShort point; + TT_F26Dot6 org_dist, distance; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp1.n_points ) || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: Is there some undocumented feature while in the */ + /* twilight zone? */ + + org_dist = CUR_Func_dualproj( CUR.zp1.org + point, + CUR.zp0.org + CUR.GS.rp0 ); + + /* single width cutin test */ + + if ( ABS( org_dist ) < CUR.GS.single_width_cutin ) + { + if ( org_dist >= 0 ) + org_dist = CUR.GS.single_width_value; + else + org_dist = -CUR.GS.single_width_value; + } + + /* round flag */ + + if ( (CUR.opcode & 4) != 0 ) + distance = CUR_Func_round( org_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + else + distance = Round_None( EXEC_ARGS + org_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + + /* minimum distance flag */ + + if ( (CUR.opcode & 8) != 0 ) + { + if ( org_dist >= 0 ) + { + if ( distance < CUR.GS.minimum_distance ) + distance = CUR.GS.minimum_distance; + } + else + { + if ( distance > -CUR.GS.minimum_distance ) + distance = -CUR.GS.minimum_distance; + } + } + + /* now move the point */ + + org_dist = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + CUR_Func_move( &CUR.zp1, point, distance - org_dist ); + + CUR.GS.rp1 = CUR.GS.rp0; + CUR.GS.rp2 = point; + + if ( (CUR.opcode & 16) != 0 ) + CUR.GS.rp0 = point; + } + + +/**********************************************/ +/* MIRP[abcde] : Move Indirect Relative Point */ +/* CodeRange : $E0-$FF */ +/* Stack : int32? uint32 --> */ + + static void Ins_MIRP( INS_ARG ) + { + UShort point; + ULong cvtEntry; + + TT_F26Dot6 cvt_dist, + distance, + cur_dist, + org_dist; + + + point = (UShort)args[0]; + cvtEntry = (ULong)(args[1] + 1); + + /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */ + + if ( BOUNDS( point, CUR.zp1.n_points ) || + BOUNDS( cvtEntry, CUR.cvtSize + 1 ) || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( !cvtEntry ) + cvt_dist = 0; + else + cvt_dist = CUR_Func_read_cvt( cvtEntry - 1 ); + + /* single width test */ + + if ( ABS( cvt_dist ) < CUR.GS.single_width_cutin ) + { + if ( cvt_dist >= 0 ) + cvt_dist = CUR.GS.single_width_value; + else + cvt_dist = -CUR.GS.single_width_value; + } + + /* XXX : UNDOCUMENTED! -- twilight zone */ + + if ( CUR.GS.gep1 == 0 ) + { + CUR.zp1.org[point].x = CUR.zp0.org[CUR.GS.rp0].x + + TT_MulDiv( cvt_dist, + CUR.GS.freeVector.x, + 0x4000 ); + + CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y + + TT_MulDiv( cvt_dist, + CUR.GS.freeVector.y, + 0x4000 ); + + CUR.zp1.cur[point] = CUR.zp1.org[point]; + } + + org_dist = CUR_Func_dualproj( CUR.zp1.org + point, + CUR.zp0.org + CUR.GS.rp0 ); + + cur_dist = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + /* auto-flip test */ + + if ( CUR.GS.auto_flip ) + { + if ( (org_dist ^ cvt_dist) < 0 ) + cvt_dist = -cvt_dist; + } + + /* control value cutin and round */ + + if ( (CUR.opcode & 4) != 0 ) + { + /* XXX: UNDOCUMENTED! Only perform cut-in test when both points */ + /* refer to the same zone. */ + + if ( CUR.GS.gep0 == CUR.GS.gep1 ) + if ( ABS( cvt_dist - org_dist ) >= CUR.GS.control_value_cutin ) + cvt_dist = org_dist; + + distance = CUR_Func_round( cvt_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + } + else + distance = Round_None( EXEC_ARGS + cvt_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + + /* minimum distance test */ + + if ( (CUR.opcode & 8) != 0 ) + { + if ( org_dist >= 0 ) + { + if ( distance < CUR.GS.minimum_distance ) + distance = CUR.GS.minimum_distance; + } + else + { + if ( distance > -CUR.GS.minimum_distance ) + distance = -CUR.GS.minimum_distance; + } + } + + CUR_Func_move( &CUR.zp1, point, distance - cur_dist ); + + CUR.GS.rp1 = CUR.GS.rp0; + + if ( (CUR.opcode & 16) != 0 ) + CUR.GS.rp0 = point; + + /* UNDOCUMENTED! */ + + CUR.GS.rp2 = point; + } + + +/**********************************************/ +/* ALIGNRP[] : ALIGN Relative Point */ +/* CodeRange : $3C */ +/* Stack : uint32 uint32... --> */ + + static void Ins_ALIGNRP( INS_ARG ) + { + UShort point; + TT_F26Dot6 distance; + + + if ( CUR.top < CUR.GS.loop || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.zp1.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + { + distance = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + CUR_Func_move( &CUR.zp1, point, -distance ); + } + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* ISECT[] : moves point to InterSECTion */ +/* CodeRange : $0F */ +/* Stack : 5 * uint32 --> */ + + static void Ins_ISECT( INS_ARG ) + { + UShort point, + a0, a1, + b0, b1; + + TT_F26Dot6 discriminant; + + TT_F26Dot6 dx, dy, + dax, day, + dbx, dby; + + TT_F26Dot6 val; + + TT_Vector R; + + + point = (UShort)args[0]; + + a0 = (UShort)args[1]; + a1 = (UShort)args[2]; + b0 = (UShort)args[3]; + b1 = (UShort)args[4]; + + if ( BOUNDS( b0, CUR.zp0.n_points ) || + BOUNDS( b1, CUR.zp0.n_points ) || + BOUNDS( a0, CUR.zp1.n_points ) || + BOUNDS( a1, CUR.zp1.n_points ) || + BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + dbx = CUR.zp0.cur[b1].x - CUR.zp0.cur[b0].x; + dby = CUR.zp0.cur[b1].y - CUR.zp0.cur[b0].y; + + dax = CUR.zp1.cur[a1].x - CUR.zp1.cur[a0].x; + day = CUR.zp1.cur[a1].y - CUR.zp1.cur[a0].y; + + dx = CUR.zp0.cur[b0].x - CUR.zp1.cur[a0].x; + dy = CUR.zp0.cur[b0].y - CUR.zp1.cur[a0].y; + + CUR.zp2.touch[point] |= TT_Flag_Touched_Both; + + discriminant = TT_MulDiv( dax, -dby, 0x40L ) + + TT_MulDiv( day, dbx, 0x40L ); + + if ( ABS( discriminant ) >= 0x40 ) + { + val = TT_MulDiv( dx, -dby, 0x40L ) + TT_MulDiv( dy, dbx, 0x40L ); + + R.x = TT_MulDiv( val, dax, discriminant ); + R.y = TT_MulDiv( val, day, discriminant ); + + CUR.zp2.cur[point].x = CUR.zp1.cur[a0].x + R.x; + CUR.zp2.cur[point].y = CUR.zp1.cur[a0].y + R.y; + } + else + { + /* else, take the middle of the middles of A and B */ + + CUR.zp2.cur[point].x = ( CUR.zp1.cur[a0].x + + CUR.zp1.cur[a1].x + + CUR.zp0.cur[b0].x + + CUR.zp0.cur[b1].x ) / 4; + CUR.zp2.cur[point].y = ( CUR.zp1.cur[a0].y + + CUR.zp1.cur[a1].y + + CUR.zp0.cur[b0].y + + CUR.zp0.cur[b1].y ) / 4; + } + } + + +/**********************************************/ +/* ALIGNPTS[] : ALIGN PoinTS */ +/* CodeRange : $27 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_ALIGNPTS( INS_ARG ) + { + UShort p1, p2; + TT_F26Dot6 distance; + + + p1 = (UShort)args[0]; + p2 = (UShort)args[1]; + + if ( BOUNDS( args[0], CUR.zp1.n_points ) || + BOUNDS( args[1], CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + distance = CUR_Func_project( CUR.zp0.cur + p2, + CUR.zp1.cur + p1 ) / 2; + + CUR_Func_move( &CUR.zp1, p1, distance ); + CUR_Func_move( &CUR.zp0, p2, -distance ); + } + + +/**********************************************/ +/* IP[] : Interpolate Point */ +/* CodeRange : $39 */ +/* Stack : uint32... --> */ + + static void Ins_IP( INS_ARG ) + { + TT_F26Dot6 org_a, org_b, org_x, + cur_a, cur_b, cur_x, + distance; + UShort point; + + + if ( CUR.top < CUR.GS.loop ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: there are some glyphs in some braindead but popular */ + /* fonts out there (e.g. [aeu]grave in monotype.ttf) */ + /* calling IP[] with bad values of rp[12] */ + /* do something sane when this odd thing happens */ + + if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) || + BOUNDS( CUR.GS.rp2, CUR.zp1.n_points ) ) + { + org_a = cur_a = 0; + org_b = cur_b = 0; + } + else + { + org_a = CUR_Func_dualproj( CUR.zp0.org + CUR.GS.rp1, NULL_Vector ); + org_b = CUR_Func_dualproj( CUR.zp1.org + CUR.GS.rp2, NULL_Vector ); + + cur_a = CUR_Func_project( CUR.zp0.cur + CUR.GS.rp1, NULL_Vector ); + cur_b = CUR_Func_project( CUR.zp1.cur + CUR.GS.rp2, NULL_Vector ); + } + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + if ( BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + { + org_x = CUR_Func_dualproj( CUR.zp2.org + point, NULL_Vector ); + cur_x = CUR_Func_project ( CUR.zp2.cur + point, NULL_Vector ); + + if ( ( org_a <= org_b && org_x <= org_a ) || + ( org_a > org_b && org_x >= org_a ) ) + + distance = ( cur_a - org_a ) + ( org_x - cur_x ); + + else if ( ( org_a <= org_b && org_x >= org_b ) || + ( org_a > org_b && org_x < org_b ) ) + + distance = ( cur_b - org_b ) + ( org_x - cur_x ); + + else + /* note: it seems that rounding this value isn't a good */ + /* idea (cf. width of capital 'S' in Times) */ + + distance = TT_MulDiv( cur_b - cur_a, + org_x - org_a, + org_b - org_a ) + ( cur_a - cur_x ); + + CUR_Func_move( &CUR.zp2, point, distance ); + } + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* UTP[a] : UnTouch Point */ +/* CodeRange : $29 */ +/* Stack : uint32 --> */ + + static void Ins_UTP( INS_ARG ) + { + UShort point; + Byte mask; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + mask = 0xFF; + + if ( CUR.GS.freeVector.x != 0 ) + mask &= ~TT_Flag_Touched_X; + + if ( CUR.GS.freeVector.y != 0 ) + mask &= ~TT_Flag_Touched_Y; + + CUR.zp0.touch[point] &= mask; + } + + + /* Local variables for Ins_IUP: */ + struct LOC_Ins_IUP + { + TT_Vector* orgs; /* original and current coordinate */ + TT_Vector* curs; /* arrays */ + }; + + + static void Shift( UShort p1, + UShort p2, + UShort p, + struct LOC_Ins_IUP* LINK ) + { + UShort i; + TT_F26Dot6 x; + + + x = LINK->curs[p].x - LINK->orgs[p].x; + + for ( i = p1; i < p; i++ ) + LINK->curs[i].x += x; + + for ( i = p + 1; i <= p2; i++ ) + LINK->curs[i].x += x; + } + + + static void Interp( UShort p1, + UShort p2, + UShort ref1, + UShort ref2, + struct LOC_Ins_IUP* LINK ) + { + UShort i; + TT_F26Dot6 x, x1, x2, d1, d2; + + + if ( p1 > p2 ) + return; + + x1 = LINK->orgs[ref1].x; + d1 = LINK->curs[ref1].x - LINK->orgs[ref1].x; + x2 = LINK->orgs[ref2].x; + d2 = LINK->curs[ref2].x - LINK->orgs[ref2].x; + + if ( x1 == x2 ) + { + for ( i = p1; i <= p2; i++ ) + { + x = LINK->orgs[i].x; + + if ( x <= x1 ) + x += d1; + else + x += d2; + + LINK->curs[i].x = x; + } + return; + } + + if ( x1 < x2 ) + { + for ( i = p1; i <= p2; i++ ) + { + x = LINK->orgs[i].x; + + if ( x <= x1 ) + x += d1; + else + { + if ( x >= x2 ) + x += d2; + else + x = LINK->curs[ref1].x + + TT_MulDiv( x - x1, + LINK->curs[ref2].x - LINK->curs[ref1].x, + x2 - x1 ); + } + LINK->curs[i].x = x; + } + return; + } + + /* x2 < x1 */ + + for ( i = p1; i <= p2; i++ ) + { + x = LINK->orgs[i].x; + if ( x <= x2 ) + x += d2; + else + { + if ( x >= x1 ) + x += d1; + else + x = LINK->curs[ref1].x + + TT_MulDiv( x - x1, + LINK->curs[ref2].x - LINK->curs[ref1].x, + x2 - x1 ); + } + LINK->curs[i].x = x; + } + } + + +/**********************************************/ +/* IUP[a] : Interpolate Untouched Points */ +/* CodeRange : $30-$31 */ +/* Stack : --> */ + + static void Ins_IUP( INS_ARG ) + { + struct LOC_Ins_IUP V; + Byte mask; + + UShort first_point; /* first point of contour */ + UShort end_point; /* end point (last+1) of contour */ + + UShort first_touched; /* first touched point in contour */ + UShort cur_touched; /* current touched point in contour */ + + UShort point; /* current point */ + Short contour; /* current contour */ + + + if ( CUR.opcode & 1 ) + { + mask = TT_Flag_Touched_X; + V.orgs = CUR.pts.org; + V.curs = CUR.pts.cur; + } + else + { + mask = TT_Flag_Touched_Y; + V.orgs = (TT_Vector*)( ((TT_F26Dot6*)CUR.pts.org) + 1 ); + V.curs = (TT_Vector*)( ((TT_F26Dot6*)CUR.pts.cur) + 1 ); + } + + contour = 0; + point = 0; + + do + { + end_point = CUR.pts.contours[contour]; + first_point = point; + + while ( point <= end_point && (CUR.pts.touch[point] & mask) == 0 ) + point++; + + if ( point <= end_point ) + { + first_touched = point; + cur_touched = point; + + point++; + + while ( point <= end_point ) + { + if ( (CUR.pts.touch[point] & mask) != 0 ) + { + if ( point > 0 ) + Interp( cur_touched + 1, + point - 1, + cur_touched, + point, + &V ); + cur_touched = point; + } + + point++; + } + + if ( cur_touched == first_touched ) + Shift( first_point, end_point, cur_touched, &V ); + else + { + Interp( cur_touched + 1, + end_point, + cur_touched, + first_touched, + &V ); + + if ( first_touched > 0 ) + Interp( first_point, + first_touched - 1, + cur_touched, + first_touched, + &V ); + } + } + contour++; + } while ( contour < CUR.pts.n_contours ); + } + + +/**********************************************/ +/* DELTAPn[] : DELTA Exceptions P1, P2, P3 */ +/* CodeRange : $5D,$71,$72 */ +/* Stack : uint32 (2 * uint32)... --> */ + + static void Ins_DELTAP( INS_ARG ) + { + ULong nump, k; + UShort A; + ULong C; + Long B; + + + nump = (ULong)args[0]; /* some points theoretically may occur more + than once, thus UShort isn't enough */ + + for ( k = 1; k <= nump; k++ ) + { + if ( CUR.args < 2 ) + { + CUR.error = TT_Err_Too_Few_Arguments; + return; + } + + CUR.args -= 2; + + A = (UShort)CUR.stack[CUR.args + 1]; + B = CUR.stack[CUR.args]; + + /* XXX : because some popular fonts contain some invalid DeltaP */ + /* instructions, we simply ignore them when the stacked */ + /* point reference is off limit, rather than returning an */ + /* error. As a delta instruction doesn't change a glyph */ + /* in great ways, this shouldn't be a problem.. */ + + if ( !BOUNDS( A, CUR.zp0.n_points ) ) + { + C = ((ULong)B & 0xF0) >> 4; + + switch ( CUR.opcode ) + { + case 0x5d: + break; + + case 0x71: + C += 16; + break; + + case 0x72: + C += 32; + break; + } + + C += CUR.GS.delta_base; + + if ( CURRENT_Ppem() == (Long)C ) + { + B = ((ULong)B & 0xF) - 8; + if ( B >= 0 ) + B++; + B = B * 64L / (1L << CUR.GS.delta_shift); + + CUR_Func_move( &CUR.zp0, A, B ); + } + } + else + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + } + + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* DELTACn[] : DELTA Exceptions C1, C2, C3 */ +/* CodeRange : $73,$74,$75 */ +/* Stack : uint32 (2 * uint32)... --> */ + + static void Ins_DELTAC( INS_ARG ) + { + ULong nump, k; + ULong A, C; + Long B; + + + nump = (ULong)args[0]; + + for ( k = 1; k <= nump; k++ ) + { + if ( CUR.args < 2 ) + { + CUR.error = TT_Err_Too_Few_Arguments; + return; + } + + CUR.args -= 2; + + A = (ULong)CUR.stack[CUR.args + 1]; + B = CUR.stack[CUR.args]; + + if ( BOUNDS( A, CUR.cvtSize ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + { + C = ((ULong)B & 0xF0) >> 4; + + switch ( CUR.opcode ) + { + case 0x73: + break; + + case 0x74: + C += 16; + break; + + case 0x75: + C += 32; + break; + } + + C += CUR.GS.delta_base; + + if ( CURRENT_Ppem() == (Long)C ) + { + B = ((ULong)B & 0xF) - 8; + if ( B >= 0 ) + B++; + B = B * 64L / (1L << CUR.GS.delta_shift); + + CUR_Func_move_cvt( A, B ); + } + } + } + + CUR.new_top = CUR.args; + } + + + +/****************************************************************/ +/* */ +/* MISC. INSTRUCTIONS */ +/* */ +/****************************************************************/ + + +/**********************************************/ +/* GETINFO[] : GET INFOrmation */ +/* CodeRange : $88 */ +/* Stack : uint32 --> uint32 */ + +/* XXX According to Apple specs, bits 1 & 2 of the argument ought to be */ +/* consulted before rotated / stretched info is returned */ + + static void Ins_GETINFO( INS_ARG ) + { + Long K; + + + K = 0; + + /* We return then Windows 3.1 version number */ + /* for the font scaler */ + if ( (args[0] & 1) != 0 ) + K = 3; + + /* Has the glyph been rotated ? */ + if ( CUR.metrics.rotated ) + K |= 0x80; + + /* Has the glyph been stretched ? */ + if ( CUR.metrics.stretched ) + K |= 0x100; + + args[0] = K; + } + + + static void Ins_UNKNOWN( INS_ARG ) + { + /* look up the current instruction in our table */ + PDefRecord def, limit; + + def = CUR.IDefs; + limit = def + CUR.numIDefs; + for ( ; def < limit; def++ ) + { + if ( def->Opc == CUR.opcode && def->Active ) + { + PCallRecord pCrec; + + /* implement instruction as a function call */ + + /* check call stack */ + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + pCrec = CUR.callStack + CUR.callTop; + + pCrec->Caller_Range = CUR.curRange; + pCrec->Caller_IP = CUR.IP + 1; + pCrec->Cur_Count = 1; + pCrec->Cur_Restart = def->Start; + + CUR.callTop++; + + INS_Goto_CodeRange( def->Range, + def->Start ); + + CUR.step_ins = FALSE; + return; + } + } + + CUR.error = TT_Err_Invalid_Opcode; + } + + +#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH + static TInstruction_Function Instruct_Dispatch[256] = + { + /* Opcodes are gathered in groups of 16. */ + /* Please keep the spaces as they are. */ + + /* SVTCA y */ Ins_SVTCA, + /* SVTCA x */ Ins_SVTCA, + /* SPvTCA y */ Ins_SPVTCA, + /* SPvTCA x */ Ins_SPVTCA, + /* SFvTCA y */ Ins_SFVTCA, + /* SFvTCA x */ Ins_SFVTCA, + /* SPvTL // */ Ins_SPVTL, + /* SPvTL + */ Ins_SPVTL, + /* SFvTL // */ Ins_SFVTL, + /* SFvTL + */ Ins_SFVTL, + /* SPvFS */ Ins_SPVFS, + /* SFvFS */ Ins_SFVFS, + /* GPV */ Ins_GPV, + /* GFV */ Ins_GFV, + /* SFvTPv */ Ins_SFVTPV, + /* ISECT */ Ins_ISECT, + + /* SRP0 */ Ins_SRP0, + /* SRP1 */ Ins_SRP1, + /* SRP2 */ Ins_SRP2, + /* SZP0 */ Ins_SZP0, + /* SZP1 */ Ins_SZP1, + /* SZP2 */ Ins_SZP2, + /* SZPS */ Ins_SZPS, + /* SLOOP */ Ins_SLOOP, + /* RTG */ Ins_RTG, + /* RTHG */ Ins_RTHG, + /* SMD */ Ins_SMD, + /* ELSE */ Ins_ELSE, + /* JMPR */ Ins_JMPR, + /* SCvTCi */ Ins_SCVTCI, + /* SSwCi */ Ins_SSWCI, + /* SSW */ Ins_SSW, + + /* DUP */ Ins_DUP, + /* POP */ Ins_POP, + /* CLEAR */ Ins_CLEAR, + /* SWAP */ Ins_SWAP, + /* DEPTH */ Ins_DEPTH, + /* CINDEX */ Ins_CINDEX, + /* MINDEX */ Ins_MINDEX, + /* AlignPTS */ Ins_ALIGNPTS, + /* INS_$28 */ Ins_UNKNOWN, + /* UTP */ Ins_UTP, + /* LOOPCALL */ Ins_LOOPCALL, + /* CALL */ Ins_CALL, + /* FDEF */ Ins_FDEF, + /* ENDF */ Ins_ENDF, + /* MDAP[0] */ Ins_MDAP, + /* MDAP[1] */ Ins_MDAP, + + /* IUP[0] */ Ins_IUP, + /* IUP[1] */ Ins_IUP, + /* SHP[0] */ Ins_SHP, + /* SHP[1] */ Ins_SHP, + /* SHC[0] */ Ins_SHC, + /* SHC[1] */ Ins_SHC, + /* SHZ[0] */ Ins_SHZ, + /* SHZ[1] */ Ins_SHZ, + /* SHPIX */ Ins_SHPIX, + /* IP */ Ins_IP, + /* MSIRP[0] */ Ins_MSIRP, + /* MSIRP[1] */ Ins_MSIRP, + /* AlignRP */ Ins_ALIGNRP, + /* RTDG */ Ins_RTDG, + /* MIAP[0] */ Ins_MIAP, + /* MIAP[1] */ Ins_MIAP, + + /* NPushB */ Ins_NPUSHB, + /* NPushW */ Ins_NPUSHW, + /* WS */ Ins_WS, + /* RS */ Ins_RS, + /* WCvtP */ Ins_WCVTP, + /* RCvt */ Ins_RCVT, + /* GC[0] */ Ins_GC, + /* GC[1] */ Ins_GC, + /* SCFS */ Ins_SCFS, + /* MD[0] */ Ins_MD, + /* MD[1] */ Ins_MD, + /* MPPEM */ Ins_MPPEM, + /* MPS */ Ins_MPS, + /* FlipON */ Ins_FLIPON, + /* FlipOFF */ Ins_FLIPOFF, + /* DEBUG */ Ins_DEBUG, + + /* LT */ Ins_LT, + /* LTEQ */ Ins_LTEQ, + /* GT */ Ins_GT, + /* GTEQ */ Ins_GTEQ, + /* EQ */ Ins_EQ, + /* NEQ */ Ins_NEQ, + /* ODD */ Ins_ODD, + /* EVEN */ Ins_EVEN, + /* IF */ Ins_IF, + /* EIF */ Ins_EIF, + /* AND */ Ins_AND, + /* OR */ Ins_OR, + /* NOT */ Ins_NOT, + /* DeltaP1 */ Ins_DELTAP, + /* SDB */ Ins_SDB, + /* SDS */ Ins_SDS, + + /* ADD */ Ins_ADD, + /* SUB */ Ins_SUB, + /* DIV */ Ins_DIV, + /* MUL */ Ins_MUL, + /* ABS */ Ins_ABS, + /* NEG */ Ins_NEG, + /* FLOOR */ Ins_FLOOR, + /* CEILING */ Ins_CEILING, + /* ROUND[0] */ Ins_ROUND, + /* ROUND[1] */ Ins_ROUND, + /* ROUND[2] */ Ins_ROUND, + /* ROUND[3] */ Ins_ROUND, + /* NROUND[0] */ Ins_NROUND, + /* NROUND[1] */ Ins_NROUND, + /* NROUND[2] */ Ins_NROUND, + /* NROUND[3] */ Ins_NROUND, + + /* WCvtF */ Ins_WCVTF, + /* DeltaP2 */ Ins_DELTAP, + /* DeltaP3 */ Ins_DELTAP, + /* DeltaCn[0] */ Ins_DELTAC, + /* DeltaCn[1] */ Ins_DELTAC, + /* DeltaCn[2] */ Ins_DELTAC, + /* SROUND */ Ins_SROUND, + /* S45Round */ Ins_S45ROUND, + /* JROT */ Ins_JROT, + /* JROF */ Ins_JROF, + /* ROFF */ Ins_ROFF, + /* INS_$7B */ Ins_UNKNOWN, + /* RUTG */ Ins_RUTG, + /* RDTG */ Ins_RDTG, + /* SANGW */ Ins_SANGW, + /* AA */ Ins_AA, + + /* FlipPT */ Ins_FLIPPT, + /* FlipRgON */ Ins_FLIPRGON, + /* FlipRgOFF */ Ins_FLIPRGOFF, + /* INS_$83 */ Ins_UNKNOWN, + /* INS_$84 */ Ins_UNKNOWN, + /* ScanCTRL */ Ins_SCANCTRL, + /* SDPVTL[0] */ Ins_SDPVTL, + /* SDPVTL[1] */ Ins_SDPVTL, + /* GetINFO */ Ins_GETINFO, + /* IDEF */ Ins_IDEF, + /* ROLL */ Ins_ROLL, + /* MAX */ Ins_MAX, + /* MIN */ Ins_MIN, + /* ScanTYPE */ Ins_SCANTYPE, + /* InstCTRL */ Ins_INSTCTRL, + /* INS_$8F */ Ins_UNKNOWN, + + /* INS_$90 */ Ins_UNKNOWN, + /* INS_$91 */ Ins_UNKNOWN, + /* INS_$92 */ Ins_UNKNOWN, + /* INS_$93 */ Ins_UNKNOWN, + /* INS_$94 */ Ins_UNKNOWN, + /* INS_$95 */ Ins_UNKNOWN, + /* INS_$96 */ Ins_UNKNOWN, + /* INS_$97 */ Ins_UNKNOWN, + /* INS_$98 */ Ins_UNKNOWN, + /* INS_$99 */ Ins_UNKNOWN, + /* INS_$9A */ Ins_UNKNOWN, + /* INS_$9B */ Ins_UNKNOWN, + /* INS_$9C */ Ins_UNKNOWN, + /* INS_$9D */ Ins_UNKNOWN, + /* INS_$9E */ Ins_UNKNOWN, + /* INS_$9F */ Ins_UNKNOWN, + + /* INS_$A0 */ Ins_UNKNOWN, + /* INS_$A1 */ Ins_UNKNOWN, + /* INS_$A2 */ Ins_UNKNOWN, + /* INS_$A3 */ Ins_UNKNOWN, + /* INS_$A4 */ Ins_UNKNOWN, + /* INS_$A5 */ Ins_UNKNOWN, + /* INS_$A6 */ Ins_UNKNOWN, + /* INS_$A7 */ Ins_UNKNOWN, + /* INS_$A8 */ Ins_UNKNOWN, + /* INS_$A9 */ Ins_UNKNOWN, + /* INS_$AA */ Ins_UNKNOWN, + /* INS_$AB */ Ins_UNKNOWN, + /* INS_$AC */ Ins_UNKNOWN, + /* INS_$AD */ Ins_UNKNOWN, + /* INS_$AE */ Ins_UNKNOWN, + /* INS_$AF */ Ins_UNKNOWN, + + /* PushB[0] */ Ins_PUSHB, + /* PushB[1] */ Ins_PUSHB, + /* PushB[2] */ Ins_PUSHB, + /* PushB[3] */ Ins_PUSHB, + /* PushB[4] */ Ins_PUSHB, + /* PushB[5] */ Ins_PUSHB, + /* PushB[6] */ Ins_PUSHB, + /* PushB[7] */ Ins_PUSHB, + /* PushW[0] */ Ins_PUSHW, + /* PushW[1] */ Ins_PUSHW, + /* PushW[2] */ Ins_PUSHW, + /* PushW[3] */ Ins_PUSHW, + /* PushW[4] */ Ins_PUSHW, + /* PushW[5] */ Ins_PUSHW, + /* PushW[6] */ Ins_PUSHW, + /* PushW[7] */ Ins_PUSHW, + + /* MDRP[00] */ Ins_MDRP, + /* MDRP[01] */ Ins_MDRP, + /* MDRP[02] */ Ins_MDRP, + /* MDRP[03] */ Ins_MDRP, + /* MDRP[04] */ Ins_MDRP, + /* MDRP[05] */ Ins_MDRP, + /* MDRP[06] */ Ins_MDRP, + /* MDRP[07] */ Ins_MDRP, + /* MDRP[08] */ Ins_MDRP, + /* MDRP[09] */ Ins_MDRP, + /* MDRP[10] */ Ins_MDRP, + /* MDRP[11] */ Ins_MDRP, + /* MDRP[12] */ Ins_MDRP, + /* MDRP[13] */ Ins_MDRP, + /* MDRP[14] */ Ins_MDRP, + /* MDRP[15] */ Ins_MDRP, + + /* MDRP[16] */ Ins_MDRP, + /* MDRP[17] */ Ins_MDRP, + /* MDRP[18] */ Ins_MDRP, + /* MDRP[19] */ Ins_MDRP, + /* MDRP[20] */ Ins_MDRP, + /* MDRP[21] */ Ins_MDRP, + /* MDRP[22] */ Ins_MDRP, + /* MDRP[23] */ Ins_MDRP, + /* MDRP[24] */ Ins_MDRP, + /* MDRP[25] */ Ins_MDRP, + /* MDRP[26] */ Ins_MDRP, + /* MDRP[27] */ Ins_MDRP, + /* MDRP[28] */ Ins_MDRP, + /* MDRP[29] */ Ins_MDRP, + /* MDRP[30] */ Ins_MDRP, + /* MDRP[31] */ Ins_MDRP, + + /* MIRP[00] */ Ins_MIRP, + /* MIRP[01] */ Ins_MIRP, + /* MIRP[02] */ Ins_MIRP, + /* MIRP[03] */ Ins_MIRP, + /* MIRP[04] */ Ins_MIRP, + /* MIRP[05] */ Ins_MIRP, + /* MIRP[06] */ Ins_MIRP, + /* MIRP[07] */ Ins_MIRP, + /* MIRP[08] */ Ins_MIRP, + /* MIRP[09] */ Ins_MIRP, + /* MIRP[10] */ Ins_MIRP, + /* MIRP[11] */ Ins_MIRP, + /* MIRP[12] */ Ins_MIRP, + /* MIRP[13] */ Ins_MIRP, + /* MIRP[14] */ Ins_MIRP, + /* MIRP[15] */ Ins_MIRP, + + /* MIRP[16] */ Ins_MIRP, + /* MIRP[17] */ Ins_MIRP, + /* MIRP[18] */ Ins_MIRP, + /* MIRP[19] */ Ins_MIRP, + /* MIRP[20] */ Ins_MIRP, + /* MIRP[21] */ Ins_MIRP, + /* MIRP[22] */ Ins_MIRP, + /* MIRP[23] */ Ins_MIRP, + /* MIRP[24] */ Ins_MIRP, + /* MIRP[25] */ Ins_MIRP, + /* MIRP[26] */ Ins_MIRP, + /* MIRP[27] */ Ins_MIRP, + /* MIRP[28] */ Ins_MIRP, + /* MIRP[29] */ Ins_MIRP, + /* MIRP[30] */ Ins_MIRP, + /* MIRP[31] */ Ins_MIRP + }; +#endif + + +/****************************************************************/ +/* */ +/* RUN */ +/* */ +/* This function executes a run of opcodes. It will exit */ +/* in the following cases: */ +/* */ +/* - Errors (in which case it returns FALSE) */ +/* */ +/* - Reaching the end of the main code range (returns TRUE). */ +/* Reaching the end of a code range within a function */ +/* call is an error. */ +/* */ +/* - After executing one single opcode, if the flag */ +/* 'Instruction_Trap' is set to TRUE (returns TRUE). */ +/* */ +/* On exit whith TRUE, test IP < CodeSize to know wether it */ +/* comes from a instruction trap or a normal termination. */ +/* */ +/* */ +/* Note: The documented DEBUG opcode pops a value from */ +/* the stack. This behaviour is unsupported, here */ +/* a DEBUG opcode is always an error. */ +/* */ +/* */ +/* THIS IS THE INTERPRETER'S MAIN LOOP */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + + LOCAL_FUNC +#ifndef DEBUG_INTERPRETER + TT_Error RunIns( PExecution_Context exc ) +#else + TT_Error RunIns2( PExecution_Context exc ) +#endif + { + UShort A; + PDefRecord WITH; + PCallRecord WITH1; + + Long ins_counter = 0; /* executed instructions counter */ + +#ifdef TT_CONFIG_OPTION_STATIC_INTERPRETER + cur = *exc; +#endif + + /* set CVT functions */ + CUR.metrics.ratio = 0; + if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem ) + { + /* non-square pixels, use the stretched routines */ + CUR.func_read_cvt = Read_CVT_Stretched; + CUR.func_write_cvt = Write_CVT_Stretched; + CUR.func_move_cvt = Move_CVT_Stretched; + } + else + { + /* square pixels, use normal routines */ + CUR.func_read_cvt = Read_CVT; + CUR.func_write_cvt = Write_CVT; + CUR.func_move_cvt = Move_CVT; + } + + COMPUTE_Funcs(); + Compute_Round( EXEC_ARGS (Byte)exc->GS.round_state ); + + do + { + if ( CALC_Length() != SUCCESS ) + { + CUR.error = TT_Err_Code_Overflow; + goto LErrorLabel_; + } + + /* First, let's check for empty stack and overflow */ + + CUR.args = CUR.top - (Pop_Push_Count[CUR.opcode] >> 4); + + /* `args' is the top of the stack once arguments have been popped. */ + /* One can also interpret it as the index of the last argument. */ + + if ( CUR.args < 0 ) + { + CUR.error = TT_Err_Too_Few_Arguments; + goto LErrorLabel_; + } + + CUR.new_top = CUR.args + (Pop_Push_Count[CUR.opcode] & 15); + + /* `new_top' is the new top of the stack, after the instruction's */ + /* execution. `top' will be set to `new_top' after the 'switch' */ + /* statement. */ + + if ( CUR.new_top > CUR.stackSize ) + { + CUR.error = TT_Err_Stack_Overflow; + goto LErrorLabel_; + } + + CUR.step_ins = TRUE; + CUR.error = TT_Err_Ok; + +#ifdef TT_CONFIG_OPTION_INTERPRETER_SWITCH + { + PStorage args = CUR.stack + CUR.args; + Byte opcode = CUR.opcode; + + +#undef ARRAY_BOUND_ERROR +#define ARRAY_BOUND_ERROR goto Set_Invalid_Ref + + switch ( opcode ) + { + case 0x00: /* SVTCA y */ + case 0x01: /* SVTCA x */ + case 0x02: /* SPvTCA y */ + case 0x03: /* SPvTCA x */ + case 0x04: /* SFvTCA y */ + case 0x05: /* SFvTCA x */ + { + Short AA, BB; + + + AA = (Short)(opcode & 1) << 14; + BB = AA ^ (Short)0x4000; + + if ( opcode < 4 ) + { + CUR.GS.projVector.x = AA; + CUR.GS.projVector.y = BB; + + CUR.GS.dualVector.x = AA; + CUR.GS.dualVector.y = BB; + } + + if ( (opcode & 2) == 0 ) + { + CUR.GS.freeVector.x = AA; + CUR.GS.freeVector.y = BB; + } + + COMPUTE_Funcs(); + } + break; + + case 0x06: /* SPvTL // */ + case 0x07: /* SPvTL + */ + DO_SPVTL + break; + + case 0x08: /* SFvTL // */ + case 0x09: /* SFvTL + */ + DO_SFVTL + break; + + case 0x0A: /* SPvFS */ + DO_SPVFS + break; + + case 0x0B: /* SFvFS */ + DO_SFVFS + break; + + case 0x0C: /* GPV */ + DO_GPV + break; + + case 0x0D: /* GFV */ + DO_GFV + break; + + case 0x0E: /* SFvTPv */ + DO_SFVTPV + break; + + case 0x0F: /* ISECT */ + Ins_ISECT( EXEC_ARGS args ); + break; + + case 0x10: /* SRP0 */ + DO_SRP0 + break; + + case 0x11: /* SRP1 */ + DO_SRP1 + break; + + case 0x12: /* SRP2 */ + DO_SRP2 + break; + + case 0x13: /* SZP0 */ + Ins_SZP0( EXEC_ARGS args ); + break; + + case 0x14: /* SZP1 */ + Ins_SZP1( EXEC_ARGS args ); + break; + + case 0x15: /* SZP2 */ + Ins_SZP2( EXEC_ARGS args ); + break; + + case 0x16: /* SZPS */ + Ins_SZPS( EXEC_ARGS args ); + break; + + case 0x17: /* SLOOP */ + DO_SLOOP + break; + + case 0x18: /* RTG */ + DO_RTG + break; + + case 0x19: /* RTHG */ + DO_RTHG + break; + + case 0x1A: /* SMD */ + DO_SMD + break; + + case 0x1B: /* ELSE */ + Ins_ELSE( EXEC_ARGS args ); + break; + + case 0x1C: /* JMPR */ + DO_JMPR + break; + + case 0x1D: /* SCVTCI */ + DO_SCVTCI + break; + + case 0x1E: /* SSWCI */ + DO_SSWCI + break; + + case 0x1F: /* SSW */ + DO_SSW + break; + + case 0x20: /* DUP */ + DO_DUP + break; + + case 0x21: /* POP */ + /* nothing :-) !! */ + break; + + case 0x22: /* CLEAR */ + DO_CLEAR + break; + + case 0x23: /* SWAP */ + DO_SWAP + break; + + case 0x24: /* DEPTH */ + DO_DEPTH + break; + + case 0x25: /* CINDEX */ + DO_CINDEX + break; + + case 0x26: /* MINDEX */ + Ins_MINDEX( EXEC_ARGS args ); + break; + + case 0x27: /* ALIGNPTS */ + Ins_ALIGNPTS( EXEC_ARGS args ); + break; + + case 0x28: /* ???? */ + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + case 0x29: /* UTP */ + Ins_UTP( EXEC_ARGS args ); + break; + + case 0x2A: /* LOOPCALL */ + Ins_LOOPCALL( EXEC_ARGS args ); + break; + + case 0x2B: /* CALL */ + Ins_CALL( EXEC_ARGS args ); + break; + + case 0x2C: /* FDEF */ + Ins_FDEF( EXEC_ARGS args ); + break; + + case 0x2D: /* ENDF */ + Ins_ENDF( EXEC_ARGS args ); + break; + + case 0x2E: /* MDAP */ + case 0x2F: /* MDAP */ + Ins_MDAP( EXEC_ARGS args ); + break; + + + case 0x30: /* IUP */ + case 0x31: /* IUP */ + Ins_IUP( EXEC_ARGS args ); + break; + + case 0x32: /* SHP */ + case 0x33: /* SHP */ + Ins_SHP( EXEC_ARGS args ); + break; + + case 0x34: /* SHC */ + case 0x35: /* SHC */ + Ins_SHC( EXEC_ARGS args ); + break; + + case 0x36: /* SHZ */ + case 0x37: /* SHZ */ + Ins_SHZ( EXEC_ARGS args ); + break; + + case 0x38: /* SHPIX */ + Ins_SHPIX( EXEC_ARGS args ); + break; + + case 0x39: /* IP */ + Ins_IP( EXEC_ARGS args ); + break; + + case 0x3A: /* MSIRP */ + case 0x3B: /* MSIRP */ + Ins_MSIRP( EXEC_ARGS args ); + break; + + case 0x3C: /* AlignRP */ + Ins_ALIGNRP( EXEC_ARGS args ); + break; + + case 0x3D: /* RTDG */ + DO_RTDG + break; + + case 0x3E: /* MIAP */ + case 0x3F: /* MIAP */ + Ins_MIAP( EXEC_ARGS args ); + break; + + case 0x40: /* NPUSHB */ + Ins_NPUSHB( EXEC_ARGS args ); + break; + + case 0x41: /* NPUSHW */ + Ins_NPUSHW( EXEC_ARGS args ); + break; + + case 0x42: /* WS */ + DO_WS + break; + + Set_Invalid_Ref: + CUR.error = TT_Err_Invalid_Reference; + break; + + case 0x43: /* RS */ + DO_RS + break; + + case 0x44: /* WCVTP */ + DO_WCVTP + break; + + case 0x45: /* RCVT */ + DO_RCVT + break; + + case 0x46: /* GC */ + case 0x47: /* GC */ + Ins_GC( EXEC_ARGS args ); + break; + + case 0x48: /* SCFS */ + Ins_SCFS( EXEC_ARGS args ); + break; + + case 0x49: /* MD */ + case 0x4A: /* MD */ + Ins_MD( EXEC_ARGS args ); + break; + + case 0x4B: /* MPPEM */ + DO_MPPEM + break; + + case 0x4C: /* MPS */ + DO_MPS + break; + + case 0x4D: /* FLIPON */ + DO_FLIPON + break; + + case 0x4E: /* FLIPOFF */ + DO_FLIPOFF + break; + + case 0x4F: /* DEBUG */ + DO_DEBUG + break; + + case 0x50: /* LT */ + DO_LT + break; + + case 0x51: /* LTEQ */ + DO_LTEQ + break; + + case 0x52: /* GT */ + DO_GT + break; + + case 0x53: /* GTEQ */ + DO_GTEQ + break; + + case 0x54: /* EQ */ + DO_EQ + break; + + case 0x55: /* NEQ */ + DO_NEQ + break; + + case 0x56: /* ODD */ + DO_ODD + break; + + case 0x57: /* EVEN */ + DO_EVEN + break; + + case 0x58: /* IF */ + Ins_IF( EXEC_ARGS args ); + break; + + case 0x59: /* EIF */ + /* do nothing */ + break; + + case 0x5A: /* AND */ + DO_AND + break; + + case 0x5B: /* OR */ + DO_OR + break; + + case 0x5C: /* NOT */ + DO_NOT + break; + + case 0x5D: /* DELTAP1 */ + Ins_DELTAP( EXEC_ARGS args ); + break; + + case 0x5E: /* SDB */ + DO_SDB + break; + + case 0x5F: /* SDS */ + DO_SDS + break; + + case 0x60: /* ADD */ + DO_ADD + break; + + case 0x61: /* SUB */ + DO_SUB + break; + + case 0x62: /* DIV */ + DO_DIV + break; + + case 0x63: /* MUL */ + DO_MUL + break; + + case 0x64: /* ABS */ + DO_ABS + break; + + case 0x65: /* NEG */ + DO_NEG + break; + + case 0x66: /* FLOOR */ + DO_FLOOR + break; + + case 0x67: /* CEILING */ + DO_CEILING + break; + + case 0x68: /* ROUND */ + case 0x69: /* ROUND */ + case 0x6A: /* ROUND */ + case 0x6B: /* ROUND */ + DO_ROUND + break; + + case 0x6C: /* NROUND */ + case 0x6D: /* NROUND */ + case 0x6E: /* NRRUND */ + case 0x6F: /* NROUND */ + DO_NROUND + break; + + case 0x70: /* WCVTF */ + DO_WCVTF + break; + + case 0x71: /* DELTAP2 */ + case 0x72: /* DELTAP3 */ + Ins_DELTAP( EXEC_ARGS args ); + break; + + case 0x73: /* DELTAC0 */ + case 0x74: /* DELTAC1 */ + case 0x75: /* DELTAC2 */ + Ins_DELTAC( EXEC_ARGS args ); + break; + + case 0x76: /* SROUND */ + DO_SROUND + break; + + case 0x77: /* S45Round */ + DO_S45ROUND + break; + + case 0x78: /* JROT */ + DO_JROT + break; + + case 0x79: /* JROF */ + DO_JROF + break; + + case 0x7A: /* ROFF */ + DO_ROFF + break; + + case 0x7B: /* ???? */ + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + case 0x7C: /* RUTG */ + DO_RUTG + break; + + case 0x7D: /* RDTG */ + DO_RDTG + break; + + case 0x7E: /* SANGW */ + case 0x7F: /* AA */ + /* nothing - obsolete */ + break; + + case 0x80: /* FLIPPT */ + Ins_FLIPPT( EXEC_ARGS args ); + break; + + case 0x81: /* FLIPRGON */ + Ins_FLIPRGON( EXEC_ARGS args ); + break; + + case 0x82: /* FLIPRGOFF */ + Ins_FLIPRGOFF( EXEC_ARGS args ); + break; + + case 0x83: /* UNKNOWN */ + case 0x84: /* UNKNOWN */ + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + case 0x85: /* SCANCTRL */ + Ins_SCANCTRL( EXEC_ARGS args ); + break; + + case 0x86: /* SDPVTL */ + case 0x87: /* SDPVTL */ + Ins_SDPVTL( EXEC_ARGS args ); + break; + + case 0x88: /* GETINFO */ + Ins_GETINFO( EXEC_ARGS args ); + break; + + case 0x89: /* IDEF */ + Ins_IDEF( EXEC_ARGS args ); + break; + + case 0x8A: /* ROLL */ + Ins_ROLL( EXEC_ARGS args ); + break; + + case 0x8B: /* MAX */ + DO_MAX + break; + + case 0x8C: /* MIN */ + DO_MIN + break; + + case 0x8D: /* SCANTYPE */ + Ins_SCANTYPE( EXEC_ARGS args ); + break; + + case 0x8E: /* INSTCTRL */ + Ins_INSTCTRL( EXEC_ARGS args ); + break; + + case 0x8F: + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + default: + if ( opcode >= 0xE0 ) + Ins_MIRP( EXEC_ARGS args ); + else if ( opcode >= 0xC0 ) + Ins_MDRP( EXEC_ARGS args ); + else if ( opcode >= 0xB8 ) + Ins_PUSHW( EXEC_ARGS args ); + else if ( opcode >= 0xB0 ) + Ins_PUSHB( EXEC_ARGS args ); + else + Ins_UNKNOWN( EXEC_ARGS args ); + } + + } +#else + Instruct_Dispatch[CUR.opcode]( EXEC_ARGS &CUR.stack[CUR.args] ); +#endif + if ( CUR.error != TT_Err_Ok ) + { + switch ( (Int)(CUR.error) ) + { + case TT_Err_Invalid_Opcode: /* looking for redefined instructions */ + A = 0; + + while ( A < CUR.numIDefs ) + { + WITH = &CUR.IDefs[A]; + + if ( WITH->Active && CUR.opcode == WITH->Opc ) + { + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Invalid_Reference; + goto LErrorLabel_; + } + + WITH1 = &CUR.callStack[CUR.callTop]; + + WITH1->Caller_Range = CUR.curRange; + WITH1->Caller_IP = CUR.IP + 1; + WITH1->Cur_Count = 1; + WITH1->Cur_Restart = WITH->Start; + + if ( INS_Goto_CodeRange( WITH->Range, WITH->Start ) == FAILURE ) + goto LErrorLabel_; + + goto LSuiteLabel_; + } + else + { + A++; + continue; + } + } + + CUR.error = TT_Err_Invalid_Opcode; + goto LErrorLabel_; +/* break; Unreachable code warning suppress. Leave in case a later + change to remind the editor to consider break; */ + + default: + goto LErrorLabel_; +/* break; */ + } + } + + CUR.top = CUR.new_top; + + if ( CUR.step_ins ) + CUR.IP += CUR.length; + + /* increment instruction counter and check if we didn't */ + /* run this program for too long ?? (e.g. infinite loops) */ + if ( ++ins_counter > MAX_RUNNABLE_OPCODES ) + { + CUR.error = TT_Err_Execution_Too_Long; + goto LErrorLabel_; + } + + LSuiteLabel_: + + if ( CUR.IP >= CUR.codeSize ) + { + if ( CUR.callTop > 0 ) + { + CUR.error = TT_Err_Code_Overflow; + goto LErrorLabel_; + } + else + goto LNo_Error_; + } + } while ( !CUR.instruction_trap ); + + LNo_Error_: + CUR.error = TT_Err_Ok; + + LErrorLabel_: + +#ifdef TT_CONFIG_OPTION_STATIC_INTERPRETER + *exc = cur; +#endif + + return CUR.error; + + + } + + +#ifdef DEBUG_INTERPRETER + + /* This function must be declared by the debugger front end */ + /* in order to specify which code range to debug. */ + + int debug_coderange = TT_CodeRange_Glyph; + + + LOCAL_FUNC + TT_Error RunIns( PExecution_Context exc ) + { + Int A, diff; + ULong next_IP; + Char ch, oldch; + char *temp; + int key; + + TT_Error error = 0; + + TGlyph_Zone save; + TGlyph_Zone pts; + +#define TT_Round_Off 5 +#define TT_Round_To_Half_Grid 0 +#define TT_Round_To_Grid 1 +#define TT_Round_To_Double_Grid 2 +#define TT_Round_Up_To_Grid 4 +#define TT_Round_Down_To_Grid 3 +#define TT_Round_Super 6 +#define TT_Round_Super_45 7 + + const String* round_str[8] = + { + "to half-grid", + "to grid", + "to double grid", + "down to grid", + "up to grid", + "off", + "super", + "super 45" + }; + + /* Check that we're running the code range that is effectively */ + /* asked by the debugger front end. */ + if ( exc->curRange != debug_coderange ) + return RunIns2( exc ); + + pts = exc->pts; + + save.n_points = pts.n_points; + save.n_contours = pts.n_contours; + + MEM_Alloc( save.org, sizeof ( TT_Vector ) * save.n_points ); + MEM_Alloc( save.cur, sizeof ( TT_Vector ) * save.n_points ); + MEM_Alloc( save.touch, sizeof ( Byte ) * save.n_points ); + + exc->instruction_trap = 1; + + oldch = '\0'; + + do + { + if ( exc->IP < exc->codeSize ) + { +#ifdef TT_CONFIG_OPTION_STATIC_INTERPRETER + cur = *exc; +#endif + CALC_Length(); + + exc->args = exc->top - (Pop_Push_Count[exc->opcode] >> 4); + + /* `args' is the top of the stack once arguments have been popped. */ + /* One can also interpret it as the index of the last argument. */ + + /* Print the current line. We use a 80-columns console with the */ + /* following formatting: */ + /* */ + /* [loc]:[addr] [opcode] [disassemby] [a][b]|[c][d] */ + /* */ + + { + char temp[80]; + int n, col, pop; + int args = CUR.args; + + + sprintf( temp, "%78c\n", ' ' ); + + /* first letter of location */ + switch ( CUR.curRange ) + { + case TT_CodeRange_Glyph: + temp[0] = 'g'; + break; + case TT_CodeRange_Cvt: + temp[0] = 'c'; + break; + default: + temp[0] = 'f'; + } + + /* current IP */ + sprintf( temp+1, "%04lx: %02x %-36.36s", + CUR.IP, + CUR.opcode, + Cur_U_Line(&CUR) ); + + strncpy( temp+46, " (", 2 ); + + args = CUR.top - 1; + pop = Pop_Push_Count[CUR.opcode] >> 4; + col = 48; + for ( n = 6; n > 0; n-- ) + { + if ( pop == 0 ) + temp[col-1] = (temp[col-1] == '(' ? ' ' : ')' ); + + if ( args < CUR.top && args >= 0 ) + sprintf( temp+col, "%04lx", CUR.stack[args] ); + else + sprintf( temp+col, " " ); + + temp[col+4] = ' '; + col += 5; + pop--; + args--; + } + temp[78] = '\n'; + temp[79] = '\0'; + PTRACE0(( temp )); + } + + /* First, check for empty stack and overflow */ + if ( CUR.args < 0 ) + { + PTRACE0(( "ERROR : Too few arguments\n" )); + exc->error = TT_Err_Too_Few_Arguments; + goto LErrorLabel_; + } + + CUR.new_top = CUR.args + (Pop_Push_Count[CUR.opcode] & 15); + + /* new_top is the new top of the stack, after the instruction's */ + /* execution. top will be set to new_top after the 'case' */ + + if ( CUR.new_top > CUR.stackSize ) + { + PTRACE0(( "ERROR : Stack overflow\n" )); + exc->error = TT_Err_Stack_Overflow; + goto LErrorLabel_; + } + } + else + PTRACE0(( "End of program reached.\n" )); + + key = 0; + do + { + /* read keyboard */ + + ch = getch(); + + switch ( ch ) + { + /* Help - show keybindings */ + case '?': + PTRACE0(( "FDebug Help\n\n" )); + PTRACE0(( "? Show this page\n" )); + PTRACE0(( "q Quit debugger\n" )); + PTRACE0(( "n Skip to next instruction\n" )); + PTRACE0(( "s Step into\n" )); + PTRACE0(( "v Show vector info\n" )); + PTRACE0(( "g Show graphics state\n" )); + PTRACE0(( "p Show points zone\n\n" )); + break; + + /* Show vectors */ + case 'v': + PTRACE0(( "freedom (%04hx,%04hx)\n", exc->GS.freeVector.x, + exc->GS.freeVector.y )); + PTRACE0(( "projection (%04hx,%04hx)\n", exc->GS.projVector.x, + exc->GS.projVector.y )); + PTRACE0(( "dual (%04hx,%04hx)\n\n", exc->GS.dualVector.x, + exc->GS.dualVector.y )); + break; + + /* Show graphics state */ + case 'g': + PTRACE0(( "rounding %s\n", round_str[exc->GS.round_state] )); + PTRACE0(( "min dist %04lx\n", exc->GS.minimum_distance )); + PTRACE0(( "cvt_cutin %04lx\n", exc->GS.control_value_cutin )); + break; + + /* Show points table */ + case 'p': + for ( A = 0; A < exc->pts.n_points; A++ ) + { + PTRACE0(( "%02hx ", A )); + PTRACE0(( "%08lx,%08lx - ", pts.org[A].x, pts.org[A].y )); + PTRACE0(( "%08lx,%08lx\n", pts.cur[A].x, pts.cur[A].y )); + } + PTRACE0(( "\n" )); + break; + + default: + key = 1; + } + } while ( !key ); + + MEM_Copy( save.org, pts.org, pts.n_points * sizeof ( TT_Vector ) ); + MEM_Copy( save.cur, pts.cur, pts.n_points * sizeof ( TT_Vector ) ); + MEM_Copy( save.touch, pts.touch, pts.n_points ); + + /* a return indicate the last command */ + if (ch == '\r') + ch = oldch; + + switch ( ch ) + { + /* Quit debugger */ + case 'q': + goto LErrorLabel_; + + /* Step over */ + case 'n': + if ( exc->IP < exc->codeSize ) + { + /* `step over' is equivalent to `step into' except if */ + /* the current opcode is a CALL or LOOPCALL */ + if ( CUR.opcode != 0x2a && CUR.opcode != 0x2b ) + goto Step_into; + + /* otherwise, loop execution until we reach the next opcode */ + next_IP = CUR.IP + CUR.length; + while ( exc->IP != next_IP ) + { + if ( ( error = RunIns2( exc ) ) ) + goto LErrorLabel_; + } + } + oldch = ch; + break; + + /* Step into */ + case 's': + if ( exc->IP < exc->codeSize ) + + Step_into: + if ( ( error = RunIns2( exc ) ) ) + goto LErrorLabel_; + oldch = ch; + break; + + default: + PTRACE0(( "unknown command. Press ? for help\n" )); + oldch = '\0'; + } + + for ( A = 0; A < pts.n_points; A++ ) + { + diff = 0; + if ( save.org[A].x != pts.org[A].x ) diff |= 1; + if ( save.org[A].y != pts.org[A].y ) diff |= 2; + if ( save.cur[A].x != pts.cur[A].x ) diff |= 4; + if ( save.cur[A].y != pts.cur[A].y ) diff |= 8; + if ( save.touch[A] != pts.touch[A] ) diff |= 16; + + if ( diff ) + { + PTRACE0(( "%02hx ", A )); + + if ( diff & 16 ) temp = "(%01hx)"; else temp = " %01hx "; + PTRACE0(( temp, save.touch[A] & 7 )); + + if ( diff & 1 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.org[A].x )); + + if ( diff & 2 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.org[A].y )); + + if ( diff & 4 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.cur[A].x )); + + if ( diff & 8 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.cur[A].y )); + + PTRACE0(( "\n" )); + + PTRACE0(( "%02hx ", A )); + + if ( diff & 16 ) temp = "[%01hx]"; else temp = " %01hx "; + PTRACE0(( temp, pts.touch[A] & 7 )); + + if ( diff & 1 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.org[A].x )); + + if ( diff & 2 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.org[A].y )); + + if ( diff & 4 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.cur[A].x )); + + if ( diff & 8 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.cur[A].y )); + + PTRACE0(( "\n\n" )); + } + } + } while ( TRUE ); + + LErrorLabel_: + + return error; + } + +#endif /* DEBUG_INTERPRETER */ + + +#endif /* TT_CONFIG_OPTION_NO_INTERPRETER */ + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.h new file mode 100644 index 000000000..0bc3836f3 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.h @@ -0,0 +1,54 @@ +/******************************************************************* + * + * ttinterp.h 2.2 + * + * TrueType bytecode intepreter. + * + * 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. + * + * + * Changes between 2.2 and 2.1: + * + * - a small bugfix in the Push opcodes + * + * Changes between 2.1 and 2.0: + * + * - created the TTExec component to take care of all execution + * context management. The interpreter has now one single + * function. + * + * - made some changes to support re-entrancy. The re-entrant + * interpreter is smaller! + * + ******************************************************************/ + +#ifndef TTINTERP_H +#define TTINTERP_H + +#include "ttconfig.h" +#include "ttobjs.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* Run instructions in current execution context */ + + LOCAL_DEF TT_Error RunIns( PExecution_Context exc ); + +#ifdef __cplusplus + } +#endif + +#endif /* TTINTERP_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c new file mode 100644 index 000000000..981386995 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c @@ -0,0 +1,1574 @@ + +/******************************************************************* + * + * ttload.c 1.0 + * + * TrueType Tables Loader. + * + * 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 "tttypes.h" +#include "ttdebug.h" +#include "ttcalc.h" +#include "ttfile.h" + +#include "tttables.h" +#include "ttobjs.h" + +#include "ttmemory.h" +#include "tttags.h" +#include "ttload.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_load + +/* In all functions, the stream is taken from the 'face' object */ +#define DEFINE_LOCALS DEFINE_LOAD_LOCALS( face->stream ) +#define DEFINE_LOCALS_WO_FRAME DEFINE_LOAD_LOCALS_WO_FRAME( face->stream ) + + +/******************************************************************* + * + * Function : LookUp_TrueType_Table + * + * Description : Looks for a TrueType table by name. + * + * Input : face face table to look for + * tag searched tag + * + * Output : Index of table if found, -1 otherwise. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_LookUp_Table( PFace face, + ULong tag ) + { + UShort i; + + + PTRACE4(( "TT_LookUp_Table( %08lx, %c%c%c%c )\n", + (Long)face, + (Char)(tag >> 24), + (Char)(tag >> 16), + (Char)(tag >> 8), + (Char)(tag) )); + + for ( i = 0; i < face->numTables; i++ ) + if ( face->dirTables[i].Tag == tag ) + return i; + + PTRACE4(( " Could not find table!\n" )); + return -1; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Collection + * + * Description : Loads the TTC table directory into face table. + * + * Input : face face record to look for + * + * Output : Error code. + * + ******************************************************************/ + + static TT_Error Load_TrueType_Collection( PFace face ) + { + DEFINE_LOCALS; + + ULong n; + + + PTRACE3(( "Load_TrueType_Collection( %08lx )\n", (long)face )); + + if ( FILE_Seek ( 0L ) || + ACCESS_Frame( 12L ) ) + return error; + + face->ttcHeader.Tag = GET_Tag4(); + face->ttcHeader.version = GET_Long(); + face->ttcHeader.DirCount = GET_Long(); + + FORGET_Frame(); + + if ( face->ttcHeader.Tag != TTAG_ttcf ) + { + face->ttcHeader.Tag = 0; + face->ttcHeader.version = 0; + face->ttcHeader.DirCount = 0; + + face->ttcHeader.TableDirectory = NULL; + + PTRACE3(("skipped.\n")); + + return TT_Err_File_Is_Not_Collection; + } + + if ( ALLOC_ARRAY( face->ttcHeader.TableDirectory, + face->ttcHeader.DirCount, + ULong ) || + ACCESS_Frame( face->ttcHeader.DirCount * 4L ) ) + return error; + + for ( n = 0; n < face->ttcHeader.DirCount; n++ ) + face->ttcHeader.TableDirectory[n] = GET_ULong(); + + FORGET_Frame(); + + PTRACE3(( "collections directory loaded.\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Directory + * + * Description : Loads the table directory into face table. + * + * Input : face face record to look for + * + * faceIndex the index of the TrueType font, when + * we're opening a collection. + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Directory( PFace face, ULong faceIndex ) + { + DEFINE_LOCALS; + + UShort n, limit; + TTableDir tableDir; + + PTableDirEntry entry; + + + PTRACE2(("Load_TT_Directory( %08lx, %ld )\n", (long)face, faceIndex)); + + error = Load_TrueType_Collection( face ); + + if ( error ) + { + if ( error != TT_Err_File_Is_Not_Collection ) + return error; + + /* the file isn't a collection, exit if we're asking */ + /* for a collected font */ + if ( faceIndex != 0 ) + return error; + + /* Now skip to the beginning of the file */ + if ( FILE_Seek( 0L ) ) + return error; + } + else + { + /* The file is a collection. Check the font index */ + if ( faceIndex >= face->ttcHeader.DirCount ) + return TT_Err_Invalid_Argument; + + /* select a TrueType font in the ttc file */ + if ( FILE_Seek( face->ttcHeader.TableDirectory[faceIndex] ) ) + return error; + } + + if ( ACCESS_Frame( 12L ) ) + return error; + + tableDir.version = GET_Long(); + tableDir.numTables = GET_UShort(); + + tableDir.searchRange = GET_UShort(); + tableDir.entrySelector = GET_UShort(); + tableDir.rangeShift = GET_UShort(); + + FORGET_Frame(); + + PTRACE2(( "-- Tables count : %12u\n", tableDir.numTables )); + PTRACE2(( "-- Format version : %08lx\n", tableDir.version )); + + /* Check that we have a 'sfnt' format there */ + + if ( tableDir.version != 0x00010000 && /* MS fonts */ + tableDir.version != 0x74727565 && /* Mac fonts */ + tableDir.version != 0x00000000 ) /* some Korean fonts */ + { + PERROR(( "!! invalid file format" )); + return TT_Err_Invalid_File_Format; + } + + face->numTables = tableDir.numTables; + + if ( ALLOC_ARRAY( face->dirTables, + face->numTables, + TTableDirEntry ) ) + return error; + + if ( ACCESS_Frame( face->numTables * 16L ) ) + return error; + + limit = face->numTables; + entry = face->dirTables; + + for ( n = 0; n < limit; n++ ) + { /* loop through the tables and get all entries */ + entry->Tag = GET_Tag4(); + entry->CheckSum = GET_ULong(); + entry->Offset = GET_Long(); + entry->Length = GET_Long(); + + PTRACE2(( " %c%c%c%c - %08lx - %08lx\n", + (Char)(entry->Tag >> 24), + (Char)(entry->Tag >> 16), + (Char)(entry->Tag >> 8 ), + (Char)(entry->Tag), + entry->Offset, + entry->Length )); + entry++; + } + + FORGET_Frame(); + + PTRACE2(( "Directory loaded\n\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_MaxProfile + * + * Description : Loads the maxp table into face table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_MaxProfile( PFace face ) + { + DEFINE_LOCALS; + + Long i; + PMaxProfile maxProfile = &face->maxProfile; + + + PTRACE2(( "Load_TT_MaxProfile( %08lx )\n", (long)face )); + + if ( ( i = TT_LookUp_Table( face, TTAG_maxp ) ) < 0 ) + return TT_Err_Max_Profile_Missing; + + if ( FILE_Seek( face->dirTables[i].Offset ) ) /* seek to maxprofile */ + return error; + + if ( ACCESS_Frame( 32L ) ) /* read into frame */ + return error; + + /* read frame data into face table */ + maxProfile->version = GET_ULong(); + + maxProfile->numGlyphs = GET_UShort(); + + maxProfile->maxPoints = GET_UShort(); + maxProfile->maxContours = GET_UShort(); + maxProfile->maxCompositePoints = GET_UShort(); + maxProfile->maxCompositeContours = GET_UShort(); + + maxProfile->maxZones = GET_UShort(); + maxProfile->maxTwilightPoints = GET_UShort(); + + maxProfile->maxStorage = GET_UShort(); + maxProfile->maxFunctionDefs = GET_UShort(); + maxProfile->maxInstructionDefs = GET_UShort(); + maxProfile->maxStackElements = GET_UShort(); + maxProfile->maxSizeOfInstructions = GET_UShort(); + maxProfile->maxComponentElements = GET_UShort(); + maxProfile->maxComponentDepth = GET_UShort(); + + FORGET_Frame(); + + /* XXX : an adjustement that is necessary to load certain */ + /* broken fonts like "Keystrokes MT" :-( */ + /* */ + /* We allocate 64 function entries by default when */ + /* the maxFunctionDefs field is null. */ + + if (maxProfile->maxFunctionDefs == 0) + maxProfile->maxFunctionDefs = 64; + + face->numGlyphs = maxProfile->numGlyphs; + + face->maxPoints = MAX( maxProfile->maxCompositePoints, + maxProfile->maxPoints ); + face->maxContours = MAX( maxProfile->maxCompositeContours, + maxProfile->maxContours ); + face->maxComponents = maxProfile->maxComponentElements + + maxProfile->maxComponentDepth; + + /* XXX: Some fonts have maxComponents set to 0; we will */ + /* then use 16 of them by default. */ + if ( face->maxComponents == 0 ) + face->maxComponents = 16; + + /* We also increase maxPoints and maxContours in order to support */ + /* some broken fonts. */ + face->maxPoints += 8; + face->maxContours += 4; + + PTRACE2(( "GASP loaded.\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Gasp + * + * Description : Loads the TrueType Gasp table into the face + * table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Gasp( PFace face ) + { + DEFINE_LOCALS; + + Long i; + UShort j; + TGasp* gas; + GaspRange* gaspranges; + + + PTRACE2(( "Load_TT_Gasp( %08lx )\n", (long)face )); + + if ( ( i = TT_LookUp_Table( face, TTAG_gasp ) ) < 0 ) + return TT_Err_Ok; /* gasp table is not required */ + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 4L ) ) + return error; + + gas = &face->gasp; + + gas->version = GET_UShort(); + gas->numRanges = GET_UShort(); + + FORGET_Frame(); + + PTRACE3(( "number of ranges = %d\n", gas->numRanges )); + + if ( ALLOC_ARRAY( gaspranges, gas->numRanges, GaspRange ) || + ACCESS_Frame( gas->numRanges * 4L ) ) + goto Fail; + + face->gasp.gaspRanges = gaspranges; + + for ( j = 0; j < gas->numRanges; j++ ) + { + gaspranges[j].maxPPEM = GET_UShort(); + gaspranges[j].gaspFlag = GET_UShort(); + + PTRACE3(( " [max:%d flag:%d]", + gaspranges[j].maxPPEM, + gaspranges[j].gaspFlag )); + } + PTRACE3(("\n")); + + FORGET_Frame(); + + PTRACE2(( "GASP loaded\n" )); + return TT_Err_Ok; + + Fail: + FREE( gaspranges ); + gas->numRanges = 0; + return error; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Header + * + * Description : Loads the TrueType header table into the face + * table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Header( PFace face ) + { + DEFINE_LOCALS; + + Long i; + TT_Header* header; + + + PTRACE2(( "Load_TT_Header( %08lx )\n", (long)face )); + + if ( ( i = TT_LookUp_Table( face, TTAG_head ) ) < 0 ) + { + PTRACE0(( "Font Header is missing !!\n" )); + return TT_Err_Header_Table_Missing; + } + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 54L ) ) + return error; + + header = &face->fontHeader; + + header->Table_Version = GET_ULong(); + header->Font_Revision = GET_ULong(); + + header->CheckSum_Adjust = GET_Long(); + header->Magic_Number = GET_Long(); + + header->Flags = GET_UShort(); + header->Units_Per_EM = GET_UShort(); + + header->Created [0] = GET_Long(); + header->Created [1] = GET_Long(); + header->Modified[0] = GET_Long(); + header->Modified[1] = GET_Long(); + + header->xMin = GET_Short(); + header->yMin = GET_Short(); + header->xMax = GET_Short(); + header->yMax = GET_Short(); + + header->Mac_Style = GET_UShort(); + header->Lowest_Rec_PPEM = GET_UShort(); + + header->Font_Direction = GET_Short(); + header->Index_To_Loc_Format = GET_Short(); + header->Glyph_Data_Format = GET_Short(); + + FORGET_Frame(); + + PTRACE2(( " Units per EM : %8u\n", header->Units_Per_EM )); + PTRACE2(( " IndexToLoc : %8d\n", header->Index_To_Loc_Format )); + PTRACE2(( "Font Header Loaded.\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Metrics + * + * Description : Loads the horizontal or vertical metrics table + * into face object. + * + * Input : face + * vertical set to true when loading the vmtx table, + * or false for hmtx + * + * Output : Error code. + * + ******************************************************************/ + + static + TT_Error Load_TrueType_Metrics( PFace face, + Bool vertical ) + { + DEFINE_LOCALS; + + Long n, num_shorts, num_shorts_checked, num_longs; + + PLongMetrics* longs; + PShortMetrics* shorts; + + PLongMetrics long_metric; + + + PTRACE2(( "Load_TT_%s_Metrics( %08lx )\n", + vertical ? "Vertical" : "Horizontal", + (long)face )); + + if ( vertical ) + { + /* The table is optional, quit silently if it wasn't found */ + /* XXX : Some fonts have a valid vertical header with a non-null */ + /* "number_of_VMetrics" fields, but no corresponding */ + /* 'vmtx' table to get the metrics from (e.g. mingliu) */ + /* */ + /* For safety, we set the field to 0 ! */ + /* */ + n = TT_LookUp_Table( face, TTAG_vmtx ); + if ( n < 0 ) + { + /* Set the number_Of_VMetrics to 0! */ + PTRACE2(( " no vertical header in file.\n" )); + face->verticalHeader.number_Of_VMetrics = 0; + return TT_Err_Ok; + } + + num_longs = face->verticalHeader.number_Of_VMetrics; + longs = (PLongMetrics*)&face->verticalHeader.long_metrics; + shorts = (PShortMetrics*)&face->verticalHeader.short_metrics; + } + else + { + if ( ( n = TT_LookUp_Table( face, TTAG_hmtx ) ) < 0 ) + { + PERROR(( "!! No Horizontal metrics in file !!\n" )); + return TT_Err_Hmtx_Table_Missing; + } + + num_longs = face->horizontalHeader.number_Of_HMetrics; + longs = (PLongMetrics*)&face->horizontalHeader.long_metrics; + shorts = (PShortMetrics*)&face->horizontalHeader.short_metrics; + } + + /* never trust derived values! */ + + num_shorts = face->maxProfile.numGlyphs - num_longs; + num_shorts_checked = ( face->dirTables[n].Length - num_longs * 4 ) / 2; + + if ( num_shorts < 0 ) /* sanity check */ + { + PERROR(( "!! more metrics than glyphs!\n" )); + if ( vertical ) + return TT_Err_Invalid_Vert_Metrics; + else + return TT_Err_Invalid_Horiz_Metrics; + } + + if ( ALLOC_ARRAY( *longs, num_longs, TLongMetrics ) || + ALLOC_ARRAY( *shorts, num_shorts, TShortMetrics ) ) + return error; + + if ( FILE_Seek( face->dirTables[n].Offset ) || + ACCESS_Frame( face->dirTables[n].Length ) ) + return error; + + long_metric = *longs; + for ( n = 0; n < num_longs; n++ ) + { + long_metric->advance = GET_UShort(); + long_metric->bearing = GET_Short(); + long_metric++; + } + + /* do we have an inconsistent number of metric values? */ + + if ( num_shorts > num_shorts_checked ) + { + for ( n = 0; n < num_shorts_checked; n++ ) + (*shorts)[n] = GET_Short(); + + /* we fill up the missing left side bearings with the */ + /* last valid value. Since this will occur for buggy CJK */ + /* fonts usually, nothing serious will happen. */ + + for ( n = num_shorts_checked; n < num_shorts; n++ ) + (*shorts)[n] = (*shorts)[num_shorts_checked - 1]; + } + else + { + for ( n = 0; n < num_shorts; n++ ) + (*shorts)[n] = GET_Short(); + } + + FORGET_Frame(); + + PTRACE2(( "loaded\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Metrics_Header + * + * Description : Loads either the "hhea" or "vhea" table in memory + * + * Input : face face table to look for + * vertical a boolean. When set, queries the optional + * "vhea" table. Otherwise, load the mandatory + * "hhea" horizontal header. + * + * Output : Error code. + * + * Note : This function now loads the corresponding metrics table + * (either hmtx or vmtx) and attaches it to the header. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Metrics_Header( PFace face, + Bool vertical ) + { + DEFINE_LOCALS; + + Long i; + + TT_Horizontal_Header* header; + + + PTRACE2(( vertical ? "Vertical header" : "Horizontal header " )); + + if ( vertical ) + { + face->verticalInfo = 0; + + /* The vertical header table is optional, so return quietly if */ + /* we don't find it.. */ + if ( ( i = TT_LookUp_Table( face, TTAG_vhea ) ) < 0 ) + return TT_Err_Ok; + + face->verticalInfo = 1; + header = (TT_Horizontal_Header*)&face->verticalHeader; + } + else + { + /* The orizontal header is mandatory, return an error if we */ + /* don't find it. */ + if ( ( i = TT_LookUp_Table( face, TTAG_hhea ) ) < 0 ) + return TT_Err_Horiz_Header_Missing; + + header = &face->horizontalHeader; + } + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 36L ) ) + return error; + + header->Version = GET_ULong(); + header->Ascender = GET_Short(); + header->Descender = GET_Short(); + header->Line_Gap = GET_Short(); + + header->advance_Width_Max = GET_UShort(); + + header->min_Left_Side_Bearing = GET_Short(); + header->min_Right_Side_Bearing = GET_Short(); + header->xMax_Extent = GET_Short(); + header->caret_Slope_Rise = GET_Short(); + header->caret_Slope_Run = GET_Short(); + + header->Reserved0 = GET_Short(); /* this is caret_Offset for + vertical headers */ + header->Reserved1 = GET_Short(); + header->Reserved2 = GET_Short(); + header->Reserved3 = GET_Short(); + header->Reserved4 = GET_Short(); + + header->metric_Data_Format = GET_Short(); + header->number_Of_HMetrics = GET_UShort(); + + FORGET_Frame(); + + header->long_metrics = NULL; + header->short_metrics = NULL; + + PTRACE2(( "loaded\n" )); + + /* Now try to load the corresponding metrics */ + + return Load_TrueType_Metrics( face, vertical ); + } + + +/******************************************************************* + * + * Function : Load_TrueType_Locations + * + * Description : Loads the location table into face table. + * + * Input : face face table to look for + * + * Output : Error code. + * + * NOTE: + * The Font Header *must* be loaded in the leading segment + * calling this function. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Locations( PFace face ) + { + DEFINE_LOCALS; + + Long n, limit; + Short LongOffsets; + + + PTRACE2(( "Locations " )); + + LongOffsets = face->fontHeader.Index_To_Loc_Format; + + if ( ( n = TT_LookUp_Table( face, TTAG_loca ) ) < 0 ) + return TT_Err_Locations_Missing; + + if ( FILE_Seek( face->dirTables[n].Offset ) ) + return error; + + if ( LongOffsets != 0 ) + { + face->numLocations = face->dirTables[n].Length >> 2; + + PTRACE2(( "(32 bit offsets): %12lu ", + face->numLocations )); + + if ( ALLOC_ARRAY( face->glyphLocations, + face->numLocations, + Long ) ) + return error; + + if ( ACCESS_Frame( face->numLocations * 4L ) ) + return error; + + limit = face->numLocations; + + for ( n = 0; n < limit; n++ ) + face->glyphLocations[n] = GET_Long(); + + FORGET_Frame(); + } + else + { + face->numLocations = face->dirTables[n].Length >> 1; + + PTRACE2(( "(16 bit offsets): %12lu ", + face->numLocations )); + + if ( ALLOC_ARRAY( face->glyphLocations, + face->numLocations, + Long ) ) + return error; + + if ( ACCESS_Frame( face->numLocations * 2L ) ) + return error; + + limit = face->numLocations; + + for ( n = 0; n < limit; n++ ) + face->glyphLocations[n] = + (Long)((ULong)GET_UShort() * 2); + + FORGET_Frame(); + } + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Names + * + * Description : Loads the name table into face table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Names( PFace face ) + { + DEFINE_LOCALS; + + UShort i, bytes; + Long n; + PByte storage; + + TName_Table* names; + TNameRec* namerec; + + + PTRACE2(( "Names " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_name ) ) < 0 ) + { + /* The name table is required so indicate failure. */ + PTRACE2(( "is missing!\n" )); + + return TT_Err_Name_Table_Missing; + } + + /* Seek to the beginning of the table and check the frame access. */ + /* The names table has a 6 byte header. */ + if ( FILE_Seek( face->dirTables[n].Offset ) || + ACCESS_Frame( 6L ) ) + return error; + + names = &face->nameTable; + + /* Load the initial names data. */ + names->format = GET_UShort(); + names->numNameRecords = GET_UShort(); + names->storageOffset = GET_UShort(); + + FORGET_Frame(); + + /* Allocate the array of name records. */ + if ( ALLOC_ARRAY( names->names, + names->numNameRecords, + TNameRec ) || + ACCESS_Frame( names->numNameRecords * 12L ) ) + { + names->numNameRecords = 0; + goto Fail; + } + + /* Load the name records and determine how much storage is needed */ + /* to hold the strings themselves. */ + + for ( i = bytes = 0; i < names->numNameRecords; i++ ) + { + namerec = names->names + i; + namerec->platformID = GET_UShort(); + namerec->encodingID = GET_UShort(); + namerec->languageID = GET_UShort(); + namerec->nameID = GET_UShort(); + namerec->stringLength = GET_UShort(); + namerec->stringOffset = GET_UShort(); + +#if 0 + /* check the ids */ + if ( namerec->platformID <= 3 ) + { +#endif + /* this test takes care of 'holes' in the names tables, as */ + /* reported by Erwin */ + if ( (namerec->stringOffset + namerec->stringLength) > bytes ) + bytes = namerec->stringOffset + namerec->stringLength; +#if 0 + } +#endif + } + + FORGET_Frame(); + + /* Allocate storage for the strings if they exist. */ + + names->storage = NULL; + + if ( bytes > 0 ) + { + if ( ALLOC( storage, bytes ) || + FILE_Read_At( face->dirTables[n].Offset + names->storageOffset, + (void*)storage, + bytes ) ) + goto Fail_Storage; + + names->storage = storage; + + /* Go through and assign the string pointers to the name records. */ + + for ( i = 0; i < names->numNameRecords; i++ ) + { + namerec = names->names + i; + namerec->string = storage + names->names[i].stringOffset; + +/* It is possible (but rather unlikely) that a new platform ID will be */ +/* added by Apple, so we can't rule out IDs > 3. */ + +#if 0 + if ( namerec->platformID <= 3 ) + namerec->string = storage + names->names[i].stringOffset; + else + { + namerec->string = NULL; + namerec->stringLength = 0; + } +#endif + } + } + +#ifdef DEBUG_LEVEL_TRACE + + for ( i = 0; i < names->numNameRecords; i++ ) + { + int j; + + + PTRACE2(( "%d %d %x %d ", + names->names[i].platformID, + names->names[i].encodingID, + names->names[i].languageID, + names->names[i].nameID )); + + /* I know that M$ encoded strings are Unicode, */ + /* but this works reasonable well for debugging purposes. */ + for ( j = 0; j < names->names[i].stringLength; j++ ) + { + if (names->names[i].string) + { + Char c = *(names->names[i].string + j); + + + if ( (Byte)c < 128 ) + PTRACE2(( "%c", c )); + } + } + + PTRACE2(( "\n" )); + } + +#endif /* DEBUG_LEVEL_TRACE */ + + PTRACE2(( "loaded\n" )); + return TT_Err_Ok; + + Fail_Storage: + FREE( storage ); + + Fail: + Free_TrueType_Names( face ); + return error; + } + + +/******************************************************************* + * + * Function : Free_TrueType_Names + * + * Description : Frees a name table. + * + * Input : face face table to look for + * + * Output : TT_Err_Ok. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Free_TrueType_Names( PFace face ) + { + TName_Table* names = &face->nameTable; + + + /* free strings table */ + FREE( names->names ); + + /* free strings storage */ + FREE( names->storage ); + + names->numNameRecords = 0; + names->format = 0; + names->storageOffset = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_CVT + * + * Description : Loads cvt table into resident table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_CVT( PFace face ) + { + DEFINE_LOCALS; + + Long n, limit; + + + PTRACE2(( "CVT " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_cvt ) ) < 0 ) + { + PTRACE2(( "is missing!\n" )); + + face->cvtSize = 0; + face->cvt = NULL; + return TT_Err_Ok; + } + + face->cvtSize = face->dirTables[n].Length / 2; + + if ( ALLOC_ARRAY( face->cvt, + face->cvtSize, + Short ) ) + return error; + + if ( FILE_Seek( face->dirTables[n].Offset ) || + ACCESS_Frame( face->cvtSize * 2L ) ) + return error; + + limit = face->cvtSize; + + for ( n = 0; n < limit; n++ ) + face->cvt[n] = GET_Short(); + + FORGET_Frame(); + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_CMap + * + * Description : Loads the cmap directory in memory. + * The cmaps themselves are loaded in ttcmap.c . + * + * Input : face + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_CMap( PFace face ) + { + DEFINE_LOCALS; + + Long off, table_start; + Long n, limit; + + TCMapDir cmap_dir; + TCMapDirEntry entry_; + PCMapTable cmap; + + + PTRACE2(( "CMaps " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_cmap ) ) < 0 ) + return TT_Err_CMap_Table_Missing; + + table_start = face->dirTables[n].Offset; + + if ( ( FILE_Seek( table_start ) ) || + ( ACCESS_Frame( 4L ) ) ) /* 4 bytes cmap header */ + return error; + + cmap_dir.tableVersionNumber = GET_UShort(); + cmap_dir.numCMaps = GET_UShort(); + + FORGET_Frame(); + + off = FILE_Pos(); /* save offset to cmapdir[] which follows */ + + /* save space in face table for cmap tables */ + if ( ALLOC_ARRAY( face->cMaps, + cmap_dir.numCMaps, + TCMapTable ) ) + return error; + + face->numCMaps = cmap_dir.numCMaps; + + limit = face->numCMaps; + cmap = face->cMaps; + + for ( n = 0; n < limit; n++ ) + { + if ( FILE_Seek( off ) || + ACCESS_Frame( 8L ) ) + return error; + + /* extra code using entry_ for platxxx could be cleaned up later */ + cmap->loaded = FALSE; + cmap->platformID = entry_.platformID = GET_UShort(); + cmap->platformEncodingID = entry_.platformEncodingID = GET_UShort(); + + entry_.offset = GET_Long(); + + FORGET_Frame(); + + off = FILE_Pos(); + + if ( FILE_Seek( table_start + entry_.offset ) || + ACCESS_Frame( 6L ) ) + return error; + + cmap->format = GET_UShort(); + cmap->length = GET_UShort(); + cmap->version = GET_UShort(); + + FORGET_Frame(); + + cmap->offset = FILE_Pos(); + + cmap++; + } + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Programs + * + * Description : Loads the font (fpgm) and cvt programs into the + * face table. + * + * Input : face + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Programs( PFace face ) + { + DEFINE_LOCALS_WO_FRAME; + + Long n; + + + PTRACE2(( "Font program " )); + + /* The font program is optional */ + if ( ( n = TT_LookUp_Table( face, TTAG_fpgm ) ) < 0 ) + { + face->fontProgram = NULL; + face->fontPgmSize = 0; + + PTRACE2(( "is missing!\n" )); + } + else + { + face->fontPgmSize = face->dirTables[n].Length; + + if ( ALLOC( face->fontProgram, + face->fontPgmSize ) || + FILE_Read_At( face->dirTables[n].Offset, + (void*)face->fontProgram, + face->fontPgmSize ) ) + return error; + + PTRACE2(( "loaded, %12d bytes\n", face->fontPgmSize )); + } + + PTRACE2(( "Prep program " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_prep ) ) < 0 ) + { + face->cvtProgram = NULL; + face->cvtPgmSize = 0; + + PTRACE2(( "is missing!\n" )); + } + else + { + face->cvtPgmSize = face->dirTables[n].Length; + + if ( ALLOC( face->cvtProgram, + face->cvtPgmSize ) || + FILE_Read_At( face->dirTables[n].Offset, + (void*)face->cvtProgram, + face->cvtPgmSize ) ) + return error; + + PTRACE2(( "loaded, %12d bytes\n", face->cvtPgmSize )); + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_OS2 + * + * Description : Loads the OS2 Table. + * + * Input : face + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_OS2( PFace face ) + { + DEFINE_LOCALS; + + Long i; + TT_OS2* os2; + + + PTRACE2(( "OS/2 Table " )); + + /* We now support old Mac fonts where the OS/2 table doesn't */ + /* exist. Simply put, we set the `version' field to 0xFFFF */ + /* and test this value each time we need to access the table. */ + if ( ( i = TT_LookUp_Table( face, TTAG_OS2 ) ) < 0 ) + { + PTRACE2(( "is missing\n!" )); + face->os2.version = 0xFFFF; + error = TT_Err_Ok; + return TT_Err_Ok; + } + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 78L ) ) + return error; + + os2 = &face->os2; + + os2->version = GET_UShort(); + os2->xAvgCharWidth = GET_Short(); + os2->usWeightClass = GET_UShort(); + os2->usWidthClass = GET_UShort(); + os2->fsType = GET_Short(); + os2->ySubscriptXSize = GET_Short(); + os2->ySubscriptYSize = GET_Short(); + os2->ySubscriptXOffset = GET_Short(); + os2->ySubscriptYOffset = GET_Short(); + os2->ySuperscriptXSize = GET_Short(); + os2->ySuperscriptYSize = GET_Short(); + os2->ySuperscriptXOffset = GET_Short(); + os2->ySuperscriptYOffset = GET_Short(); + os2->yStrikeoutSize = GET_Short(); + os2->yStrikeoutPosition = GET_Short(); + os2->sFamilyClass = GET_Short(); + + for ( i = 0; i < 10; i++ ) + os2->panose[i] = GET_Byte(); + + os2->ulUnicodeRange1 = GET_ULong(); + os2->ulUnicodeRange2 = GET_ULong(); + os2->ulUnicodeRange3 = GET_ULong(); + os2->ulUnicodeRange4 = GET_ULong(); + + for ( i = 0; i < 4; i++ ) + os2->achVendID[i] = GET_Byte(); + + os2->fsSelection = GET_UShort(); + os2->usFirstCharIndex = GET_UShort(); + os2->usLastCharIndex = GET_UShort(); + os2->sTypoAscender = GET_Short(); + os2->sTypoDescender = GET_Short(); + os2->sTypoLineGap = GET_Short(); + os2->usWinAscent = GET_UShort(); + os2->usWinDescent = GET_UShort(); + + FORGET_Frame(); + + if ( os2->version >= 0x0001 ) + { + /* only version 1 tables */ + + if ( ACCESS_Frame( 8L ) ) /* read into frame */ + return error; + + os2->ulCodePageRange1 = GET_ULong(); + os2->ulCodePageRange2 = GET_ULong(); + + FORGET_Frame(); + } + else + { + os2->ulCodePageRange1 = 0; + os2->ulCodePageRange2 = 0; + } + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_PostScript + * + * Description : Loads the post table into face table. + * + * Input : face face table to look for + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_PostScript( PFace face ) + { + DEFINE_LOCALS; + + Long i; + + TT_Postscript* post = &face->postscript; + + + PTRACE2(( "PostScript " )); + + if ( ( i = TT_LookUp_Table( face, TTAG_post ) ) < 0 ) + return TT_Err_Post_Table_Missing; + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 32L ) ) + return error; + + /* read frame data into face table */ + + post->FormatType = GET_ULong(); + post->italicAngle = GET_ULong(); + post->underlinePosition = GET_Short(); + post->underlineThickness = GET_Short(); + post->isFixedPitch = GET_ULong(); + post->minMemType42 = GET_ULong(); + post->maxMemType42 = GET_ULong(); + post->minMemType1 = GET_ULong(); + post->maxMemType1 = GET_ULong(); + + FORGET_Frame(); + + /* we don't load the glyph names, we do that in a */ + /* library extension (ftxpost). */ + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Hdmx + * + * Description : Loads the horizontal device metrics table. + * + * Input : face face object to look for + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Hdmx( PFace face ) + { + DEFINE_LOCALS; + + TT_Hdmx_Record* rec; + TT_Hdmx hdmx; + Long table; + UShort n, num_glyphs; + Long record_size; + + + hdmx.version = 0; + hdmx.num_records = 0; + hdmx.records = 0; + + face->hdmx = hdmx; + + if ( ( table = TT_LookUp_Table( face, TTAG_hdmx ) ) < 0 ) + return TT_Err_Ok; + + if ( FILE_Seek( face->dirTables[table].Offset ) || + ACCESS_Frame( 8L ) ) + return error; + + hdmx.version = GET_UShort(); + hdmx.num_records = GET_Short(); + record_size = GET_Long(); + + FORGET_Frame(); + + /* Only recognize format 0 */ + + if ( hdmx.version != 0 ) + return TT_Err_Ok; + + if ( ALLOC( hdmx.records, sizeof ( TT_Hdmx_Record ) * hdmx.num_records ) ) + return error; + + num_glyphs = face->numGlyphs; + record_size -= num_glyphs+2; + rec = hdmx.records; + + for ( n = 0; n < hdmx.num_records; n++ ) + { + /* read record */ + + if ( ACCESS_Frame( 2L ) ) + goto Fail; + + rec->ppem = GET_Byte(); + rec->max_width = GET_Byte(); + + FORGET_Frame(); + + if ( ALLOC( rec->widths, num_glyphs ) || + FILE_Read( rec->widths, num_glyphs ) ) + goto Fail; + + /* skip padding bytes */ + if ( record_size > 0 ) + if ( FILE_Skip( record_size ) ) + goto Fail; + + rec++; + } + + face->hdmx = hdmx; + + return TT_Err_Ok; + + Fail: + for ( n = 0; n < hdmx.num_records; n++ ) + FREE( hdmx.records[n].widths ); + + FREE( hdmx.records ); + return error; + } + + +/******************************************************************* + * + * Function : Free_TrueType_Hdmx + * + * Description : Frees the horizontal device metrics table. + * + * Input : face face object to look for + * + * Output : TT_Err_Ok. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Free_TrueType_Hdmx( PFace face ) + { + UShort n; + + + if ( !face ) + return TT_Err_Ok; + + for ( n = 0; n < face->hdmx.num_records; n++ ) + FREE( face->hdmx.records[n].widths ); + + FREE( face->hdmx.records ); + face->hdmx.num_records = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Any + * + * Description : Loads any font table into client memory. Used by + * the TT_Get_Font_Data() API function. + * + * Input : face face object to look for + * + * tag tag of table to load. Use the value 0 if you + * want to access the whole font file, else set + * this parameter to a valid TrueType table tag + * that you can forge with the MAKE_TT_TAG + * macro. + * + * offset starting offset in the table (or the file + * if tag == 0 ) + * + * buffer address of target buffer + * + * length address of decision variable : + * + * if length == NULL : + * load the whole table. returns an + * an error if 'offset' == 0 !! + * + * if *length == 0 : + * exit immediately, returning the + * length of the given table, or of + * the font file, depending on the + * value of 'tag' + * + * if *length != 0 : + * load the next 'length' bytes of + * table or font, starting at offset + * 'offset' (in table or font too). + * + * Output : Error condition + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Any( PFace face, + ULong tag, + Long offset, + void* buffer, + Long* length ) + { + TT_Stream stream; + TT_Error error; + Long table; + ULong size; + + + if ( tag != 0 ) + { + /* look for tag in font directory */ + table = TT_LookUp_Table( face, tag ); + if ( table < 0 ) + return TT_Err_Table_Missing; + + offset += face->dirTables[table].Offset; + size = face->dirTables[table].Length; + } + else + /* tag = 0 -- the use want to access the font file directly */ + size = TT_Stream_Size( face->stream ); + + if ( length && *length == 0 ) + { + *length = size; + return TT_Err_Ok; + } + + if ( length ) + size = *length; + + if ( !USE_Stream( face->stream, stream ) ) + (void)FILE_Read_At( offset, buffer, size ); + DONE_Stream( stream ); + + return error; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttload.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.h new file mode 100644 index 000000000..6172fd965 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.h @@ -0,0 +1,217 @@ +/******************************************************************* + * + * ttload.h 1.1 + * + * TrueType Tables Loader. + * + * 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. + * + * + * Changes between 1.1 and 1.0 : + * + * - add function Load_TrueType_Any used by TT_Get_Font_Data + * + ******************************************************************/ + +#ifndef TTLOAD_H +#define TTLOAD_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + +#ifdef __cplusplus + extern "C" { +#endif + + EXPORT_DEF + Long TT_LookUp_Table( PFace face, ULong tag ); + + LOCAL_DEF TT_Error Load_TrueType_Directory ( PFace face, + ULong faceIndex ); + + LOCAL_DEF TT_Error Load_TrueType_MaxProfile ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Gasp ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Header ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Locations ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Names ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_CVT ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_CMap ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Programs ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_OS2 ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_PostScript ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Hdmx ( PFace face ); + + LOCAL_DEF TT_Error Load_TrueType_Metrics_Header( PFace face, + Bool vertical ); + + LOCAL_DEF TT_Error Load_TrueType_Any( PFace face, + ULong tag, + Long offset, + void* buffer, + Long* length ); + + LOCAL_DEF TT_Error Free_TrueType_Names( PFace face ); + LOCAL_DEF TT_Error Free_TrueType_Hdmx ( PFace face ); + + +/* The following macros are defined to simplify the writing of */ +/* the various table and glyph loaders. */ + +/* For examples see the code in ttload.c, ttgload.c etc. */ + +#define USE_Stream( original, duplicate ) \ + ( (error = TT_Use_Stream( original, &duplicate )) != TT_Err_Ok ) + +#define DONE_Stream( _stream ) \ + TT_Done_Stream( &_stream ) + +/* Define a file frame -- use it only when needed */ +#define DEFINE_A_FRAME TFileFrame frame = TT_Null_FileFrame + +/* Define a stream -- use it only when needed */ +#define DEFINE_A_STREAM TT_Stream stream + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* re-entrant implementation */ + +/* The following macros define the necessary local */ +/* variables used to access streams and frames. */ + +/* Define stream locals with frame */ +#define DEFINE_STREAM_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM; \ + DEFINE_A_FRAME + +/* Define stream locals without frame */ +#define DEFINE_STREAM_LOCALS_WO_FRAME \ + TT_Error error; \ + DEFINE_A_STREAM + +/* Define locals with a predefined stream in reentrant mode -- see ttload.c */ +#define DEFINE_LOAD_LOCALS( STREAM ) \ + TT_Error error; \ + DEFINE_A_STREAM = (STREAM); \ + DEFINE_A_FRAME + +/* Define locals without frame with a predefined stream - see ttload.c */ +#define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \ + TT_Error error; \ + DEFINE_A_STREAM = (STREAM) + +/* Define all locals necessary to access a font file */ +#define DEFINE_ALL_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM; \ + DEFINE_A_FRAME + + +#define ACCESS_Frame( _size_ ) \ + ( (error = TT_Access_Frame( stream, \ + &frame, \ + (Long)(_size_) )) != TT_Err_Ok ) +#define CHECK_ACCESS_Frame( _size_ ) \ + ( (error = TT_Check_And_Access_Frame( stream, \ + &frame, \ + (Long)(_size_) )) != TT_Err_Ok ) +#define FORGET_Frame() \ + ( (void)TT_Forget_Frame( &frame ) ) + +#define GET_Byte() TT_Get_Byte ( &frame ) +#define GET_Char() TT_Get_Char ( &frame ) +#define GET_UShort() TT_Get_UShort( &frame ) +#define GET_Short() TT_Get_Short ( &frame ) +#define GET_Long() TT_Get_Long ( &frame ) +#define GET_ULong() TT_Get_ULong ( &frame ) +#define GET_Tag4() TT_Get_ULong ( &frame ) + +#define FILE_Pos() TT_File_Pos ( stream ) + +#define FILE_Seek( _position_ ) \ + ( (error = TT_Seek_File( stream, \ + (Long)(_position_) )) != TT_Err_Ok ) +#define FILE_Skip( _distance_ ) \ + ( (error = TT_Skip_File( stream, \ + (Long)(_distance_) )) != TT_Err_Ok ) +#define FILE_Read( buffer, count ) \ + ( (error = TT_Read_File ( stream, \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) +#define FILE_Read_At( pos, buffer, count ) \ + ( (error = TT_Read_At_File( stream, \ + (Long)(pos), \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) + +#else /* thread-safe implementation */ + +/* Define stream locals with frame -- nothing in thread-safe mode */ +#define DEFINE_STREAM_LOCALS \ + TT_Error error + +/* Define stream locals without frame -- nothing in thread-safe mode */ +#define DEFINE_STREAM_LOCALS_WO_FRAME \ + TT_Error error + +/* Define locals with a predefined stream in reentrant mode -- see ttload.c */ +#define DEFINE_LOAD_LOCALS( STREAM ) \ + TT_Error error + + +/* Define locals without frame with a predefined stream - see ttload.c */ +#define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \ + TT_Error error + +/* Define all locals necessary to access a font file */ +#define DEFINE_ALL_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM + + +#define ACCESS_Frame( _size_ ) \ + ( (error = TT_Access_Frame( (Long)(_size_) )) != TT_Err_Ok ) +#define CHECK_ACCESS_Frame( _size_ ) \ + ( (error = TT_Check_And_Access_Frame( (Long)(_size_) )) != TT_Err_Ok ) +#define FORGET_Frame() \ + ( (void)TT_Forget_Frame() ) + +#define GET_Byte() TT_Get_Byte () +#define GET_Char() TT_Get_Char () +#define GET_UShort() TT_Get_UShort() +#define GET_Short() TT_Get_Short () +#define GET_Long() TT_Get_Long () +#define GET_ULong() TT_Get_ULong () +#define GET_Tag4() TT_Get_ULong () + +#define FILE_Pos() TT_File_Pos() + +#define FILE_Seek( _position_ ) \ + ( (error = TT_Seek_File( (Long)(_position_) )) != TT_Err_Ok ) +#define FILE_Skip( _distance_ ) \ + ( (error = TT_Skip_File( (Long)(_distance_) )) != TT_Err_Ok ) +#define FILE_Read( buffer, count ) \ + ( (error = TT_Read_File ( buffer, \ + (Long)(count) )) != TT_Err_Ok ) +#define FILE_Read_At( pos, buffer, count ) \ + ( (error = TT_Read_At_File( (Long)(pos), \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTLOAD_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c new file mode 100644 index 000000000..3687b5ca0 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c @@ -0,0 +1,397 @@ +/******************************************************************* + * + * ttmemory.c 1.2 + * + * Memory management component (body). + * + * 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. + * + * + * Changes between 1.1 and 1.2: + * + * - the font pool is gone. + * + * - introduced the FREE macro and the Free function for + * future use in destructors. + * + * - Init_FontPool() is now a macro to allow the compilation of + * 'legacy' applications (all four test programs have been updated). + * + ******************************************************************/ + +#include "ttdebug.h" +#include "ttmemory.h" +#include "ttengine.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_memory + + +#ifdef DEBUG_MEMORY + +#include + +#define MAX_TRACKED_BLOCKS 1024 + + struct TMemRec_ + { + void* base; + Long size; + }; + + typedef struct TMemRec_ TMemRec; + + static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; + + static Int num_alloc; + static Int num_free; + static Int num_realloc; /* counts only `real' reallocations + (i.e., an existing buffer will be resized + to a value larger than zero */ + + static Int fail_alloc; + static Int fail_realloc; + static Int fail_free; + +#endif /* DEBUG_MEMORY */ + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + Long TTMemory_Allocated; + Long TTMemory_MaxAllocated; +#endif + + +/******************************************************************* + * + * Function : TT_Alloc + * + * Description : Allocates memory from the heap buffer. + * + * Input : Size size of the memory to be allocated + * P pointer to a buffer pointer + * + * Output : Error code. + * + * NOTE : The newly allocated block should _always_ be zeroed + * on return. Many parts of the engine rely on this to + * work properly. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Alloc( ULong Size, void** P ) + { +#ifdef DEBUG_MEMORY + Int i; +#endif + + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( Size > (size_t)-1 ) + return TT_Err_Out_Of_Memory; + if ( Size > 0 ) + { + *P = (void*)malloc( Size ); + if ( !*P ) + return TT_Err_Out_Of_Memory; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated += Size; + TTMemory_MaxAllocated += Size; +#endif + +#ifdef DEBUG_MEMORY + + num_alloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_alloc++; + else + { + pointers[i].base = *P; + pointers[i].size = Size; + } + +#endif /* DEBUG_MEMORY */ + + MEM_Set( *P, 0, Size ); + } + else + *P = NULL; + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + +/******************************************************************* + * + * Function : TT_Realloc + * + * Description : Reallocates memory from the heap buffer. + * + * Input : Size new size of the memory to be allocated; + * if zero, TT_Free() will be called + * P pointer to a buffer pointer; if *P == NULL, + * TT_Alloc() will be called + * + * Output : Error code. + * + * NOTES : It's not necessary to zero the memory in case the + * reallocated buffer is larger than before -- the + * application has to take care of this. + * + * If the memory request fails, TT_Free() will be + * called on *P, and TT_Err_Out_Of_Memory returned. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Realloc( ULong Size, void** P ) + { + void* Q; + +#ifdef DEBUG_MEMORY + Int i; +#endif + + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( !*P ) + return TT_Alloc( Size, P ); + + if ( Size == 0 ) + return TT_Free( P ); + + if ( Size > (size_t)-1 ) + { + TT_Free( *P ); + return TT_Err_Out_Of_Memory; + } + + Q = (void*)realloc( *P, Size ); + if ( !Q ) + { + TT_Free( *P ); + return TT_Err_Out_Of_Memory; + } + +#ifdef DEBUG_MEMORY + + num_realloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_realloc++; + else + { +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated += Size - pointers[i].size; + if ( Size > pointers[i].size ) + TTMemory_MaxAllocated += Size - pointers[i].size; +#endif + + pointers[i].base = Q; + pointers[i].size = size; + } +#endif /* DEBUG_MEMORY */ + + *P = Q; + + return TT_Err_Ok; + } + + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + +/******************************************************************* + * + * Function : TT_Free + * + * Description : Releases a previously allocated block of memory. + * + * Input : P pointer to memory block + * + * Output : Always SUCCESS. + * + * Note : The pointer must _always_ be set to NULL by this function. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Free( void** P ) + { +#ifdef DEBUG_MEMORY + Int i; +#endif /* DEBUG_MEMORY */ + + + if ( !P || !*P ) + return TT_Err_Ok; + +#ifdef DEBUG_MEMORY + + num_free++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_free++; + else + { +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated -= pointers[i].size; +#endif + + pointers[i].base = NULL; + pointers[i].size = 0; + } +#endif /* DEBUG_MEMORY */ + + free( *P ); + + *P = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Init + * + * Description : Initializes the memory. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Init( void ) + { +#ifdef DEBUG_MEMORY + Int i; + + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + pointers[i].base = NULL; + pointers[i].size = 0; + } + + num_alloc = 0; + num_realloc = 0; + num_free = 0; + + fail_alloc = 0; + fail_realloc = 0; + fail_free = 0; +#endif + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated = 0; + TTMemory_MaxAllocated = 0; +#endif + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Done + * + * Description : Finalizes memory usage. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Done( void ) + { +#ifdef DEBUG_MEMORY + Int i, num_leaked, tot_leaked; + + + num_leaked = 0; + tot_leaked = 0; + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + num_leaked ++; + tot_leaked += pointers[i].size; + } + } + + fprintf( stderr, + "%d memory allocations, of which %d failed\n", + num_alloc, + fail_alloc ); + + fprintf( stderr, + "%d memory reallocations, of which %d failed\n", + num_realloc, + fail_realloc ); + + fprintf( stderr, + "%d memory frees, of which %d failed\n", + num_free, + fail_free ); + + if ( num_leaked > 0 ) + { + fprintf( stderr, + "There are %d leaked memory blocks, totalizing %d bytes\n", + num_leaked, tot_leaked ); + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + fprintf( stderr, + "index: %4d (base: $%08lx, size: %08ld)\n", + i, + (long)pointers[i].base, + pointers[i].size ); + } + } + } + else + fprintf( stderr, "No memory leaks !\n" ); + +#endif /* DEBUG_MEMORY */ + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h new file mode 100644 index 000000000..54394ecc2 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -0,0 +1,125 @@ +/******************************************************************* + * + * ttmemory.h 1.2 + * + * Memory management component (specification). + * + * 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. + * + * Changes between 1.2 and 1.1: + * + * - the font pool is gone! All allocations are now performed + * with malloc() and free(). + * + * - introduced the FREE() macro and the Free() function for + * future use in destructors. + * + * - Init_FontPool() is now a macro to allow the compilation of + * 'legacy' applications (all four test programs have been updated). + * + ******************************************************************/ + +#ifndef TTMEMORY_H +#define TTMEMORY_H + +#include "ttconfig.h" +#include "tttypes.h" +#include + + +#ifdef __cplusplus + extern "C" { +#endif + +#define MEM_Set( dest, byte, count ) memset( dest, byte, count ) + +#ifdef HAVE_MEMCPY +#define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) +#else +#define MEM_Copy( dest, source, count ) bcopy( source, dest, count ) +#endif + +#ifdef HAVE_MEMMOVE +#define MEM_Move( dest, source, count ) memmove( dest, source, count ) +#else +#define MEM_Move( dest, source, count ) bcopy( source, dest, count ) +#endif + + +#define MEM_Alloc( _pointer_, _size_ ) \ + TT_Alloc( _size_, (void**)&(_pointer_) ) + +#define MEM_Realloc( _pointer_, _size_ ) \ + TT_Realloc( _size_, (void**)&(_pointer_) ) + +#define ALLOC( _pointer_, _size_ ) \ + ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok ) + +#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( ( error = MEM_Alloc( _pointer_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define REALLOC( _pointer_, _size_ ) \ + ( ( error = MEM_Realloc( _pointer_, _size_ ) ) != TT_Err_Ok ) + +#define REALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( (error = MEM_Realloc( _pointer_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define FREE( _pointer_ ) \ + TT_Free( (void**)&(_pointer_) ) + + + /* Allocate a block of memory of 'Size' bytes from the heap, and */ + /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ + /* case of error, the pointer is always set to NULL. */ + + EXPORT_DEF + TT_Error TT_Alloc( ULong Size, void** P ); + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + /* Reallocates a block of memory pointed to by '*P' to 'Size' */ + /* bytes from the heap, possibly changing '*P'. If 'Size' is 0, */ + /* TT_Free() is called, if '*P' is NULL, TT_Alloc() is called. */ + /* '*P' is freed (if it's non-NULL) in case of error. */ + + EXPORT_DEF + TT_Error TT_Realloc( ULong Size, void** P ); + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + /* Releases a block that was previously allocated through Alloc. */ + /* Note that the function returns successfully when P or *P are */ + /* already NULL. The pointer '*P' is set to NULL on exit in */ + /* case of success. */ + + EXPORT_DEF + TT_Error TT_Free( void** P ); + + + /* For "legacy" applications, that should be re-coded. */ + /* Note that this won't release the previously allocated font pool. */ + +#define Init_FontPool( x, y ) while( 0 ) { } + + + LOCAL_DEF TT_Error TTMemory_Init( void ); + LOCAL_DEF TT_Error TTMemory_Done( void ); + + +#ifdef __cplusplus + } +#endif + +#endif /* TTMEMORY_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.c new file mode 100644 index 000000000..95f71f801 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.c @@ -0,0 +1,85 @@ +/******************************************************************* + * + * ttmutex.c 1.0 + * + * Mutual exclusion object, single-threaded implementation + * + * 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. + * + * NOTE: This is a generic non-functional implementation + * that you are welcome to refine for your own system. + * + * Please name your system-specific source with a + * different name (like ttmutex-os2.c or ttmutex-linux.c) + * and change your makefile accordingly. + * + ******************************************************************/ + +#include "ttmutex.h" + + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_mutex + + +/* ANSI C prevents the compilation of empty units. We thus introduce */ +/* a dummy typedef to get rid of compiler warnings/errors. */ +/* Note that gcc's -ansi -pedantic does not report any error here. */ +/* Watcom, VC++ or Borland C++ do however. */ + + typedef void _ttmutex_to_satisfy_ANSI_C_; + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + + LOCAL_FUNC + void TT_Mutex_Create ( TMutex* mutex ) + { + *mutex = (void*)-1; + /* Replace this line with your own mutex creation code */ + } + + + LOCAL_FUNC + void TT_Mutex_Delete ( TMutex* mutex ) + { + *mutex = (void*)0; + /* Replace this line with your own mutex destruction code */ + } + + + LOCAL_FUNC + void TT_Mutex_Lock ( TMutex* mutex ) + { + /* NOTE: It is legal to call this function with a NULL argument */ + /* in which case an immediate return is appropriate. */ + if ( !mutex ) + return; + + ; /* Insert your own mutex locking code here */ + } + + + LOCAL_FUNC + void TT_Mutex_Release( TMutex* mutex ) + { + /* NOTE: It is legal to call this function with a NULL argument */ + /* in which case an immediate return is appropriate */ + if ( !mutex ) + return; + + ; /* Insert your own mutex release code here */ + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.h new file mode 100644 index 000000000..3223cbbc0 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmutex.h @@ -0,0 +1,59 @@ +/******************************************************************* + * + * ttmutex.h 1.0 + * + * Mutual exclusion object / dummy generic interface. + * + * 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. + * + * Note: This file provides a generic interface. The implementation + * to compile depends on your system and the type of + * library you want to build (either singly-threaded, + * thread-safe or re-entrant). + * + * Please read the technical documentation for more details. + * + ******************************************************************/ + +#ifndef TTMUTEX_H +#define TTMUTEX_H + +#include "ttconfig.h" + + + typedef void* TMutex; /* typeless reference to a mutex */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* thread-safe and re-entrant builds */ + +#define MUTEX_Create( mutex ) TT_Mutex_Create ( &(mutex) ) +#define MUTEX_Destroy( mutex ) TT_Mutex_Delete ( &(mutex) ) +#define MUTEX_Lock( mutex ) TT_Mutex_Lock ( &(mutex) ) +#define MUTEX_Release( mutex ) TT_Mutex_Release( &(mutex) ) + + LOCAL_DEF void TT_Mutex_Create ( TMutex* mutex ); /* Create a new mutex */ + LOCAL_DEF void TT_Mutex_Delete ( TMutex* mutex ); /* Delete a mutex */ + LOCAL_DEF void TT_Mutex_Lock ( TMutex* mutex ); /* Lock a mutex. */ + LOCAL_DEF void TT_Mutex_Release( TMutex* mutex ); /* Release a mutex */ + +#else /* for the single-thread build */ + +#define MUTEX_Create( mutex ) /* nothing */ +#define MUTEX_Destroy( mutex ) /* nothing */ +#define MUTEX_Lock( mutex ) /* nothing */ +#define MUTEX_Release( mutex ) /* nothing */ + + /* No code will be generated for mutex operations */ + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#endif /* TTMUTEX_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c new file mode 100644 index 000000000..d51bd7f8c --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -0,0 +1,1494 @@ +/******************************************************************* + * + * ttobjs.c 1.0 + * + * Objects manager. + * + * 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 "ttobjs.h" +#include "ttfile.h" +#include "ttcalc.h" +#include "ttmemory.h" +#include "ttload.h" +#include "ttinterp.h" +#include "ttdebug.h" + + +/* Add extensions definition */ +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.h" +#endif + +/* Required by tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_objs + +/******************************************************************* + * + * Function : New_Context + * + * Description : Creates a new execution context for a given + * face object. + * + ******************************************************************/ + + LOCAL_FUNC + PExecution_Context New_Context( PFace face ) + { + PEngine_Instance engine; + PExecution_Context exec; + + + if ( !face ) + return NULL; + + engine = face->engine; + CACHE_New( engine->objs_exec_cache, exec, face ); + return exec; + } + + +/******************************************************************* + * + * Function : Done_Context + * + * Description : Discards an execution context. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Done_Context( PExecution_Context exec ) + { + PEngine_Instance engine; + + + if ( !exec ) + return TT_Err_Ok; + + engine = exec->face->engine; + return CACHE_Done( engine->objs_exec_cache, exec ); + } + + +#if 0 + +/******************************************************************* + * + * Function : New_Instance + * + * Description : Creates a new instance for a given face object. + * + ******************************************************************/ + + LOCAL_FUNC + PInstance New_Instance( PFace face ) + { + PInstance ins; + + + if ( !face ) + return NULL; + + CACHE_New( &face->instances, ins, face ); + + return ins; + } + + +/******************************************************************* + * + * Function : Done_Instance + * + * Description : Discards an instance. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Done_Instance( PInstance instance ) + { + return CACHE_Done( &instance->owner->instances, instance ); + } + +#endif + + +/******************************************************************* + * * + * GLYPH ZONE FUNCTIONS * + * * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : New_Glyph_Zone + * + * Description : Allocates a new glyph zone + * + * Input : pts pointer to the target glyph zone record + * maxPoints capacity of glyph zone in points + * maxContours capacity of glyph zone in contours + * + * Return : Error code. + * + *****************************************************************/ + + static + TT_Error New_Glyph_Zone( PGlyph_Zone pts, + UShort maxPoints, + UShort maxContours ) + { + TT_Error error; + + + if ( ALLOC( pts->org, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || + ALLOC( pts->cur, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || + ALLOC( pts->touch, maxPoints * sizeof ( Byte ) ) || + ALLOC( pts->contours, maxContours * sizeof ( Short ) ) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Done_Glyph_Zone + * + * Description : Deallocates a glyph zone + * + * Input : pts pointer to the target glyph zone record + * + * Return : Error code. + * + *****************************************************************/ + + static + TT_Error Done_Glyph_Zone( PGlyph_Zone pts ) + { + FREE( pts->contours ); + FREE( pts->touch ); + FREE( pts->cur ); + FREE( pts->org ); + + return TT_Err_Ok; + } + + + +/******************************************************************* + * * + * CODERANGE FUNCTIONS * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Goto_CodeRange + * + * Description : Switch to a new code range (updates Code and IP). + * + * Input : exec target execution context + * range new execution code range + * IP new IP in new code range + * + * Output : SUCCESS on success. FAILURE on error (no code range). + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Goto_CodeRange( PExecution_Context exec, + Int range, + ULong IP ) + { + PCodeRange cr; + + + if ( range < 1 || range > 3 ) + return TT_Err_Bad_Argument; + + cr = &exec->codeRangeTable[range - 1]; + + if ( cr->Base == NULL ) + return TT_Err_Invalid_CodeRange; + + /* NOTE: Because the last instruction of a program may be a CALL */ + /* which will return to the first byte *after* the code */ + /* range, we test for IP <= Size, instead of IP < Size. */ + + if ( IP > cr->Size ) + return TT_Err_Code_Overflow; + + exec->code = cr->Base; + exec->codeSize = cr->Size; + exec->IP = IP; + exec->curRange = range; + + return TT_Err_Ok; + } + + +#if 0 + +/******************************************************************* + * + * Function : Get_CodeRange + * + * Description : Returns a pointer to a given code range. Should + * be used only by the debugger. Returns NULL if + * 'range' is out of current bounds. + * + * Input : exec target execution context + * range new execution code range + * + * Output : Pointer to the code range record. NULL on failure. + * + *****************************************************************/ + + LOCAL_FUNC + PCodeRange Get_CodeRange( PExecution_Context exec, Int range ) + { + if ( range < 1 || range > 3 ) + return NULL; + else /* arrays start with 1 in Pascal, and with 0 in C */ + return &exec->codeRangeTable[range - 1]; + } + +#endif + + +/******************************************************************* + * + * Function : Set_CodeRange + * + * Description : Sets a code range. + * + * Input : exec target execution context + * range code range index + * base new code base + * length range size in bytes + * + * Output : SUCCESS on success. FAILURE on error. + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Set_CodeRange( PExecution_Context exec, + Int range, + void* base, + ULong length ) + { + if ( range < 1 || range > 3 ) + return TT_Err_Bad_Argument; + + exec->codeRangeTable[range - 1].Base = (Byte*)base; + exec->codeRangeTable[range - 1].Size = length; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Clear_CodeRange + * + * Description : Clears a code range. + * + * Input : exec target execution context + * range code range index + * + * Output : SUCCESS on success. FAILURE on error. + * + * Note : Does not set the Error variable. + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Clear_CodeRange( PExecution_Context exec, Int range ) + { + if ( range < 1 || range > 3 ) + return TT_Err_Bad_Argument; + + exec->codeRangeTable[range - 1].Base = NULL; + exec->codeRangeTable[range - 1].Size = 0; + + return TT_Err_Ok; + } + + + +/******************************************************************* + * * + * EXECUTION CONTEXT ROUTINES * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Context_Destroy + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Destroy( void* _context ) + { + PExecution_Context exec = (PExecution_Context)_context; + + if ( !exec ) + return TT_Err_Ok; + + /* free composite load stack */ + FREE( exec->loadStack ); + exec->loadSize = 0; + + /* points zone */ + Done_Glyph_Zone( &exec->pts ); + exec->maxPoints = 0; + exec->maxContours = 0; + + /* free stack */ + FREE( exec->stack ); + exec->stackSize = 0; + + /* free call stack */ + FREE( exec->callStack ); + exec->callSize = 0; + exec->callTop = 0; + + /* free glyph code range */ + FREE( exec->glyphIns ); + exec->glyphSize = 0; + + exec->instance = NULL; + exec->face = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Context_Create + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Create( void* _context, void* _face ) + { + PExecution_Context exec = (PExecution_Context)_context; + + PFace face = (PFace)_face; + TT_Error error; + + + /* XXX : We don't reserve arrays anymore, this is done automatically */ + /* during a "Context_Load".. */ + + exec->callSize = 32; + if ( ALLOC_ARRAY( exec->callStack, exec->callSize, TCallRecord ) ) + goto Fail_Memory; + + /* all values in the context are set to 0 already, but this is */ + /* here as a remainder */ + exec->maxPoints = 0; + exec->maxContours = 0; + + exec->stackSize = 0; + exec->loadSize = 0; + exec->glyphSize = 0; + + exec->stack = NULL; + exec->loadStack = NULL; + exec->glyphIns = NULL; + + exec->face = face; + exec->instance = NULL; + + return TT_Err_Ok; + + Fail_Memory: + Context_Destroy( exec ); + return error; + } + + +/******************************************************************* + * + * Function : Context_Load + * + *****************************************************************/ + +/****************************************************************/ +/* */ +/* Update_Max : Reallocate a buffer if it needs to */ +/* */ +/* input: size address of buffer's current size */ +/* expressed in elements */ +/* */ +/* multiplier size in bytes of each element in the */ +/* buffer */ +/* */ +/* buff address of the buffer base pointer */ +/* */ +/* new_max new capacity (size) of the buffer */ + + static + TT_Error Update_Max( ULong* size, + ULong multiplier, + void** buff, + ULong new_max ) + { + TT_Error error; + + if ( *size < new_max ) + { + FREE( *buff ); + if ( ALLOC( *buff, new_max * multiplier ) ) + return error; + *size = new_max; + } + return TT_Err_Ok; + } + + +/****************************************************************/ +/* */ +/* Update_Zone: Reallocate a zone if it needs to */ +/* */ +/* input: zone address of the target zone */ +/* */ +/* maxPoints address of the zone's current capacity */ +/* in points */ +/* */ +/* maxContours address of the zone's current capacity */ +/* in contours */ +/* */ +/* newPoints new capacity in points */ +/* */ +/* newContours new capacity in contours */ +/* */ + + static + TT_Error Update_Zone( PGlyph_Zone zone, + UShort* maxPoints, + UShort* maxContours, + UShort newPoints, + UShort newContours ) + { + if ( *maxPoints < newPoints || *maxContours < newContours ) + { + TT_Error error; + + + Done_Glyph_Zone( zone ); + + error = New_Glyph_Zone( zone, newPoints, newContours ); + if ( error ) + return error; + + *maxPoints = newPoints; + *maxContours = newContours; + } + return TT_Err_Ok; + } + + + LOCAL_FUNC + TT_Error Context_Load( PExecution_Context exec, + PFace face, + PInstance ins ) + { + Int i; + TMaxProfile* maxp; + TT_Error error; + + exec->face = face; + maxp = &face->maxProfile; + + exec->instance = ins; + + if ( ins ) + { + exec->numFDefs = ins->numFDefs; + exec->numIDefs = ins->numIDefs; + exec->maxFDefs = ins->maxFDefs; + exec->maxIDefs = ins->maxIDefs; + exec->FDefs = ins->FDefs; + exec->IDefs = ins->IDefs; + exec->metrics = ins->metrics; + + exec->maxFunc = ins->maxFunc; + exec->maxIns = ins->maxIns; + + for ( i = 0; i < MAX_CODE_RANGES; i++ ) + exec->codeRangeTable[i] = ins->codeRangeTable[i]; + + /* set graphics state */ + exec->GS = ins->GS; + + exec->cvtSize = ins->cvtSize; + exec->cvt = ins->cvt; + + exec->storeSize = ins->storeSize; + exec->storage = ins->storage; + + exec->twilight = ins->twilight; + } + + error = Update_Max( &exec->loadSize, + sizeof ( TSubglyph_Record ), + (void**)&exec->loadStack, + face->maxComponents + 1 ); + if ( error ) + return error; + + error = Update_Max( &exec->stackSize, + sizeof ( TT_F26Dot6 ), + (void**)&exec->stack, + maxp->maxStackElements + 32 ); + /* XXX : We reserve a little more elements on the stack to deal safely */ + /* with broken fonts like arialbs, courbs, timesbs... */ + if ( error ) + return error; + + error = Update_Max( &exec->glyphSize, + sizeof ( Byte ), + (void**)&exec->glyphIns, + maxp->maxSizeOfInstructions ); + if ( error ) + return error; + + error = Update_Zone( &exec->pts, + &exec->maxPoints, + &exec->maxContours, + exec->face->maxPoints + 2, + exec->face->maxContours ); + /* XXX : We reserve two positions for the phantom points! */ + if ( error ) + return error; + + exec->pts.n_points = 0; + exec->pts.n_contours = 0; + + exec->instruction_trap = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Context_Save + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Save( PExecution_Context exec, + PInstance ins ) + { + Int i; + + /* XXXX : Will probably disappear soon with all the coderange */ + /* management, which is now rather obsolete. */ + + ins->numFDefs = exec->numFDefs; + ins->numIDefs = exec->numIDefs; + ins->maxFunc = exec->maxFunc; + ins->maxIns = exec->maxIns; + + for ( i = 0; i < MAX_CODE_RANGES; i++ ) + ins->codeRangeTable[i] = exec->codeRangeTable[i]; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Context_Run + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Run( PExecution_Context exec, + Bool debug ) + { + TT_Error error; + + + if ( (error = Goto_CodeRange( exec, + TT_CodeRange_Glyph, 0 )) != TT_Err_Ok ) + return error; + + exec->zp0 = exec->pts; + exec->zp1 = exec->pts; + exec->zp2 = exec->pts; + + exec->GS.gep0 = 1; + exec->GS.gep1 = 1; + exec->GS.gep2 = 1; + + exec->GS.projVector.x = 0x4000; + exec->GS.projVector.y = 0x0000; + + exec->GS.freeVector = exec->GS.projVector; + exec->GS.dualVector = exec->GS.projVector; + + exec->GS.round_state = 1; + exec->GS.loop = 1; + + /* some glyphs leave something on the stack. so we clean it */ + /* before a new execution. */ + exec->top = 0; + exec->callTop = 0; + + if ( !debug ) + return RunIns( exec ); + else + return TT_Err_Ok; + } + + + LOCAL_FUNC + const TGraphicsState Default_GraphicsState = + { + 0, 0, 0, + { 0x4000, 0 }, + { 0x4000, 0 }, + { 0x4000, 0 }, + 1, 64, 1, + TRUE, 68, 0, 0, 9, 3, + 0, FALSE, 2, 1, 1, 1 + }; + + + +/******************************************************************* + * * + * INSTANCE FUNCTIONS * + * * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Instance_Destroy + * + * Description : + * + * Input : _instance the instance object to destroy + * + * Output : error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Destroy( void* _instance ) + { + PInstance ins = (PInstance)_instance; + + + if ( !_instance ) + return TT_Err_Ok; + + if ( ins->debug ) + { + /* the debug context must be deleted by the debugger itself */ + ins->context = NULL; + ins->debug = FALSE; + } + + FREE( ins->cvt ); + ins->cvtSize = 0; + + /* free storage area */ + FREE( ins->storage ); + ins->storeSize = 0; + + /* twilight zone */ + Done_Glyph_Zone( &ins->twilight ); + + FREE( ins->FDefs ); + FREE( ins->IDefs ); + ins->numFDefs = 0; + ins->numIDefs = 0; + ins->maxFDefs = 0; + ins->maxIDefs = 0; + ins->maxFunc = -1; + ins->maxIns = -1; + + ins->owner = NULL; + ins->valid = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Instance_Create + * + * Description : + * + * Input : _instance instance record to initialize + * _face parent face object + * + * Output : Error code. All partially built subtables are + * released on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Create( void* _instance, + void* _face ) + { + PInstance ins = (PInstance)_instance; + PFace face = (PFace)_face; + TT_Error error; + Int i; + UShort n_twilight; + + PMaxProfile maxp = &face->maxProfile; + + + ins->owner = face; + ins->valid = FALSE; + + ins->maxFDefs = maxp->maxFunctionDefs; + ins->maxIDefs = maxp->maxInstructionDefs; + ins->cvtSize = face->cvtSize; + ins->storeSize = maxp->maxStorage; + + /* Set default metrics */ + { + PIns_Metrics metrics = &ins->metrics; + + + metrics->pointSize = 10 * 64; /* default pointsize = 10pts */ + + metrics->x_resolution = 96; /* default resolution = 96dpi */ + metrics->y_resolution = 96; + + metrics->x_ppem = 0; + metrics->y_ppem = 0; + + metrics->rotated = FALSE; + metrics->stretched = FALSE; + + /* set default compensation ( all 0 ) */ + for ( i = 0; i < 4; i++ ) + metrics->compensations[i] = 0; + } + + /* allocate function defs, instruction defs, cvt and storage area */ + if ( ALLOC_ARRAY( ins->FDefs, ins->maxFDefs, TDefRecord ) || + ALLOC_ARRAY( ins->IDefs, ins->maxIDefs, TDefRecord ) || + ALLOC_ARRAY( ins->cvt, ins->cvtSize, Long ) || + ALLOC_ARRAY( ins->storage, ins->storeSize, Long ) ) + goto Fail_Memory; + + /* reserve twilight zone */ + n_twilight = maxp->maxTwilightPoints; + error = New_Glyph_Zone( &ins->twilight, n_twilight, 0 ); + if (error) + goto Fail_Memory; + + ins->twilight.n_points = n_twilight; + + return TT_Err_Ok; + + Fail_Memory: + Instance_Destroy( ins ); + return error; + } + + +/******************************************************************* + * + * Function : Instance_Init + * + * Description : Initialize a fresh new instance. + * Executes the font program if any is found. + * + * Input : _instance the instance object to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Init( PInstance ins ) + { + PExecution_Context exec; + + TT_Error error; + PFace face = ins->owner; + + + if ( ins->debug ) + exec = ins->context; + else + exec = New_Context( face ); + /* debugging instances have their own context */ + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + ins->GS = Default_GraphicsState; + + ins->numFDefs = 0; + ins->numIDefs = 0; + ins->maxFunc = -1; + ins->maxIns = -1; + + Context_Load( exec, face, ins ); + + exec->callTop = 0; + exec->top = 0; + + exec->period = 64; + exec->phase = 0; + exec->threshold = 0; + + { + PIns_Metrics metrics = &exec->metrics; + + + metrics->x_ppem = 0; + metrics->y_ppem = 0; + metrics->pointSize = 0; + metrics->x_scale1 = 0; + metrics->x_scale2 = 1; + metrics->y_scale1 = 0; + metrics->y_scale2 = 1; + + metrics->ppem = 0; + metrics->scale1 = 0; + metrics->scale2 = 1; + metrics->ratio = 1L << 16; + } + + exec->instruction_trap = FALSE; + + exec->cvtSize = ins->cvtSize; + exec->cvt = ins->cvt; + + exec->F_dot_P = 0x10000; + + /* allow font program execution */ + Set_CodeRange( exec, + TT_CodeRange_Font, + face->fontProgram, + face->fontPgmSize ); + + /* disable CVT and glyph programs coderange */ + Clear_CodeRange( exec, TT_CodeRange_Cvt ); + Clear_CodeRange( exec, TT_CodeRange_Glyph ); + + if ( face->fontPgmSize > 0 ) + { + error = Goto_CodeRange( exec, TT_CodeRange_Font, 0 ); + if ( error ) + goto Fin; + + error = RunIns( exec ); + } + else + error = TT_Err_Ok; + + Fin: + Context_Save( exec, ins ); + + if ( !ins->debug ) + Done_Context( exec ); + /* debugging instances keep their context */ + + ins->valid = FALSE; + + return error; + } + + +/******************************************************************* + * + * Function : Instance_Reset + * + * Description : Resets an instance to a new pointsize/transform. + * Executes the cvt program if any is found. + * + * Input : _instance the instance object to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Reset( PInstance ins ) + { + PExecution_Context exec; + + TT_Error error; + ULong i; + UShort j; + PFace face; + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( ins->valid ) + return TT_Err_Ok; + + face = ins->owner; + + if ( ins->metrics.x_ppem < 1 || + ins->metrics.y_ppem < 1 ) + return TT_Err_Invalid_PPem; + + /* compute new transformation */ + if ( ins->metrics.x_ppem >= ins->metrics.y_ppem ) + { + ins->metrics.scale1 = ins->metrics.x_scale1; + ins->metrics.scale2 = ins->metrics.x_scale2; + ins->metrics.ppem = ins->metrics.x_ppem; + ins->metrics.x_ratio = 1L << 16; + ins->metrics.y_ratio = TT_MulDiv( ins->metrics.y_ppem, + 0x10000, + ins->metrics.x_ppem ); + } + else + { + ins->metrics.scale1 = ins->metrics.y_scale1; + ins->metrics.scale2 = ins->metrics.y_scale2; + ins->metrics.ppem = ins->metrics.y_ppem; + ins->metrics.x_ratio = TT_MulDiv( ins->metrics.x_ppem, + 0x10000, + ins->metrics.y_ppem ); + ins->metrics.y_ratio = 1L << 16; + } + + /* Scale the cvt values to the new ppem. */ + /* We use by default the y ppem to scale the CVT. */ + + for ( i = 0; i < ins->cvtSize; i++ ) + ins->cvt[i] = TT_MulDiv( face->cvt[i], + ins->metrics.scale1, + ins->metrics.scale2 ); + + /* All twilight points are originally zero */ + for ( j = 0; j < ins->twilight.n_points; j++ ) + { + ins->twilight.org[j].x = 0; + ins->twilight.org[j].y = 0; + ins->twilight.cur[j].x = 0; + ins->twilight.cur[j].y = 0; + } + + /* clear storage area */ + for ( i = 0; i < ins->storeSize; i++ ) + ins->storage[i] = 0; + + ins->GS = Default_GraphicsState; + + /* get execution context and run prep program */ + + if ( ins->debug ) + exec = ins->context; + else + exec = New_Context(face); + /* debugging instances have their own context */ + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + Context_Load( exec, face, ins ); + + Set_CodeRange( exec, + TT_CodeRange_Cvt, + face->cvtProgram, + face->cvtPgmSize ); + + Clear_CodeRange( exec, TT_CodeRange_Glyph ); + + exec->instruction_trap = FALSE; + + exec->top = 0; + exec->callTop = 0; + + if ( face->cvtPgmSize > 0 ) + { + error = Goto_CodeRange( exec, TT_CodeRange_Cvt, 0 ); + if ( error ) + goto Fin; + + if ( !ins->debug ) + error = RunIns( exec ); + } + else + error = TT_Err_Ok; + + ins->GS = exec->GS; + /* save default graphics state */ + + Fin: + Context_Save( exec, ins ); + + if ( !ins->debug ) + Done_Context( exec ); + /* debugging instances keep their context */ + + if ( !error ) + ins->valid = TRUE; + + return error; + } + + + +/******************************************************************* + * * + * FACE FUNCTIONS * + * * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Face_Destroy + * + * Description : The face object destructor. + * + * Input : _face typeless pointer to the face object to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Face_Destroy( void* _face ) + { + PFace face = (PFace)_face; + UShort n; + + + if ( !face ) + return TT_Err_Ok; + + /* well, we assume that no other thread is using the face */ + /* at this moment, but one is never sure enough. */ + MUTEX_Lock( face->lock ); + + /* first of all, destroys the cached sub-objects */ + Cache_Destroy( &face->instances ); + Cache_Destroy( &face->glyphs ); + + /* destroy the extensions */ +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + Extension_Destroy( face ); +#endif + + /* freeing the collection table */ + FREE( face->ttcHeader.TableDirectory ); + face->ttcHeader.DirCount = 0; + + /* freeing table directory */ + FREE( face->dirTables ); + face->numTables = 0; + + /* freeing the locations table */ + FREE( face->glyphLocations ); + face->numLocations = 0; + + /* freeing the character mapping tables */ + for ( n = 0; n < face->numCMaps; n++ ) + CharMap_Free( face->cMaps + n ); + + FREE( face->cMaps ); + face->numCMaps = 0; + + /* freeing the CVT */ + FREE( face->cvt ); + face->cvtSize = 0; + + /* freeing the horizontal metrics */ + FREE( face->horizontalHeader.long_metrics ); + FREE( face->horizontalHeader.short_metrics ); + + /* freeing the vertical ones, if any */ + if (face->verticalInfo) + { + FREE( face->verticalHeader.long_metrics ); + FREE( face->verticalHeader.short_metrics ); + face->verticalInfo = 0; + } + + /* freeing the programs */ + FREE( face->fontProgram ); + FREE( face->cvtProgram ); + face->fontPgmSize = 0; + face->cvtPgmSize = 0; + + /* freeing the gasp table */ + FREE( face->gasp.gaspRanges ); + face->gasp.numRanges = 0; + + /* freeing the name table */ + Free_TrueType_Names( face ); + + /* freeing the hdmx table */ + Free_TrueType_Hdmx( face ); + + /* TT_Close_Stream( &face->stream ); -- this is performed by the API */ + + /* destroy the mutex */ + MUTEX_Destroy(face->lock); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Face_Create + * + * Description : The face object constructor. + * + * Input : _face face record to build + * _input input stream where to load font data + * + * Output : Error code. + * + * NOTE : The input stream is kept in the face object. The + * caller shouldn't destroy it after calling Face_Create(). + * + ******************************************************************/ + +#undef LOAD_ +#define LOAD_( table ) \ + (error = Load_TrueType_##table (face)) != TT_Err_Ok + + + /* LOCAL_FUNC */ + TT_Error Face_Create( void* _face, + void* _input ) + { + PEngine_Instance engine; + + TFont_Input* input = (TFont_Input*)_input; + PFace face = (PFace)_face; + TT_Error error; + + + face->stream = input->stream; + face->engine = input->engine; + + engine = face->engine; + + MUTEX_Create( face->lock ); + + Cache_Create( engine, + engine->objs_instance_class, + &face->instances, + &face->lock ); + + Cache_Create( engine, + engine->objs_glyph_class, + &face->glyphs, + &face->lock ); + + /* Load collection directory if present, then font directory */ + + error = Load_TrueType_Directory( face, input->fontIndex ); + if ( error ) + goto Fail; + + /* Load tables */ + + if ( LOAD_( Header ) || + LOAD_( MaxProfile ) || + LOAD_( Locations ) || + + (error = Load_TrueType_Metrics_Header( face, 0 )) != TT_Err_Ok || + /* load the 'hhea' & 'hmtx' tables at once */ + + LOAD_( CMap ) || + LOAD_( CVT ) || + LOAD_( Programs ) || + LOAD_( Gasp ) || + LOAD_( Names ) || + LOAD_( OS2 ) || + LOAD_( PostScript ) || + + (error = Load_TrueType_Metrics_Header( face, 1 )) != TT_Err_Ok || + /* try to load the 'vhea' & 'vmtx' at once if present */ + + LOAD_( Hdmx ) ) + + goto Fail; + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + if ( ( error = Extension_Create( face ) ) != TT_Err_Ok ) + return error; +#endif + + return TT_Err_Ok; + + Fail : + Face_Destroy( face ); + return error; + } + +#undef LOAD_ + + +/******************************************************************* + * + * Function : Glyph_Destroy + * + * Description : The glyph object destructor. + * + * Input : _glyph typeless pointer to the glyph record to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Glyph_Destroy( void* _glyph ) + { + PGlyph glyph = (PGlyph)_glyph; + + + if ( !glyph ) + return TT_Err_Ok; + + glyph->outline.owner = TRUE; + return TT_Done_Outline( &glyph->outline ); + } + + +/******************************************************************* + * + * Function : Glyph_Create + * + * Description : The glyph object constructor. + * + * Input : _glyph glyph record to build. + * _face the glyph's parent face. + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Glyph_Create( void* _glyph, + void* _face ) + { + PFace face = (PFace)_face; + PGlyph glyph = (PGlyph)_glyph; + + + if ( !face ) + return TT_Err_Invalid_Face_Handle; + + if ( !glyph ) + return TT_Err_Invalid_Glyph_Handle; + + glyph->face = face; + + /* XXX: Don't forget the space for the 2 phantom points */ + return TT_New_Outline( glyph->face->maxPoints + 2, + glyph->face->maxContours, + &glyph->outline ); + } + + +/******************************************************************* + * + * Function : Scale_X + * + * Description : scale an horizontal distance from font + * units to 26.6 pixels + * + * Input : metrics pointer to metrics + * x value to scale + * + * Output : scaled value + * + ******************************************************************/ + + LOCAL_FUNC + TT_Pos Scale_X( PIns_Metrics metrics, TT_Pos x ) + { + return TT_MulDiv( x, metrics->x_scale1, metrics->x_scale2 ); + } + + +/******************************************************************* + * + * Function : Scale_Y + * + * Description : scale a vertical distance from font + * units to 26.6 pixels + * + * Input : metrics pointer to metrics + * y value to scale + * + * Output : scaled value + * + ******************************************************************/ + + LOCAL_FUNC + TT_Pos Scale_Y( PIns_Metrics metrics, TT_Pos y ) + { + return TT_MulDiv( y, metrics->y_scale1, metrics->y_scale2 ); + } + + +/******************************************************************* + * + * Function : TTObjs_Init + * + * Description : The TTObjs component initializer. Creates the + * object cache classes, as well as the face record + * cache. + * + * Input : engine engine instance + * + * Output : Error code. + * + ******************************************************************/ + + static + const TCache_Class objs_face_class = + { + sizeof ( TFace ), + -1, + Face_Create, + Face_Destroy, + NULL, + NULL + }; + + static + const TCache_Class objs_instance_class = + { + sizeof ( TInstance ), + -1, + Instance_Create, + Instance_Destroy, + NULL, + NULL + }; + + /* Note that we use a cache size of 1 for the execution context. */ + /* This is to avoid re-creating a new context each time we */ + /* change one instance's attribute (resolution and/or char sizes) */ + /* or when we load a glyph. */ + + static + const TCache_Class objs_exec_class = + { + sizeof ( TExecution_Context ), + 1, + Context_Create, + Context_Destroy, + NULL, + NULL + }; + + static + const TCache_Class objs_glyph_class = + { + sizeof ( TGlyph ), + -1, + Glyph_Create, + Glyph_Destroy, + NULL, + NULL + }; + + LOCAL_FUNC + TT_Error TTObjs_Init( PEngine_Instance engine ) + { + PCache face_cache, exec_cache; + TT_Error error; + + face_cache = 0; + exec_cache = 0; + + if ( ALLOC( face_cache, sizeof ( TCache ) ) || + ALLOC( exec_cache, sizeof ( TCache ) ) ) + goto Fail; + + /* create face cache */ + error = Cache_Create( engine, (PCache_Class)&objs_face_class, + face_cache, &engine->lock ); + + if ( error ) + goto Fail; + + engine->objs_face_cache = face_cache; + + error = Cache_Create( engine, (PCache_Class)&objs_exec_class, + exec_cache, &engine->lock ); + if ( error ) + goto Fail; + + engine->objs_exec_cache = exec_cache; + + engine->objs_face_class = (PCache_Class)&objs_face_class; + engine->objs_instance_class = (PCache_Class)&objs_instance_class; + engine->objs_execution_class = (PCache_Class)&objs_exec_class; + engine->objs_glyph_class = (PCache_Class)&objs_glyph_class; + + goto Exit; + + Fail: + FREE( face_cache ); + FREE( exec_cache ); + + Exit: + return error; + } + + +/******************************************************************* + * + * Function : TTObjs_Done + * + * Description : The TTObjs component finalizer. + * + * Input : engine engine instance + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTObjs_Done( PEngine_Instance engine ) + { + /* destroy all active faces and contexts before releasing the */ + /* caches */ + Cache_Destroy( (TCache*)engine->objs_exec_cache ); + Cache_Destroy( (TCache*)engine->objs_face_cache ); + + /* Now frees caches and cache classes */ + FREE( engine->objs_exec_cache ); + FREE( engine->objs_face_cache ); + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h new file mode 100644 index 000000000..2414c9fcf --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -0,0 +1,873 @@ +/******************************************************************* + * + * ttobjs.h 1.0 + * + * Objects definition unit. + * + * 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 TTOBJS_H +#define TTOBJS_H + +#include "ttconfig.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttcache.h" +#include "tttables.h" +#include "ttcmap.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* */ +/* This file contains the definitions and methods of the four */ +/* kinds of objects managed by the FreeType engine. These are: */ +/* */ +/* */ +/* Face objects: */ +/* */ +/* There is always one face object per opened TrueType font */ +/* file, and only one. The face object contains data that is */ +/* independent of current transform/scaling/rotation and */ +/* pointsize, or glyph index. This data is made of several */ +/* critical tables that are loaded on face object creation. */ +/* */ +/* A face object tracks all active and recycled objects of */ +/* the instance and execution context classes. Destroying a face */ +/* object will automatically destroy all associated instances. */ +/* */ +/* */ +/* Instance objects: */ +/* */ +/* An instance object always relates to a given face object, */ +/* known as its 'parent' or 'owner', and contains only the */ +/* data that is specific to one given pointsize/transform of */ +/* the face. You can only create an instance from a face object. */ +/* */ +/* An instance's current transform/pointsize can be changed */ +/* at any time using a single high-level API call, */ +/* TT_Reset_Instance(). */ +/* */ +/* Execution Context objects: */ +/* */ +/* An execution context (or context in short) relates to a face. */ +/* It contains the data and tables that are necessary to load */ +/* and hint (i.e. execute the glyph instructions of) one glyph. */ +/* A context is a transient object that is queried/created on */ +/* the fly: client applications never deal with them directly. */ +/* */ +/* */ +/* Glyph objects: */ +/* */ +/* A glyph object contains only the minimal glyph information */ +/* needed to render one glyph correctly. This means that a glyph */ +/* object really contains tables that are sized to hold the */ +/* contents of _any_ glyph of a given face. A client application */ +/* can usually create one glyph object for a given face, then use */ +/* it for all subsequent loads. */ +/* */ +/* Here is an example of a client application : */ +/* (NOTE: No error checking performed here!) */ +/* */ +/* */ +/* TT_Face face; -- face handle */ +/* TT_Instance ins1, ins2; -- two instance handles */ +/* TT_Glyph glyph; -- glyph handle */ +/* */ +/* TT_Init_FreeType(); */ +/* */ +/* -- Initialize the engine. This must be done prior to _any_ */ +/* operation. */ +/* */ +/* TT_Open_Face( "/some/face/name.ttf", &face ); */ +/* */ +/* -- create the face object. This call opens the font file */ +/* */ +/* TT_New_Instance( face, &ins1 ); */ +/* TT_New_Instance( face, &ins2 ); */ +/* */ +/* TT_Set_Instance_PointSize( ins1, 8 ); */ +/* TT_Set_Instance_PointSize( ins2, 12 ); */ +/* */ +/* -- create two distinct instances of the same face */ +/* -- ins1 is pointsize 8 at resolution 96 dpi */ +/* -- ins2 is pointsize 12 at resolution 96 dpi */ +/* */ +/* TT_New_Glyph( face, &glyph ); */ +/* */ +/* -- create a new glyph object which will receive the contents */ +/* of any glyph of 'face' */ +/* */ +/* TT_Load_Glyph( ins1, glyph, 64, DEFAULT_GLYPH_LOAD ); */ +/* */ +/* -- load glyph indexed 64 at pointsize 8 in the 'glyph' object */ +/* -- NOTE: This call will fail if the instance and the glyph */ +/* do not relate to the same face object. */ +/* */ +/* TT_Get_Outline( glyph, &outline ); */ +/* */ +/* -- extract the glyph outline from the object and copies it */ +/* to the 'outline' record */ +/* */ +/* TT_Get_Metrics( glyph, &metrics ); */ +/* */ +/* -- extract the glyph metrics and put them into the 'metrics' */ +/* record */ +/* */ +/* TT_Load_Glyph( ins2, glyph, 64, DEFAULT_GLYPH_LOAD ); */ +/* */ +/* -- load the same glyph at pointsize 12 in the 'glyph' object */ +/* */ +/* */ +/* TT_Close_Face( &face ); */ +/* */ +/* -- destroy the face object. This will destroy 'ins1' and */ +/* 'ins2'. However, the glyph object will still be available */ +/* */ +/* TT_Done_FreeType(); */ +/* */ +/* -- Finalize the engine. This will also destroy all pending */ +/* glyph objects (here 'glyph'). */ + + struct TFace_; + struct TInstance_; + struct TExecution_Context_; + struct TGlyph_; + + typedef struct TFace_ TFace; + typedef TFace* PFace; + + typedef struct TInstance_ TInstance; + typedef TInstance* PInstance; + + typedef struct TExecution_Context_ TExecution_Context; + typedef TExecution_Context* PExecution_Context; + + typedef struct TGlyph_ TGlyph; + typedef TGlyph* PGlyph; + + + /*************************************************************/ + /* */ + /* ADDITIONAL SUBTABLES */ + /* */ + /* These tables are not precisely defined by the specs */ + /* but their structures is implied by the TrueType font */ + /* file layout. */ + /* */ + /*************************************************************/ + + /* Graphics State */ + /* */ + /* The Graphics State (GS) is managed by the */ + /* instruction field, but does not come from */ + /* the font file. Thus, we can use 'int's */ + /* where needed. */ + + struct TGraphicsState_ + { + UShort rp0; + UShort rp1; + UShort rp2; + + TT_UnitVector dualVector; + TT_UnitVector projVector; + TT_UnitVector freeVector; + + Long loop; + TT_F26Dot6 minimum_distance; + Int round_state; + + Bool auto_flip; + TT_F26Dot6 control_value_cutin; + TT_F26Dot6 single_width_cutin; + TT_F26Dot6 single_width_value; + Short delta_base; + Short delta_shift; + + Byte instruct_control; + Bool scan_control; + Int scan_type; + + UShort gep0; + UShort gep1; + UShort gep2; + }; + + typedef struct TGraphicsState_ TGraphicsState; + + + LOCAL_DEF + const TGraphicsState Default_GraphicsState; + + + /*************************************************************/ + /* */ + /* EXECUTION SUBTABLES */ + /* */ + /* These sub-tables relate to instruction execution. */ + /* */ + /*************************************************************/ + +#define MAX_CODE_RANGES 3 + +/* There can only be 3 active code ranges at once: */ +/* - the Font Program */ +/* - the CVT Program */ +/* - a glyph's instructions set */ + +#define TT_CodeRange_Font 1 +#define TT_CodeRange_Cvt 2 +#define TT_CodeRange_Glyph 3 + + + struct TCodeRange_ + { + PByte Base; + ULong Size; + }; + + typedef struct TCodeRange_ TCodeRange; + typedef TCodeRange* PCodeRange; + + + /* Defintion of a code range */ + /* */ + /* Code ranges can be resident to a glyph (i.e. the Font Program) */ + /* while some others are volatile (Glyph instructions). */ + /* Tracking the state and presence of code ranges allows function */ + /* and instruction definitions within a code range to be forgotten */ + /* when the range is discarded. */ + + typedef TCodeRange TCodeRangeTable[MAX_CODE_RANGES]; + + /* defines a function/instruction definition record */ + + struct TDefRecord_ + { + Int Range; /* in which code range is it located ? */ + ULong Start; /* where does it start ? */ + Int Opc; /* function #, or instruction code */ + Bool Active; /* is it active ? */ + }; + + typedef struct TDefRecord_ TDefRecord; + typedef TDefRecord* PDefRecord; + typedef TDefRecord* PDefArray; + + /* defines a call record, used to manage function calls. */ + + struct TCallRecord_ + { + Int Caller_Range; + ULong Caller_IP; + Long Cur_Count; + ULong Cur_Restart; + }; + + typedef struct TCallRecord_ TCallRecord; + typedef TCallRecord* PCallRecord; + typedef TCallRecord* PCallStack; /* defines a simple call stack */ + + + /* This type defining a set of glyph points will be used to represent */ + /* each zone (regular and twilight) during instructions decoding. */ + struct TGlyph_Zone_ + { + UShort n_points; /* number of points in zone */ + Short n_contours; /* number of contours */ + + TT_Vector* org; /* original points coordinates */ + TT_Vector* cur; /* current points coordinates */ + + Byte* touch; /* current touch flags */ + UShort* contours; /* contour end points */ + }; + + typedef struct TGlyph_Zone_ TGlyph_Zone; + typedef TGlyph_Zone* PGlyph_Zone; + + + +#ifndef TT_STATIC_INTEPRETER /* indirect implementation */ + +#define EXEC_OPS PExecution_Context exc, +#define EXEC_OP PExecution_Context exc +#define EXEC_ARGS exc, +#define EXEC_ARG exc + +#else /* static implementation */ + +#define EXEC_OPS /* void */ +#define EXEC_OP /* void */ +#define EXEC_ARGS /* void */ +#define EXEC_ARG /* void */ + +#endif + + /* Rounding function, as used by the interpreter */ + typedef TT_F26Dot6 (*TRound_Function)( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ); + + /* Point displacement along the freedom vector routine, as */ + /* used by the interpreter */ + typedef void (*TMove_Function)( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ); + + /* Distance projection along one of the proj. vectors, as used */ + /* by the interpreter */ + typedef TT_F26Dot6 (*TProject_Function)( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ); + + /* reading a cvt value. Take care of non-square pixels when needed */ + typedef TT_F26Dot6 (*TGet_CVT_Function)( EXEC_OPS ULong index ); + + /* setting or moving a cvt value. Take care of non-square pixels */ + /* when needed */ + typedef void (*TSet_CVT_Function)( EXEC_OPS ULong index, + TT_F26Dot6 value ); + + /* subglyph transformation record */ + struct TTransform_ + { + TT_Fixed xx, xy; /* transformation */ + TT_Fixed yx, yy; /* matrix */ + TT_F26Dot6 ox, oy; /* offsets */ + }; + + typedef struct TTransform_ TTransform; + typedef TTransform* PTransform; + + /* subglyph loading record. Used to load composite components */ + struct TSubglyph_Record_ + { + Long index; /* subglyph index; initialized with -1 */ + Bool is_scaled; /* is the subglyph scaled? */ + Bool is_hinted; /* should it be hinted? */ + Bool preserve_pps; /* preserve phantom points? */ + + Long file_offset; + + TT_Big_Glyph_Metrics metrics; + + TGlyph_Zone zone; + + Long arg1; /* first argument */ + Long arg2; /* second argument */ + + UShort element_flag; /* current load element flag */ + + TTransform transform; /* transform */ + + TT_Vector pp1, pp2; /* phantom points */ + + }; + + typedef struct TSubglyph_Record_ TSubglyph_Record; + typedef TSubglyph_Record* PSubglyph_Record; + typedef TSubglyph_Record* PSubglyph_Stack; + + /* A note regarding non-squared pixels: */ + /* */ + /* (This text will probably go into some docs at some time, for */ + /* now, it is kept there to explain some definitions in the */ + /* TIns_Metrics record). */ + /* */ + /* The CVT is a one-dimensional array containing values that */ + /* control certain important characteristics in a font, like */ + /* the height of all capitals, all lowercase letter, default */ + /* spacing or stem width/height. */ + /* */ + /* These values are found in FUnits in the font file, and must be */ + /* scaled to pixel coordinates before being used by the CVT and */ + /* glyph programs. Unfortunately, when using distinct x and y */ + /* resolutions (or distinct x and y pointsizes), there are two */ + /* possible scalings. */ + /* */ + /* A first try was to implement a 'lazy' scheme where all values */ + /* were scaled when first used. However, while some values are always */ + /* used in the same direction, and some other are used in many */ + /* different circumstances and orientations. */ + /* */ + /* I have found a simpler way to do the same, and it even seems to */ + /* work in most of the cases: */ + /* */ + /* - all CVT values are scaled to the maximum ppem size */ + /* */ + /* - when performing a read or write in the CVT, a ratio factor */ + /* is used to perform adequate scaling. Example: */ + /* */ + /* x_ppem = 14 */ + /* y_ppem = 10 */ + /* */ + /* we choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */ + /* entries are scaled to it. */ + /* */ + /* x_ratio = 1.0 */ + /* y_ratio = y_ppem/ppem (< 1.0) */ + /* */ + /* we compute the current ratio like: */ + /* */ + /* - if projVector is horizontal, */ + /* ratio = x_ratio = 1.0 */ + /* - if projVector is vertical, */ + /* ratop = y_ratio */ + /* - else, */ + /* ratio = sqrt((proj.x*x_ratio)^2 + (proj.y*y_ratio)^2) */ + /* */ + /* reading a cvt value returns ratio * cvt[index] */ + /* writing a cvt value in pixels cvt[index] / ratio */ + /* */ + /* the current ppem is simply ratio * ppem */ + /* */ + + /* metrics used by the instance and execution context objects */ + struct TIns_Metrics_ + { + TT_F26Dot6 pointSize; /* point size. 1 point = 1/72 inch. */ + + UShort x_resolution; /* device horizontal resolution in dpi. */ + UShort y_resolution; /* device vertical resolution in dpi. */ + + UShort x_ppem; /* horizontal pixels per EM */ + UShort y_ppem; /* vertical pixels per EM */ + + Long x_scale1; + Long x_scale2; /* used to scale FUnits to fractional pixels */ + + Long y_scale1; + Long y_scale2; /* used to scale FUnits to fractional pixels */ + + /* for non-square pixels */ + Long x_ratio; + Long y_ratio; + + UShort ppem; /* maximum ppem size */ + Long ratio; /* current ratio */ + Long scale1; + Long scale2; /* scale for ppem */ + + TT_F26Dot6 compensations[4]; /* device-specific compensations */ + + Bool rotated; /* `is the glyph rotated?'-flag */ + Bool stretched; /* `is the glyph stretched?'-flag */ + }; + + typedef struct TIns_Metrics_ TIns_Metrics; + typedef TIns_Metrics* PIns_Metrics; + + + + /***********************************************************************/ + /* */ + /* FreeType Face Type */ + /* */ + /***********************************************************************/ + + struct TFace_ + { + /* parent engine instance for the face object */ + PEngine_Instance engine; + + /* i/o stream */ + TT_Stream stream; + + /* used only by the threaded builds of the library */ + TMutex lock; + + /* TrueType collection header, if any was found */ + TTTCHeader ttcHeader; + + /* maximum profile table, as found in the TrueType file */ + TMaxProfile maxProfile; + + /* Note: */ + /* it seems that some maximum values cannot be */ + /* taken directly from this table, but rather by */ + /* combining some of its fields; e.g. the max. */ + /* number of points seems to be given by */ + /* MAX( maxPoints, maxCompositePoints ) */ + /* */ + /* For this reason, we define later our own */ + /* max values that are used to load and allocate */ + /* further tables. */ + + TT_Header fontHeader; /* the font header, as */ + /* found in the TTF file */ + TT_Horizontal_Header horizontalHeader; /* the horizontal header */ + + Bool verticalInfo; /* True when vertical table */ + TT_Vertical_Header verticalHeader; /* is present in the font */ + + TT_OS2 os2; /* 'OS/2' table */ + + TT_Postscript postscript; /* 'Post' table */ + + TT_Hdmx hdmx; /* 'Hdmx' table */ + + TName_Table nameTable; /* name table */ + + TGasp gasp; /* the 'gasp' table */ + + /* The directory of TrueType tables for this typeface */ + UShort numTables; + PTableDirEntry dirTables; + + /* The directory of character mappings table for */ + /* this typeface */ + UShort numCMaps; + PCMapTable cMaps; + + /* The glyph locations table */ + ULong numLocations; /* UShort is not enough */ +#ifndef TT_HUGE_PTR + PStorage glyphLocations; +#else + Storage TT_HUGE_PTR * glyphLocations; +#endif + + /* NOTE : The "hmtx" is now part of the horizontal header */ + + /* the font program, if any */ + ULong fontPgmSize; + PByte fontProgram; + + /* the cvt program, if any */ + ULong cvtPgmSize; + PByte cvtProgram; + + /* the original, unscaled, control value table */ + ULong cvtSize; + PShort cvt; + + /* The following values _must_ be set by the */ + /* maximum profile loader */ + + UShort numGlyphs; /* the face's total number of glyphs */ + UShort maxPoints; /* max glyph points number, simple and composite */ + UShort maxContours; /* max glyph contours numb, simple and composite */ + UShort maxComponents; /* max components in a composite glyph */ + + /* the following are object caches to track active */ + /* and recycled instances and execution contexts */ + /* objects. See 'ttcache.h' */ + + TCache instances; /* current instances for this face */ + TCache glyphs; /* current glyph containers for this face */ + + + /* A typeless pointer to the face object extensions defined */ + /* in the 'ttextend.*' files. */ + void* extension; + Int n_extensions; /* number of extensions */ + + /* Use extensions to provide additional capabilities to the */ + /* engine. Read the developer's guide in the documentation */ + /* directory to know how to do that. */ + + /* a generic pointer for client use - see TT_Set/Get_Face_Pointer */ + void* generic; + }; + + + + /***********************************************************************/ + /* */ + /* FreeType Instance Type */ + /* */ + /***********************************************************************/ + + struct TInstance_ + { + PFace owner; /* face object */ + + Bool valid; + + TIns_Metrics metrics; + + UShort numFDefs; /* number of function definitions */ + UShort maxFDefs; + PDefArray FDefs; /* table of FDefs entries */ + + UShort numIDefs; /* number of instruction definitions */ + UShort maxIDefs; + PDefArray IDefs; /* table of IDefs entries */ + + Int maxFunc; /* maximum function definition id */ + Int maxIns; /* maximum instruction definition id */ + + TCodeRangeTable codeRangeTable; + + TGraphicsState GS; + TGraphicsState default_GS; + + ULong cvtSize; /* the scaled control value table */ + PLong cvt; + + ULong storeSize; /* The storage area is now part of the */ + PLong storage; /* instance */ + + TGlyph_Zone twilight; /* The instance's twilight zone */ + + /* debugging variables */ + + /* When using the debugger, we must keep the */ + /* execution context tied to the instance */ + /* object rather than asking it on demand */ + + Bool debug; + PExecution_Context context; + + /* a generic pointer for client use - see TT_Set/Get_Instance_Pointer */ + void* generic; + }; + + + /***********************************************************************/ + /* */ + /* FreeType Execution Context Type */ + /* */ + /***********************************************************************/ + + struct TExecution_Context_ + { + PFace face; + PInstance instance; + + /* instructions state */ + + TT_Error error; /* last execution error */ + + Long top; /* top of exec. stack */ + + ULong stackSize; /* size of exec. stack */ + PStorage stack; /* current exec. stack */ + + Long args; + ULong new_top; /* new top after exec. */ + + TGlyph_Zone zp0, /* zone records */ + zp1, + zp2, + pts, + twilight; + + TIns_Metrics metrics; /* instance metrics */ + + TGraphicsState GS; /* current graphics state */ + + Int curRange; /* current code range number */ + PByte code; /* current code range */ + ULong IP; /* current instruction pointer */ + ULong codeSize; /* size of current range */ + + Byte opcode; /* current opcode */ + Int length; /* length of current opcode */ + + Bool step_ins; /* true if the interpreter must */ + /* increment IP after ins. exec */ + ULong cvtSize; + PLong cvt; + + ULong glyphSize; /* glyph instructions buffer size */ + PByte glyphIns; /* glyph instructions buffer */ + + UShort numFDefs; /* number of function defs */ + UShort maxFDefs; /* maximum number of function defs */ + PDefRecord FDefs; /* table of FDefs entries */ + + UShort numIDefs; /* number of instruction defs */ + UShort maxIDefs; /* maximum number of instruction defs */ + PDefRecord IDefs; /* table of IDefs entries */ + + Int maxFunc; + Int maxIns; + + Int callTop, /* top of call stack during execution */ + callSize; /* size of call stack */ + PCallStack callStack; /* call stack */ + + UShort maxPoints; /* capacity of this context's "pts" */ + UShort maxContours; /* record, expressed in points and */ + /* contours.. */ + + TCodeRangeTable codeRangeTable; /* table of valid coderanges */ + /* useful for the debugger */ + + ULong storeSize; /* size of current storage */ + PLong storage; /* storage area */ + + TT_F26Dot6 period; /* values used for the */ + TT_F26Dot6 phase; /* 'SuperRounding' */ + TT_F26Dot6 threshold; + + /* this seems to be unused */ +#if 0 + Int cur_ppem; /* ppem along the current proj vector */ +#endif + Long scale1; /* scaling values along the current */ + Long scale2; /* projection vector too.. */ + Bool cached_metrics; /* the ppem is computed lazily. used */ + /* to trigger computation when needed */ + + Bool instruction_trap; /* If True, the interpreter will */ + /* exit after each instruction */ + + TGraphicsState default_GS; /* graphics state resulting from */ + /* the prep program */ + Bool is_composite; /* ture if the glyph is composite */ + + Bool pedantic_hinting; /* if true, read and write array */ + /* bounds faults halt the hinting */ + + /* latest interpreter additions */ + + Long F_dot_P; /* dot product of freedom and projection */ + /* vectors */ + TRound_Function func_round; /* current rounding function */ + + TProject_Function func_project, /* current projection function */ + func_dualproj, /* current dual proj. function */ + func_freeProj; /* current freedom proj. func */ + + TMove_Function func_move; /* current point move function */ + + TGet_CVT_Function func_read_cvt; /* read a cvt entry */ + TSet_CVT_Function func_write_cvt; /* write a cvt entry (in pixels) */ + TSet_CVT_Function func_move_cvt; /* incr a cvt entry (in pixels) */ + + ULong loadSize; + PSubglyph_Stack loadStack; /* loading subglyph stack */ + + }; + + + /***********************************************************************/ + /* */ + /* FreeType Glyph Object Type */ + /* */ + /***********************************************************************/ + + struct TGlyph_ + { + PFace face; + TT_Big_Glyph_Metrics metrics; + TT_Outline outline; + }; + + + /* The following type is used to load a font from a collection. */ + /* See Face_Create in ttobjs.c */ + + struct TFont_Input_ + { + TT_Stream stream; /* input stream */ + ULong fontIndex; /* index of font in collection */ + PEngine_Instance engine; /* parent engine instance */ + + }; + + typedef struct TFont_Input_ TFont_Input; + + + /********************************************************************/ + /* */ + /* Code Range Functions */ + /* */ + /********************************************************************/ + + /* Goto a specified coderange */ + LOCAL_DEF + TT_Error Goto_CodeRange( PExecution_Context exec, + Int range, + ULong IP ); + +#if 0 + /* Return a pointer to a given coderange record. */ + /* Used only by the debugger. */ + LOCAL_DEF + PCodeRange Get_CodeRange( PExecution_Context exec, + Int range ); +#endif + + /* Set a given code range properties */ + LOCAL_DEF + TT_Error Set_CodeRange( PExecution_Context exec, + Int range, + void* base, + ULong length ); + + /* Clear a given coderange */ + LOCAL_DEF + TT_Error Clear_CodeRange( PExecution_Context exec, Int range ); + + + LOCAL_DEF + PExecution_Context New_Context( PFace face ); + + LOCAL_DEF + TT_Error Done_Context( PExecution_Context exec ); + + + LOCAL_DEF + TT_Error Context_Load( PExecution_Context exec, + PFace face, + PInstance ins ); + + LOCAL_DEF + TT_Error Context_Save( PExecution_Context exec, + PInstance ins ); + + LOCAL_DEF + TT_Error Context_Run( PExecution_Context exec, + Bool debug ); + + LOCAL_DEF + TT_Error Instance_Init( PInstance ins ); + + LOCAL_DEF + TT_Error Instance_Reset( PInstance ins ); + + + /********************************************************************/ + /* */ + /* Handy scaling functions */ + /* */ + /********************************************************************/ + + LOCAL_DEF TT_Pos Scale_X( PIns_Metrics metrics, TT_Pos x ); + LOCAL_DEF TT_Pos Scale_Y( PIns_Metrics metrics, TT_Pos y ); + + /********************************************************************/ + /* */ + /* Component Initializer/Finalizer */ + /* */ + /* Called from 'freetype.c' */ + /* The component must create and register the face, instance and */ + /* execution context cache classes before any object can be */ + /* managed. */ + /* */ + /********************************************************************/ + + LOCAL_DEF TT_Error TTObjs_Init( PEngine_Instance engine ); + LOCAL_DEF TT_Error TTObjs_Done( PEngine_Instance engine ); + +#ifdef __cplusplus + } +#endif + +#endif /* TTOBJS_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c new file mode 100644 index 000000000..5563b4895 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -0,0 +1,2727 @@ +/******************************************************************* + * + * ttraster.c 1.5 + * + * The FreeType glyph rasterizer (body). + * + * 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. + * + * NOTES: + * + * This version supports the following: + * + * - direct grayscaling + * - sub-banding + * - drop-out modes 4 and 5 + * - second pass for complete drop-out control (bitmap only) + * - variable precision + * + * Changes between 1.5 and 1.4: + * + * Performance tuning. + * + * Changes between 1.4 and 1.3: + * + * Mainly performance tunings: + * + * - Line_Down() and Bezier_Down() now use the functions Line_Up() + * and Bezier_Up() to do their work. + * - optimized Split_Bezier() + * - optimized linked lists used during sweeps + * + ******************************************************************/ + +#include "ttraster.h" +#include "ttdebug.h" +#include "tttypes.h" +#include "ttengine.h" +#include "ttcalc.h" /* for TT_MulDiv only */ + +#include "ttmemory.h" /* only used to allocate memory on engine init */ + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_raster + + +/* The default render pool size */ +#define RASTER_RENDER_POOL 4096 + +/* The size of the two-lines intermediate bitmap used */ +/* for anti-aliasing */ +#define RASTER_GRAY_LINES 2048 + + +#define Raster_Err_None TT_Err_Ok +#define Raster_Err_Not_Ini TT_Err_Raster_Not_Initialized +#define Raster_Err_Overflow TT_Err_Raster_Pool_Overflow +#define Raster_Err_Neg_Height TT_Err_Raster_Negative_Height +#define Raster_Err_Invalid TT_Err_Raster_Invalid_Value +#define Raster_Err_Gray_Unsupported TT_Err_Raster_Gray_Unsupported + + +/* FMulDiv means "Fast MulDiv", it is uses in case where 'b' is typically */ +/* a small value and the result of (a*b) is known to fit in 32 bits. */ +#define FMulDiv( a, b, c ) ( (a) * (b) / (c) ) + +/* On the other hand, SMulDiv is for "Slow MulDiv", and is used typically */ +/* for clipping computations. It simply uses the TT_MulDiv() function */ +/* defined in "ttcalc.h" */ +/* */ +/* So, the following definition fits the bill nicely, and we don't need */ +/* to use the one in 'ttcalc' anymore, even for 16-bit systems... */ +#define SMulDiv TT_MulDiv + + +/* Define DEBUG_RASTER if you want to generate a debug version of the */ +/* rasterizer. This will progressively draw the glyphs while all the */ +/* computation are done directly on the graphics screen (the glyphs */ +/* will be inverted). */ + +/* Note that DEBUG_RASTER should only be used for debugging with b/w */ +/* rendering, not with gray levels. */ + +/* The definition of DEBUG_RASTER should appear in the file */ +/* "ttconfig.h". */ + +#ifdef DEBUG_RASTER + extern Char* Vio; /* A pointer to VRAM or display buffer */ +#endif + + +/* The rasterizer is a very general purpose component, please leave */ +/* the following redefinitions there (you never know your target */ +/* environment). */ + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + +#define MaxBezier 32 /* The maximum number of stacked Bezier curves. */ + /* Setting this constant to more than 32 is a */ + /* pure waste of space. */ + +#define Pixel_Bits 6 /* fractional bits of *input* coordinates */ + + /* States of each line, arc and profile */ + enum TStates_ + { + Unknown, + Ascending, + Descending, + Flat + }; + + typedef enum TStates_ TStates; + + struct TProfile_; + typedef struct TProfile_ TProfile; + typedef TProfile* PProfile; + + struct TProfile_ + { + TT_F26Dot6 X; /* current coordinate during sweep */ + PProfile link; /* link to next profile - various purpose */ + PStorage offset; /* start of profile's data in render pool */ + Int flow; /* Profile orientation: Asc/Descending */ + Long height; /* profile's height in scanlines */ + Long start; /* profile's starting scanline */ + + UShort countL; /* number of lines to step before this */ + /* profile becomes drawable */ + + PProfile next; /* next profile in same contour, used */ + /* during drop-out control */ + }; + + typedef PProfile TProfileList; + typedef PProfile* PProfileList; + + + /* I use the classic trick of two dummy records for the head and tail */ + /* of a linked list; this reduces tests in insertion/deletion/sorting. */ + /* NOTE: used during sweeps only. */ + + /* Simple record used to implement a stack of bands, required */ + /* by the sub-banding mechanism */ + + struct TBand_ + { + Short y_min; /* band's minimum */ + Short y_max; /* band's maximum */ + }; + + typedef struct TBand_ TBand; + + +#define AlignProfileSize \ + (( sizeof(TProfile)+sizeof(long)-1 ) / sizeof(long)) + + + /* Left fill bitmask */ + static const Byte LMask[8] = + { 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01 }; + + /* Right fill bitmask */ + static const Byte RMask[8] = + { 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; + + /* prototypes used for sweep function dispatch */ + typedef void Function_Sweep_Init( RAS_ARGS Short* min, + Short* max ); + + typedef void Function_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ); + + typedef void Function_Sweep_Step( RAS_ARG ); + + +/* NOTE: These operations are only valid on 2's complement processors */ + +#define FLOOR( x ) ( (x) & -ras.precision ) +#define CEILING( x ) ( ((x) + ras.precision - 1) & -ras.precision ) +#define TRUNC( x ) ( (signed long)(x) >> ras.precision_bits ) +#define FRAC( x ) ( (x) & (ras.precision - 1) ) +#define SCALED( x ) ( ((x) << ras.scale_shift) - ras.precision_half ) + +#ifdef DEBUG_RASTER +#define DEBUG_PSET Pset() +#else +#define DEBUG_PSET +#endif + + struct TPoint_ + { + Long x, y; + }; + + typedef struct TPoint_ TPoint; + + + /* Note that I have moved the location of some fields in the */ + /* structure to ensure that the most used variables are used */ + /* at the top. Thus, their offset can be coded with less */ + /* opcodes, and it results in a smaller executable. */ + + struct TRaster_Instance_ + { + Int precision_bits; /* precision related variables */ + Int precision; + Int precision_half; + Long precision_mask; + Int precision_shift; + Int precision_step; + Int precision_jitter; + + Int scale_shift; /* == precision_shift for bitmaps */ + /* == precision_shift+1 for pixmaps */ + + PStorage buff; /* The profiles buffer */ + PStorage sizeBuff; /* Render pool size */ + PStorage maxBuff; /* Profiles buffer size */ + PStorage top; /* Current cursor in buffer */ + + TT_Error error; + + PByte flags; /* current flags table */ + PUShort outs; /* current outlines table */ + + UShort nPoints; /* number of points in current glyph */ + Short nContours; /* number of contours in current glyph */ + Int numTurns; /* number of Y-turns in outline */ + + TPoint* arc; /* current Bezier arc pointer */ + + UShort bWidth; /* target bitmap width */ + PByte bTarget; /* target bitmap buffer */ + PByte gTarget; /* target pixmap buffer */ + + Long lastX, lastY, minY, maxY; + + UShort num_Profs; /* current number of profiles */ + + Bool fresh; /* signals a fresh new profile which */ + /* 'start' field must be completed */ + Bool joint; /* signals that the last arc ended */ + /* exactly on a scanline. Allows */ + /* removal of doublets */ + PProfile cProfile; /* current profile */ + PProfile fProfile; /* head of linked list of profiles */ + PProfile gProfile; /* contour's first profile in case */ + /* of impact */ + TStates state; /* rendering state */ + + TT_Raster_Map target; /* description of target bit/pixmap */ + + Long traceOfs; /* current offset in target bitmap */ + Long traceG; /* current offset in target pixmap */ + + Short traceIncr; /* sweep's increment in target bitmap */ + + Short gray_min_x; /* current min x during gray rendering */ + Short gray_max_x; /* current max x during gray rendering */ + + /* dispatch variables */ + + Function_Sweep_Init* Proc_Sweep_Init; + Function_Sweep_Span* Proc_Sweep_Span; + Function_Sweep_Span* Proc_Sweep_Drop; + Function_Sweep_Step* Proc_Sweep_Step; + + TT_Vector* coords; + + Byte dropOutControl; /* current drop_out control method */ + + Byte grays[5]; /* Palette of gray levels used for render */ + + Byte* gray_lines; /* Intermediate table used to render the */ + /* graylevels pixmaps. */ + /* gray_lines is a buffer holding two */ + /* monochrome scanlines */ + Short gray_width; /* width in bytes of one monochrome */ + /* intermediate scanline of gray_lines. */ + /* Each gray pixel takes 2 bits long there */ + + /* The gray_lines must hold 2 lines, thus with size */ + /* in bytes of at least 'gray_width*2' */ + + Bool second_pass; /* indicates wether a horizontal pass */ + /* should be performed to control drop-out */ + /* accurately when calling Render_Glyph. */ + /* Note that there is no horizontal pass */ + /* during gray rendering. */ + TPoint arcs[2 * MaxBezier + 1]; /* The Bezier stack */ + + TBand band_stack[16]; /* band stack used for sub-banding */ + Int band_top; /* band stack top */ + + Int count_table[256]; /* Look-up table used to quickly count */ + /* set bits in a gray 2x2 cell */ + }; + + +#ifdef TT_CONFIG_OPTION_STATIC_RASTER + + static TRaster_Instance cur_ras; +#define ras cur_ras + +#else + +#define ras (*raster) + +#endif /* TT_STATIC_RASTER */ + + +#ifdef DEBUG_RASTER + + /************************************************/ + /* */ + /* Pset: */ + /* */ + /* Used for debugging only. Plots a point */ + /* in VRAM during rendering (not afterwards). */ + /* */ + /* NOTE: This procedure relies on the value */ + /* of cProfile->start, which may not */ + /* be set when Pset is called sometimes. */ + /* This will usually result in a dot */ + /* plotted on the first screen scanline */ + /* (far away its original position). */ + /* */ + /* This "bug" reflects nothing wrong */ + /* in the current implementation, and */ + /* the bitmap is rendered correctly, */ + /* so don't panic if you see 'flying' */ + /* dots in debugging mode. */ + /* */ + /* - David */ + /* */ + /************************************************/ + + static void Pset( RAS_ARG ) + { + Long o; + Long x; + + + x = ras.top[-1]; + + switch ( ras.cProfile->flow ) + { + case TT_Flow_Up: + o = Vio_ScanLineWidth * + ( ras.top-ras.cProfile->offset + ras.cProfile->start ) + + ( x / (ras.precision*8) ); + break; + + case TT_Flow_Down: + o = Vio_ScanLineWidth * + ( ras.cProfile->start-ras.top + ras.cProfile->offset ) + + ( x / (ras.precision*8) ); + break; + } + + if ( o > 0 ) + Vio[o] |= (unsigned)0x80 >> ( (x/ras.precision) & 7 ); + } + + + static void Clear_Band( RAS_ARGS Int y1, Int y2 ) + { + MEM_Set( Vio + y1*Vio_ScanLineWidth, (y2-y1+1)*Vio_ScanLineWidth, 0 ); + } + +#endif /* DEBUG_RASTER */ + + +/************************************************************************/ +/* */ +/* Function: Set_High_Precision */ +/* */ +/* Description: Sets precision variables according to param flag. */ +/* */ +/* Input: High set to True for high precision (typically for */ +/* ppem < 18), false otherwise. */ +/* */ +/************************************************************************/ + + static void Set_High_Precision( RAS_ARGS Bool High ) + { + if ( High ) + { + ras.precision_bits = 10; + ras.precision_step = 128; + ras.precision_jitter = 24; + } + else + { + ras.precision_bits = 6; + ras.precision_step = 32; + ras.precision_jitter = 2; + } + + PTRACE7(( "Set_High_Precision(%s)\n", High ? "true" : "false" )); + + ras.precision = 1 << ras.precision_bits; + ras.precision_half = ras.precision / 2; + ras.precision_shift = ras.precision_bits - Pixel_Bits; + ras.precision_mask = -ras.precision; + } + + +/****************************************************************************/ +/* */ +/* Function: New_Profile */ +/* */ +/* Description: Creates a new Profile in the render pool. */ +/* */ +/* Input: aState state/orientation of the new Profile */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE in case of overflow or of incoherent Profile. */ +/* */ +/****************************************************************************/ + + static Bool New_Profile( RAS_ARGS TStates aState ) + { + if ( !ras.fProfile ) + { + ras.cProfile = (PProfile)ras.top; + ras.fProfile = ras.cProfile; + ras.top += AlignProfileSize; + } + + if ( ras.top >= ras.maxBuff ) + { + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + switch ( aState ) + { + case Ascending: + ras.cProfile->flow = TT_Flow_Up; + PTRACE7(( "New ascending profile = %lx\n", (long)ras.cProfile )); + break; + + case Descending: + ras.cProfile->flow = TT_Flow_Down; + PTRACE7(( "New descending profile = %lx\n", (long)ras.cProfile )); + break; + + default: + PTRACE0(( "Invalid profile direction in Raster:New_Profile !!\n" )); + ras.error = Raster_Err_Invalid; + return FAILURE; + } + + ras.cProfile->start = 0; + ras.cProfile->height = 0; + ras.cProfile->offset = ras.top; + ras.cProfile->link = (PProfile)0; + ras.cProfile->next = (PProfile)0; + + if ( !ras.gProfile ) + ras.gProfile = ras.cProfile; + + ras.state = aState; + ras.fresh = TRUE; + ras.joint = FALSE; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: End_Profile */ +/* */ +/* Description: Finalizes the current Profile. */ +/* */ +/* Input: None */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE in case of overflow or incoherency. */ +/* */ +/****************************************************************************/ + + static Bool End_Profile( RAS_ARG ) + { + Long h; + PProfile oldProfile; + + + h = ras.top - ras.cProfile->offset; + + if ( h < 0 ) + { + PTRACE0(( "Negative height encountered in End_Profile!\n" )); + ras.error = Raster_Err_Neg_Height; + return FAILURE; + } + + if ( h > 0 ) + { + PTRACE1(( "Ending profile %lx, start = %ld, height = %ld\n", + (long)ras.cProfile, ras.cProfile->start, h )); + + oldProfile = ras.cProfile; + ras.cProfile->height = h; + ras.cProfile = (PProfile)ras.top; + + ras.top += AlignProfileSize; + + ras.cProfile->height = 0; + ras.cProfile->offset = ras.top; + oldProfile->next = ras.cProfile; + ras.num_Profs++; + } + + if ( ras.top >= ras.maxBuff ) + { + PTRACE1(( "overflow in End_Profile\n" )); + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + ras.joint = FALSE; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Insert_Y_Turn */ +/* */ +/* Description: Insert a salient into the sorted list placed on top */ +/* of the render pool */ +/* */ +/* Input: New y scanline position */ +/* */ +/****************************************************************************/ + + static + Bool Insert_Y_Turn( RAS_ARGS Int y ) + { + PStorage y_turns; + Int y2, n; + + n = ras.numTurns-1; + y_turns = ras.sizeBuff - ras.numTurns; + + /* look for first y value that is <= */ + while ( n >= 0 && y < y_turns[n] ) + n--; + + /* if it is <, simply insert it, ignore if == */ + if ( n >= 0 && y > y_turns[n] ) + while ( n >= 0 ) + { + y2 = y_turns[n]; + y_turns[n] = y; + y = y2; + n--; + } + + if ( n < 0 ) + { + if (ras.maxBuff <= ras.top) + { + ras.error = Raster_Err_Overflow; + return FAILURE; + } + ras.maxBuff--; + ras.numTurns++; + ras.sizeBuff[-ras.numTurns] = y; + } + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Finalize_Profile_Table */ +/* */ +/* Description: Adjusts all links in the Profiles list. */ +/* */ +/* Input: None */ +/* */ +/* Returns: None. */ +/* */ +/****************************************************************************/ + + static + Bool Finalize_Profile_Table( RAS_ARG ) + { + Int bottom, top; + UShort n; + PProfile p; + + + n = ras.num_Profs; + + if ( n > 1 ) + { + p = ras.fProfile; + while ( n > 0 ) + { + if ( n > 1 ) + p->link = (PProfile)( p->offset + p->height ); + else + p->link = NULL; + + switch ( p->flow ) + { + case TT_Flow_Down: + bottom = p->start - p->height+1; + top = p->start; + p->start = bottom; + p->offset += p->height-1; + break; + + case TT_Flow_Up: + default: + bottom = p->start; + top = p->start + p->height-1; + } + + if ( Insert_Y_Turn( RAS_VARS bottom ) || + Insert_Y_Turn( RAS_VARS top+1 ) ) + return FAILURE; + + p = p->link; + n--; + } + } + else + ras.fProfile = NULL; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Split_Bezier */ +/* */ +/* Description: Subdivides one Bezier arc into two joint */ +/* sub-arcs in the Bezier stack. */ +/* */ +/* Input: None (subdivided bezier is taken from the top of the */ +/* stack). */ +/* */ +/* Returns: None. */ +/* */ +/* */ +/* Note: This routine is the 'beef' of this component. It is _the_ */ +/* inner loop that should be optimized to hell to get the */ +/* best performance. */ +/* */ +/****************************************************************************/ + + static void Split_Bezier( TPoint* base ) + { + Long a, b; + + + base[4].x = base[2].x; + b = base[1].x; + a = base[3].x = ( base[2].x + b ) / 2; + b = base[1].x = ( base[0].x + b ) / 2; + base[2].x = ( a + b ) / 2; + + base[4].y = base[2].y; + b = base[1].y; + a = base[3].y = ( base[2].y + b ) / 2; + b = base[1].y = ( base[0].y + b ) / 2; + base[2].y = ( a + b ) / 2; + + /* hand optimized. gcc doesn't seem too good at common expression */ + /* substitution and instruction scheduling ;-) */ + } + + +/****************************************************************************/ +/* */ +/* Function: Push_Bezier */ +/* */ +/* Description: Clears the Bezier stack and pushes a new arc on top of it. */ +/* */ +/* Input: x1,y1 x2,y2 x3,y3 new Bezier arc */ +/* */ +/* Returns: None. */ +/* */ +/****************************************************************************/ + + static void Push_Bezier( RAS_ARGS Long x1, Long y1, + Long x2, Long y2, + Long x3, Long y3 ) + { + ras.arc = ras.arcs; + ras.arc[2].x = x1; ras.arc[2].y = y1; + ras.arc[1].x = x2; ras.arc[1].y = y2; + ras.arc[0].x = x3; ras.arc[0].y = y3; + } + + +/****************************************************************************/ +/* */ +/* Function: Line_Up */ +/* */ +/* Description: Computes the x-coordinates of an ascending line segment */ +/* and stores them in the render pool. */ +/* */ +/* Input: x1,y1,x2,y2 Segment start (x1,y1) and end (x2,y2) points */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow. */ +/* */ +/****************************************************************************/ + + static Bool Line_Up( RAS_ARGS Long x1, Long y1, + Long x2, Long y2, + Long miny, Long maxy ) + { + Long Dx, Dy; + Int e1, e2, f1, f2, size; /* XXX: is `Short' sufficient? */ + Long Ix, Rx, Ax; + + PStorage top; + + + Dx = x2 - x1; + Dy = y2 - y1; + + if ( Dy <= 0 || y2 < miny || y1 > maxy ) + return SUCCESS; + + if ( y1 < miny ) + { + /* Take care : miny-y1 can be a very large value, we use */ + /* a slow MulDiv function to avoid clipping bugs */ + x1 += SMulDiv( Dx, miny - y1, Dy ); + e1 = TRUNC( miny ); + f1 = 0; + } + else + { + e1 = TRUNC( y1 ); + f1 = FRAC( y1 ); + } + + if ( y2 > maxy ) + { + /* x2 += FMulDiv( Dx, maxy - y2, Dy ); UNNECESSARY */ + e2 = TRUNC( maxy ); + f2 = 0; + } + else + { + e2 = TRUNC( y2 ); + f2 = FRAC( y2 ); + } + + if ( f1 > 0 ) + { + if ( e1 == e2 ) return SUCCESS; + else + { + x1 += FMulDiv( Dx, ras.precision - f1, Dy ); + e1 += 1; + } + } + else + if ( ras.joint ) + { + ras.top--; + ras.joint = FALSE; + } + + ras.joint = ( f2 == 0 ); + + if ( ras.fresh ) + { + ras.cProfile->start = e1; + ras.fresh = FALSE; + } + + size = e2 - e1 + 1; + if ( ras.top + size >= ras.maxBuff ) + { + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + if ( Dx > 0 ) + { + Ix = (ras.precision*Dx) / Dy; + Rx = (ras.precision*Dx) % Dy; + Dx = 1; + } + else + { + Ix = -( (ras.precision*-Dx) / Dy ); + Rx = (ras.precision*-Dx) % Dy; + Dx = -1; + } + + Ax = -Dy; + top = ras.top; + + while ( size > 0 ) + { + *top++ = x1; + + DEBUG_PSET; + + x1 += Ix; + Ax += Rx; + if ( Ax >= 0 ) + { + Ax -= Dy; + x1 += Dx; + } + size--; + } + + ras.top = top; + return SUCCESS; + } + + + static Bool Line_Down( RAS_ARGS Long x1, Long y1, + Long x2, Long y2, + Long miny, Long maxy ) + { + Bool result, fresh; + + + fresh = ras.fresh; + + result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny ); + + if ( fresh && !ras.fresh ) + ras.cProfile->start = -ras.cProfile->start; + + return result; + } + + +/****************************************************************************/ +/* */ +/* Function: Bezier_Up */ +/* */ +/* Description: Computes thes x-coordinates of an ascending bezier arc */ +/* and stores them in the render pool. */ +/* */ +/* Input: None. The arc is taken from the top of the Bezier stack. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow. */ +/* */ +/****************************************************************************/ + + static Bool Bezier_Up( RAS_ARGS Long miny, Long maxy ) + { + Long y1, y2, e, e2, e0; + Short f1; + + TPoint* arc; + TPoint* start_arc; + + PStorage top; + + + arc = ras.arc; + y1 = arc[2].y; + y2 = arc[0].y; + top = ras.top; + + if ( y2 < miny || y1 > maxy ) + goto Fin; + + e2 = FLOOR( y2 ); + + if ( e2 > maxy ) + e2 = maxy; + + e0 = miny; + + if ( y1 < miny ) + e = miny; + else + { + e = CEILING( y1 ); + f1 = FRAC( y1 ); + e0 = e; + + if ( f1 == 0 ) + { + if ( ras.joint ) + { + top--; + ras.joint = FALSE; + } + + *top++ = arc[2].x; + + DEBUG_PSET; + + e += ras.precision; + } + } + + if ( ras.fresh ) + { + ras.cProfile->start = TRUNC( e0 ); + ras.fresh = FALSE; + } + + if ( e2 < e ) + goto Fin; + + if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff ) + { + ras.top = top; + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + start_arc = arc; + + while ( arc >= start_arc && e <= e2 ) + { + ras.joint = FALSE; + + y2 = arc[0].y; + + if ( y2 > e ) + { + y1 = arc[2].y; + if ( y2 - y1 >= ras.precision_step ) + { + Split_Bezier( arc ); + arc += 2; + } + else + { + *top++ = arc[2].x + FMulDiv( arc[0].x - arc[2].x, + e - y1, + y2 - y1 ); + DEBUG_PSET; + + arc -= 2; + e += ras.precision; + } + } + else + { + if ( y2 == e ) + { + ras.joint = TRUE; + *top++ = arc[0].x; + + DEBUG_PSET; + + e += ras.precision; + } + arc -= 2; + } + } + + Fin: + ras.top = top; + ras.arc -= 2; + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Bezier_Down */ +/* */ +/* Description: Computes the x-coordinates of a descending bezier arc */ +/* and stores them in the render pool. */ +/* */ +/* Input: None. Arc is taken from the top of the Bezier stack. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow. */ +/* */ +/****************************************************************************/ + + static Bool Bezier_Down( RAS_ARGS Long miny, Long maxy ) + { + TPoint* arc = ras.arc; + Bool result, fresh; + + + arc[0].y = -arc[0].y; + arc[1].y = -arc[1].y; + arc[2].y = -arc[2].y; + + fresh = ras.fresh; + + result = Bezier_Up( RAS_VARS -maxy, -miny ); + + if ( fresh && !ras.fresh ) + ras.cProfile->start = -ras.cProfile->start; + + arc[0].y = -arc[0].y; + return result; + } + + +/****************************************************************************/ +/* */ +/* Function: Line_To */ +/* */ +/* Description: Injects a new line segment and adjusts Profiles list. */ +/* */ +/* Input: x, y : segment endpoint (start point in LastX,LastY) */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow or Incorrect Profile. */ +/* */ +/****************************************************************************/ + + static Bool Line_To( RAS_ARGS Long x, Long y ) + { + /* First, detect a change of direction */ + + switch ( ras.state ) + { + case Unknown: + if ( y > ras.lastY ) + { + if ( New_Profile( RAS_VARS Ascending ) ) return FAILURE; + } + else + { + if ( y < ras.lastY ) + if ( New_Profile( RAS_VARS Descending ) ) return FAILURE; + } + break; + + case Ascending: + if ( y < ras.lastY ) + { + if ( End_Profile( RAS_VAR ) || + New_Profile( RAS_VARS Descending ) ) return FAILURE; + } + break; + + case Descending: + if ( y > ras.lastY ) + { + if ( End_Profile( RAS_VAR ) || + New_Profile( RAS_VARS Ascending ) ) return FAILURE; + } + break; + + default: + ; + } + + /* Then compute the lines */ + + switch ( ras.state ) + { + case Ascending: + if ( Line_Up ( RAS_VARS ras.lastX, ras.lastY, + x, y, ras.minY, ras.maxY ) ) + return FAILURE; + break; + + case Descending: + if ( Line_Down( RAS_VARS ras.lastX, ras.lastY, + x, y, ras.minY, ras.maxY ) ) + return FAILURE; + break; + + default: + ; + } + + ras.lastX = x; + ras.lastY = y; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Bezier_To */ +/* */ +/* Description: Injects a new bezier arc and adjusts the profile list. */ +/* */ +/* Input: x, y : arc endpoint (start point in LastX, LastY) */ +/* Cx, Cy : control point */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow or Incorrect Profile. */ +/* */ +/****************************************************************************/ + + static Bool Bezier_To( RAS_ARGS Long x, + Long y, + Long cx, + Long cy ) + { + Long y1, y2, y3, x3; + TStates state_bez; + + + Push_Bezier( RAS_VARS ras.lastX, ras.lastY, cx, cy, x, y ); + + do + { + y1 = ras.arc[2].y; + y2 = ras.arc[1].y; + y3 = ras.arc[0].y; + x3 = ras.arc[0].x; + + /* first, categorize the bezier arc */ + + if ( y1 == y2 ) + { + if ( y2 == y3 ) + state_bez = Flat; + else if ( y2 > y3 ) + state_bez = Descending; + else + state_bez = Ascending; + } + else if ( y1 > y2 ) + { + if ( y2 >= y3 ) + state_bez = Descending; + else + state_bez = Unknown; + } + else if ( y2 <= y3 ) + state_bez = Ascending; + else + state_bez = Unknown; + + /* split non-monotonic arcs, ignore flat ones, or */ + /* computes the up and down ones */ + + switch ( state_bez ) + { + case Flat: + ras.arc -= 2; + break; + + case Unknown: + Split_Bezier( ras.arc ); + ras.arc += 2; + break; + + default: + /* detect a change of direction */ + + if ( ras.state != state_bez ) + { + if ( ras.state != Unknown ) + if ( End_Profile( RAS_VAR ) ) return FAILURE; + + if ( New_Profile( RAS_VARS state_bez ) ) return FAILURE; + } + + /* compute */ + + switch ( ras.state ) + { + case Ascending: + if ( Bezier_Up ( RAS_VARS ras.minY, ras.maxY ) ) + return FAILURE; + break; + + case Descending: + if ( Bezier_Down( RAS_VARS ras.minY, ras.maxY ) ) + return FAILURE; + break; + + default: + ; + } + } + } while ( ras.arc >= ras.arcs ); + + ras.lastX = x3; + ras.lastY = y3; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Decompose_Curve */ +/* */ +/* Description: Scans the outline arays in order to emit individual */ +/* segments and beziers by calling Line_To() and Bezier_To(). */ +/* It handles all weird cases, like when the first point */ +/* is off the curve, or when there are simply no 'on' */ +/* points in the contour! */ +/* */ +/* Input: first, last : indexes of first and last point in */ +/* contour. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on error. */ +/* */ +/****************************************************************************/ + +#undef SWAP_ +#define SWAP_(x,y) { Long swap = x; x = y; y = swap; } + + static Bool Decompose_Curve( RAS_ARGS UShort first, + UShort last, + Bool flipped ) + { + Long x, y; /* current point */ + Long cx, cy; /* current Bezier control point */ + Long mx, my; /* current middle point */ + + Long x_first, y_first; /* first point's coordinates */ + Long x_last, y_last; /* last point's coordinates */ + + UShort index; /* current point's index */ + Bool on_curve; /* current point's state */ + + x_first = SCALED( ras.coords[first].x ); + y_first = SCALED( ras.coords[first].y ); + + if ( flipped ) SWAP_( x_first,y_first ); + + x_last = SCALED( ras.coords[last].x ); + y_last = SCALED( ras.coords[last].y ); + + if ( flipped ) SWAP_( x_last,y_last ); + + ras.lastX = cx = x_first; + ras.lastY = cy = y_first; + + on_curve = (ras.flags[first] & 1); + index = first; + + /* check first point to determine origin */ + if ( !on_curve ) + { + /* first point is off the curve. Yes, this happens... */ + if ( ras.flags[last] & 1 ) + { + ras.lastX = x_last; /* start at last point if it */ + ras.lastY = y_last; /* is on the curve */ + } + else + { + /* if both first and last points are off the curve, */ + /* start at their middle and record its position */ + /* for closure */ + ras.lastX = (ras.lastX + x_last)/2; + ras.lastY = (ras.lastY + y_last)/2; + + x_last = ras.lastX; + y_last = ras.lastY; + } + } + + /* now process each contour point individually */ + while ( index < last ) + { + index++; + x = SCALED( ras.coords[index].x ); + y = SCALED( ras.coords[index].y ); + + if ( flipped ) SWAP_( x, y ); + + if ( on_curve ) + { + /* the previous point was on the curve */ + on_curve = ( ras.flags[index] & 1 ); + if ( on_curve ) + { + /* two successive on points => emit segment */ + if ( Line_To( RAS_VARS x, y ) ) return FAILURE; + } + else + { + /* else, keep current control point for next bezier */ + cx = x; + cy = y; + } + } + else + { + /* the previous point was off the curve */ + on_curve = ( ras.flags[index] & 1 ); + if ( on_curve ) + { + /* reaching an `on' point */ + if ( Bezier_To( RAS_VARS x, y, cx, cy ) ) return FAILURE; + } + else + { + /* two successive `off' points => create middle point */ + mx = ( cx + x ) / 2; + my = ( cy + y ) / 2; + + if ( Bezier_To( RAS_VARS mx, my, cx, cy ) ) return FAILURE; + + cx = x; + cy = y; + } + } + } + + /* end of contour, close curve cleanly */ + if ( ras.flags[first] & 1 ) + { + if ( on_curve ) + return Line_To( RAS_VARS x_first, y_first ); + else + return Bezier_To( RAS_VARS x_first, y_first, cx, cy ); + } + else + if ( !on_curve ) + return Bezier_To( RAS_VARS x_last, y_last, cx, cy ); + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Convert_Glyph */ +/* */ +/* Description: Converts a glyph into a series of segments and arcs */ +/* and makes a Profiles list with them. */ +/* */ +/* Input: _xCoord, _yCoord : coordinates tables. */ +/* */ +/* Uses the 'Flag' table too. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + + static Bool Convert_Glyph( RAS_ARGS int flipped ) + { + Short i; + UShort start; + + PProfile lastProfile; + + + ras.fProfile = NULL; + ras.joint = FALSE; + ras.fresh = FALSE; + + ras.maxBuff = ras.sizeBuff - AlignProfileSize; + + ras.numTurns = 0; + + ras.cProfile = (PProfile)ras.top; + ras.cProfile->offset = ras.top; + ras.num_Profs = 0; + + start = 0; + + for ( i = 0; i < ras.nContours; i++ ) + { + ras.state = Unknown; + ras.gProfile = NULL; + + if ( Decompose_Curve( RAS_VARS start, ras.outs[i], flipped ) ) + return FAILURE; + + start = ras.outs[i] + 1; + + /* We must now see if the extreme arcs join or not */ + if ( ( FRAC( ras.lastY ) == 0 && + ras.lastY >= ras.minY && + ras.lastY <= ras.maxY ) ) + if ( ras.gProfile && ras.gProfile->flow == ras.cProfile->flow ) + ras.top--; + /* Note that ras.gProfile can be nil if the contour was too small */ + /* to be drawn. */ + + lastProfile = ras.cProfile; + if ( End_Profile( RAS_VAR ) ) return FAILURE; + + /* close the 'next profile in contour' linked list */ + if ( ras.gProfile ) + lastProfile->next = ras.gProfile; + } + + if (Finalize_Profile_Table( RAS_VAR )) + return FAILURE; + + return (ras.top < ras.maxBuff ? SUCCESS : FAILURE ); + } + + +/************************************************/ +/* */ +/* Init_Linked */ +/* */ +/* Inits an empty linked list. */ +/* */ +/************************************************/ + + static void Init_Linked( TProfileList* l ) + { + *l = NULL; + } + + +/************************************************/ +/* */ +/* InsNew : */ +/* */ +/* Inserts a new Profile in a linked list. */ +/* */ +/************************************************/ + + static void InsNew( PProfileList list, + PProfile profile ) + { + PProfile *old, current; + Long x; + + + old = list; + current = *old; + x = profile->X; + + while ( current ) + { + if ( x < current->X ) + break; + old = ¤t->link; + current = *old; + } + + profile->link = current; + *old = profile; + } + + +/*************************************************/ +/* */ +/* DelOld : */ +/* */ +/* Removes an old Profile from a linked list. */ +/* */ +/*************************************************/ + + static void DelOld( PProfileList list, + PProfile profile ) + { + PProfile *old, current; + + + old = list; + current = *old; + + while ( current ) + { + if ( current == profile ) + { + *old = current->link; + return; + } + + old = ¤t->link; + current = *old; + } + + /* we should never get there, unless the Profile was not part of */ + /* the list. */ + } + + +/************************************************/ +/* */ +/* Update : */ +/* */ +/* Update all X offsets of a drawing list */ +/* */ +/************************************************/ + + static void Update( PProfile first ) + { + PProfile current = first; + + + while ( current ) + { + current->X = *current->offset; + current->offset += current->flow; + current->height--; + current = current->link; + } + } + + +/************************************************/ +/* */ +/* Sort : */ +/* */ +/* Sorts a trace list. In 95%, the list */ +/* is already sorted. We need an algorithm */ +/* which is fast in this case. Bubble sort */ +/* is enough and simple. */ +/* */ +/************************************************/ + + static void Sort( PProfileList list ) + { + PProfile *old, current, next; + + + /* First, set the new X coordinate of each profile */ + Update( *list ); + + /* Then sort them */ + old = list; + current = *old; + + if ( !current ) + return; + + next = current->link; + + while ( next ) + { + if ( current->X <= next->X ) + { + old = ¤t->link; + current = *old; + + if ( !current ) + return; + } + else + { + *old = next; + current->link = next->link; + next->link = current; + + old = list; + current = *old; + } + + next = current->link; + } + } + + +/***********************************************************************/ +/* */ +/* Vertical Sweep Procedure Set : */ +/* */ +/* These three routines are used during the vertical black/white */ +/* sweep phase by the generic Draw_Sweep() function. */ +/* */ +/***********************************************************************/ + + static void Vertical_Sweep_Init( RAS_ARGS Short* min, Short* max ) + { + switch ( ras.target.flow ) + { + case TT_Flow_Up: + ras.traceOfs = *min * ras.target.cols; + ras.traceIncr = ras.target.cols; + break; + + default: + ras.traceOfs = ( ras.target.rows - 1 - *min ) * ras.target.cols; + ras.traceIncr = -ras.target.cols; + } + + ras.gray_min_x = 0; + ras.gray_max_x = 0; + } + + + static void Vertical_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + Short c1, c2; + Short f1, f2; + Byte* target; + + + /* Drop-out control */ + + e1 = TRUNC( CEILING( x1 ) ); + + if ( x2-x1-ras.precision <= ras.precision_jitter ) + e2 = e1; + else + e2 = TRUNC( FLOOR( x2 ) ); + + if ( e2 >= 0 && e1 < ras.bWidth ) + { + if ( e1 < 0 ) e1 = 0; + if ( e2 >= ras.bWidth ) e2 = ras.bWidth-1; + + c1 = (Short)(e1 >> 3); + c2 = (Short)(e2 >> 3); + + f1 = e1 & 7; + f2 = e2 & 7; + + if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1; + if ( ras.gray_max_x < c2 ) ras.gray_max_x = c2; + + target = ras.bTarget + ras.traceOfs + c1; + + if ( c1 != c2 ) + { + *target |= LMask[f1]; + + if ( c2 > c1 + 1 ) + MEM_Set( target + 1, 0xFF, c2 - c1 - 1 ); + + target[c2 - c1] |= RMask[f2]; + } + else + *target |= ( LMask[f1] & RMask[f2] ); + } + } + + + static void Vertical_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + Short c1, f1; + + + /* Drop-out control */ + + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 > e2 ) + { + if ( e1 == e2 + ras.precision ) + { + switch ( ras.dropOutControl ) + { + case 1: + e1 = e2; + break; + + case 4: + e1 = CEILING( (x1 + x2 + 1) / 2 ); + break; + + case 2: + case 5: + /* Drop-out Control Rule #4 */ + + /* The spec is not very clear regarding rule #4. It */ + /* presents a method that is way too costly to implement */ + /* while the general idea seems to get rid of 'stubs'. */ + /* */ + /* Here, we only get rid of stubs recognized when: */ + /* */ + /* upper stub: */ + /* */ + /* - P_Left and P_Right are in the same contour */ + /* - P_Right is the successor of P_Left in that contour */ + /* - y is the top of P_Left and P_Right */ + /* */ + /* lower stub: */ + /* */ + /* - P_Left and P_Right are in the same contour */ + /* - P_Left is the successor of P_Right in that contour */ + /* - y is the bottom of P_Left */ + /* */ + + /* FIXXXME : uncommenting this line solves the disappearing */ + /* bit problem in the '7' of verdana 10pts, but */ + /* makes a new one in the 'C' of arial 14pts */ + + /* if ( x2-x1 < ras.precision_half ) */ + { + /* upper stub test */ + + if ( left->next == right && left->height <= 0 ) return; + + /* lower stub test */ + + if ( right->next == left && left->start == y ) return; + } + + /* check that the rightmost pixel isn't set */ + + e1 = TRUNC( e1 ); + + c1 = (Short)(e1 >> 3); + f1 = e1 & 7; + + if ( e1 >= 0 && e1 < ras.bWidth && + ras.bTarget[ras.traceOfs + c1] & (0x80 >> f1) ) + return; + + if ( ras.dropOutControl == 2 ) + e1 = e2; + else + e1 = CEILING( (x1 + x2 + 1) / 2 ); + + break; + + default: + return; /* unsupported mode */ + } + } + else + return; + } + + e1 = TRUNC( e1 ); + + if ( e1 >= 0 && e1 < ras.bWidth ) + { + c1 = (Short)(e1 >> 3); + f1 = e1 & 7; + + if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1; + if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1; + + ras.bTarget[ras.traceOfs + c1] |= (Char)(0x80 >> f1); + } + } + + + static void Vertical_Sweep_Step( RAS_ARG ) + { + ras.traceOfs += ras.traceIncr; + } + + +/***********************************************************************/ +/* */ +/* Horizontal Sweep Procedure Set : */ +/* */ +/* These three routines are used during the horizontal black/white */ +/* sweep phase by the generic Draw_Sweep() function. */ +/* */ +/***********************************************************************/ + + static void Horizontal_Sweep_Init( RAS_ARGS Short* min, Short* max ) + { + /* nothing, really */ + } + + + static void Horizontal_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + PByte bits; + Byte f1; + + + if ( x2-x1 < ras.precision ) + { + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 == e2 ) + { + bits = ras.bTarget + (y >> 3); + f1 = (Byte)(0x80 >> (y & 7)); + + e1 = TRUNC( e1 ); + + if ( e1 >= 0 && e1 < ras.target.rows ) + { + if ( ras.target.flow == TT_Flow_Down ) + bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1; + else + bits[e1 * ras.target.cols] |= f1; + } + } + } +#if 0 + e2 = TRUNC( e2 ); + + if ( e2 >= 0 && e2 < ras.target.rows ) + if ( ras.target.flow == TT_Flow_Down ) + bits[(ras.target.rows-1-e2) * ras.target.cols] |= f1; + else + bits[e2 * ras.target.cols] |= f1; +#endif + } + + + static void Horizontal_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + PByte bits; + Byte f1; + + + /* During the horizontal sweep, we only take care of drop-outs */ + + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 > e2 ) + { + if ( e1 == e2 + ras.precision ) + { + switch ( ras.dropOutControl ) + { + case 1: + e1 = e2; + break; + + case 4: + e1 = CEILING( (x1 + x2 + 1) / 2 ); + break; + + case 2: + case 5: + + /* Drop-out Control Rule #4 */ + + /* The spec is not very clear regarding rule #4. It */ + /* presents a method that is way too costly to implement */ + /* while the general idea seems to get rid of 'stubs'. */ + /* */ + + /* rightmost stub test */ + + if ( left->next == right && left->height <= 0 ) return; + + /* leftmost stub test */ + + if ( right->next == left && left->start == y ) return; + + /* check that the rightmost pixel isn't set */ + + e1 = TRUNC( e1 ); + + bits = ras.bTarget + (y >> 3); + f1 = (Byte)(0x80 >> (y & 7)); + + if ( ras.target.flow == TT_Flow_Down ) + bits += (ras.target.rows-1-e1) * ras.target.cols; + else + bits += e1 * ras.target.cols; + + if ( e1 >= 0 && + e1 < ras.target.rows && + *bits & f1 ) + return; + + if ( ras.dropOutControl == 2 ) + e1 = e2; + else + e1 = CEILING( (x1 + x2 + 1) / 2 ); + + break; + + default: + return; /* unsupported mode */ + } + } + else + return; + } + + bits = ras.bTarget + (y >> 3); + f1 = (Byte)(0x80 >> (y & 7)); + + e1 = TRUNC( e1 ); + + if ( e1 >= 0 && e1 < ras.target.rows ) + { + if (ras.target.flow==TT_Flow_Down) + bits[(ras.target.rows-1-e1) * ras.target.cols] |= f1; + else + bits[e1 * ras.target.cols] |= f1; + } + } + + + static void Horizontal_Sweep_Step( RAS_ARG ) + { + /* Nothing, really */ + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/***********************************************************************/ +/* */ +/* Vertical Gray Sweep Procedure Set: */ +/* */ +/* These two routines are used during the vertical gray-levels */ +/* sweep phase by the generic Draw_Sweep() function. */ +/* */ +/* */ +/* NOTES: */ +/* */ +/* - The target pixmap's width *must* be a multiple of 4. */ +/* */ +/* - you have to use the function Vertical_Sweep_Span() for */ +/* the gray span call. */ +/* */ +/***********************************************************************/ + + static void Vertical_Gray_Sweep_Init( RAS_ARGS Short* min, Short* max ) + { + *min = *min & -2; + *max = ( *max + 3 ) & -2; + + ras.traceOfs = 0; + + switch ( ras.target.flow ) + { + case TT_Flow_Up: + ras.traceG = (*min / 2) * ras.target.cols; + ras.traceIncr = ras.target.cols; + break; + + default: + ras.traceG = (ras.target.rows-1 - *min/2) * ras.target.cols; + ras.traceIncr = -ras.target.cols; + } + + ras.gray_min_x = ras.target.cols; + ras.gray_max_x = -ras.target.cols; + } + + + static void Vertical_Gray_Sweep_Step( RAS_ARG ) + { + Int c1, c2; + PByte pix, bit, bit2; + Int* count = ras.count_table; + Byte* grays; + + + ras.traceOfs += ras.gray_width; + + if ( ras.traceOfs > ras.gray_width ) + { + pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4; + grays = ras.grays; + + if ( ras.gray_max_x >= 0 ) + { + if ( ras.gray_max_x >= ras.target.width ) + ras.gray_max_x = ras.target.width-1; + + if ( ras.gray_min_x < 0 ) + ras.gray_min_x = 0; + + bit = ras.bTarget + ras.gray_min_x; + bit2 = bit + ras.gray_width; + + c1 = ras.gray_max_x - ras.gray_min_x; + + while ( c1 >= 0 ) + { + c2 = count[*bit] + count[*bit2]; + + if ( c2 ) + { + pix[0] = grays[(c2 & 0xF000) >> 12]; + pix[1] = grays[(c2 & 0x0F00) >> 8]; + pix[2] = grays[(c2 & 0x00F0) >> 4]; + pix[3] = grays[(c2 & 0x000F) ]; + + *bit = 0; + *bit2 = 0; + } + + bit ++; + bit2++; + pix += 4; + c1 --; + } + } + + ras.traceOfs = 0; + ras.traceG += ras.traceIncr; + + ras.gray_min_x = ras.target.cols; + ras.gray_max_x = -ras.target.cols; + } + } + + + static void Horizontal_Gray_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + /* nothing, really */ + } + + static void Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + PByte pixel; + Byte color; + + + /* During the horizontal sweep, we only take care of drop-outs */ + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 > e2 ) + { + if ( e1 == e2 + ras.precision ) + { + switch ( ras.dropOutControl ) + { + case 1: + e1 = e2; + break; + + case 4: + e1 = CEILING( (x1 + x2 + 1) / 2 ); + break; + + case 2: + case 5: + + /* Drop-out Control Rule #4 */ + + /* The spec is not very clear regarding rule #4. It */ + /* presents a method that is way too costly to implement */ + /* while the general idea seems to get rid of 'stubs'. */ + /* */ + + /* rightmost stub test */ + if ( left->next == right && left->height <= 0 ) return; + + /* leftmost stub test */ + if ( right->next == left && left->start == y ) return; + + if ( ras.dropOutControl == 2 ) + e1 = e2; + else + e1 = CEILING( (x1 + x2 + 1) / 2 ); + + break; + + default: + return; /* unsupported mode */ + } + } + else + return; + } + + if ( e1 >= 0 ) + { + if ( x2 - x1 >= ras.precision_half ) + color = ras.grays[2]; + else + color = ras.grays[1]; + + e1 = TRUNC( e1 ) / 2; + if ( e1 < ras.target.rows ) + { + if ( ras.target.flow == TT_Flow_Down ) + pixel = ras.gTarget + + (ras.target.rows - 1 - e1) * ras.target.cols + y / 2; + else + pixel = ras.gTarget + + e1 * ras.target.cols + y / 2; + + if (pixel[0] == ras.grays[0]) + pixel[0] = color; + } + } + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/********************************************************************/ +/* */ +/* Generic Sweep Drawing routine */ +/* */ +/********************************************************************/ + + static Bool Draw_Sweep( RAS_ARG ) + { + Short y, y_change, y_height; + + PProfile P, Q, P_Left, P_Right; + + Short min_Y, max_Y, top, bottom, dropouts; + + Long x1, x2, xs, e1, e2; + + TProfileList wait; + TProfileList draw_left, draw_right; + + + /* Init empty linked lists */ + + Init_Linked( &wait ); + + Init_Linked( &draw_left ); + Init_Linked( &draw_right ); + + /* first, compute min and max Y */ + + P = ras.fProfile; + max_Y = (short)TRUNC( ras.minY ); + min_Y = (short)TRUNC( ras.maxY ); + + while ( P ) + { + Q = P->link; + + bottom = P->start; + top = P->start + P->height-1; + + if ( min_Y > bottom ) min_Y = bottom; + if ( max_Y < top ) max_Y = top; + + P->X = 0; + InsNew( &wait, P ); + + P = Q; + } + + /* Check the Y-turns */ + if ( ras.numTurns == 0 ) + { + ras.error = Raster_Err_Invalid; + return FAILURE; + } + + /* Now inits the sweep */ + + ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); + + /* Then compute the distance of each profile from min_Y */ + + P = wait; + + while ( P ) + { + P->countL = P->start - min_Y; + P = P->link; + } + + /* Let's go */ + + y = min_Y; + y_height = 0; + + if ( ras.numTurns > 0 && + ras.sizeBuff[-ras.numTurns] == min_Y ) + ras.numTurns--; + + while ( ras.numTurns > 0 ) + { + /* look in the wait list for new activations */ + + P = wait; + + while ( P ) + { + Q = P->link; + P->countL -= y_height; + if ( P->countL == 0 ) + { + DelOld( &wait, P ); + + switch ( P->flow ) + { + case TT_Flow_Up: InsNew( &draw_left, P ); break; + case TT_Flow_Down: InsNew( &draw_right, P ); break; + } + } + + P = Q; + } + + /* Sort the drawing lists */ + + Sort( &draw_left ); + Sort( &draw_right ); + + y_change = (Short)ras.sizeBuff[-ras.numTurns--]; + y_height = y_change - y; + + while ( y < y_change ) + { + + /* Let's trace */ + + dropouts = 0; + + P_Left = draw_left; + P_Right = draw_right; + + while ( P_Left ) + { + x1 = P_Left ->X; + x2 = P_Right->X; + + if ( x1 > x2 ) + { + xs = x1; + x1 = x2; + x2 = xs; + } + + if ( x2-x1 <= ras.precision ) + { + e1 = FLOOR( x1 ); + e2 = CEILING( x2 ); + + if ( ras.dropOutControl != 0 && + (e1 > e2 || e2 == e1 + ras.precision) ) + { + /* a drop out was detected */ + + P_Left ->X = x1; + P_Right->X = x2; + + /* mark profile for drop-out processing */ + P_Left->countL = 1; + dropouts++; + + goto Skip_To_Next; + } + } + + ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right ); + + Skip_To_Next: + + P_Left = P_Left->link; + P_Right = P_Right->link; + } + + /* now perform the dropouts _after_ the span drawing */ + /* drop-outs processing has been moved out of the loop */ + /* for performance tuning */ + if (dropouts > 0) + goto Scan_DropOuts; + + Next_Line: + + ras.Proc_Sweep_Step( RAS_VAR ); + + y++; + + if ( y < y_change ) + { + Sort( &draw_left ); + Sort( &draw_right ); + } + + } + + /* Now finalize the profiles that needs it */ + + { + PProfile Q, P; + P = draw_left; + while ( P ) + { + Q = P->link; + if ( P->height == 0 ) + DelOld( &draw_left, P ); + P = Q; + } + } + + { + PProfile Q, P = draw_right; + while ( P ) + { + Q = P->link; + if ( P->height == 0 ) + DelOld( &draw_right, P ); + P = Q; + } + } + } + + /* for gray-scaling, flushes the bitmap scanline cache */ + while ( y <= max_Y ) + { + ras.Proc_Sweep_Step( RAS_VAR ); + y++; + } + + return SUCCESS; + +Scan_DropOuts : + + P_Left = draw_left; + P_Right = draw_right; + + while ( P_Left ) + { + if ( P_Left->countL ) + { + P_Left->countL = 0; + /* dropouts--; -- this is useful when debugging only */ + ras.Proc_Sweep_Drop( RAS_VARS y, + P_Left->X, + P_Right->X, + P_Left, + P_Right ); + } + + P_Left = P_Left->link; + P_Right = P_Right->link; + } + + goto Next_Line; + } + + +/****************************************************************************/ +/* */ +/* Function: Render_Single_Pass */ +/* */ +/* Description: Performs one sweep with sub-banding. */ +/* */ +/* Input: _XCoord, _YCoord : x and y coordinates arrays */ +/* */ +/* Returns: SUCCESS on success */ +/* FAILURE if any error was encountered during render. */ +/* */ +/****************************************************************************/ + + static TT_Error Render_Single_Pass( RAS_ARGS Bool flipped ) + { + Short i, j, k; + + + while ( ras.band_top >= 0 ) + { + ras.maxY = (Long)ras.band_stack[ras.band_top].y_max * ras.precision; + ras.minY = (Long)ras.band_stack[ras.band_top].y_min * ras.precision; + + ras.top = ras.buff; + + ras.error = Raster_Err_None; + + if ( Convert_Glyph( RAS_VARS flipped ) ) + { + if ( ras.error != Raster_Err_Overflow ) return FAILURE; + + ras.error = Raster_Err_None; + + /* sub-banding */ + +#ifdef DEBUG_RASTER + ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) ); +#endif + + i = ras.band_stack[ras.band_top].y_min; + j = ras.band_stack[ras.band_top].y_max; + + k = ( i + j ) / 2; + + if ( ras.band_top >= 7 || k < i ) + { + ras.band_top = 0; + ras.error = Raster_Err_Invalid; + return ras.error; + } + + ras.band_stack[ras.band_top+1].y_min = k; + ras.band_stack[ras.band_top+1].y_max = j; + + ras.band_stack[ras.band_top].y_max = k - 1; + + ras.band_top++; + } + else + { + if ( ras.fProfile ) + if ( Draw_Sweep( RAS_VAR ) ) return ras.error; + ras.band_top--; + } + } + + return TT_Err_Ok; + } + + +/****************************************************************************/ +/* */ +/* Function: Render_Glyph */ +/* */ +/* Description: Renders a glyph in a bitmap. Sub-banding if needed. */ +/* */ +/* Input: AGlyph Glyph record */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + + LOCAL_FUNC + TT_Error Render_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target_map ) + { + TT_Error error; + + + if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + return TT_Err_Ok; + + if ( !ras.buff ) + { + ras.error = Raster_Err_Not_Ini; + return ras.error; + } + + if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) + { + ras.error = TT_Err_Too_Many_Points; + return ras.error; + } + + if ( target_map ) + ras.target = *target_map; + + ras.outs = glyph->contours; + ras.flags = glyph->flags; + ras.nPoints = glyph->n_points; + ras.nContours = glyph->n_contours; + ras.coords = glyph->points; + + Set_High_Precision( RAS_VARS glyph->high_precision ); + ras.scale_shift = ras.precision_shift; + ras.dropOutControl = glyph->dropout_mode; + ras.second_pass = glyph->second_pass; + + + /* Vertical Sweep */ + ras.Proc_Sweep_Init = Vertical_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.rows - 1; + + ras.bWidth = ras.target.width; + ras.bTarget = (Byte*)ras.target.bitmap; + + if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) + return error; + + /* Horizontal Sweep */ + + if ( ras.second_pass && ras.dropOutControl != 0 ) + { + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.width - 1; + + if ( (error = Render_Single_Pass( RAS_VARS 1 )) != 0 ) + return error; + } + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/****************************************************************************/ +/* */ +/* Function: Render_Gray_Glyph */ +/* */ +/* Description: Renders a glyph with grayscaling. Sub-banding if needed. */ +/* */ +/* Input: AGlyph Glyph record */ +/* */ +/* Returns: SUCCESS on success */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + + LOCAL_FUNC + TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target_map, + Byte* palette ) + { + Int i; + TT_Error error; + + if ( !ras.buff ) + { + ras.error = Raster_Err_Not_Ini; + return ras.error; + } + + if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + return TT_Err_Ok; + + if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) + { + ras.error = TT_Err_Too_Many_Points; + return ras.error; + } + + if ( palette ) + { + for ( i = 0; i < 5; i++ ) + ras.grays[i] = palette[i]; + } + + if ( target_map ) + ras.target = *target_map; + + ras.outs = glyph->contours; + ras.flags = glyph->flags; + ras.nPoints = glyph->n_points; + ras.nContours = glyph->n_contours; + ras.coords = glyph->points; + + Set_High_Precision( RAS_VARS glyph->high_precision ); + ras.scale_shift = ras.precision_shift+1; + ras.dropOutControl = glyph->dropout_mode; + ras.second_pass = glyph->second_pass; + + + /* Vertical Sweep */ + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = 2 * ras.target.rows - 1; + + ras.bWidth = ras.gray_width; + if ( ras.bWidth > ras.target.cols/4 ) + ras.bWidth = ras.target.cols/4; + + ras.bWidth = ras.bWidth * 8; + ras.bTarget = (Byte*)ras.gray_lines; + ras.gTarget = (Byte*)ras.target.bitmap; + + ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; + + error = Render_Single_Pass( RAS_VARS 0 ); + if (error) + return error; + + /* Horizontal Sweep */ + + if ( ras.second_pass && ras.dropOutControl != 0 ) + { + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.width * 2 - 1; + + error = Render_Single_Pass( RAS_VARS 1 ); + if (error) + return error; + } + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/************************************************/ +/* */ +/* InitRasterizer */ +/* */ +/* Raster Initialization. */ +/* Gets the bitmap description and render pool */ +/* addresses. */ +/* */ +/************************************************/ + +#undef ras + + LOCAL_FUNC + TT_Error TTRaster_Done( PEngine_Instance engine ) + { + TRaster_Instance* ras = (TRaster_Instance*)engine->raster_component; + + + if ( !ras ) + return TT_Err_Ok; + + FREE( ras->buff ); + FREE( ras->gray_lines ); + +#ifndef TT_CONFIG_OPTION_STATIC_RASTER + FREE( engine->raster_component ); +#endif + + return TT_Err_Ok; + } + + + LOCAL_FUNC + TT_Error TTRaster_Init( PEngine_Instance engine ) + { + TT_Error error; + + Int i, l, j, c; + + TRaster_Instance* ras; + + +#ifdef TT_CONFIG_OPTION_STATIC_RASTER + ras = engine->raster_component = &cur_ras; +#else + if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) + return error; + + ras = (TRaster_Instance*)engine->raster_component; +#endif + + if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) || + ALLOC( ras->gray_lines, RASTER_GRAY_LINES ) ) + return error; + + ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) ); + ras->gray_width = RASTER_GRAY_LINES/2; + + /* Initialization of Count_Table */ + + for ( i = 0; i < 256; i++ ) + { + l = 0; + j = i; + + for ( c = 0; c < 4; c++ ) + { + l <<= 4; + + if ( j & 0x80 ) l++; + if ( j & 0x40 ) l++; + + j = ( j << 2 ) & 0xFF; + } + + ras->count_table[i] = l; + } + + ras->dropOutControl = 2; + ras->error = Raster_Err_None; + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h new file mode 100644 index 000000000..6af372090 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h @@ -0,0 +1,127 @@ +/******************************************************************* + * + * ttraster.h v 1.4 + * + * The FreeType glyph rasterizer. + * + * 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. + * + * NOTES: + * + * This version supports the following: + * + * - direct grayscaling + * - sub-banding + * - drop-out modes 4 and 5 + * - second pass for complete drop-out control (bitmap only) + * - variable precision + * + * + * Changes between 1.4 and 1.3: + * + * Mainly performance tunings: + * + * - Line_Down() and Bezier_Down() now use the functions Line_Up() + * and Bezier_Up() to do their work. + * - optimized Split_Bezier() + * - optimized linked lists used during sweeps + * + * Changes between 1.2 and 1.3: + * + * - made the engine optionaly re-entrant. Saves a lot + * of code for a moderate performance hit. + * + ******************************************************************/ + +#ifndef TTRASTER_H +#define TTRASTER_H + +#include "ttconfig.h" +#include "freetype.h" /* for TT_Outline */ +#include "ttengine.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* We provide two different builds of the scan-line converter */ + /* The static build uses global variables and isn't */ + /* re-entrant. */ + /* The indirect build is re-entrant but accesses all variables */ + /* indirectly. */ + /* */ + /* As a consequence, the indirect build is about 10% slower */ + /* than the static one on a _Pentium_ (this could get worse */ + /* on older processors), but the code size is reduced by */ + /* more than 30% ! */ + /* */ + /* The indirect build is now the default, defined in */ + /* ttconfig.h. Be careful if you experiment with this. */ + + /* Note also that, though its code can be re-entrant, the */ + /* component is always used in thread-safe mode. This is */ + /* simply due to the fact that we want to use a single */ + /* render pool (of 64 Kb), and not to waste memory. */ + +#ifdef TT_STATIC_RASTER + +#define RAS_ARGS /* void */ +#define RAS_ARG /* void */ + +#define RAS_VARS /* void */ +#define RAS_VAR /* void */ + +#else + +#define RAS_ARGS TRaster_Instance* raster, +#define RAS_ARG TRaster_Instance* raster + +#define RAS_VARS raster, +#define RAS_VAR raster + +#endif + + + struct TRaster_Instance_; + typedef struct TRaster_Instance_ TRaster_Instance; + + /* Render one glyph in the target bitmap, using drop-out control */ + /* mode 'scan'. */ + LOCAL_DEF + TT_Error Render_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target ); + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + /* Render one gray-level glyph in the target pixmap. */ + /* Palette points to an array of 5 colors used for the rendering. */ + /* Use NULL to reuse the last palette. Default is VGA graylevels. */ + LOCAL_DEF + TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target, + Byte* palette ); +#endif + + /* Initialize rasterizer */ + LOCAL_DEF + TT_Error TTRaster_Init( PEngine_Instance engine ); + + /* Finalize it */ + LOCAL_DEF + TT_Error TTRaster_Done( PEngine_Instance engine ); + + +#ifdef __cplusplus +} +#endif + +#endif /* TTRASTER_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/tttables.h b/Appl/Breadbox/testapps/ttf2/FreeType/tttables.h new file mode 100644 index 000000000..0ea5fffe8 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/tttables.h @@ -0,0 +1,215 @@ +/******************************************************************* + * + * tttables.h 1.1 + * + * TrueType Tables structures and handling (specification). + * + * 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 TTTABLES_H +#define TTTABLES_H + +#include "ttconfig.h" +#include "tttypes.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /***********************************************************************/ + /* */ + /* TrueType Table Types */ + /* */ + /***********************************************************************/ + + /* TrueType Collection Header */ + + struct TTTCHeader_ + { + ULong Tag; + TT_Fixed version; + ULong DirCount; + PULong TableDirectory; + }; + + typedef struct TTTCHeader_ TTTCHeader; + typedef TTTCHeader* PTTCHeader; + + + /* TrueType Table Directory type */ + + struct TTableDir_ + { + TT_Fixed version; /* should be 0x10000 */ + UShort numTables; /* number of tables */ + + UShort searchRange; /* These parameters are only used */ + UShort entrySelector; /* for a dichotomy search in the */ + UShort rangeShift; /* directory. We ignore them. */ + }; + + typedef struct TTableDir_ TTableDir; + typedef TTableDir* PTableDir; + + + /* The 'TableDir' is followed by 'numTables' TableDirEntries */ + + struct TTableDirEntry_ + { + ULong Tag; /* table type */ + ULong CheckSum; /* table checksum */ + ULong Offset; /* table file offset */ + ULong Length; /* table length */ + }; + + typedef struct TTableDirEntry_ TTableDirEntry; + typedef TTableDirEntry* PTableDirEntry; + + + /* 'cmap' tables */ + + struct TCMapDir_ + { + UShort tableVersionNumber; + UShort numCMaps; + }; + + typedef struct TCMapDir_ TCMapDir; + typedef TCMapDir* PCMapDir; + + struct TCMapDirEntry_ + { + UShort platformID; + UShort platformEncodingID; + Long offset; + }; + + typedef struct TCMapDirEntry_ TCMapDirEntry; + typedef TCMapDirEntry* PCMapDirEntries; + + + /* 'maxp' Maximum Profiles table */ + + struct TMaxProfile_ + { + TT_Fixed version; + UShort numGlyphs, + maxPoints, + maxContours, + maxCompositePoints, + maxCompositeContours, + maxZones, + maxTwilightPoints, + maxStorage, + maxFunctionDefs, + maxInstructionDefs, + maxStackElements, + maxSizeOfInstructions, + maxComponentElements, + maxComponentDepth; + }; + + typedef struct TMaxProfile_ TMaxProfile; + typedef TMaxProfile* PMaxProfile; + + + /* table "gasp" */ + +#define GASP_GRIDFIT 0x01 +#define GASP_DOGRAY 0x02 + + struct GaspRange_ + { + UShort maxPPEM; + UShort gaspFlag; + }; + + typedef struct GaspRange_ GaspRange; + + + struct TGasp_ + { + UShort version; + UShort numRanges; + GaspRange* gaspRanges; + }; + + typedef struct TGasp_ TGasp; + + + /* table "head" - now defined in freetype.h */ + /* table "hhea" - now defined in freetype.h */ + + + /* tables "HMTX" and "VMTX" */ + + struct TLongMetrics_ + { + UShort advance; + Short bearing; + }; + + typedef struct TLongMetrics_ TLongMetrics, *PLongMetrics; + + typedef Short TShortMetrics, *PShortMetrics; + + /* 'loca' location table type */ + + struct TLoca_ + { + UShort Size; + PStorage Table; + }; + + typedef struct TLoca_ TLoca; + + + /* table "name" */ + + struct TNameRec_ + { + UShort platformID; + UShort encodingID; + UShort languageID; + UShort nameID; + UShort stringLength; + UShort stringOffset; + + /* this last field is not defined in the spec */ + /* but used by the FreeType engine */ + + PByte string; + }; + + typedef struct TNameRec_ TNameRec; + + + struct TName_Table_ + { + UShort format; + UShort numNameRecords; + UShort storageOffset; + TNameRec* names; + PByte storage; + }; + + typedef struct TName_Table_ TName_Table; + + +#ifdef __cplusplus + } +#endif + +#endif /* TTTABLES_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/tttags.h b/Appl/Breadbox/testapps/ttf2/FreeType/tttags.h new file mode 100644 index 000000000..474a3b80b --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/tttags.h @@ -0,0 +1,61 @@ +/******************************************************************* + * + * tttags.h + * + * tags for TrueType tables (specification only). + * + * 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 TTAGS_H +#define TTAGS_H + +#include "ttconfig.h" +#include "freetype.h" /* for MAKE_TT_TAG() */ + +#define TTAG_BASE MAKE_TT_TAG( 'B', 'A', 'S', 'E' ) +#define TTAG_bloc MAKE_TT_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bdat MAKE_TT_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_cmap MAKE_TT_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_cvt MAKE_TT_TAG( 'c', 'v', 't', ' ' ) +#define TTAG_EBDT MAKE_TT_TAG( 'E', 'B', 'D', 'T' ) +#define TTAG_EBLC MAKE_TT_TAG( 'E', 'B', 'L', 'C' ) +#define TTAG_EBSC MAKE_TT_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_fpgm MAKE_TT_TAG( 'f', 'p', 'g', 'm' ) +#define TTAG_gasp MAKE_TT_TAG( 'g', 'a', 's', 'p' ) +#define TTAG_glyf MAKE_TT_TAG( 'g', 'l', 'y', 'f' ) +#define TTAG_GDEF MAKE_TT_TAG( 'G', 'D', 'E', 'F' ) +#define TTAG_GPOS MAKE_TT_TAG( 'G', 'P', 'O', 'S' ) +#define TTAG_GSUB MAKE_TT_TAG( 'G', 'S', 'U', 'B' ) +#define TTAG_hdmx MAKE_TT_TAG( 'h', 'd', 'm', 'x' ) +#define TTAG_head MAKE_TT_TAG( 'h', 'e', 'a', 'd' ) +#define TTAG_hhea MAKE_TT_TAG( 'h', 'h', 'e', 'a' ) +#define TTAG_hmtx MAKE_TT_TAG( 'h', 'm', 't', 'x' ) +#define TTAG_JSTF MAKE_TT_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_kern MAKE_TT_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_loca MAKE_TT_TAG( 'l', 'o', 'c', 'a' ) +#define TTAG_LTSH MAKE_TT_TAG( 'L', 'T', 'S', 'H' ) +#define TTAG_maxp MAKE_TT_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_name MAKE_TT_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_OS2 MAKE_TT_TAG( 'O', 'S', '/', '2' ) +#define TTAG_PCLT MAKE_TT_TAG( 'P', 'C', 'L', 'T' ) +#define TTAG_post MAKE_TT_TAG( 'p', 'o', 's', 't' ) +#define TTAG_prep MAKE_TT_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_ttc MAKE_TT_TAG( 't', 't', 'c', ' ' ) +#define TTAG_ttcf MAKE_TT_TAG( 't', 't', 'c', 'f' ) +#define TTAG_VDMX MAKE_TT_TAG( 'V', 'D', 'M', 'X' ) +#define TTAG_vhea MAKE_TT_TAG( 'v', 'h', 'e', 'a' ) +#define TTAG_vmtx MAKE_TT_TAG( 'v', 'm', 't', 'x' ) + +#endif /* TTAGS_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/tttypes.h b/Appl/Breadbox/testapps/ttf2/FreeType/tttypes.h new file mode 100644 index 000000000..9ebf472f7 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/tttypes.h @@ -0,0 +1,150 @@ +/******************************************************************* + * + * tttypes.h + * + * Freetype engine's common types specification + * (this spec has no associated body). + * + * 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. + * + * NOTE: + * + * All these declarations are library internals, and *not* part + * of the high-level interface. See also 'freetype.h'. + * + ******************************************************************/ + +#ifndef TTTYPES_H +#define TTTYPES_H + +#include "ttconfig.h" +#include "freetype.h" + +#ifdef __MACTYPES__ +#error " have been included, and this prevents the proper\ + compilation of this library. Please remove the precompiled headers." +#endif + + typedef char String; + typedef signed char Char; + typedef unsigned char Byte; + + typedef unsigned short UShort; + typedef signed short Short; + + typedef unsigned long ULong; + typedef signed long Long; + + typedef TT_Int32 Fixed; + + typedef int Int; + + /* Simple access types: pointers and tables */ + + typedef Byte* PByte; + typedef UShort* PUShort; + typedef Short* PShort; + typedef ULong* PULong; + typedef Long* PLong; + + typedef Fixed* PFixed; + + typedef Int* PInt; + + typedef void* Pointer; + + typedef TT_F26Dot6* PCoordinates; + typedef unsigned char* PTouchTable; + + +#ifndef Bool + typedef int Bool; /* No boolean type in C */ +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + + typedef Long Storage; + typedef Storage* PStorage; + + +/* Rounding mode constants */ + +#define TT_Round_Off 5 +#define TT_Round_To_Half_Grid 0 +#define TT_Round_To_Grid 1 +#define TT_Round_To_Double_Grid 2 +#define TT_Round_Up_To_Grid 4 +#define TT_Round_Down_To_Grid 3 +#define TT_Round_Super 6 +#define TT_Round_Super_45 7 + + +/* Touch flag masks */ + +#define TT_Flag_On_Curve 1 +#define TT_Flag_Touched_X 2 +#define TT_Flag_Touched_Y 4 +#define TT_Flag_Touched_Both 6 + + +/* Error management constants :) */ + +#define SUCCESS 0 +#define FAILURE -1 + + +/* The min and max functions missing in C. As usual, be careful not to */ +/* write things like MIN( a++, b++ ) to avoid side effects. */ + +#ifndef MIN +#define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) +#endif + +#ifndef MAX +#define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) +#endif + +#ifndef ABS +#define ABS( a ) ( (a) < 0 ? -(a) : (a) ) +#endif + +/* conversion macros for the handles defined in freetype.h */ + +#define HANDLE_Val( handle ) ((handle).z) + +#define HANDLE_Engine( handle ) ((PEngine_Instance)HANDLE_Val( handle )) + +#define HANDLE_Face( handle ) ((PFace)HANDLE_Val( handle )) + +#define HANDLE_Instance( handle ) ((PInstance)HANDLE_Val( handle )) + +/* HANDLE_Stream( handle ) must be defined in ttfile.c */ + +#define HANDLE_Glyph( handle ) ((PGlyph)HANDLE_Val( handle )) + +#define HANDLE_CharMap( handle ) ((PCMapTable)HANDLE_Val( handle )) + +#define HANDLE_Set( handle, val ) ((handle).z = (void*)(val)) + + +#endif /* TTTYPES_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc new file mode 100644 index 000000000..2445bd965 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -0,0 +1,124 @@ +/******************************************************************** + * + * Testapp für das Rendern von TTF-Fonts + * + *******************************************************************/ +@include +#include +#include +#include "FreeType/freetype.h" + + +#define FONT_SIZE 16 + +TT_Engine engine; +TT_Face face; + + +@class TtfProcessClass, GenProcessClass; +@endc; +@classdecl TtfProcessClass, neverSaved; + +/******************************************************************** + * UI Object Resources + *******************************************************************/ +@start AppResource; + +@object GenApplicationClass TtfApp = { + GI_visMoniker = list { @TtfTextMoniker }; + GI_comp = @TtfPrimary; + + gcnList( MANUFACTURER_ID_GEOWORKS, GAGCNLT_WINDOWS ) = @TtfPrimary; +} + +@visMoniker TtfTextMoniker = "TTF Test"; + +@end AppResource; + + +@start Interface; + +@object GenPrimaryClass TtfPrimary = { + GI_comp = @TtfView, + @LogText; + ATTR_GEN_DISPLAY_NOT_MINIMIZABLE; + HINT_ORIENT_CHILDREN_HORIZONTALLY; +} + +@object GenViewClass TtfView = { + GVI_horizAttrs = @default | GVDA_SCROLLABLE | GVDA_NO_LARGER_THAN_CONTENT; + GVI_vertAttrs = @default | GVDA_SCROLLABLE | GVDA_NO_LARGER_THAN_CONTENT; + GVI_content = process; + GVI_docBounds = { 0, 0, 500, 450 }; + + ATTR_GEN_VIEW_DOES_NOT_ACCEPT_TEXT_INPUT; +} + +@object GenTextClass LogText = { + HINT_EXPAND_WIDTH_TO_FIT_PARENT; + HINT_EXPAND_HEIGHT_TO_FIT_PARENT; +} + +@end Interface; + +/******************************************************************** + * Zeichensatz rendern + ********************************************************************/ +void TtfDraw( GStateHandle gstate ) { + word character; + + // Zeichensatz durchlaufen in einer 16 x 16 Matrix + for(character = 32; character <= 255; character++ ) { + word posX = ( character % 16 ) * FONT_SIZE + FONT_SIZE/2; + word posY = ( character / 16 ) * FONT_SIZE - FONT_SIZE; + + //TODO: Zeichen character an posX, posY ausgeben + } +} + +@method TtfProcessClass, MSG_META_EXPOSED { + GStateHandle gstate = GrCreateState( win ); + char tmpStr[40]; + TT_Face_Properties props; + TT_Error error; + + + error = TT_Init_FreeType(&engine); + if(error) { + _log("Fehler bei Initialisierung\r"); + goto Fail; + } + + error = TT_Open_Face(engine, "Lib.ttf", &face); + if(error) { + _log("Fehler beim laden des Fonts\r"); + goto Fail; + } + + error = TT_Get_Face_Properties(face, &props); + if(error) { + _log("Fehler beim laden der Properties\r"); + return; + } + + sprintf(tmpStr, "num glyphs: %d\r", props.num_Glyphs); _log(tmpStr); + sprintf(tmpStr, "num faces: %d\r", props.num_Faces); _log(tmpStr); + sprintf(tmpStr, "max points: %d\r", props.max_Points); _log(tmpStr); + + GrBeginUpdate( gstate ); + TtfDraw( gstate ); + GrEndUpdate( gstate ); + + GrDestroyState( gstate ); + + Fail: + return; +} + +void _log(char * message) { + @call LogText::MSG_VIS_TEXT_APPEND_PTR(message, 0); +} + +void clear_log() { + @call LogText::MSG_VIS_TEXT_DELETE_ALL(); +} diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md new file mode 100644 index 000000000..fa51dc7d3 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -0,0 +1,22 @@ +## TODO +- ft_conf.h aus /FreeType/arch/geos nutzen und unter /FreeType löschen +- ~~Speicherbedarf begrenzen (ttraster.c RASTER_RENDER_POOL)~~ + +## Meilensteine +- ~~Gerüst für Testprogramm erstellen~~ +- ~~Gerüst für Testprogramm übersetzbar und lauffähig~~ +- ~~TT-Engine Objekt anlegen, übersetzbar und lauffähig~~ +- ~~Aufruf TT_Init_FreeType, übersetzbar und lauffähig~~ +- ~~Dateihandling auf FileHandle umstellen, übersetzbar und lauffähig~~ +- Font öffnen mit TT_Open_Face, übersetzbar und lauffähig +- Font Properties abfragen mit TT_Get_Face_Properties, übersetzbar und lauffähig +- Instanz eines Face Objekts erzeugen, übersetzbar und lauffähig +- Pointsize mit TT_Set_Instance_CharSize setzen, übersetbar und lauffähig +- Glyph als Bitmap erzeugen, übersetzbar und lauffähig +- Bitmap im Testprogramm anzeigen, übersetzbar und lauffähig +- Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig +- Memorymanagement auf Geos Spezifika (hugemem.c könnte genügen) umstellen, übersetzbar und lauffähig +- Extension für Kerning aktivieren +- angepasstes FreeType in Treibersourcen verschieben +- FreeType in Treiber integrieren +- Registrierung eines Fonts anpassen (FontID, TTC???) diff --git a/Appl/Breadbox/testapps/ttf2/ttf2.gp b/Appl/Breadbox/testapps/ttf2/ttf2.gp new file mode 100644 index 000000000..9c8d1b550 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/ttf2.gp @@ -0,0 +1,18 @@ +name ttf2.app +longname "TTF2 Test" + +tokenchars "TTFT" +tokenid 8 + +type appl, process, single + +class TtfProcessClass + +appobj TtfApp + +library geos +library ui +library ansic + +resource AppResource ui-object +resource Interface ui-object diff --git a/Appl/Breadbox/testapps/ttf2/ttmutex.c b/Appl/Breadbox/testapps/ttf2/ttmutex.c new file mode 100644 index 000000000..95f71f801 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/ttmutex.c @@ -0,0 +1,85 @@ +/******************************************************************* + * + * ttmutex.c 1.0 + * + * Mutual exclusion object, single-threaded implementation + * + * 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. + * + * NOTE: This is a generic non-functional implementation + * that you are welcome to refine for your own system. + * + * Please name your system-specific source with a + * different name (like ttmutex-os2.c or ttmutex-linux.c) + * and change your makefile accordingly. + * + ******************************************************************/ + +#include "ttmutex.h" + + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_mutex + + +/* ANSI C prevents the compilation of empty units. We thus introduce */ +/* a dummy typedef to get rid of compiler warnings/errors. */ +/* Note that gcc's -ansi -pedantic does not report any error here. */ +/* Watcom, VC++ or Borland C++ do however. */ + + typedef void _ttmutex_to_satisfy_ANSI_C_; + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + + LOCAL_FUNC + void TT_Mutex_Create ( TMutex* mutex ) + { + *mutex = (void*)-1; + /* Replace this line with your own mutex creation code */ + } + + + LOCAL_FUNC + void TT_Mutex_Delete ( TMutex* mutex ) + { + *mutex = (void*)0; + /* Replace this line with your own mutex destruction code */ + } + + + LOCAL_FUNC + void TT_Mutex_Lock ( TMutex* mutex ) + { + /* NOTE: It is legal to call this function with a NULL argument */ + /* in which case an immediate return is appropriate. */ + if ( !mutex ) + return; + + ; /* Insert your own mutex locking code here */ + } + + + LOCAL_FUNC + void TT_Mutex_Release( TMutex* mutex ) + { + /* NOTE: It is legal to call this function with a NULL argument */ + /* in which case an immediate return is appropriate */ + if ( !mutex ) + return; + + ; /* Insert your own mutex release code here */ + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + +/* END */ diff --git a/Installed/Appl/Breadbox/testapps/ttf2/Makefile b/Installed/Appl/Breadbox/testapps/ttf2/Makefile new file mode 100644 index 000000000..4675830fd --- /dev/null +++ b/Installed/Appl/Breadbox/testapps/ttf2/Makefile @@ -0,0 +1,40 @@ +# +# THIS FILE HAS BEEN GENERATED AUTOMATICALLY. +# +# If you edit it, you will lose your changes, should it be regenerated. +# +GEODE = ttf2 +FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ + ttcalc.c ttapi.c ttdebug.c ttinterp.c ttload.c ttfile.c\ + ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ + header.h ttinterp.h ttload.h tttables.h ttobjs.h\ + fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ + ft_conf.h ttextend.h ftnameid.h ttcalc.h ttmemory.h\ + tttags.h +UI = ttf2.goc +UI_TO_RDFS = +OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ + ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj\ + ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ + ttmemory.obj ttf2.obj +COMMON = +MODULES = +CMODULES = FreeType Ui +SRCS = $(FREETYPE) $(UI) $(COMMON) +LOBJS = + +SYSMAKEFILE = geode.mk + +#include +#include + +#if exists(local.mk) +#include "local.mk" +#else +#include <$(SYSMAKEFILE)> +#endif + +#if exists($(DEPFILE)) +#include "$(DEPFILE)" +#endif diff --git a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk new file mode 100644 index 000000000..b0df14826 --- /dev/null +++ b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk @@ -0,0 +1,133 @@ +ttf2.obj \ +ttf2.eobj: stdapp.goh object.goh ui.goh Objects/metaC.goh \ + Objects/inputC.goh Objects/clipbrd.goh \ + Objects/uiInputC.goh iacp.goh Objects/winC.goh \ + Objects/gProcC.goh alb.goh Objects/processC.goh \ + Objects/visC.goh Objects/vCompC.goh Objects/vCntC.goh \ + Objects/gAppC.goh Objects/genC.goh Objects/gInterC.goh \ + Objects/gPrimC.goh Objects/gDispC.goh Objects/gTrigC.goh \ + Objects/gViewC.goh Objects/gTextC.goh Objects/vTextC.goh \ + Objects/gCtrlC.goh gcnlist.goh spool.goh \ + Objects/gFSelC.goh Objects/gGlyphC.goh \ + Objects/gDocCtrl.goh Objects/gDocGrpC.goh \ + Objects/gDocC.goh Objects/gContC.goh Objects/gDCtrlC.goh \ + Objects/gEditCC.goh Objects/gBoolGC.goh \ + Objects/gItemGC.goh Objects/gDListC.goh \ + Objects/gItemC.goh Objects/gBoolC.goh \ + Objects/gGadgetC.goh Objects/gToolCC.goh \ + Objects/gValueC.goh Objects/gToolGC.goh \ + Objects/helpCC.goh +ttf2.obj \ +ttf2.eobj: geos.h heap.h geode.h resource.h ec.h object.h lmem.h \ + graphics.h fontID.h font.h color.h gstring.h timer.h vm.h \ + dbase.h localize.h Ansi/ctype.h timedate.h file.h \ + sllang.h system.h geoworks.h chunkarr.h Objects/helpCC.h \ + disk.h drive.h input.h char.h hwr.h win.h uDialog.h \ + Objects/gInterC.h Objects/Text/tCommon.h stylesh.h \ + driver.h thread.h print.h Internal/spoolInt.h serialDr.h \ + parallDr.h hugearr.h fileEnum.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h +ttcache.obj \ +ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ + FreeType/ft_conf.h geos.h file.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttdebug.h +ttraster.obj \ +ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h +ttmutex.obj \ +ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h +ttgload.obj \ +ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttgload.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/tttags.h \ + FreeType/ttload.h +ttextend.obj \ +ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h +ttcalc.obj \ +ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/tttypes.h FreeType/tttables.h +ttapi.obj \ +ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + Ansi/stdlib.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ + FreeType/ttfile.h FreeType/ttdebug.h FreeType/ttobjs.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttload.h \ + FreeType/ttgload.h FreeType/ttraster.h \ + FreeType/ttextend.h +ttdebug.obj \ +ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/ttcmap.h +ttinterp.obj \ +ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h +ttload.obj \ +ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h +ttfile.obj \ +ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttmemory.h FreeType/ttfile.h +ttcmap.obj \ +ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ + FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttload.h +ttobjs.obj \ +ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h +ttmemory.obj \ +ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttengine.h FreeType/ttmutex.h + +ttf2EC.geo ttf2.geo : geos.ldf ui.ldf ansic.ldf \ No newline at end of file From 5a273cfc648e79e0783af16a90b0583d8131395f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 16 Jan 2022 17:05:37 +0100 Subject: [PATCH 013/246] function pointer problem solved --- .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 4 + Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 18 +++- Appl/Breadbox/testapps/ttf2/backlog.md | 4 +- Appl/Breadbox/testapps/ttf2/ttmutex.c | 85 ------------------- 4 files changed, 20 insertions(+), 91 deletions(-) delete mode 100644 Appl/Breadbox/testapps/ttf2/ttmutex.c diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index effa5c824..8707598de 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -304,7 +304,11 @@ current->data = object; +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( build, object, parent_object ); +#else error = build( object, parent_object ); +#endif /* ifdef __GEOS__ */ if ( error ) { Element_Done( cache->engine, current ); diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 2445bd965..fe9d5e045 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -80,6 +80,7 @@ void TtfDraw( GStateHandle gstate ) { GStateHandle gstate = GrCreateState( win ); char tmpStr[40]; TT_Face_Properties props; + TT_Instance instance; TT_Error error; @@ -98,12 +99,21 @@ void TtfDraw( GStateHandle gstate ) { error = TT_Get_Face_Properties(face, &props); if(error) { _log("Fehler beim laden der Properties\r"); - return; + goto Fail; } - sprintf(tmpStr, "num glyphs: %d\r", props.num_Glyphs); _log(tmpStr); - sprintf(tmpStr, "num faces: %d\r", props.num_Faces); _log(tmpStr); - sprintf(tmpStr, "max points: %d\r", props.max_Points); _log(tmpStr); + sprintf(tmpStr, "num glyphs:\t%d\r", props.num_Glyphs); _log(tmpStr); + sprintf(tmpStr, "num faces:\t%d\r", props.num_Faces); _log(tmpStr); + sprintf(tmpStr, "num names:\t%d\r", props.num_Names); _log(tmpStr); + sprintf(tmpStr, "num charMaps:\t%d\r", props.num_CharMaps); _log(tmpStr); + sprintf(tmpStr, "max points:\t%d\r", props.max_Points); _log(tmpStr); + sprintf(tmpStr, "max contours:\t%d\r", props.max_Contours); _log(tmpStr); + + error = TT_New_Instance(face, &instance); + if(error) { + _log("Fehler beim erzeugen einer Instance\r"); + goto Fail; + } GrBeginUpdate( gstate ); TtfDraw( gstate ); diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index fa51dc7d3..d5ee55383 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -8,8 +8,8 @@ - ~~TT-Engine Objekt anlegen, übersetzbar und lauffähig~~ - ~~Aufruf TT_Init_FreeType, übersetzbar und lauffähig~~ - ~~Dateihandling auf FileHandle umstellen, übersetzbar und lauffähig~~ -- Font öffnen mit TT_Open_Face, übersetzbar und lauffähig -- Font Properties abfragen mit TT_Get_Face_Properties, übersetzbar und lauffähig +- ~~Font öffnen mit TT_Open_Face, übersetzbar und lauffähig~~ +- ~~Font Properties abfragen mit TT_Get_Face_Properties, übersetzbar und lauffähig~~ - Instanz eines Face Objekts erzeugen, übersetzbar und lauffähig - Pointsize mit TT_Set_Instance_CharSize setzen, übersetbar und lauffähig - Glyph als Bitmap erzeugen, übersetzbar und lauffähig diff --git a/Appl/Breadbox/testapps/ttf2/ttmutex.c b/Appl/Breadbox/testapps/ttf2/ttmutex.c deleted file mode 100644 index 95f71f801..000000000 --- a/Appl/Breadbox/testapps/ttf2/ttmutex.c +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************* - * - * ttmutex.c 1.0 - * - * Mutual exclusion object, single-threaded implementation - * - * 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. - * - * NOTE: This is a generic non-functional implementation - * that you are welcome to refine for your own system. - * - * Please name your system-specific source with a - * different name (like ttmutex-os2.c or ttmutex-linux.c) - * and change your makefile accordingly. - * - ******************************************************************/ - -#include "ttmutex.h" - - -/* required by the tracing mode */ -#undef TT_COMPONENT -#define TT_COMPONENT trace_mutex - - -/* ANSI C prevents the compilation of empty units. We thus introduce */ -/* a dummy typedef to get rid of compiler warnings/errors. */ -/* Note that gcc's -ansi -pedantic does not report any error here. */ -/* Watcom, VC++ or Borland C++ do however. */ - - typedef void _ttmutex_to_satisfy_ANSI_C_; - - -#ifdef TT_CONFIG_OPTION_THREAD_SAFE - - LOCAL_FUNC - void TT_Mutex_Create ( TMutex* mutex ) - { - *mutex = (void*)-1; - /* Replace this line with your own mutex creation code */ - } - - - LOCAL_FUNC - void TT_Mutex_Delete ( TMutex* mutex ) - { - *mutex = (void*)0; - /* Replace this line with your own mutex destruction code */ - } - - - LOCAL_FUNC - void TT_Mutex_Lock ( TMutex* mutex ) - { - /* NOTE: It is legal to call this function with a NULL argument */ - /* in which case an immediate return is appropriate. */ - if ( !mutex ) - return; - - ; /* Insert your own mutex locking code here */ - } - - - LOCAL_FUNC - void TT_Mutex_Release( TMutex* mutex ) - { - /* NOTE: It is legal to call this function with a NULL argument */ - /* in which case an immediate return is appropriate */ - if ( !mutex ) - return; - - ; /* Insert your own mutex release code here */ - } - -#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ - - -/* END */ From 9b82ac44d06a4a26a0d27ba8ea30c4ded69d2616 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 16 Jan 2022 21:43:43 +0100 Subject: [PATCH 014/246] Everything up to the rendering is now tested --- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 72 +++++++++++++++++++++++++ Appl/Breadbox/testapps/ttf2/backlog.md | 5 +- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index fe9d5e045..453f30b9d 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -76,11 +76,35 @@ void TtfDraw( GStateHandle gstate ) { } } +TT_UShort getWindowsUnicodeCharMap(TT_Face face) { + TT_UShort charMap; + TT_Error error; + + for(charMap = 0; charMap < TT_Get_CharMap_Count(face); charMap++) { + TT_UShort platformID; + TT_UShort encodingID; + + error = TT_Get_CharMap_ID(face, charMap, &platformID, &encodingID); + if(error) + return -1; + + /* platformId = Windows, encodingId = Unicode */ + if(platformID == 3 && encodingID == 1) + return charMap; + } + return -1; +} + @method TtfProcessClass, MSG_META_EXPOSED { GStateHandle gstate = GrCreateState( win ); char tmpStr[40]; TT_Face_Properties props; TT_Instance instance; + TT_Glyph glyph; + TT_UShort charMapId; + TT_CharMap charMap; + TT_Glyph_Metrics metrics; + TT_Raster_Map bitmap; TT_Error error; @@ -115,6 +139,53 @@ void TtfDraw( GStateHandle gstate ) { goto Fail; } + error = TT_Set_Instance_CharSize(instance, 9*64); + if(error) { + _log("Fehler beim setzen der Pointsize\r"); + goto Fail; + } + + error = TT_New_Glyph(face, &glyph); + if(error) { + _log("Fehler beim anlegen eines Glyphs\r"); + goto Fail; + } + + charMapId = getWindowsUnicodeCharMap(face); + if(charMapId < 0) { + _log("Windows Unicode Charmap nicht gefunden\r"); + goto Fail; + } + + error = TT_Get_CharMap(face, charMapId, &charMap); + if(error) { + _log("Fehler beim laden der CharMap\r"); + goto Fail; + } + + /* TODO: Index aus CharMap benutzen */ + error = TT_Load_Glyph( instance, glyph, 36, TTLOAD_DEFAULT ); + if(error) { + _log("Fehler beim laden eines Glyphs\r"); + goto Fail; + } + + error = TT_Get_Glyph_Metrics(glyph, &metrics); + if(error) { + _log("Fehler beim laden der Glyphmetriken\r"); + goto Fail; + } + + sprintf(tmpStr, "bearingX:\t%d\r", metrics.bearingX >> 6); _log(tmpStr); + sprintf(tmpStr, "bearingY:\t%d\r", metrics.bearingY >> 6); _log(tmpStr); + sprintf(tmpStr, "advance:\t%d\r", metrics.advance >> 6); _log(tmpStr); + + error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, 0); + if(error) { + _log("Fehler beim rendern des Glyphs\r"); + goto Fail; + } + GrBeginUpdate( gstate ); TtfDraw( gstate ); GrEndUpdate( gstate ); @@ -122,6 +193,7 @@ void TtfDraw( GStateHandle gstate ) { GrDestroyState( gstate ); Fail: + /* Resourcen freigeben */ return; } diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index d5ee55383..d7ddbba6d 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -10,8 +10,9 @@ - ~~Dateihandling auf FileHandle umstellen, übersetzbar und lauffähig~~ - ~~Font öffnen mit TT_Open_Face, übersetzbar und lauffähig~~ - ~~Font Properties abfragen mit TT_Get_Face_Properties, übersetzbar und lauffähig~~ -- Instanz eines Face Objekts erzeugen, übersetzbar und lauffähig -- Pointsize mit TT_Set_Instance_CharSize setzen, übersetbar und lauffähig +- ~~Instanz eines Face Objekts erzeugen, übersetzbar und lauffähig~~ +- ~~Pointsize mit TT_Set_Instance_CharSize setzen, übersetbar und lauffähig~~ +- ~~Metriken eines Glyphs lesen und anzeigen, übersetzbar und lauffähig~~ - Glyph als Bitmap erzeugen, übersetzbar und lauffähig - Bitmap im Testprogramm anzeigen, übersetzbar und lauffähig - Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig From 9741adefcd0ea011dbc220e488ba120ae9b3cf8b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 17 Jan 2022 20:17:01 +0100 Subject: [PATCH 015/246] ttraster.c adapted to FreeGEOS. But the rendering is still fault. --- .../testapps/ttf2/FreeType/ttraster.c | 24 +++++++++++++++++++ Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 7 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 5563b4895..ad744b6da 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -2191,7 +2191,11 @@ /* Now inits the sweep */ +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Init, RAS_VARS &min_Y, &max_Y ); +#else ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); +#endif /* ifdef __GEOS__ */ /* Then compute the distance of each profile from min_Y */ @@ -2287,7 +2291,11 @@ } } +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Span, RAS_VARS y, x1, x2, P_Left, P_Right ); +#else ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right ); +#endif /* __GEOS__ */ Skip_To_Next: @@ -2303,7 +2311,11 @@ Next_Line: +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); +#else ras.Proc_Sweep_Step( RAS_VAR ); +#endif /* ifdef __GEOS__ */ y++; @@ -2344,7 +2356,11 @@ /* for gray-scaling, flushes the bitmap scanline cache */ while ( y <= max_Y ) { +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); +#else ras.Proc_Sweep_Step( RAS_VAR ); +#endif /* __GEOS__ */ y++; } @@ -2361,11 +2377,19 @@ Scan_DropOuts : { P_Left->countL = 0; /* dropouts--; -- this is useful when debugging only */ +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Drop, RAS_VARS y, + P_Left->X, + P_Right->X, + P_Left, + P_Right ); +#else ras.Proc_Sweep_Drop( RAS_VARS y, P_Left->X, P_Right->X, P_Left, P_Right ); +#endif /* ifdef __GEOS__ */ } P_Left = P_Left->link; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 453f30b9d..0b45c76df 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -181,11 +181,16 @@ TT_UShort getWindowsUnicodeCharMap(TT_Face face) { sprintf(tmpStr, "advance:\t%d\r", metrics.advance >> 6); _log(tmpStr); error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, 0); - if(error) { + if(error) { _log("Fehler beim rendern des Glyphs\r"); goto Fail; } + sprintf(tmpStr, "rows:\t%d\r", bitmap.rows); _log(tmpStr); + sprintf(tmpStr, "cols:\t%d\r", bitmap.cols); _log(tmpStr); + sprintf(tmpStr, "width:\t%d\r", bitmap.width); _log(tmpStr); + sprintf(tmpStr, "size:\t%ld\r", bitmap.size); _log(tmpStr); + GrBeginUpdate( gstate ); TtfDraw( gstate ); GrEndUpdate( gstate ); From adb6dd408a3f8b294027668ea0ed4fc115e2fb9a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 20 Jan 2022 21:43:07 +0100 Subject: [PATCH 016/246] app no longer freezes after releasing resources --- .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 16 +++ Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 105 +++++++----------- Appl/Breadbox/testapps/ttf2/backlog.md | 12 +- 3 files changed, 63 insertions(+), 70 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index 8707598de..719f74ac2 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -198,7 +198,11 @@ while ( current ) { next = current->next; +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( destroy, current->data ); +#else destroy( current->data ); +#endif FREE( current->data ); Element_Done( cache->engine, current ); @@ -211,7 +215,11 @@ while ( current ) { next = current->next; +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( destroy, current->data ); +#else destroy( current->data ); +#endif FREE( current->data ); Element_Done( cache->engine, current ); @@ -398,7 +406,11 @@ if ( destroy ) { /* destroy the object when the cache is full */ +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( cache->clazz->done, element->data ); +#else cache->clazz->done( element->data ); +#endif /* ifdef __GEOS__ */ FREE( element->data ); Element_Done( cache->engine, element ); } @@ -410,7 +422,11 @@ finalize = cache->clazz->finalize; if ( finalize ) { +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( finalize, element->data ); +#else error = finalize( element->data ); +#endif /* ifdef __GEOS__ */ if ( error ) goto Exit; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 0b45c76df..919be06b1 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -6,14 +6,21 @@ @include #include #include +#include +#include #include "FreeType/freetype.h" -#define FONT_SIZE 16 +#define FONT_SIZE 30 TT_Engine engine; TT_Face face; +typedef struct { + Bitmap b; + char data[24 * 3]; +} Bmp; + @class TtfProcessClass, GenProcessClass; @endc; @@ -64,35 +71,40 @@ TT_Face face; /******************************************************************** * Zeichensatz rendern ********************************************************************/ -void TtfDraw( GStateHandle gstate ) { - word character; +void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { + word characterId; + TT_Raster_Map bitmap; + Bmp bmp; // Zeichensatz durchlaufen in einer 16 x 16 Matrix - for(character = 32; character <= 255; character++ ) { - word posX = ( character % 16 ) * FONT_SIZE + FONT_SIZE/2; - word posY = ( character / 16 ) * FONT_SIZE - FONT_SIZE; - - //TODO: Zeichen character an posX, posY ausgeben - } -} - -TT_UShort getWindowsUnicodeCharMap(TT_Face face) { - TT_UShort charMap; - TT_Error error; - - for(charMap = 0; charMap < TT_Get_CharMap_Count(face); charMap++) { - TT_UShort platformID; - TT_UShort encodingID; + for(characterId = 1; characterId <= 200; characterId++ ) { + TT_Error error; + word posX = ( characterId % 16 ) * FONT_SIZE + FONT_SIZE/2; + word posY = ( characterId / 16 ) * FONT_SIZE + FONT_SIZE; + + memset(&bmp, 0, sizeof(Bmp)); + bmp.b.B_compact = BMC_UNCOMPACTED; + bmp.b.B_type = BMF_MONO; + bmp.b.B_width = 24; + bmp.b.B_height = 24; + + bitmap.flow = TT_Flow_Down; + bitmap.rows = 24; + bitmap.cols = 3; + bitmap.width = 24; + bitmap.size = 3*24; + bitmap.bitmap = &bmp.data; + + error = TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ); + if(error) + continue; - error = TT_Get_CharMap_ID(face, charMap, &platformID, &encodingID); + error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, 0); if(error) - return -1; + continue; - /* platformId = Windows, encodingId = Unicode */ - if(platformID == 3 && encodingID == 1) - return charMap; + GrDrawImage(gstate, posX, posY, IBS_1, (Bitmap *) &bmp); } - return -1; } @method TtfProcessClass, MSG_META_EXPOSED { @@ -104,7 +116,6 @@ TT_UShort getWindowsUnicodeCharMap(TT_Face face) { TT_UShort charMapId; TT_CharMap charMap; TT_Glyph_Metrics metrics; - TT_Raster_Map bitmap; TT_Error error; @@ -151,54 +162,14 @@ TT_UShort getWindowsUnicodeCharMap(TT_Face face) { goto Fail; } - charMapId = getWindowsUnicodeCharMap(face); - if(charMapId < 0) { - _log("Windows Unicode Charmap nicht gefunden\r"); - goto Fail; - } - - error = TT_Get_CharMap(face, charMapId, &charMap); - if(error) { - _log("Fehler beim laden der CharMap\r"); - goto Fail; - } - - /* TODO: Index aus CharMap benutzen */ - error = TT_Load_Glyph( instance, glyph, 36, TTLOAD_DEFAULT ); - if(error) { - _log("Fehler beim laden eines Glyphs\r"); - goto Fail; - } - - error = TT_Get_Glyph_Metrics(glyph, &metrics); - if(error) { - _log("Fehler beim laden der Glyphmetriken\r"); - goto Fail; - } - - sprintf(tmpStr, "bearingX:\t%d\r", metrics.bearingX >> 6); _log(tmpStr); - sprintf(tmpStr, "bearingY:\t%d\r", metrics.bearingY >> 6); _log(tmpStr); - sprintf(tmpStr, "advance:\t%d\r", metrics.advance >> 6); _log(tmpStr); - - error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, 0); - if(error) { - _log("Fehler beim rendern des Glyphs\r"); - goto Fail; - } - - sprintf(tmpStr, "rows:\t%d\r", bitmap.rows); _log(tmpStr); - sprintf(tmpStr, "cols:\t%d\r", bitmap.cols); _log(tmpStr); - sprintf(tmpStr, "width:\t%d\r", bitmap.width); _log(tmpStr); - sprintf(tmpStr, "size:\t%ld\r", bitmap.size); _log(tmpStr); - GrBeginUpdate( gstate ); - TtfDraw( gstate ); + TtfDraw( gstate, instance, glyph); GrEndUpdate( gstate ); GrDestroyState( gstate ); Fail: - /* Resourcen freigeben */ + TT_Done_FreeType(engine); return; } diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index d7ddbba6d..5c49d6006 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -13,11 +13,17 @@ - ~~Instanz eines Face Objekts erzeugen, übersetzbar und lauffähig~~ - ~~Pointsize mit TT_Set_Instance_CharSize setzen, übersetbar und lauffähig~~ - ~~Metriken eines Glyphs lesen und anzeigen, übersetzbar und lauffähig~~ -- Glyph als Bitmap erzeugen, übersetzbar und lauffähig -- Bitmap im Testprogramm anzeigen, übersetzbar und lauffähig -- Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig +- ~~Glyph als Bitmap erzeugen, übersetzbar und lauffähig~~ +- ~~Bitmap im Testprogramm anzeigen, übersetzbar und lauffähig~~ +- ~~Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig~~ - Memorymanagement auf Geos Spezifika (hugemem.c könnte genügen) umstellen, übersetzbar und lauffähig - Extension für Kerning aktivieren - angepasstes FreeType in Treibersourcen verschieben +- Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH - FreeType in Treiber integrieren - Registrierung eines Fonts anpassen (FontID, TTC???) +- Darstellung kleiner PUnktgrößen weiter verbessern (bspw. high precision & scond pass) + +## Fehler +- ~~freigeben von resiervierten Resoucen führt zum einfrieren~~ +- Teile eines Zeiches die unter der Basislinie liegen werden nicht angezeigt \ No newline at end of file From 46bbf5444cea28e827944e27315654fbb4dad5bd Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 21 Jan 2022 22:58:04 +0100 Subject: [PATCH 017/246] Character correctly positioned on baseline. --- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 16 ++++++++++++---- Appl/Breadbox/testapps/ttf2/backlog.md | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 919be06b1..c248cf14d 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -73,14 +73,16 @@ typedef struct { ********************************************************************/ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { word characterId; + TT_Glyph_Metrics metrics; TT_Raster_Map bitmap; + int offsetY = 0; Bmp bmp; // Zeichensatz durchlaufen in einer 16 x 16 Matrix for(characterId = 1; characterId <= 200; characterId++ ) { TT_Error error; - word posX = ( characterId % 16 ) * FONT_SIZE + FONT_SIZE/2; - word posY = ( characterId / 16 ) * FONT_SIZE + FONT_SIZE; + int posX = ( characterId % 16 ) * FONT_SIZE + FONT_SIZE/2; + int posY = ( characterId / 16 ) * FONT_SIZE + FONT_SIZE; memset(&bmp, 0, sizeof(Bmp)); bmp.b.B_compact = BMC_UNCOMPACTED; @@ -99,11 +101,17 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if(error) continue; - error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, 0); + error = TT_Get_Glyph_Metrics(glyph, &metrics); + if(error) + continue; + + offsetY = metrics.bbox.yMin; + + error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, -offsetY); if(error) continue; - GrDrawImage(gstate, posX, posY, IBS_1, (Bitmap *) &bmp); + GrDrawImage(gstate, posX, posY - (offsetY>>6), IBS_1, (Bitmap *) &bmp); } } diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 5c49d6006..415cd4d5f 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -26,4 +26,4 @@ ## Fehler - ~~freigeben von resiervierten Resoucen führt zum einfrieren~~ -- Teile eines Zeiches die unter der Basislinie liegen werden nicht angezeigt \ No newline at end of file +- ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ \ No newline at end of file From 42bc5fb73e5d369e9e1c36432e98159bc801a404 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 22 Jan 2022 22:04:36 +0100 Subject: [PATCH 018/246] kerning added, but not yet working --- .../testapps/ttf2/FreeType/extend/ftxkern.c | 564 ++++++++++++++++++ .../testapps/ttf2/FreeType/extend/ftxkern.h | 181 ++++++ .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 1 + Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c | 5 + Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 16 +- Appl/Breadbox/testapps/ttf2/backlog.md | 5 +- Appl/Breadbox/testapps/ttf2/local.mk | 4 + .../Breadbox/testapps/ttf2/dependencies.mk | 2 +- 8 files changed, 775 insertions(+), 3 deletions(-) create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.h create mode 100644 Appl/Breadbox/testapps/ttf2/local.mk diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.c new file mode 100644 index 000000000..6d6c9f9a0 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.c @@ -0,0 +1,564 @@ +/******************************************************************* + * + * ftxkern.c 1.0 + * + * Kerning support extension. + * + * 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. + * + * + * The kerning support is currently part of the engine extensions. + * + ******************************************************************/ + +#include "ftxkern.h" + +#include "ttextend.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttmemory.h" +#include "ttfile.h" +#include "ttobjs.h" +#include "ttload.h" /* For the macros */ +#include "tttags.h" + +/* Required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_any + +#define KERNING_ID Build_Extension_ID( 'k', 'e', 'r', 'n' ) + + +/******************************************************************* + * + * Function : SubTable_Load_0 + * + * Description : Loads a format 0 kerning subtable data. + * + * Input : kern0 pointer to the kerning subtable + * + * Output : error code + * + * Notes : - Assumes that the stream is already `used' + * + * - the file cursor must be set by the caller + * + * - in case of error, the function _must_ destroy + * the data it allocates! + * + ******************************************************************/ + + static TT_Error Subtable_Load_0( TT_Kern_0* kern0, + PFace input ) + { + DEFINE_LOAD_LOCALS( input->stream ); + + UShort num_pairs, n; + + + if ( ACCESS_Frame( 8L ) ) + return error; + + num_pairs = GET_UShort(); + kern0->nPairs = 0; + kern0->searchRange = GET_UShort(); + kern0->entrySelector = GET_UShort(); + kern0->rangeShift = GET_UShort(); + + /* we only set kern0->nPairs if the subtable has been loaded */ + + FORGET_Frame(); + + if ( ALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) ) + return error; + + if ( ACCESS_Frame( num_pairs * 6L ) ) + goto Fail; + + for ( n = 0; n < num_pairs; n++ ) + { + kern0->pairs[n].left = GET_UShort(); + kern0->pairs[n].right = GET_UShort(); + kern0->pairs[n].value = GET_UShort(); + + if ( kern0->pairs[n].left >= input->numGlyphs || + kern0->pairs[n].right >= input->numGlyphs ) + { + FORGET_Frame(); + error = TT_Err_Invalid_Kerning_Table; + goto Fail; + } + } + + FORGET_Frame(); + + /* we're ok, set the pairs count */ + kern0->nPairs = num_pairs; + + return TT_Err_Ok; + + Fail: + FREE( kern0->pairs ); + return error; + } + + +/******************************************************************* + * + * Function : SubTable_Load_2 + * + * Description : Loads a format 2 kerning subtable data. + * + * Input : kern2 pointer to the kerning subtable + * length subtable length. This is required as + * the subheader doesn't give any indication + * of the size of the `array' table. + * + * Output : error code + * + * Notes : - Assumes that the stream is already `used' + * + * - the file cursor must be set by the caller + * + * - in case of error, the function _must_ destroy + * the data it allocates! + * + ******************************************************************/ + + static TT_Error Subtable_Load_2( TT_Kern_2* kern2, + PFace input ) + { + DEFINE_LOAD_LOCALS( input->stream ); + + Long table_base; + + UShort left_offset, right_offset, array_offset; + ULong array_size; + UShort left_max, right_max, n; + + + /* record the table offset */ + table_base = FILE_Pos(); + + if ( ACCESS_Frame( 8L ) ) + return error; + + kern2->rowWidth = GET_UShort(); + left_offset = GET_UShort(); + right_offset = GET_UShort(); + array_offset = GET_UShort(); + + FORGET_Frame(); + + /* first load left and right glyph classes */ + + if ( FILE_Seek( table_base + left_offset ) || + ACCESS_Frame( 4L ) ) + return error; + + kern2->leftClass.firstGlyph = GET_UShort(); + kern2->leftClass.nGlyphs = GET_UShort(); + + FORGET_Frame(); + + if ( ALLOC_ARRAY( kern2->leftClass.classes, + kern2->leftClass.nGlyphs, + UShort ) ) + return error; + + /* load left offsets */ + + if ( ACCESS_Frame( kern2->leftClass.nGlyphs * 2L ) ) + goto Fail_Left; + + for ( n = 0; n < kern2->leftClass.nGlyphs; n++ ) + kern2->leftClass.classes[n] = GET_UShort(); + + FORGET_Frame(); + + /* right class */ + + if ( FILE_Seek( table_base + right_offset ) || + ACCESS_Frame( 4L ) ) + goto Fail_Left; + + kern2->rightClass.firstGlyph = GET_UShort(); + kern2->rightClass.nGlyphs = GET_UShort(); + + FORGET_Frame(); + + if ( ALLOC_ARRAY( kern2->rightClass.classes, + kern2->rightClass.nGlyphs, + UShort ) ) + goto Fail_Left; + + /* load right offsets */ + + if ( ACCESS_Frame( kern2->rightClass.nGlyphs * 2L ) ) + goto Fail_Right; + + for ( n = 0; n < kern2->rightClass.nGlyphs; n++ ) + kern2->rightClass.classes[n] = GET_UShort(); + + FORGET_Frame(); + + /* Now load the kerning array. We don't have its size, we */ + /* must compute it from what we know. */ + + /* We thus compute the maximum left and right offsets and */ + /* add them to get the array size. */ + + left_max = right_max = 0; + + for ( n = 0; n < kern2->leftClass.nGlyphs; n++ ) + left_max = MAX( left_max, kern2->leftClass.classes[n] ); + + for ( n = 0; n < kern2->rightClass.nGlyphs; n++ ) + right_max = MAX( right_max, kern2->leftClass.classes[n] ); + + array_size = left_max + right_max + 2; + + if ( ALLOC( kern2->array, array_size ) ) + goto Fail_Right; + + if ( ACCESS_Frame( array_size ) ) + goto Fail_Array; + + for ( n = 0; n < array_size/2; n++ ) + kern2->array[n] = GET_Short(); + + FORGET_Frame(); + + /* we're good now */ + + return TT_Err_Ok; + + Fail_Array: + FREE( kern2->array ); + + Fail_Right: + FREE( kern2->rightClass.classes ); + kern2->rightClass.nGlyphs = 0; + + Fail_Left: + FREE( kern2->leftClass.classes ); + kern2->leftClass.nGlyphs = 0; + + return error; + } + + +/******************************************************************* + * + * Function : Kerning_Create + * + * Description : Creates the kerning directory if a face is + * loaded. The tables however are loaded on + * demand to save space. + * + * Input : face pointer to the parent face object + * kern pointer to the extension's kerning field + * + * Output : error code + * + * Notes : as in all constructors, the memory allocated isn't + * released in case of failure. Rather, the task is left + * to the destructor (which is called if an error + * occurs during the loading of a face). + * + ******************************************************************/ + + static TT_Error Kerning_Create( void* ext, + PFace face ) + { + DEFINE_LOAD_LOCALS( face->stream ); + + TT_Kerning* kern = (TT_Kerning*)ext; + UShort num_tables; + Long table; + + TT_Kern_Subtable* sub; + + + /* by convention */ + if ( !kern ) + return TT_Err_Ok; + + /* Now load the kerning directory. We're called from the face */ + /* constructor. We thus need not use the stream. */ + + kern->version = 0; + kern->nTables = 0; + kern->tables = NULL; + + table = TT_LookUp_Table( face, TTAG_kern ); + if ( table < 0 ) + return TT_Err_Ok; /* The table is optional */ + + if ( FILE_Seek( face->dirTables[table].Offset ) || + ACCESS_Frame( 4L ) ) + return error; + + kern->version = GET_UShort(); + num_tables = GET_UShort(); + + FORGET_Frame(); + + /* we don't set kern->nTables until we have allocated the array */ + + if ( ALLOC_ARRAY( kern->tables, num_tables, TT_Kern_Subtable ) ) + return error; + + kern->nTables = num_tables; + + /* now load the directory entries, but do _not_ load the tables ! */ + + sub = kern->tables; + + for ( table = 0; table < num_tables; table++ ) + { + if ( ACCESS_Frame( 6L ) ) + return error; + + sub->loaded = FALSE; /* redundant, but good to see */ + sub->version = GET_UShort(); + sub->length = GET_UShort() - 6; /* substract header length */ + sub->format = GET_Byte(); + sub->coverage = GET_Byte(); + + FORGET_Frame(); + + sub->offset = FILE_Pos(); + + /* now skip to the next table */ + + if ( FILE_Skip( sub->length ) ) + return error; + + sub++; + } + + /* that's fine, leave now */ + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Kerning_Destroy + * + * Description : Destroys all kerning information. + * + * Input : kern pointer to the extension's kerning field + * + * Output : error code + * + * Notes : This function is a destructor; it must be able + * to destroy partially built tables. + * + ******************************************************************/ + + static TT_Error Kerning_Destroy( void* ext, + PFace face ) + { + TT_Kerning* kern = (TT_Kerning*)ext; + TT_Kern_Subtable* sub; + UShort n; + + + /* by convention */ + if ( !kern ) + return TT_Err_Ok; + + if ( kern->nTables == 0 ) + return TT_Err_Ok; /* no tables to release */ + + /* scan the table directory and release loaded entries */ + + sub = kern->tables; + for ( n = 0; n < kern->nTables; n++ ) + { + if ( sub->loaded ) + { + switch ( sub->format ) + { + case 0: + FREE( sub->t.kern0.pairs ); + sub->t.kern0.nPairs = 0; + sub->t.kern0.searchRange = 0; + sub->t.kern0.entrySelector = 0; + sub->t.kern0.rangeShift = 0; + break; + + case 2: + FREE( sub->t.kern2.leftClass.classes ); + sub->t.kern2.leftClass.firstGlyph = 0; + sub->t.kern2.leftClass.nGlyphs = 0; + + FREE( sub->t.kern2.rightClass.classes ); + sub->t.kern2.rightClass.firstGlyph = 0; + sub->t.kern2.rightClass.nGlyphs = 0; + + FREE( sub->t.kern2.array ); + sub->t.kern2.rowWidth = 0; + break; + + default: + ; /* invalid subtable format - do nothing */ + } + + sub->loaded = FALSE; + sub->version = 0; + sub->offset = 0; + sub->length = 0; + sub->coverage = 0; + sub->format = 0; + } + sub++; + } + + FREE( kern->tables ); + kern->nTables = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Kerning_Directory + * + * Description : Returns a given face's kerning directory. + * + * Input : face handle to the face object + * directory pointer to client's target directory + * + * Output : error code + * + * Notes : The kerning table directory is loaded with the face + * through the extension constructor. However, the kerning + * tables themselves are only loaded on demand, as they + * may represent a lot of data, unneeded by most uses of + * the engine. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Kerning_Directory( TT_Face face, + TT_Kerning* directory ) + { + PFace faze = HANDLE_Face( face ); + TT_Error error; + TT_Kerning* kerning; + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + /* copy directory header */ + error = TT_Extension_Get( faze, KERNING_ID, (void**)&kerning ); + if ( !error ) + *directory = *kerning; + + return error; + } + + +/******************************************************************* + * + * Function : TT_Load_Kerning_Table + * + * Description : Loads a kerning table intro memory. + * + * Input : face face handle + * kern_index index in the face's kerning directory + * + * Output : error code + * + * Notes : + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Load_Kerning_Table( TT_Face face, + TT_UShort kern_index ) + { + TT_Error error; + TT_Stream stream; + + TT_Kerning* kern; + TT_Kern_Subtable* sub; + + + PFace faze = HANDLE_Face( face ); + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + error = TT_Extension_Get( faze, KERNING_ID, (void**)&kern ); + if ( error ) + return error; + + if ( kern->nTables == 0 ) + return TT_Err_Table_Missing; + + if ( kern_index >= kern->nTables ) + return TT_Err_Invalid_Argument; + + sub = kern->tables + kern_index; + + if ( sub->format != 0 && sub->format != 2 ) + return TT_Err_Invalid_Kerning_Table_Format; + + /* now access stream */ + if ( USE_Stream( faze->stream, stream ) ) + return error; + + if ( FILE_Seek( sub->offset ) ) + goto Fail; + + if ( sub->format == 0 ) + error = Subtable_Load_0( &sub->t.kern0, faze ); + else if ( sub->format == 2 ) + error = Subtable_Load_2( &sub->t.kern2, faze ); + + if ( !error ) + sub->loaded = TRUE; + + Fail: + /* release stream */ + DONE_Stream( stream ); + + return error; + } + + + EXPORT_FUNC + TT_Error TT_Init_Kerning_Extension( TT_Engine engine ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + error = TT_Register_Extension( _engine, + KERNING_ID, + sizeof ( TT_Kerning ), + Kerning_Create, + Kerning_Destroy ); + return error; + } + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.h b/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.h new file mode 100644 index 000000000..719ec6e51 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.h @@ -0,0 +1,181 @@ +/******************************************************************* + * + * ftxkern.h 1.0 + * + * High-Level API Kerning extension + * + * 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. + * + * + * The kerning support is currently part of the engine extensions. + * + * This file should _not_ depend on engine internal types. + * + ******************************************************************/ + +#ifndef FTXKERN_H +#define FTXKERN_H + +#include "freetype.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* The kerning support in FreeType is minimal. This means that */ + /* we do not try to interpret the kerning data in any way to */ + /* `cook' it for a user application. This API lets you access */ + /* directly the kerning tables found in the TrueType file; it's */ + /* up to the client application to apply its own processing on */ + /* these. */ + + /* The reason for this is that we generally do not encourage */ + /* feature-bloat of the core engine. Moreover, not all */ + /* libraries or font servers really need kerning data, or all */ + /* formats of this data. */ + + /************** kerning error codes *****************************/ + + /* we choose the class 0x0A for our errors, this should not */ + /* match with any error code class used in any other extension */ + +#define TT_Err_Invalid_Kerning_Table_Format 0x0A00 +#define TT_Err_Invalid_Kerning_Table 0x0A01 + + + /********** structures definitions ******************************/ + + /* Remember that all types and function are accessible by client */ + /* applications in this section, and thus should have the `TT_' */ + /* prefix. */ + + /* format 0 kerning pair */ + + struct TT_Kern_0_Pair_ + { + TT_UShort left; /* index of left glyph in pair */ + TT_UShort right; /* index of right glyph in pair */ + TT_FWord value; /* kerning value */ + }; + + typedef struct TT_Kern_0_Pair_ TT_Kern_0_Pair; + + + /* format 0 kerning subtable */ + + struct TT_Kern_0_ + { + TT_UShort nPairs; /* number of kerning pairs */ + + TT_UShort searchRange; /* these values are defined by the TT spec */ + TT_UShort entrySelector; /* for table searchs. */ + TT_UShort rangeShift; + + TT_Kern_0_Pair* pairs; /* a table of nPairs `pairs' */ + }; + + typedef struct TT_Kern_0_ TT_Kern_0; + + + /* format 2 kerning glyph class */ + + struct TT_Kern_2_Class_ + { + TT_UShort firstGlyph; /* first glyph in range */ + TT_UShort nGlyphs; /* number of glyphs in range */ + TT_UShort* classes; /* a table giving for each ranged glyph */ + /* its class offset in the subtable pairs */ + /* two-dimensional array */ + }; + + typedef struct TT_Kern_2_Class_ TT_Kern_2_Class; + + + /* format 2 kerning subtable */ + + struct TT_Kern_2_ + { + TT_UShort rowWidth; /* length of one row in bytes */ + TT_Kern_2_Class leftClass; /* left class table */ + TT_Kern_2_Class rightClass; /* right class table */ + TT_FWord* array; /* 2-dimensional kerning values array */ + }; + + typedef struct TT_Kern_2_ TT_Kern_2; + + + /* kerning subtable */ + + struct TT_Kern_Subtable_ + { + TT_Bool loaded; /* boolean; indicates whether the table is */ + /* loaded */ + TT_UShort version; /* table version number */ + TT_Long offset; /* file offset of table */ + TT_UShort length; /* length of table, _excluding_ header */ + TT_Byte coverage; /* lower 8 bit of the coverage table entry */ + TT_Byte format; /* the subtable format, as found in the */ + /* higher 8 bits of the coverage table entry */ + union + { + TT_Kern_0 kern0; + TT_Kern_2 kern2; + } t; + }; + + typedef struct TT_Kern_Subtable_ TT_Kern_Subtable; + + + struct TT_Kerning_ + { + TT_UShort version; /* kern table version number. starts at 0 */ + TT_UShort nTables; /* number of tables */ + + TT_Kern_Subtable* tables; /* the kerning sub-tables */ + }; + + typedef struct TT_Kerning_ TT_Kerning; + + + + /***************** high-level API extension **************************/ + + /* Initialize Kerning extension, must be called after */ + /* TT_Init_FreeType(). There is no need for a finalizer */ + EXPORT_DEF + TT_Error TT_Init_Kerning_Extension( TT_Engine engine ); + + /* Note on the implemented mechanism: */ + + /* The kerning table directory is loaded with the face through the */ + /* extension constructor. However, the tables will only be loaded */ + /* on demand, as they may represent a lot of data, unnecessary to */ + /* most applications. */ + + /* Queries a pointer to the kerning directory for the face object */ + EXPORT_DEF + TT_Error TT_Get_Kerning_Directory( TT_Face face, + TT_Kerning* directory ); + + /* Load the kerning table number `kern_index' in the kerning */ + /* directory. The table will stay in memory until the `face' */ + /* face is destroyed. */ + EXPORT_DEF + TT_Error TT_Load_Kerning_Table( TT_Face face, + TT_UShort kern_index ); + +#ifdef __cplusplus +} +#endif + +#endif /* FTXKERN_H */ + + +/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index e0edc4697..c4d48db1b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -11,6 +11,7 @@ /* Under FreeGEOS we need this for the file operations. */ #include #include +#include /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c index 0a9092de0..f748aea15 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c @@ -970,8 +970,13 @@ EXPORT_FUNC TT_Error TT_Skip_File( STREAM_ARGS Long distance ) { +#ifdef __GEOS__ + return TT_Seek_File( STREAM_VARS FilePos( CUR_Stream->file, 0, FILE_POS_RELATIVE ) - + CUR_Stream->base + distance ); +#else return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) - CUR_Stream->base + distance ); +#endif /* ifdef __GEOS__ */ } diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index c248cf14d..cfb3d1c39 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -75,6 +75,7 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { word characterId; TT_Glyph_Metrics metrics; TT_Raster_Map bitmap; + TT_Outline outline; int offsetY = 0; Bmp bmp; @@ -101,6 +102,13 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if(error) continue; + error = TT_Get_Glyph_Outline(glyph, &outline); + if(error) + continue; + + outline.second_pass = TRUE; + outline.high_precision = TRUE; + error = TT_Get_Glyph_Metrics(glyph, &metrics); if(error) continue; @@ -133,6 +141,12 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } + /* error = TT_Init_Kerning_Extension(&engine); + if(error) { + _log("Fehler bei der Initialisierung des Kernings\r"); + goto Fail; + } */ + error = TT_Open_Face(engine, "Lib.ttf", &face); if(error) { _log("Fehler beim laden des Fonts\r"); @@ -158,7 +172,7 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 9*64); + error = TT_Set_Instance_CharSize(instance, 16*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 415cd4d5f..639701368 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -26,4 +26,7 @@ ## Fehler - ~~freigeben von resiervierten Resoucen führt zum einfrieren~~ -- ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ \ No newline at end of file +- ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ + +## Bemerkungen +- die Darstellung keiner Punktgröße ist jetzt wesentlich besser aber stark vom Font abhänging; das ist bei der Font-Selektion zu beachten \ No newline at end of file diff --git a/Appl/Breadbox/testapps/ttf2/local.mk b/Appl/Breadbox/testapps/ttf2/local.mk new file mode 100644 index 000000000..60a31b299 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/local.mk @@ -0,0 +1,4 @@ + +.PATH : /FreeType/extend + +#include <$(SYSMAKEFILE)> \ No newline at end of file diff --git a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk index b0df14826..5d6383718 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk +++ b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk @@ -26,7 +26,7 @@ ttf2.eobj: geos.h heap.h geode.h resource.h ec.h object.h lmem.h \ Objects/gInterC.h Objects/Text/tCommon.h stylesh.h \ driver.h thread.h print.h Internal/spoolInt.h serialDr.h \ parallDr.h hugearr.h fileEnum.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ + Ansi/string.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ From b17d54752d1dfca713da2baf9a1e4a9ecc139975 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 23 Jan 2022 13:26:16 +0100 Subject: [PATCH 019/246] support for kerning added --- .../ttf2/FreeType/arch/geos/ft_conf.h | 8 +- .../ttf2/FreeType/{extend => }/ftxkern.c | 0 .../ttf2/FreeType/{extend => }/ftxkern.h | 0 Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 12 +-- Appl/Breadbox/testapps/ttf2/backlog.md | 2 +- Appl/Breadbox/testapps/ttf2/local.mk | 4 - .../Appl/Breadbox/testapps/ttf2/Makefile | 10 +- .../Breadbox/testapps/ttf2/dependencies.mk | 91 +++++++++++-------- 8 files changed, 69 insertions(+), 58 deletions(-) rename Appl/Breadbox/testapps/ttf2/FreeType/{extend => }/ftxkern.c (100%) rename Appl/Breadbox/testapps/ttf2/FreeType/{extend => }/ftxkern.h (100%) delete mode 100644 Appl/Breadbox/testapps/ttf2/local.mk diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h index 089ca8b7e..c4d48db1b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h @@ -9,7 +9,9 @@ #define FT_CONF_H /* Under FreeGEOS we need this for the file operations. */ +#include #include +#include /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -89,7 +91,7 @@ /* by the engine and need no extensions, undefine this configuration */ /* macro to save a few more bytes. */ -#define TT_CONFIG_OPTION_EXTEND_ENGINE +#undef TT_CONFIG_OPTION_EXTEND_ENGINE /*************************************************************************/ @@ -109,7 +111,7 @@ /* emerged recently on the FreeType lists. We still do not have Apple's */ /* opinion on the subject and will change this as soon as we have. */ -#undef TT_CONFIG_OPTION_NO_INTERPRETER +#define TT_CONFIG_OPTION_NO_INTERPRETER /*************************************************************************/ @@ -141,7 +143,7 @@ /* */ /* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ /* */ -#define TT_CONFIG_OPTION_STATIC_RASTER +#undef TT_CONFIG_OPTION_STATIC_RASTER /*************************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c similarity index 100% rename from Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.c rename to Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h similarity index 100% rename from Appl/Breadbox/testapps/ttf2/FreeType/extend/ftxkern.h rename to Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index cfb3d1c39..291eceec5 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -102,12 +102,12 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if(error) continue; - error = TT_Get_Glyph_Outline(glyph, &outline); + /*error = TT_Get_Glyph_Outline(glyph, &outline); if(error) continue; outline.second_pass = TRUE; - outline.high_precision = TRUE; + outline.high_precision = TRUE;*/ error = TT_Get_Glyph_Metrics(glyph, &metrics); if(error) @@ -141,13 +141,13 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } - /* error = TT_Init_Kerning_Extension(&engine); + error = TT_Init_Kerning_Extension(&engine); if(error) { _log("Fehler bei der Initialisierung des Kernings\r"); goto Fail; - } */ + } - error = TT_Open_Face(engine, "Lib.ttf", &face); + error = TT_Open_Face(engine, "Mont.ttf", &face); if(error) { _log("Fehler beim laden des Fonts\r"); goto Fail; @@ -172,7 +172,7 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 16*64); + error = TT_Set_Instance_CharSize(instance, 11*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 639701368..97855a1fa 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -17,7 +17,7 @@ - ~~Bitmap im Testprogramm anzeigen, übersetzbar und lauffähig~~ - ~~Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig~~ - Memorymanagement auf Geos Spezifika (hugemem.c könnte genügen) umstellen, übersetzbar und lauffähig -- Extension für Kerning aktivieren +- ~~Extension für Kerning aktivieren~~ - angepasstes FreeType in Treibersourcen verschieben - Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH - FreeType in Treiber integrieren diff --git a/Appl/Breadbox/testapps/ttf2/local.mk b/Appl/Breadbox/testapps/ttf2/local.mk deleted file mode 100644 index 60a31b299..000000000 --- a/Appl/Breadbox/testapps/ttf2/local.mk +++ /dev/null @@ -1,4 +0,0 @@ - -.PATH : /FreeType/extend - -#include <$(SYSMAKEFILE)> \ No newline at end of file diff --git a/Installed/Appl/Breadbox/testapps/ttf2/Makefile b/Installed/Appl/Breadbox/testapps/ttf2/Makefile index 4675830fd..5da7cc050 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/Makefile +++ b/Installed/Appl/Breadbox/testapps/ttf2/Makefile @@ -5,17 +5,17 @@ # GEODE = ttf2 FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ttdebug.c ttinterp.c ttload.c ttfile.c\ - ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ + ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ header.h ttinterp.h ttload.h tttables.h ttobjs.h\ fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ - ft_conf.h ttextend.h ftnameid.h ttcalc.h ttmemory.h\ - tttags.h + ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ + ttmemory.h tttags.h UI = ttf2.goc UI_TO_RDFS = OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ - ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj\ + ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ ttmemory.obj ttf2.obj COMMON = diff --git a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk index 5d6383718..350951b47 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk +++ b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk @@ -30,7 +30,7 @@ ttf2.eobj: geos.h heap.h geode.h resource.h ec.h object.h lmem.h \ FreeType/ftnameid.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ - FreeType/ft_conf.h geos.h file.h Ansi/stdlib.h \ + FreeType/ft_conf.h geos.h file.h resource.h Ansi/stdlib.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h \ FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ @@ -38,94 +38,107 @@ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ttdebug.h ttraster.obj \ ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ - FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ - Ansi/string.h + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h ttmutex.obj \ ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h + geos.h file.h resource.h Ansi/stdlib.h ttgload.obj \ ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ - FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttgload.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/tttags.h \ - FreeType/ttload.h + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ + FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h ttextend.obj \ ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h ttcalc.obj \ ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ - FreeType/tttypes.h FreeType/tttables.h + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/tttypes.h \ + FreeType/tttables.h ttapi.obj \ ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - Ansi/stdlib.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ - FreeType/ttfile.h FreeType/ttdebug.h FreeType/ttobjs.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttload.h \ - FreeType/ttgload.h FreeType/ttraster.h \ + resource.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ FreeType/ttextend.h ttdebug.obj \ ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/ttcmap.h +ftxkern.obj \ +ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttextend.h \ + FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/ttobjs.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttcache.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttdebug.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttfile.h FreeType/ttload.h FreeType/tttags.h ttinterp.obj \ ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/ttdebug.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/ttdebug.h \ FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ FreeType/ttcmap.h ttload.obj \ ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ - FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/tttags.h FreeType/ttload.h + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ + FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/tttags.h FreeType/ttload.h ttfile.obj \ ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + resource.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ FreeType/ttengine.h FreeType/ttmutex.h \ FreeType/ttmemory.h FreeType/ttfile.h ttcmap.obj \ ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ FreeType/ttload.h ttobjs.obj \ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h ttmemory.obj \ ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ FreeType/ttengine.h FreeType/ttmutex.h From a44a230a5c483a306b3127ae45e15af12b6c0ce3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 25 Jan 2022 21:33:02 +0100 Subject: [PATCH 020/246] make ttf bytecode interpreter runnable --- .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 4 +- .../testapps/ttf2/FreeType/ttinterp.c | 45 ++++++++++++++++--- Appl/Breadbox/testapps/ttf2/backlog.md | 1 + .../Breadbox/testapps/ttf2/dependencies.mk | 3 +- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index c4d48db1b..447d3ce20 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -91,7 +91,7 @@ /* by the engine and need no extensions, undefine this configuration */ /* macro to save a few more bytes. */ -#undef TT_CONFIG_OPTION_EXTEND_ENGINE +#define TT_CONFIG_OPTION_EXTEND_ENGINE /*************************************************************************/ @@ -111,7 +111,7 @@ /* emerged recently on the FreeType lists. We still do not have Apple's */ /* opinion on the subject and will change this as soon as we have. */ -#define TT_CONFIG_OPTION_NO_INTERPRETER +#undef TT_CONFIG_OPTION_NO_INTERPRETER /*************************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c index fbe2fbe74..a8e8ff510 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttinterp.c @@ -168,20 +168,53 @@ #define INS_Goto_CodeRange( range, ip ) \ Ins_Goto_CodeRange( EXEC_ARGS range, ip ) +#ifdef __GEOS__ +#define CUR_Func_project( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_project, EXEC_ARGS x, y ) +#else #define CUR_Func_project( x, y ) CUR.func_project( EXEC_ARGS x, y ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_move( z, p, d ) ProcCallFixedOrMovable_cdecl( CUR.func_move, EXEC_ARGS z, p, d ) +#else #define CUR_Func_move( z, p, d ) CUR.func_move( EXEC_ARGS z, p, d ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_dualproj( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_dualproj, EXEC_ARGS x, y ) +#else #define CUR_Func_dualproj( x, y ) CUR.func_dualproj( EXEC_ARGS x, y ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_freeProj( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_freeProj, EXEC_ARGS x, y ) +#else #define CUR_Func_freeProj( x, y ) CUR.func_freeProj( EXEC_ARGS x, y ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_round( d, c ) ProcCallFixedOrMovable_cdecl( CUR.func_round, EXEC_ARGS d, c ) +#else #define CUR_Func_round( d, c ) CUR.func_round( EXEC_ARGS d, c ) +#endif /* ifdef __GEOS__ */ -#define CUR_Func_read_cvt( index ) \ - CUR.func_read_cvt( EXEC_ARGS index ) +#ifdef __GEOS__ +#define CUR_Func_read_cvt( index ) ProcCallFixedOrMovable_cdecl( CUR.func_read_cvt, EXEC_ARGS index ) +#else +#define CUR_Func_read_cvt( index ) CUR.func_read_cvt( EXEC_ARGS index ) +#endif /* ifdef __GEOS__ */ -#define CUR_Func_write_cvt( index, val ) \ - CUR.func_write_cvt( EXEC_ARGS index, val ) +#ifdef __GEOS__ +#define CUR_Func_write_cvt( index, val ) ProcCallFixedOrMovable_cdecl( CUR.func_write_cvt, EXEC_ARGS index, val ) +#else +#define CUR_Func_write_cvt( index, val ) CUR.func_write_cvt( EXEC_ARGS index, val ) +#endif /* ifdef __GEOS__ */ -#define CUR_Func_move_cvt( index, val ) \ - CUR.func_move_cvt( EXEC_ARGS index, val ) +#ifdef __GEOS__ +#define CUR_Func_move_cvt( index, val ) ProcCallFixedOrMovable_cdecl( CUR.func_move_cvt, EXEC_ARGS index, val ) +#else +#define CUR_Func_move_cvt( index, val ) CUR.func_move_cvt( EXEC_ARGS index, val ) +#endif /* ifdef __GEOS__ */ #define CURRENT_Ratio() Current_Ratio( EXEC_ARG ) #define CURRENT_Ppem() Current_Ppem( EXEC_ARG ) diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 97855a1fa..63e9cf8d7 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -18,6 +18,7 @@ - ~~Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig~~ - Memorymanagement auf Geos Spezifika (hugemem.c könnte genügen) umstellen, übersetzbar und lauffähig - ~~Extension für Kerning aktivieren~~ +- Bytecodeinterpreter aktivieren - angepasstes FreeType in Treibersourcen verschieben - Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH - FreeType in Treiber integrieren diff --git a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk index 350951b47..efe7539d7 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk +++ b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk @@ -135,7 +135,8 @@ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h + Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h \ + FreeType/ttextend.h ttmemory.obj \ ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ From 60ee8ab94b2a7fc56ace51e6ad5e0f41644db026 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 2 Feb 2022 20:09:32 +0100 Subject: [PATCH 021/246] added ported FreeType sourcen for FreeGEOS ttf driver --- Driver/Font/TrueType/FreeType/freetype.h | 1145 +++ Driver/Font/TrueType/FreeType/ft_conf.h | 232 + Driver/Font/TrueType/FreeType/fterrid.h | 161 + Driver/Font/TrueType/FreeType/ftnameid.h | 628 ++ Driver/Font/TrueType/FreeType/ftxkern.c | 564 ++ Driver/Font/TrueType/FreeType/ftxkern.h | 181 + Driver/Font/TrueType/FreeType/header.h | 49 + Driver/Font/TrueType/FreeType/ttapi.c | 2217 ++++++ Driver/Font/TrueType/FreeType/ttcache.c | 483 ++ Driver/Font/TrueType/FreeType/ttcache.h | 216 + Driver/Font/TrueType/FreeType/ttcalc.c | 403 + Driver/Font/TrueType/FreeType/ttcalc.h | 97 + Driver/Font/TrueType/FreeType/ttcmap.c | 503 ++ Driver/Font/TrueType/FreeType/ttcmap.h | 169 + Driver/Font/TrueType/FreeType/ttconfig.h | 279 + Driver/Font/TrueType/FreeType/ttdebug.c | 404 + Driver/Font/TrueType/FreeType/ttdebug.h | 170 + Driver/Font/TrueType/FreeType/ttengine.h | 115 + Driver/Font/TrueType/FreeType/ttextend.c | 212 + Driver/Font/TrueType/FreeType/ttextend.h | 168 + Driver/Font/TrueType/FreeType/ttfile.c | 1227 +++ Driver/Font/TrueType/FreeType/ttfile.h | 271 + Driver/Font/TrueType/FreeType/ttgload.c | 1351 ++++ Driver/Font/TrueType/FreeType/ttgload.h | 51 + Driver/Font/TrueType/FreeType/ttinterp.c | 6687 +++++++++++++++++ Driver/Font/TrueType/FreeType/ttinterp.h | 54 + Driver/Font/TrueType/FreeType/ttload.c | 1574 ++++ Driver/Font/TrueType/FreeType/ttload.h | 217 + Driver/Font/TrueType/FreeType/ttmemory.c | 397 + Driver/Font/TrueType/FreeType/ttmemory.h | 125 + Driver/Font/TrueType/FreeType/ttmutex.c | 85 + Driver/Font/TrueType/FreeType/ttmutex.h | 59 + Driver/Font/TrueType/FreeType/ttobjs.c | 1494 ++++ Driver/Font/TrueType/FreeType/ttobjs.h | 873 +++ Driver/Font/TrueType/FreeType/ttraster.c | 2751 +++++++ Driver/Font/TrueType/FreeType/ttraster.h | 127 + Driver/Font/TrueType/FreeType/tttables.h | 215 + Driver/Font/TrueType/FreeType/tttags.h | 61 + Driver/Font/TrueType/FreeType/tttypes.h | 150 + .../{truetype.asm => Main/mainManager.asm} | 4 +- .../TrueType/{ => Main}/truetypeChars.asm | 0 .../TrueType/{ => Main}/truetypeConstant.def | 0 .../Font/TrueType/{ => Main}/truetypeEC.asm | 0 .../TrueType/{ => Main}/truetypeEscape.asm | 0 .../Font/TrueType/{ => Main}/truetypeInit.asm | 0 .../TrueType/{ => Main}/truetypeMacros.def | 0 .../TrueType/{ => Main}/truetypeMetrics.asm | 0 .../Font/TrueType/{ => Main}/truetypePath.asm | 0 .../TrueType/{ => Main}/truetypeVariable.def | 0 .../TrueType/{ => Main}/truetypeWidths.asm | 0 Driver/Font/TrueType/truetype.gp | 1 + Installed/Driver/Font/TrueType/Makefile | 73 +- .../Driver/Font/TrueType/dependencies.mk | 146 +- 53 files changed, 26342 insertions(+), 47 deletions(-) create mode 100644 Driver/Font/TrueType/FreeType/freetype.h create mode 100644 Driver/Font/TrueType/FreeType/ft_conf.h create mode 100644 Driver/Font/TrueType/FreeType/fterrid.h create mode 100644 Driver/Font/TrueType/FreeType/ftnameid.h create mode 100644 Driver/Font/TrueType/FreeType/ftxkern.c create mode 100644 Driver/Font/TrueType/FreeType/ftxkern.h create mode 100644 Driver/Font/TrueType/FreeType/header.h create mode 100644 Driver/Font/TrueType/FreeType/ttapi.c create mode 100644 Driver/Font/TrueType/FreeType/ttcache.c create mode 100644 Driver/Font/TrueType/FreeType/ttcache.h create mode 100644 Driver/Font/TrueType/FreeType/ttcalc.c create mode 100644 Driver/Font/TrueType/FreeType/ttcalc.h create mode 100644 Driver/Font/TrueType/FreeType/ttcmap.c create mode 100644 Driver/Font/TrueType/FreeType/ttcmap.h create mode 100644 Driver/Font/TrueType/FreeType/ttconfig.h create mode 100644 Driver/Font/TrueType/FreeType/ttdebug.c create mode 100644 Driver/Font/TrueType/FreeType/ttdebug.h create mode 100644 Driver/Font/TrueType/FreeType/ttengine.h create mode 100644 Driver/Font/TrueType/FreeType/ttextend.c create mode 100644 Driver/Font/TrueType/FreeType/ttextend.h create mode 100644 Driver/Font/TrueType/FreeType/ttfile.c create mode 100644 Driver/Font/TrueType/FreeType/ttfile.h create mode 100644 Driver/Font/TrueType/FreeType/ttgload.c create mode 100644 Driver/Font/TrueType/FreeType/ttgload.h create mode 100644 Driver/Font/TrueType/FreeType/ttinterp.c create mode 100644 Driver/Font/TrueType/FreeType/ttinterp.h create mode 100644 Driver/Font/TrueType/FreeType/ttload.c create mode 100644 Driver/Font/TrueType/FreeType/ttload.h create mode 100644 Driver/Font/TrueType/FreeType/ttmemory.c create mode 100644 Driver/Font/TrueType/FreeType/ttmemory.h create mode 100644 Driver/Font/TrueType/FreeType/ttmutex.c create mode 100644 Driver/Font/TrueType/FreeType/ttmutex.h create mode 100644 Driver/Font/TrueType/FreeType/ttobjs.c create mode 100644 Driver/Font/TrueType/FreeType/ttobjs.h create mode 100644 Driver/Font/TrueType/FreeType/ttraster.c create mode 100644 Driver/Font/TrueType/FreeType/ttraster.h create mode 100644 Driver/Font/TrueType/FreeType/tttables.h create mode 100644 Driver/Font/TrueType/FreeType/tttags.h create mode 100644 Driver/Font/TrueType/FreeType/tttypes.h rename Driver/Font/TrueType/{truetype.asm => Main/mainManager.asm} (94%) rename Driver/Font/TrueType/{ => Main}/truetypeChars.asm (100%) rename Driver/Font/TrueType/{ => Main}/truetypeConstant.def (100%) rename Driver/Font/TrueType/{ => Main}/truetypeEC.asm (100%) rename Driver/Font/TrueType/{ => Main}/truetypeEscape.asm (100%) rename Driver/Font/TrueType/{ => Main}/truetypeInit.asm (100%) rename Driver/Font/TrueType/{ => Main}/truetypeMacros.def (100%) rename Driver/Font/TrueType/{ => Main}/truetypeMetrics.asm (100%) rename Driver/Font/TrueType/{ => Main}/truetypePath.asm (100%) rename Driver/Font/TrueType/{ => Main}/truetypeVariable.def (100%) rename Driver/Font/TrueType/{ => Main}/truetypeWidths.asm (100%) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h new file mode 100644 index 000000000..b9fc1f27c --- /dev/null +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -0,0 +1,1145 @@ +/******************************************************************* + * + * freetype.h + * + * High-level interface specification. + * + * 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. + * + * Note: + * + * This is the only file that should be included by client + * application sources. All other types and functions defined + * in the `tt*.h' files are library internals and should not be + * included. + * + ******************************************************************/ + +#ifndef FREETYPE_H +#define FREETYPE_H + + +#define TT_FREETYPE_MAJOR 1 +#define TT_FREETYPE_MINOR 3 + + +#include "fterrid.h" +#include "ftnameid.h" + +/* To make freetype.h independent from configuration files we check */ +/* whether EXPORT_DEF has been defined already. */ + +#ifndef EXPORT_DEF +#define EXPORT_DEF extern +#endif + +/* The same for TT_Text. If you define the HAVE_TT_TEXT macro, you */ +/* have to provide a typedef declaration for TT_Text before */ +/* including this file. */ + +#ifndef HAVE_TT_TEXT +#define HAVE_TT_TEXT + typedef char TT_Text; /* The data type to represent */ + /* file name string elements. */ +#endif + +#ifdef __cplusplus + extern "C" { +#endif + + + /*******************************************************************/ + /* */ + /* FreeType types definitions. */ + /* */ + /* All these begin with a 'TT_' prefix. */ + /* */ + /*******************************************************************/ + + typedef int TT_Bool; + + typedef signed long TT_Fixed; /* signed fixed 16.16 float */ + + typedef signed short TT_FWord; /* distance in FUnits */ + typedef unsigned short TT_UFWord; /* unsigned distance */ + + typedef char TT_String; + typedef signed char TT_Char; + typedef unsigned char TT_Byte; + typedef signed short TT_Short; + typedef unsigned short TT_UShort; + typedef int TT_Int; + typedef unsigned int TT_UInt; + typedef signed long TT_Long; + typedef unsigned long TT_ULong; + + typedef signed short TT_F2Dot14; /* Signed fixed float 2.14 used for */ + /* unit vectors, with layout */ + /* */ + /* s : 1 -- sign bit */ + /* m : 1 -- integer bit */ + /* f : 14 -- unsigned fractional */ + /* */ + /* `s:m' is the 2-bit signed int */ + /* value to which the positive */ + /* fractional part should be added. */ + + typedef signed long TT_F26Dot6; /* 26.6 fixed float, used for */ + /* glyph points pixel coordinates. */ + + typedef signed long TT_Pos; /* Point position, expressed either */ + /* in fractional pixels or notional */ + /* units, depending on context. */ + /* For example, glyph coordinates */ + /* returned by TT_Load_Glyph() are */ + /* expressed in font units if */ + /* scaling wasn't requested, and */ + /* in 26.6 fractional pixels if it */ + /* was. */ + + + struct TT_UnitVector_ /* guess what... */ + { + TT_F2Dot14 x; + TT_F2Dot14 y; + }; + + typedef struct TT_UnitVector_ TT_UnitVector; + + + struct TT_Vector_ /* simple vector type */ + { + TT_F26Dot6 x; + TT_F26Dot6 y; + }; + + typedef struct TT_Vector_ TT_Vector; + + + /* A simple 2x2 matrix used for transformations. */ + /* You should use 16.16 fixed floats. */ + /* */ + /* x' = xx*x + xy*y */ + /* y' = yx*x + yy*y */ + /* */ + + struct TT_Matrix_ + { + TT_Fixed xx, xy; + TT_Fixed yx, yy; + }; + + typedef struct TT_Matrix_ TT_Matrix; + + + /* A structure used to describe the source glyph to the renderer. */ + + struct TT_Outline_ + { + TT_Short n_contours; /* number of contours in glyph */ + TT_UShort n_points; /* number of points in the glyph */ + + TT_Vector* points; /* the outline's points */ + TT_Byte* flags; /* the points flags */ + TT_UShort* contours; /* the contour end points */ + + /* The following flag indicates that the outline owns the arrays it */ + /* refers to. Typically, this is true of outlines created from the */ + /* TT_New_Outline() API, while it isn't for those returned by */ + /* TT_Get_Glyph_Outline(). */ + + TT_Bool owner; /* The outline owns the coordinates, */ + /* flags and contours array it uses. */ + + /* The following flags are set automatically by */ + /* TT_Get_Glyph_Outline(). Their meaning is the following: */ + /* */ + /* high_precision If true, the scan-line converter will use a */ + /* higher precision to render bitmaps (i.e., a */ + /* 1/1024 pixel precision). This is important for */ + /* small ppem sizes. */ + /* */ + /* second_pass If true, the scan-line converter performs a */ + /* second sweep phase dedicated to find vertical */ + /* drop-outs. If false, only horizontal drop-outs */ + /* will be checked during the first vertical */ + /* sweep (yes, this is a bit confusing but it is */ + /* really the way it should work). This is */ + /* important for small ppems too. */ + /* */ + /* dropout_mode Specifies the TrueType drop-out mode to use for */ + /* continuity checking. Valid values are 0 (no */ + /* check), 1, 2, 4, and 5. */ + /* */ + /* Most of the engine's users will safely ignore these fields... */ + + TT_Bool high_precision; /* high precision rendering */ + TT_Bool second_pass; /* two sweeps rendering */ + TT_Char dropout_mode; /* dropout mode */ + }; + + typedef struct TT_Outline_ TT_Outline; + + + /* A structure used to describe a simple bounding box. */ + + struct TT_BBox_ + { + TT_Pos xMin; + TT_Pos yMin; + TT_Pos xMax; + TT_Pos yMax; + }; + + typedef struct TT_BBox_ TT_BBox; + + + /* A structure used to return glyph metrics. */ + /* */ + /* The `bearingX' isn't called `left-side bearing' anymore because */ + /* it has different meanings depending on the glyph's orientation. */ + /* */ + /* The same is true for `bearingY', which is the top-side bearing */ + /* defined by the TT_Spec, i.e., the distance from the baseline to */ + /* the top of the glyph's bbox. According to our current convention, */ + /* this is always the same as `bbox.yMax' but we make it appear for */ + /* consistency in its proper field. */ + /* */ + /* The `advance' field is the advance width for horizontal layout, */ + /* and advance height for vertical layouts. */ + + struct TT_Glyph_Metrics_ + { + TT_BBox bbox; /* glyph bounding box */ + + TT_Pos bearingX; /* left-side bearing */ + TT_Pos bearingY; /* top-side bearing, per se the TT spec */ + + TT_Pos advance; /* advance width (or height) */ + }; + + typedef struct TT_Glyph_Metrics_ TT_Glyph_Metrics; + + + /* A structure used to return horizontal _and_ vertical glyph */ + /* metrics. */ + /* */ + /* A glyph can be used either in a horizontal or vertical layout. */ + /* Its glyph metrics vary with orientation. The TT_Big_Glyph_Metrics */ + /* structure is used to return _all_ metrics in one call. */ + + struct TT_Big_Glyph_Metrics_ + { + TT_BBox bbox; /* glyph bounding box */ + + TT_Pos horiBearingX; /* left side bearing in horizontal layouts */ + TT_Pos horiBearingY; /* top side bearing in horizontal layouts */ + + TT_Pos vertBearingX; /* left side bearing in vertical layouts */ + TT_Pos vertBearingY; /* top side bearing in vertical layouts */ + + TT_Pos horiAdvance; /* advance width for horizontal layout */ + TT_Pos vertAdvance; /* advance height for vertical layout */ + + /* The following fields represent unhinted scaled metrics values. */ + /* They can be useful for applications needing to do some device */ + /* independent placement of glyphs. */ + /* */ + /* Applying these metrics to hinted glyphs will most surely ruin */ + /* the grid fitting performed by the bytecode interpreter. These */ + /* values are better used to compute accumulated positioning */ + /* distances. */ + + TT_Pos linearHoriBearingX; /* linearly scaled horizontal lsb */ + TT_Pos linearHoriAdvance; /* linearly scaled horizontal advance */ + + TT_Pos linearVertBearingY; /* linearly scaled vertical tsb */ + TT_Pos linearVertAdvance; /* linearly scaled vertical advance */ + }; + + typedef struct TT_Big_Glyph_Metrics_ TT_Big_Glyph_Metrics; + + + /* A structure used to return instance metrics. */ + + struct TT_Instance_Metrics_ + { + TT_F26Dot6 pointSize; /* char. size in points (1pt = 1/72 inch) */ + + TT_UShort x_ppem; /* horizontal pixels per EM square */ + TT_UShort y_ppem; /* vertical pixels per EM square */ + + TT_Fixed x_scale; /* 16.16 to convert from EM units to 26.6 pix */ + TT_Fixed y_scale; /* 16.16 to convert from EM units to 26.6 pix */ + + TT_UShort x_resolution; /* device horizontal resolution in dpi */ + TT_UShort y_resolution; /* device vertical resolution in dpi */ + }; + + typedef struct TT_Instance_Metrics_ TT_Instance_Metrics; + + + /* Flow constants: */ + /* */ + /* The flow of a bitmap refers to the way lines are oriented */ + /* within the bitmap data, i.e., the orientation of the Y */ + /* coordinate axis. */ + /* */ + /* For example, if the first bytes of the bitmap pertain to */ + /* its top-most line, then the flow is `down'. If these bytes */ + /* pertain to its lowest line, the the flow is `up'. */ + +#define TT_Flow_Down -1 /* bitmap is oriented from top to bottom */ +#define TT_Flow_Up 1 /* bitmap is oriented from bottom to top */ +#define TT_Flow_Error 0 /* an error occurred during rendering */ + + + /* A structure used to describe the target bitmap or pixmap to the */ + /* renderer. Note that there is nothing in this structure that */ + /* gives the nature of the buffer. */ + /* */ + /* IMPORTANT NOTE: */ + /* */ + /* In the case of a pixmap, the `width' and `cols' fields must */ + /* have the _same_ values, and _must_ be padded to 32-bits, i.e., */ + /* be a multiple of 4. Clipping problems will arise otherwise, */ + /* if not even page faults! */ + /* */ + /* The typical settings are: */ + /* */ + /* - for a WxH bitmap: */ + /* */ + /* rows = H */ + /* cols = (W+7) / 8 */ + /* width = W */ + /* flow = your_choice */ + /* */ + /* - for a WxH pixmap: */ + /* */ + /* rows = H */ + /* cols = (W+3) & ~3 */ + /* width = cols */ + /* flow = your_choice */ + + struct TT_Raster_Map_ + { + int rows; /* number of rows */ + int cols; /* number of columns (bytes) per row */ + int width; /* number of pixels per line */ + int flow; /* bitmap orientation */ + + void* bitmap; /* bit/pixmap buffer */ + long size; /* bit/pixmap size in bytes */ + }; + + typedef struct TT_Raster_Map_ TT_Raster_Map; + + + /* ------ The font header TrueType table structure ------ */ + + struct TT_Header_ + { + TT_Fixed Table_Version; + TT_Fixed Font_Revision; + + TT_Long CheckSum_Adjust; + TT_Long Magic_Number; + + TT_UShort Flags; + TT_UShort Units_Per_EM; + + TT_Long Created [2]; + TT_Long Modified[2]; + + TT_FWord xMin; + TT_FWord yMin; + TT_FWord xMax; + TT_FWord yMax; + + TT_UShort Mac_Style; + TT_UShort Lowest_Rec_PPEM; + + TT_Short Font_Direction; + TT_Short Index_To_Loc_Format; + TT_Short Glyph_Data_Format; + }; + + typedef struct TT_Header_ TT_Header; + + + /* ------ The horizontal header TrueType table structure ------ */ + + /*******************************************************/ + /* This structure is the one defined by the TrueType */ + /* specification, plus two fields used to link the */ + /* font-units metrics to the header. */ + + struct TT_Horizontal_Header_ + { + TT_Fixed Version; + TT_FWord Ascender; + TT_FWord Descender; + TT_FWord Line_Gap; + + TT_UFWord advance_Width_Max; /* advance width maximum */ + + TT_FWord min_Left_Side_Bearing; /* minimum left-sb */ + TT_FWord min_Right_Side_Bearing; /* minimum right-sb */ + TT_FWord xMax_Extent; /* xmax extents */ + TT_FWord caret_Slope_Rise; + TT_FWord caret_Slope_Run; + + TT_Short Reserved0, + Reserved1, + Reserved2, + Reserved3, + Reserved4; + + TT_Short metric_Data_Format; + TT_UShort number_Of_HMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + }; + + typedef struct TT_Horizontal_Header_ TT_Horizontal_Header; + + + /*******************************************************/ + /* This structure is the one defined by the TrueType */ + /* specification. Note that it has exactly the same */ + /* layout as the horizontal header (both are loaded */ + /* by the same function). */ + + struct TT_Vertical_Header_ + { + TT_Fixed Version; + TT_FWord Ascender; + TT_FWord Descender; + TT_FWord Line_Gap; + + TT_UFWord advance_Height_Max; /* advance height maximum */ + + TT_FWord min_Top_Side_Bearing; /* minimum left-sb or top-sb */ + TT_FWord min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ + TT_FWord yMax_Extent; /* xmax or ymax extents */ + TT_FWord caret_Slope_Rise; + TT_FWord caret_Slope_Run; + TT_FWord caret_Offset; + + TT_Short Reserved1, + Reserved2, + Reserved3, + Reserved4; + + TT_Short metric_Data_Format; + TT_UShort number_Of_VMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + }; + + typedef struct TT_Vertical_Header_ TT_Vertical_Header; + + + /* ------ The OS/2 table ------ */ + + /************************************************************************/ + /* Note that since FreeType 1.3, we support Mac fonts which do not have */ + /* an OS/2 table. In this case the `version' field will be set to */ + /* 0xFFFF by the table loader; all other fields should be 0. */ + + struct TT_OS2_ + { + TT_UShort version; /* 0x0001 */ + TT_FWord xAvgCharWidth; + TT_UShort usWeightClass; + TT_UShort usWidthClass; + TT_Short fsType; + TT_FWord ySubscriptXSize; + TT_FWord ySubscriptYSize; + TT_FWord ySubscriptXOffset; + TT_FWord ySubscriptYOffset; + TT_FWord ySuperscriptXSize; + TT_FWord ySuperscriptYSize; + TT_FWord ySuperscriptXOffset; + TT_FWord ySuperscriptYOffset; + TT_FWord yStrikeoutSize; + TT_FWord yStrikeoutPosition; + TT_Short sFamilyClass; + + TT_Byte panose[10]; + + TT_ULong ulUnicodeRange1; /* Bits 0-31 */ + TT_ULong ulUnicodeRange2; /* Bits 32-63 */ + TT_ULong ulUnicodeRange3; /* Bits 64-95 */ + TT_ULong ulUnicodeRange4; /* Bits 96-127 */ + + TT_Char achVendID[4]; + + TT_UShort fsSelection; + TT_UShort usFirstCharIndex; + TT_UShort usLastCharIndex; + TT_Short sTypoAscender; + TT_Short sTypoDescender; + TT_Short sTypoLineGap; + TT_UShort usWinAscent; + TT_UShort usWinDescent; + + /* only version 1 tables: */ + + TT_ULong ulCodePageRange1; /* Bits 0-31 */ + TT_ULong ulCodePageRange2; /* Bits 32-63 */ + }; + + typedef struct TT_OS2_ TT_OS2; + + + /* ------ The PostScript table ------ */ + + struct TT_Postscript_ + { + TT_Fixed FormatType; + TT_Fixed italicAngle; + TT_FWord underlinePosition; + TT_FWord underlineThickness; + TT_ULong isFixedPitch; + TT_ULong minMemType42; + TT_ULong maxMemType42; + TT_ULong minMemType1; + TT_ULong maxMemType1; + + /* Glyph names follow in the file, but we don't */ + /* load them by default. See the ftxpost.c extension. */ + }; + + typedef struct TT_Postscript_ TT_Postscript; + + + /* ------ The horizontal device metrics table (`hdmx') ------ */ + + struct TT_Hdmx_Record_ + { + TT_Byte ppem; + TT_Byte max_width; + TT_Byte* widths; + }; + + typedef struct TT_Hdmx_Record_ TT_Hdmx_Record; + + + struct TT_Hdmx_ + { + TT_UShort version; + TT_Short num_records; + TT_Hdmx_Record* records; + }; + + typedef struct TT_Hdmx_ TT_Hdmx; + + + /* A structure used to describe face properties. */ + + struct TT_Face_Properties_ + { + TT_UShort num_Glyphs; /* number of glyphs in face */ + TT_UShort max_Points; /* maximum number of points in a glyph */ + TT_UShort max_Contours; /* maximum number of contours in a glyph */ + + TT_UShort num_CharMaps; /* number of charmaps in the face */ + TT_UShort num_Names; /* number of name records in the face */ + + TT_ULong num_Faces; /* 1 for normal TrueType files, and the */ + /* number of embedded faces for TrueType */ + /* collections */ + + TT_Header* header; /* TrueType header table */ + TT_Horizontal_Header* horizontal; /* TrueType horizontal header */ + TT_OS2* os2; /* TrueType OS/2 table */ + TT_Postscript* postscript; /* TrueType Postscript table */ + TT_Hdmx* hdmx; /* TrueType hor. dev. metr. table */ + TT_Vertical_Header* vertical; /* TT Vertical header, if present */ + }; + + typedef struct TT_Face_Properties_ TT_Face_Properties; + + + /* Here are the definitions of the handle types used for FreeType's */ + /* most common objects accessed by the client application. We use */ + /* a simple trick: */ + /* */ + /* Each handle type is a structure that only contains one */ + /* pointer. The advantage of structures is that they are */ + /* mutually exclusive types. We could have defined the */ + /* following types: */ + /* */ + /* typedef void* TT_Stream; */ + /* typedef void* TT_Face; */ + /* typedef void* TT_Instance; */ + /* typedef void* TT_Glyph; */ + /* typedef void* TT_CharMap; */ + /* */ + /* but these would have allowed lines like: */ + /* */ + /* stream = instance; */ + /* */ + /* in the client code this would be a severe bug, unnoticed */ + /* by the compiler! */ + /* */ + /* Thus, we enforce type checking with a simple language */ + /* trick... */ + /* */ + /* NOTE: Some macros are defined in tttypes.h to perform */ + /* automatic type conversions for library hackers... */ + + struct TT_Engine_ { void* z; }; + struct TT_Stream_ { void* z; }; + struct TT_Face_ { void* z; }; + struct TT_Instance_ { void* z; }; + struct TT_Glyph_ { void* z; }; + struct TT_CharMap_ { void* z; }; + + typedef struct TT_Engine_ TT_Engine; /* engine instance */ + typedef struct TT_Stream_ TT_Stream; /* stream handle type */ + typedef struct TT_Face_ TT_Face; /* face handle type */ + typedef struct TT_Instance_ TT_Instance; /* instance handle type */ + typedef struct TT_Glyph_ TT_Glyph; /* glyph handle type */ + typedef struct TT_CharMap_ TT_CharMap; /* character map handle type */ + + + /* Almost all functions return an error code of this type. */ + + typedef long TT_Error; + + + /*******************************************************************/ + /* */ + /* FreeType API */ + /* */ + /* All these begin with a `TT_' prefix. */ + /* */ + /* Most of them are implemented in the `ttapi.c' source file. */ + /* */ + /*******************************************************************/ + + /* Get version information. */ + + EXPORT_DEF + TT_Error TT_FreeType_Version( int *major, + int *minor ); + + + /* Initialize the engine. */ + + EXPORT_DEF + TT_Error TT_Init_FreeType( TT_Engine* engine ); + + + /* Finalize the engine, and release all allocated objects. */ + + EXPORT_DEF + TT_Error TT_Done_FreeType( TT_Engine engine ); + + + /* Set the gray level palette. This is an array of 5 bytes used */ + /* to produce the font smoothed pixmaps. By convention: */ + /* */ + /* palette[0] = background (white) */ + /* palette[1] = light */ + /* palette[2] = medium */ + /* palette[3] = dark */ + /* palette[4] = foreground (black) */ + /* */ + + EXPORT_DEF + TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, + TT_Byte* palette ); + + + /* ----------------------- face management ----------------------- */ + + /* Open a new TrueType font file, and returns a handle for */ + /* it in variable '*face'. */ + /* */ + /* Note: The file can be either a TrueType file (*.ttf) or */ + /* a TrueType collection (*.ttc, in this case, only */ + /* the first face is opened). The number of faces in */ + /* the same collection can be obtained in the face's */ + /* properties, using TT_Get_Face_Properties() and the */ + /* `max_Faces' field. */ + + EXPORT_DEF + TT_Error TT_Open_Face( TT_Engine engine, + const TT_Text* fontPathName, + TT_Face* face ); + + + /* Open a TrueType font file located inside a collection. */ + /* The font is assigned by its index in `fontIndex'. */ + + EXPORT_DEF + TT_Error TT_Open_Collection( TT_Engine engine, + const TT_Text* collectionPathName, + TT_ULong fontIndex, + TT_Face* face ); + + + /* Return face properties in the `properties' structure. */ + /* */ + /* Note that since version 1.3, we support font files with no */ + /* OS/2 table (mainly old Mac fonts). In this case, the OS/2 */ + /* `version' field will be set to 0xFFFF, and all other fields */ + /* will be zeroed. */ + + EXPORT_DEF + TT_Error TT_Get_Face_Properties( TT_Face face, + TT_Face_Properties* properties ); + + + /* Set a face object's generic pointer */ + + EXPORT_DEF + TT_Error TT_Set_Face_Pointer( TT_Face face, + void* data ); + + + /* Get a face object's generic pointer */ + + EXPORT_DEF + void* TT_Get_Face_Pointer( TT_Face face ); + + + /* Close a face's file handle to save system resources. The file */ + /* will be re-opened automatically on the next disk access. */ + + EXPORT_DEF + TT_Error TT_Flush_Face( TT_Face face ); + + /* Get a face's glyph metrics expressed in font units. Returns any */ + /* number of arrays. Set the fields to NULL if you are not interested */ + /* by a given array. */ + + EXPORT_DEF + TT_Error TT_Get_Face_Metrics( TT_Face face, + TT_UShort firstGlyph, + TT_UShort lastGlyph, + TT_Short* leftBearings, + TT_UShort* widths, + TT_Short* topBearings, + TT_UShort* heights ); + + + /* Close a given font object, destroying all associated */ + /* instances. */ + + EXPORT_DEF + TT_Error TT_Close_Face( TT_Face face ); + + + /* Get font or table data. */ + + EXPORT_DEF + TT_Error TT_Get_Font_Data( TT_Face face, + TT_ULong tag, + TT_Long offset, + void* buffer, + TT_Long* length ); + + +/* A simple macro to build table tags from ASCII chars */ + +#define MAKE_TT_TAG( _x1, _x2, _x3, _x4 ) \ + (((TT_ULong)_x1 << 24) | \ + ((TT_ULong)_x2 << 16) | \ + ((TT_ULong)_x3 << 8) | \ + (TT_ULong)_x4) + + + + /* ----------------------- instance management -------------------- */ + + /* Open a new font instance and returns an instance handle */ + /* for it in `*instance'. */ + + EXPORT_DEF + TT_Error TT_New_Instance( TT_Face face, + TT_Instance* instance ); + + + /* Set device resolution for a given instance. The values are */ + /* given in dpi (Dots Per Inch). Default is 96 in both directions. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, + TT_UShort xResolution, + TT_UShort yResolution ); + + + /* Set the pointsize for a given instance. Default is 10pt. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_CharSize( TT_Instance instance, + TT_F26Dot6 charSize ); + + EXPORT_DEF + TT_Error TT_Set_Instance_CharSizes( TT_Instance instance, + TT_F26Dot6 charWidth, + TT_F26Dot6 charHeight ); + +#define TT_Set_Instance_PointSize( ins, ptsize ) \ + TT_Set_Instance_CharSize( ins, ptsize*64L ) + + EXPORT_DEF + TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, + TT_UShort pixelWidth, + TT_UShort pixelHeight, + TT_F26Dot6 pointSize ); + + + /* This function has been deprecated! Do not use it, as it */ + /* doesn't work reliably. You can perfectly control hinting */ + /* yourself when loading glyphs, then apply transforms as usual. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, + TT_Bool rotated, + TT_Bool stretched ); + + + /* Return instance metrics in `metrics'. */ + + EXPORT_DEF + TT_Error TT_Get_Instance_Metrics( TT_Instance instance, + TT_Instance_Metrics* metrics ); + + + /* Set an instance's generic pointer. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Pointer( TT_Instance instance, + void* data ); + + + /* Get an instance's generic pointer. */ + + EXPORT_DEF + void* TT_Get_Instance_Pointer( TT_Instance instance ); + + + /* Close a given instance object, destroying all associated data. */ + + EXPORT_DEF + TT_Error TT_Done_Instance( TT_Instance instance ); + + + + /* ----------------------- glyph management ----------------------- */ + + /* Create a new glyph object related to the given `face'. */ + + EXPORT_DEF + TT_Error TT_New_Glyph( TT_Face face, + TT_Glyph* glyph ); + + + /* Discard (and destroy) a given glyph object. */ + + EXPORT_DEF + TT_Error TT_Done_Glyph( TT_Glyph glyph ); + + +#define TTLOAD_SCALE_GLYPH 1 +#define TTLOAD_HINT_GLYPH 2 +#define TTLOAD_PEDANTIC 128 +#define TTLOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 256 + +#define TTLOAD_DEFAULT (TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH) + + + /* Load and process (scale/transform and hint) a glyph from the */ + /* given `instance'. The glyph and instance handles must be */ + /* related to the same face object. The glyph index can be */ + /* computed with a call to TT_Char_Index(). */ + /* */ + /* The 'load_flags' argument is a combination of the macros */ + /* TTLOAD_SCALE_GLYPH and TTLOAD_HINT_GLYPH. Hinting will be */ + /* applied only if the scaling is selected. */ + /* */ + /* If scaling is off (i.e., load_flags = 0), the returned */ + /* outlines are in EM square coordinates (also called FUnits), */ + /* extracted directly from the font with no hinting. Other */ + /* glyph metrics are also in FUnits. */ + /* */ + /* If scaling is on, the returned outlines are in fractional */ + /* pixel units (i.e. TT_F26Dot6 = 26.6 fixed floats). */ + /* */ + /* NOTE: The glyph index must be in the range 0..num_glyphs-1, */ + /* where `num_glyphs' is the total number of glyphs in */ + /* the font file (given in the face properties). */ + + EXPORT_DEF + TT_Error TT_Load_Glyph( TT_Instance instance, + TT_Glyph glyph, + TT_UShort glyphIndex, + TT_UShort loadFlags ); + + + /* Return glyph outline pointers in `outline'. Note that the returned */ + /* pointers are owned by the glyph object, and will be destroyed with */ + /* it. The client application should _not_ change the pointers. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Outline( TT_Glyph glyph, + TT_Outline* outline ); + + + /* Copy the glyph metrics into `metrics'. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Metrics( TT_Glyph glyph, + TT_Glyph_Metrics* metrics ); + + + /* Copy the glyph's big metrics into `metrics'. */ + /* Necessary to obtain vertical metrics. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, + TT_Big_Glyph_Metrics* metrics ); + + + /* Render the glyph into a bitmap, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Render the glyph into a pixmap, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + /* ----------------------- outline support ------------------------ */ + + /* Allocate a new outline. Reserve space for `numPoints' and */ + /* `numContours'. */ + + EXPORT_DEF + TT_Error TT_New_Outline( TT_UShort numPoints, + TT_Short numContours, + TT_Outline* outline ); + + + /* Release an outline. */ + + EXPORT_DEF + TT_Error TT_Done_Outline( TT_Outline* outline ); + + + /* Copy an outline into another one. */ + + EXPORT_DEF + TT_Error TT_Copy_Outline( TT_Outline* source, + TT_Outline* target ); + + + /* Render an outline into a bitmap. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + + + /* Render an outline into a pixmap. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + + + /* Return an outline's bounding box -- this function is slow as it */ + /* performs a complete scan-line process, without drawing, to get */ + /* the most accurate values. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_BBox( TT_Outline* outline, + TT_BBox* bbox ); + + + /* Apply a transformation to a glyph outline. */ + + EXPORT_DEF + void TT_Transform_Outline( TT_Outline* outline, + TT_Matrix* matrix ); + + + /* Apply a translation to a glyph outline. */ + + EXPORT_DEF + void TT_Translate_Outline( TT_Outline* outline, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Apply a transformation to a vector. */ + + EXPORT_DEF + void TT_Transform_Vector( TT_F26Dot6* x, + TT_F26Dot6* y, + TT_Matrix* matrix ); + + + /* Compute A*B/C with 64 bits intermediate precision. */ + + EXPORT_DEF + TT_Long TT_MulDiv( TT_Long A, + TT_Long B, + TT_Long C ); + + + /* Compute A*B/0x10000 with 64 bits intermediate precision. */ + /* Useful to multiply by a 16.16 fixed float value. */ + + EXPORT_DEF + TT_Long TT_MulFix( TT_Long A, + TT_Long B ); + + + /* ----------------- character mapping support --------------- */ + + /* Return the number of character mappings found in this file. */ + /* Returns -1 in case of failure (invalid face handle). */ + /* */ + /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ + /* */ + /* It is retained for backwards compatibility only and will */ + /* fail on 16bit systems. */ + /* */ + /* You can now get the charmap count in the `num_CharMaps' */ + /* field of a face's properties. */ + /* */ + + EXPORT_DEF + int TT_Get_CharMap_Count( TT_Face face ); + + + /* Return the ID of charmap number `charmapIndex' of a given face */ + /* used to enumerate the charmaps present in a TrueType file. */ + + EXPORT_DEF + TT_Error TT_Get_CharMap_ID( TT_Face face, + TT_UShort charmapIndex, + TT_UShort* platformID, + TT_UShort* encodingID ); + + + /* Look up the character maps found in `face' and return a handle */ + /* for the one matching `platformID' and `platformEncodingID' */ + /* (see the TrueType specs relating to the `cmap' table for */ + /* information on these ID numbers). Returns an error code. */ + /* In case of failure, the handle is set to NULL and is invalid. */ + + EXPORT_DEF + TT_Error TT_Get_CharMap( TT_Face face, + TT_UShort charmapIndex, + TT_CharMap* charMap ); + + + /* Translate a character code through a given character map */ + /* and return the corresponding glyph index to be used in */ + /* a TT_Load_Glyph() call. This function returns 0 in case */ + /* of failure. */ + + EXPORT_DEF + TT_UShort TT_Char_Index( TT_CharMap charMap, + TT_UShort charCode ); + + + + /* --------------------- names table support ------------------- */ + + /* Return the number of name strings found in the name table. */ + /* Returns -1 in case of failure (invalid face handle). */ + /* */ + /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ + /* */ + /* It is retained for backwards compatibility only and will */ + /* fail on 16bit systems. */ + /* */ + /* You can now get the number of name strings in a face with */ + /* the `num_Names' field of its properties. */ + + EXPORT_DEF + int TT_Get_Name_Count( TT_Face face ); + + + /* Return the ID of the name number `nameIndex' of a given face */ + /* used to enumerate the charmaps present in a TrueType file. */ + + EXPORT_DEF + TT_Error TT_Get_Name_ID( TT_Face face, + TT_UShort nameIndex, + TT_UShort* platformID, + TT_UShort* encodingID, + TT_UShort* languageID, + TT_UShort* nameID ); + + + /* Return the address and length of the name number `nameIndex' */ + /* of a given face in the variables `stringPtr' resp. `length'. */ + /* The string is part of the face object and shouldn't be */ + /* written to or released. */ + /* */ + /* Note that for an invalid platform ID a null pointer will be */ + /* returned. */ + + EXPORT_DEF + TT_Error TT_Get_Name_String( TT_Face face, + TT_UShort nameIndex, + TT_String** stringPtr, + TT_UShort* length ); + + +#ifdef __cplusplus + } +#endif + +#endif /* FREETYPE_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h new file mode 100644 index 000000000..637eccd18 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -0,0 +1,232 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for the FreeGEOS Build */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Under FreeGEOS we need this for the file operations. */ +#include +#include +#include + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. Unix-specific */ +#undef HAVE_FCNTL_H + +/* command.com can't pipe stderr into a file; any message would be */ +/* written into the graphics screen. */ +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) + + +/* The number of bytes in a int. We use the ANSI header file limits.h */ +/* for determining it since there is no easy way to guess. */ +/* */ +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +/* We now try to guess the size of longs in the same way */ +/* */ +#if ULONG_MAX == 0xFFFFFFFF +#define SIZEOF_LONG 4 +#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF +#define SIZEOF_LONG 8 +#else +#error "Unsupported number of bytes in `long' type!" +#endif + + +/**********************************************************************/ +/* */ +/* The following configuration macros can be tweaked manually by */ +/* a developer to turn on or off certain features or options in the */ +/* TrueType engine. This may be useful to tune it for specific */ +/* purposes.. */ +/* */ +/**********************************************************************/ + + +/*************************************************************************/ +/* Define this if the underlying operating system uses a different */ +/* character width than 8bit for file names. You must then also supply */ +/* a typedef declaration for defining 'TT_Text'. Default is off. */ + +/* #define HAVE_TT_TEXT */ + + +/*************************************************************************/ +/* Define this if you want to generate code to support engine extensions */ +/* Default is on, but if you're satisfied by the basic services provided */ +/* by the engine and need no extensions, undefine this configuration */ +/* macro to save a few more bytes. */ + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + + +/*************************************************************************/ +/* Define this if you want to generate code to support gray-scaling, */ +/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ +/* disable it if you don't need it. */ + +#undef TT_CONFIG_OPTION_GRAY_SCALING + + +/*************************************************************************/ +/* Define this if you want to completely disable the use of the bytecode */ +/* interpreter. Doing so will produce a much smaller library, but the */ +/* quality of the rendered glyphs will enormously suffer from this. */ +/* */ +/* This switch was introduced due to the Apple patents issue which */ +/* emerged recently on the FreeType lists. We still do not have Apple's */ +/* opinion on the subject and will change this as soon as we have. */ + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to use a big 'switch' statement within the */ +/* bytecode interpreter. Because some non-optimizing compilers are not */ +/* able to produce jump tables from such statements, undefining this */ +/* configuration macro will generate the appropriate C jump table in */ +/* ttinterp.c. If you use an optimizing compiler, you should leave it */ +/* defined for better performance and code compactness.. */ + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the TrueType */ +/* bytecode interpreter. This will produce much bigger code, which */ +/* _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + + +/*************************************************************************/ +/* Define this if you want to build a 'static' version of the scan-line */ +/* converter (the component which in charge of converting outlines into */ +/* bitmaps). This will produce a bigger object file for "ttraster.c", */ +/* which _may_ be faster on some architectures.. */ +/* */ +/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ +/* */ +#undef TT_CONFIG_OPTION_STATIC_RASTER + + +/*************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#undef TT_CONFIG_OPTION_THREAD_SAFE + + +/**********************************************************************/ +/* */ +/* The following macros are used to define the debug level, as well */ +/* as individual tracing levels for each component. There are */ +/* currently three modes of operation : */ +/* */ +/* - trace mode (define DEBUG_LEVEL_TRACE) */ +/* */ +/* The engine prints all error messages, as well as tracing */ +/* ones, filtered by each component's level */ +/* */ +/* - debug mode (define DEBUG_LEVEL_ERROR) */ +/* */ +/* Disable tracing, but keeps error output and assertion */ +/* checks. */ +/* */ +/* - release mode (don't define anything) */ +/* */ +/* Don't include error-checking or tracing code in the */ +/* engine's code. Ideal for releases. */ +/* */ +/* NOTE : */ +/* */ +/* Each component's tracing level is defined in its own source. */ +/* */ +/**********************************************************************/ + +/* Define if you want to use the tracing debug mode */ +#undef DEBUG_LEVEL_TRACE + +/* Define if you want to use the error debug mode - ignored if */ +/* DEBUG_LEVEL_TRACE is defined */ +#undef DEBUG_LEVEL_ERROR + + +/**************************************************************************/ +/* Definition of various integer sizes. These types are used by ttcalc */ +/* and ttinterp (for the 64-bit integers) only.. */ + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/fterrid.h b/Driver/Font/TrueType/FreeType/fterrid.h new file mode 100644 index 000000000..5606e5dc8 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/fterrid.h @@ -0,0 +1,161 @@ +/******************************************************************* + * + * fterrid.h + * + * TrueType Error ID definitions + * + * 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 FREETYPE_H +#error "Don't include this file! Use freetype.h instead." +#endif + +#ifndef FTERRID_H +#define FTERRID_H + + /************************ error codes declaration **************/ + + /* The error codes are grouped in 'classes' used to indicate the */ + /* 'level' at which the error happened. */ + /* The class is given by an error code's high byte. */ + + + /* ------------- Success is always 0 -------- */ + +#define TT_Err_Ok 0 + + + /* -------- High-level API error codes ------ */ + +#define TT_Err_Invalid_Face_Handle 0x001 +#define TT_Err_Invalid_Instance_Handle 0x002 +#define TT_Err_Invalid_Glyph_Handle 0x003 +#define TT_Err_Invalid_CharMap_Handle 0x004 +#define TT_Err_Invalid_Result_Address 0x005 +#define TT_Err_Invalid_Glyph_Index 0x006 +#define TT_Err_Invalid_Argument 0x007 +#define TT_Err_Could_Not_Open_File 0x008 +#define TT_Err_File_Is_Not_Collection 0x009 + +#define TT_Err_Table_Missing 0x00A +#define TT_Err_Invalid_Horiz_Metrics 0x00B +#define TT_Err_Invalid_CharMap_Format 0x00C +#define TT_Err_Invalid_PPem 0x00D +#define TT_Err_Invalid_Vert_Metrics 0x00E + +#define TT_Err_Invalid_File_Format 0x010 + +#define TT_Err_Invalid_Engine 0x020 +#define TT_Err_Too_Many_Extensions 0x021 +#define TT_Err_Extensions_Unsupported 0x022 +#define TT_Err_Invalid_Extension_Id 0x023 + +#define TT_Err_No_Vertical_Data 0x030 + +#define TT_Err_Max_Profile_Missing 0x080 +#define TT_Err_Header_Table_Missing 0x081 +#define TT_Err_Horiz_Header_Missing 0x082 +#define TT_Err_Locations_Missing 0x083 +#define TT_Err_Name_Table_Missing 0x084 +#define TT_Err_CMap_Table_Missing 0x085 +#define TT_Err_Hmtx_Table_Missing 0x086 +#define TT_Err_OS2_Table_Missing 0x087 +#define TT_Err_Post_Table_Missing 0x088 +#define TT_Err_Glyf_Table_Missing 0x089 + + + /* -------- Memory component error codes ---- */ + + /* this error indicates that an operation cannot */ + /* be performed due to memory exhaustion. */ + +#define TT_Err_Out_Of_Memory 0x100 + + + /* -------- File component error codes ------ */ + + /* these error codes indicate that the file could */ + /* not be accessed properly. Usually, this means */ + /* a broken font file! */ + +#define TT_Err_Invalid_File_Offset 0x200 +#define TT_Err_Invalid_File_Read 0x201 +#define TT_Err_Invalid_Frame_Access 0x202 + + + /* -------- Glyph loader error codes -------- */ + + /* Produced only by the glyph loader, these error */ + /* codes indicate a broken glyph in a font file. */ + +#define TT_Err_Too_Many_Points 0x300 +#define TT_Err_Too_Many_Contours 0x301 +#define TT_Err_Invalid_Composite 0x302 +#define TT_Err_Too_Many_Ins 0x303 + + + /* --- bytecode interpreter error codes ----- */ + + /* These error codes are produced by the TrueType */ + /* bytecode interpreter. They usually indicate a */ + /* broken font file, a broken glyph within a font */ + /* file, or a bug in the interpreter! */ + +#define TT_Err_Invalid_Opcode 0x400 +#define TT_Err_Too_Few_Arguments 0x401 +#define TT_Err_Stack_Overflow 0x402 +#define TT_Err_Code_Overflow 0x403 +#define TT_Err_Bad_Argument 0x404 +#define TT_Err_Divide_By_Zero 0x405 +#define TT_Err_Storage_Overflow 0x406 +#define TT_Err_Cvt_Overflow 0x407 +#define TT_Err_Invalid_Reference 0x408 +#define TT_Err_Invalid_Distance 0x409 +#define TT_Err_Interpolate_Twilight 0x40A +#define TT_Err_Debug_OpCode 0x40B +#define TT_Err_ENDF_In_Exec_Stream 0x40C +#define TT_Err_Out_Of_CodeRanges 0x40D +#define TT_Err_Nested_DEFS 0x40E +#define TT_Err_Invalid_CodeRange 0x40F +#define TT_Err_Invalid_Displacement 0x410 +#define TT_Err_Execution_Too_Long 0x411 + + + /* ------ internal failure error codes ----- */ + + /* These error codes are produced when an incoherent */ + /* library state has been detected. These reflect a */ + /* severe bug in the engine! (Or a major overwrite */ + /* of your application into the library's data.) */ + +#define TT_Err_Nested_Frame_Access 0x500 +#define TT_Err_Invalid_Cache_List 0x501 +#define TT_Err_Could_Not_Find_Context 0x502 +#define TT_Err_Unlisted_Object 0x503 + + + /* ---- scan-line converter error codes ----- */ + + /* These error codes are produced by the raster component. */ + /* They indicate that an outline structure was incoherently */ + /* setup, or that you're trying to render an horribly */ + /* complex glyph! */ + +#define TT_Err_Raster_Pool_Overflow 0x600 +#define TT_Err_Raster_Negative_Height 0x601 +#define TT_Err_Raster_Invalid_Value 0x602 +#define TT_Err_Raster_Not_Initialized 0x603 + +#endif /* FTERRID_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ftnameid.h b/Driver/Font/TrueType/FreeType/ftnameid.h new file mode 100644 index 000000000..14c573230 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ftnameid.h @@ -0,0 +1,628 @@ +/******************************************************************* + * + * ftnameid.h + * + * TrueType Name ID definitions + * + * 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 FREETYPE_H +#error "Don't include this file! Use freetype.h instead." +#endif + +#ifndef FTNAMEID_H +#define FTNAMEID_H + +/* + * possible values for the 'Platform' identifier code in the name + * records of the TTF "name" table + */ + +#define TT_PLATFORM_APPLE_UNICODE 0 +#define TT_PLATFORM_MACINTOSH 1 +#define TT_PLATFORM_ISO 2 +#define TT_PLATFORM_MICROSOFT 3 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_APPLE_UNICODE + */ + +#define TT_APPLE_ID_DEFAULT 0 +#define TT_APPLE_ID_UNICODE_1_1 1 +#define TT_APPLE_ID_ISO_10646 2 +#define TT_APPLE_ID_UNICODE_2_0 3 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_MACINTOSH + */ + +#define TT_MAC_ID_ROMAN 0 +#define TT_MAC_ID_JAPANESE 1 +#define TT_MAC_ID_TRADITIONAL_CHINESE 2 +#define TT_MAC_ID_KOREAN 3 +#define TT_MAC_ID_ARABIC 4 +#define TT_MAC_ID_HEBREW 5 +#define TT_MAC_ID_GREEK 6 +#define TT_MAC_ID_RUSSIAN 7 +#define TT_MAC_ID_RSYMBOL 8 +#define TT_MAC_ID_DEVANAGARI 9 +#define TT_MAC_ID_GURMUKHI 10 +#define TT_MAC_ID_GUJARATI 11 +#define TT_MAC_ID_ORIYA 12 +#define TT_MAC_ID_BENGALI 13 +#define TT_MAC_ID_TAMIL 14 +#define TT_MAC_ID_TELUGU 15 +#define TT_MAC_ID_KANNADA 16 +#define TT_MAC_ID_MALAYALAM 17 +#define TT_MAC_ID_SINHALESE 18 +#define TT_MAC_ID_BURMESE 19 +#define TT_MAC_ID_KHMER 20 +#define TT_MAC_ID_THAI 21 +#define TT_MAC_ID_LAOTIAN 22 +#define TT_MAC_ID_GEORGIAN 23 +#define TT_MAC_ID_ARMENIAN 24 +#define TT_MAC_ID_MALDIVIAN 25 +#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 +#define TT_MAC_ID_TIBETAN 26 +#define TT_MAC_ID_MONGOLIAN 27 +#define TT_MAC_ID_GEEZ 28 +#define TT_MAC_ID_SLAVIC 29 +#define TT_MAC_ID_VIETNAMESE 30 +#define TT_MAC_ID_SINDHI 31 +#define TT_MAC_ID_UNINTERP 32 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_ISO + */ + +#define TT_ISO_ID_7BIT_ASCII 0 +#define TT_ISO_ID_10646 1 +#define TT_ISO_ID_8859_1 2 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_MICROSOFT + */ + +#define TT_MS_ID_SYMBOL_CS 0 +#define TT_MS_ID_UNICODE_CS 1 +#define TT_MS_ID_SJIS 2 +#define TT_MS_ID_GB2312 3 +#define TT_MS_ID_BIG_5 4 +#define TT_MS_ID_WANSUNG 5 +#define TT_MS_ID_JOHAB 6 + + + +/* + * possible values of the language identifier field in the name records of + * the TTF "name" table when the 'Platform' identifier code is + * TT_PLATFORM_MACINTOSH + * + * the canonical source for the Apple assigned Language ID's is at + * http://fonts.apple.com/TTRefMan/RM06/Chap6name.html + */ + +#define TT_MAC_LANGID_ENGLISH 0 +#define TT_MAC_LANGID_FRENCH 1 +#define TT_MAC_LANGID_GERMAN 2 +#define TT_MAC_LANGID_ITALIAN 3 +#define TT_MAC_LANGID_DUTCH 4 +#define TT_MAC_LANGID_SWEDISH 5 +#define TT_MAC_LANGID_SPANISH 6 +#define TT_MAC_LANGID_DANISH 7 +#define TT_MAC_LANGID_PORTUGUESE 8 +#define TT_MAC_LANGID_NORWEGIAN 9 +#define TT_MAC_LANGID_HEBREW 10 +#define TT_MAC_LANGID_JAPANESE 11 +#define TT_MAC_LANGID_ARABIC 12 +#define TT_MAC_LANGID_FINNISH 13 +#define TT_MAC_LANGID_GREEK 14 +#define TT_MAC_LANGID_ICELANDIC 15 +#define TT_MAC_LANGID_MALTESE 16 +#define TT_MAC_LANGID_TURKISH 17 +#define TT_MAC_LANGID_CROATIAN 18 +#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 +#define TT_MAC_LANGID_URDU 20 +#define TT_MAC_LANGID_HINDI 21 +#define TT_MAC_LANGID_THAI 22 +#define TT_MAC_LANGID_KOREAN 23 +#define TT_MAC_LANGID_LITHUANIAN 24 +#define TT_MAC_LANGID_POLISH 25 +#define TT_MAC_LANGID_HUNGARIAN 26 +#define TT_MAC_LANGID_ESTONIAN 27 +#define TT_MAC_LANGID_LETTISH 28 +#define TT_MAC_LANGID_SAAMISK 29 +#define TT_MAC_LANGID_FAEROESE 30 +#define TT_MAC_LANGID_FARSI 31 +#define TT_MAC_LANGID_RUSSIAN 32 +#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 +#define TT_MAC_LANGID_FLEMISH 34 +#define TT_MAC_LANGID_IRISH 35 +#define TT_MAC_LANGID_ALBANIAN 36 +#define TT_MAC_LANGID_ROMANIAN 37 +#define TT_MAC_LANGID_CZECH 38 +#define TT_MAC_LANGID_SLOVAK 39 +#define TT_MAC_LANGID_SLOVENIAN 40 +#define TT_MAC_LANGID_YIDDISH 41 +#define TT_MAC_LANGID_SERBIAN 42 +#define TT_MAC_LANGID_MACEDONIAN 43 +#define TT_MAC_LANGID_BULGARIAN 44 +#define TT_MAC_LANGID_UKRAINIAN 45 +#define TT_MAC_LANGID_BYELORUSSIAN 46 +#define TT_MAC_LANGID_UZBEK 47 +#define TT_MAC_LANGID_KAZAKH 48 +#define TT_MAC_LANGID_AZERBAIJANI 49 +#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 +#define TT_MAC_LANGID_ARMENIAN 51 +#define TT_MAC_LANGID_GEORGIAN 52 +#define TT_MAC_LANGID_MOLDAVIAN 53 +#define TT_MAC_LANGID_KIRGHIZ 54 +#define TT_MAC_LANGID_TAJIKI 55 +#define TT_MAC_LANGID_TURKMEN 56 +#define TT_MAC_LANGID_MONGOLIAN 57 +#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 +#define TT_MAC_LANGID_PASHTO 59 +#define TT_MAC_LANGID_KURDISH 60 +#define TT_MAC_LANGID_KASHMIRI 61 +#define TT_MAC_LANGID_SINDHI 62 +#define TT_MAC_LANGID_TIBETAN 63 +#define TT_MAC_LANGID_NEPALI 64 +#define TT_MAC_LANGID_SANSKRIT 65 +#define TT_MAC_LANGID_MARATHI 66 +#define TT_MAC_LANGID_BENGALI 67 +#define TT_MAC_LANGID_ASSAMESE 68 +#define TT_MAC_LANGID_GUJARATI 69 +#define TT_MAC_LANGID_PUNJABI 70 +#define TT_MAC_LANGID_ORIYA 71 +#define TT_MAC_LANGID_MALAYALAM 72 +#define TT_MAC_LANGID_KANNADA 73 +#define TT_MAC_LANGID_TAMIL 74 +#define TT_MAC_LANGID_TELUGU 75 +#define TT_MAC_LANGID_SINHALESE 76 +#define TT_MAC_LANGID_BURMESE 77 +#define TT_MAC_LANGID_KHMER 78 +#define TT_MAC_LANGID_LAO 79 +#define TT_MAC_LANGID_VIETNAMESE 80 +#define TT_MAC_LANGID_INDONESIAN 81 +#define TT_MAC_LANGID_TAGALOG 82 +#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 +#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 +#define TT_MAC_LANGID_AMHARIC 85 +#define TT_MAC_LANGID_TIGRINYA 86 +#define TT_MAC_LANGID_GALLA 87 +#define TT_MAC_LANGID_SOMALI 88 +#define TT_MAC_LANGID_SWAHILI 89 +#define TT_MAC_LANGID_RUANDA 90 +#define TT_MAC_LANGID_RUNDI 91 +#define TT_MAC_LANGID_CHEWA 92 +#define TT_MAC_LANGID_MALAGASY 93 +#define TT_MAC_LANGID_ESPERANTO 94 +#define TT_MAC_LANGID_WELSH 128 +#define TT_MAC_LANGID_BASQUE 129 +#define TT_MAC_LANGID_CATALAN 130 +#define TT_MAC_LANGID_LATIN 131 +#define TT_MAC_LANGID_QUECHUA 132 +#define TT_MAC_LANGID_GUARANI 133 +#define TT_MAC_LANGID_AYMARA 134 +#define TT_MAC_LANGID_TATAR 135 +#define TT_MAC_LANGID_UIGHUR 136 +#define TT_MAC_LANGID_DZONGKHA 137 +#define TT_MAC_LANGID_JAVANESE 138 +#define TT_MAC_LANGID_SUNDANESE 139 +#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 +#define TT_MAC_LANGID_IRISH_GAELIC 141 +#define TT_MAC_LANGID_BRETON 142 +#define TT_MAC_LANGID_INUKTITUT 143 + + +/* + * possible values of the language identifier field in the name records of + * the TTF "name" table when the 'Platform' identifier code is + * TT_PLATFORM_MICROSOFT + * + * the canonical source for the MS assigned LCID's is at + * http://www.microsoft.com/typography/OTSPEC/lcid-cp.txt + */ + +#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 +#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 +#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01 +#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 +#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 +#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 +#define TT_MS_LANGID_ARABIC_TUNISIA 0x1c01 +#define TT_MS_LANGID_ARABIC_OMAN 0x2001 +#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 +#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 +#define TT_MS_LANGID_ARABIC_JORDAN 0x2c01 +#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 +#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 +#define TT_MS_LANGID_ARABIC_UAE 0x3801 +#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3c01 +#define TT_MS_LANGID_ARABIC_QATAR 0x4001 +#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 +#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 +#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 +#define TT_MS_LANGID_CHINESE_PRC 0x0804 +#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04 +#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 +#define TT_MS_LANGID_CHINESE_MACAU 0x1404 +#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 +#define TT_MS_LANGID_DANISH_DENMARK 0x0406 +#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 +#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 +#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0c07 +#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 +#define TT_MS_LANGID_GREEK_GREECE 0x0408 +#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 +#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 +#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09 +#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 +#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 +#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 +#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1c09 +#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 +#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 +#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 +#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09 +#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 +#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 +#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a +#define TT_MS_LANGID_SPANISH_MEXICO 0x080a +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a +#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100a +#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140a +#define TT_MS_LANGID_SPANISH_PANAMA 0x180a +#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1c0a +#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200a +#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240a +#define TT_MS_LANGID_SPANISH_PERU 0x280a +#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2c0a +#define TT_MS_LANGID_SPANISH_ECUADOR 0x300a +#define TT_MS_LANGID_SPANISH_CHILE 0x340a +#define TT_MS_LANGID_SPANISH_URUGUAY 0x380a +#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3c0a +#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400a +#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440a +#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a +#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a +#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a +#define TT_MS_LANGID_FINNISH_FINLAND 0x040b +#define TT_MS_LANGID_FRENCH_FRANCE 0x040c +#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c +#define TT_MS_LANGID_FRENCH_CANADA 0x0c0c +#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c +#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c +#define TT_MS_LANGID_FRENCH_MONACO 0x180c +#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d +#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e +#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f +#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 +#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 +#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 +#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 +#define TT_MS_LANGID_POLISH_POLAND 0x0415 +#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 +#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a +#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a +#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a +#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b +#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c +#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d +#define TT_MS_LANGID_SWEDISH_FINLAND 0x081d +#define TT_MS_LANGID_THAI_THAILAND 0x041e +#define TT_MS_LANGID_TURKISH_TURKEY 0x041f +#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 +#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 +#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 +#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 +#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 +#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 +#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 +#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0428 +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a +#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b +#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042c +#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082c +#define TT_MS_LANGID_BASQUE_SPAIN 0x042d +#define TT_MS_LANGID_SORBIAN_GERMANY 0x042e +#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042f +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 +#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 +#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 +#define TT_MS_LANGID_HINDI_INDIA 0x0439 +#define TT_MS_LANGID_MALTESE_MALTA 0x043a +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c +#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e +#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e +#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f +#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 +#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 +#define TT_MS_LANGID_BENGALI_INDIA 0x0445 +#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 +#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 +#define TT_MS_LANGID_ORIYA_INDIA 0x0448 +#define TT_MS_LANGID_TAMIL_INDIA 0x0449 +#define TT_MS_LANGID_TELUGU_INDIA 0x044a +#define TT_MS_LANGID_KANNADA_INDIA 0x044b +#define TT_MS_LANGID_MALAYALAM_INDIA 0x044c +#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d +#define TT_MS_LANGID_MARATHI_INDIA 0x044e +#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f +#define TT_MS_LANGID_KONKANI_INDIA 0x0457 + + +/* + * possible values of the 'Name' identifier field in the name records of + * the TTF "name" table. These values are platform independent. + */ + +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 +/* the following values are from the OpenType spec */ +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 +/* number 15 is reserved */ +#define TT_NAME_ID_PREFERRED_FAMILY 16 +#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 + + +/* + * Bit Mask values for the Unicode Ranges from the TTF "OS2 " table. + */ + +/* General Scripts Area */ + +/* Bit 0 C0 Controls and Basic Latin */ +#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0000-U+007F */ +/* Bit 1 C1 Controls and Latin-1 Supplement */ +#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ +/* Bit 2 Latin Extended-A */ +#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ +/* Bit 3 Latin Extended-B */ +#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ +/* Bit 4 IPA Extensions */ +#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ +/* Bit 5 Spacing Modifier Letters */ +#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ +/* Bit 6 Combining Diacritical Marks */ +#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ +/* Bit 7 Greek */ +#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ +/* Bit 8 is reserved (was: Greek Symbols and Coptic) */ +/* Bit 9 Cyrillic */ +#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ +/* Bit 10 Armenian */ +#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ +/* Bit 11 Hebrew */ +#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ +/* Bit 12 is reserved (was: Hebrew Extended) */ +/* Bit 13 Arabic */ +#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ +/* Bit 14 is reserved (was: Arabic Extended) */ +/* Bit 15 Devanagari */ +#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ +/* Bit 16 Bengali */ +#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ +/* Bit 17 Gurmukhi */ +#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ +/* Bit 18 Gujarati */ +#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ +/* Bit 19 Oriya */ +#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ +/* Bit 20 Tamil */ +#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ +/* Bit 21 Telugu */ +#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ +/* Bit 22 Kannada */ +#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ +/* Bit 23 Malayalam */ +#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ +/* Bit 24 Thai */ +#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ +/* Bit 25 Lao */ +#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ +/* Bit 26 Georgian */ +#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ +/* Bit 27 is reserved (was Georgian Extended) */ +/* Bit 28 Hangul Jamo */ +#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ +/* Bit 29 Latin Extended Additional */ +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ +/* Bit 30 Greek Extended */ +#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ + +/* Symbols Area */ + +/* Bit 31 General Punctuation */ +#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ +/* Bit 32 Superscripts And Subscripts */ +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ +/* Bit 33 Currency Symbols */ +#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ +/* Bit 34 Combining Diacritical Marks For Symbols */ +#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ +/* Bit 35 Letterlike Symbols */ +#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ +/* Bit 36 Number Forms */ +#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ +/* Bit 37 Arrows */ +#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ +/* Bit 38 Mathematical Operators */ +#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ +/* Bit 39 Miscellaneous Technical */ +#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ +/* Bit 40 Control Pictures */ +#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ +/* Bit 41 Optical Character Recognition */ +#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ +/* Bit 42 Enclosed Alphanumerics */ +#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ +/* Bit 43 Box Drawing */ +#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ +/* Bit 44 Block Elements */ +#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ +/* Bit 45 Geometric Shapes */ +#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ +/* Bit 46 Miscellaneous Symbols */ +#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ +/* Bit 47 Dingbats */ +#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ + +/* CJK Phonetics and Symbols Area */ + +/* Bit 48 CJK Symbols And Punctuation */ +#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ +/* Bit 49 Hiragana */ +#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ +/* Bit 50 Katakana */ +#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ +/* Bit 51 Bopomofo */ +#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ +/* Bit 52 Hangul Compatibility Jamo */ +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ +/* Bit 53 CJK Miscellaneous */ +#define TT_UCR_CJK_MISC (1L << 21) /* U+3190-U+319F */ +/* Bit 54 Enclosed CJK Letters And Months */ +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ +/* Bit 55 CJK Compatibility */ +#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ + +/* Hangul Syllables Area */ + +/* Bit 56 Hangul */ +#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ + +/* Surrogates Area */ + +/* Bit 57 Surrogates */ +#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DFFF */ +/* Bit 58 is reserved for Unicode SubRanges */ + +/* CJK Ideographs Area */ + +/* Bit 59 CJK Unified Ideographs */ +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ + +/* Private Use Area */ + +/* Bit 60 Private Use */ +#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ + +/* Compatibility Area and Specials */ + +/* Bit 61 CJK Compatibility Ideographs */ +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+F900-U+FAFF */ +/* Bit 62 Alphabetic Presentation Forms */ +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ +/* Bit 63 Arabic Presentation Forms-A */ +#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FSFF */ +/* Bit 64 Combining Half Marks */ +#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ +/* Bit 65 CJK Compatibility Forms */ +#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE30-U+FE4F */ +/* Bit 66 Small Form Variants */ +#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ +/* Bit 67 Arabic Presentation Forms-B */ +#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFF */ +/* Bit 68 Halfwidth And Fullwidth Forms */ +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ +/* Bit 69 Specials */ +#define TT_UCR_SPECIALS (1L << 5) /* U+FEFF, + U+FFF0-U+FFFF */ +/* Bit 70 Tibetan */ +#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FBF */ + + +/* Some compilers have a very limited length of identifiers. */ +#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) +#define HAVE_LIMIT_ON_IDENTS +#endif + +#ifndef HAVE_LIMIT_ON_IDENTS + +/* + * Here some alias #defines in order to be clearer. + * + * These are not always #defined to stay within the 31 character limit + * which some compilers have. + * + * Credits go to Dave Hoo for pointing out that modern + * Borland compilers (read: from BC++ 3.1 on) can increase this limit. + * If you get a warning with such a compiler, use the -i40 switch. + */ + +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ + TT_UCR_ARABIC_PRESENTATIONS_A +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ + TT_UCR_ARABIC_PRESENTATIONS_B + +#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ + TT_UCR_COMBINING_DIACRITICS +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + TT_UCR_COMBINING_DIACRITICS_SYMB + +#endif /* ndef HAVE_LIMIT_ON_IDENTS */ + +#endif /* FTNAMEID_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ftxkern.c b/Driver/Font/TrueType/FreeType/ftxkern.c new file mode 100644 index 000000000..6d6c9f9a0 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ftxkern.c @@ -0,0 +1,564 @@ +/******************************************************************* + * + * ftxkern.c 1.0 + * + * Kerning support extension. + * + * 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. + * + * + * The kerning support is currently part of the engine extensions. + * + ******************************************************************/ + +#include "ftxkern.h" + +#include "ttextend.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttmemory.h" +#include "ttfile.h" +#include "ttobjs.h" +#include "ttload.h" /* For the macros */ +#include "tttags.h" + +/* Required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_any + +#define KERNING_ID Build_Extension_ID( 'k', 'e', 'r', 'n' ) + + +/******************************************************************* + * + * Function : SubTable_Load_0 + * + * Description : Loads a format 0 kerning subtable data. + * + * Input : kern0 pointer to the kerning subtable + * + * Output : error code + * + * Notes : - Assumes that the stream is already `used' + * + * - the file cursor must be set by the caller + * + * - in case of error, the function _must_ destroy + * the data it allocates! + * + ******************************************************************/ + + static TT_Error Subtable_Load_0( TT_Kern_0* kern0, + PFace input ) + { + DEFINE_LOAD_LOCALS( input->stream ); + + UShort num_pairs, n; + + + if ( ACCESS_Frame( 8L ) ) + return error; + + num_pairs = GET_UShort(); + kern0->nPairs = 0; + kern0->searchRange = GET_UShort(); + kern0->entrySelector = GET_UShort(); + kern0->rangeShift = GET_UShort(); + + /* we only set kern0->nPairs if the subtable has been loaded */ + + FORGET_Frame(); + + if ( ALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) ) + return error; + + if ( ACCESS_Frame( num_pairs * 6L ) ) + goto Fail; + + for ( n = 0; n < num_pairs; n++ ) + { + kern0->pairs[n].left = GET_UShort(); + kern0->pairs[n].right = GET_UShort(); + kern0->pairs[n].value = GET_UShort(); + + if ( kern0->pairs[n].left >= input->numGlyphs || + kern0->pairs[n].right >= input->numGlyphs ) + { + FORGET_Frame(); + error = TT_Err_Invalid_Kerning_Table; + goto Fail; + } + } + + FORGET_Frame(); + + /* we're ok, set the pairs count */ + kern0->nPairs = num_pairs; + + return TT_Err_Ok; + + Fail: + FREE( kern0->pairs ); + return error; + } + + +/******************************************************************* + * + * Function : SubTable_Load_2 + * + * Description : Loads a format 2 kerning subtable data. + * + * Input : kern2 pointer to the kerning subtable + * length subtable length. This is required as + * the subheader doesn't give any indication + * of the size of the `array' table. + * + * Output : error code + * + * Notes : - Assumes that the stream is already `used' + * + * - the file cursor must be set by the caller + * + * - in case of error, the function _must_ destroy + * the data it allocates! + * + ******************************************************************/ + + static TT_Error Subtable_Load_2( TT_Kern_2* kern2, + PFace input ) + { + DEFINE_LOAD_LOCALS( input->stream ); + + Long table_base; + + UShort left_offset, right_offset, array_offset; + ULong array_size; + UShort left_max, right_max, n; + + + /* record the table offset */ + table_base = FILE_Pos(); + + if ( ACCESS_Frame( 8L ) ) + return error; + + kern2->rowWidth = GET_UShort(); + left_offset = GET_UShort(); + right_offset = GET_UShort(); + array_offset = GET_UShort(); + + FORGET_Frame(); + + /* first load left and right glyph classes */ + + if ( FILE_Seek( table_base + left_offset ) || + ACCESS_Frame( 4L ) ) + return error; + + kern2->leftClass.firstGlyph = GET_UShort(); + kern2->leftClass.nGlyphs = GET_UShort(); + + FORGET_Frame(); + + if ( ALLOC_ARRAY( kern2->leftClass.classes, + kern2->leftClass.nGlyphs, + UShort ) ) + return error; + + /* load left offsets */ + + if ( ACCESS_Frame( kern2->leftClass.nGlyphs * 2L ) ) + goto Fail_Left; + + for ( n = 0; n < kern2->leftClass.nGlyphs; n++ ) + kern2->leftClass.classes[n] = GET_UShort(); + + FORGET_Frame(); + + /* right class */ + + if ( FILE_Seek( table_base + right_offset ) || + ACCESS_Frame( 4L ) ) + goto Fail_Left; + + kern2->rightClass.firstGlyph = GET_UShort(); + kern2->rightClass.nGlyphs = GET_UShort(); + + FORGET_Frame(); + + if ( ALLOC_ARRAY( kern2->rightClass.classes, + kern2->rightClass.nGlyphs, + UShort ) ) + goto Fail_Left; + + /* load right offsets */ + + if ( ACCESS_Frame( kern2->rightClass.nGlyphs * 2L ) ) + goto Fail_Right; + + for ( n = 0; n < kern2->rightClass.nGlyphs; n++ ) + kern2->rightClass.classes[n] = GET_UShort(); + + FORGET_Frame(); + + /* Now load the kerning array. We don't have its size, we */ + /* must compute it from what we know. */ + + /* We thus compute the maximum left and right offsets and */ + /* add them to get the array size. */ + + left_max = right_max = 0; + + for ( n = 0; n < kern2->leftClass.nGlyphs; n++ ) + left_max = MAX( left_max, kern2->leftClass.classes[n] ); + + for ( n = 0; n < kern2->rightClass.nGlyphs; n++ ) + right_max = MAX( right_max, kern2->leftClass.classes[n] ); + + array_size = left_max + right_max + 2; + + if ( ALLOC( kern2->array, array_size ) ) + goto Fail_Right; + + if ( ACCESS_Frame( array_size ) ) + goto Fail_Array; + + for ( n = 0; n < array_size/2; n++ ) + kern2->array[n] = GET_Short(); + + FORGET_Frame(); + + /* we're good now */ + + return TT_Err_Ok; + + Fail_Array: + FREE( kern2->array ); + + Fail_Right: + FREE( kern2->rightClass.classes ); + kern2->rightClass.nGlyphs = 0; + + Fail_Left: + FREE( kern2->leftClass.classes ); + kern2->leftClass.nGlyphs = 0; + + return error; + } + + +/******************************************************************* + * + * Function : Kerning_Create + * + * Description : Creates the kerning directory if a face is + * loaded. The tables however are loaded on + * demand to save space. + * + * Input : face pointer to the parent face object + * kern pointer to the extension's kerning field + * + * Output : error code + * + * Notes : as in all constructors, the memory allocated isn't + * released in case of failure. Rather, the task is left + * to the destructor (which is called if an error + * occurs during the loading of a face). + * + ******************************************************************/ + + static TT_Error Kerning_Create( void* ext, + PFace face ) + { + DEFINE_LOAD_LOCALS( face->stream ); + + TT_Kerning* kern = (TT_Kerning*)ext; + UShort num_tables; + Long table; + + TT_Kern_Subtable* sub; + + + /* by convention */ + if ( !kern ) + return TT_Err_Ok; + + /* Now load the kerning directory. We're called from the face */ + /* constructor. We thus need not use the stream. */ + + kern->version = 0; + kern->nTables = 0; + kern->tables = NULL; + + table = TT_LookUp_Table( face, TTAG_kern ); + if ( table < 0 ) + return TT_Err_Ok; /* The table is optional */ + + if ( FILE_Seek( face->dirTables[table].Offset ) || + ACCESS_Frame( 4L ) ) + return error; + + kern->version = GET_UShort(); + num_tables = GET_UShort(); + + FORGET_Frame(); + + /* we don't set kern->nTables until we have allocated the array */ + + if ( ALLOC_ARRAY( kern->tables, num_tables, TT_Kern_Subtable ) ) + return error; + + kern->nTables = num_tables; + + /* now load the directory entries, but do _not_ load the tables ! */ + + sub = kern->tables; + + for ( table = 0; table < num_tables; table++ ) + { + if ( ACCESS_Frame( 6L ) ) + return error; + + sub->loaded = FALSE; /* redundant, but good to see */ + sub->version = GET_UShort(); + sub->length = GET_UShort() - 6; /* substract header length */ + sub->format = GET_Byte(); + sub->coverage = GET_Byte(); + + FORGET_Frame(); + + sub->offset = FILE_Pos(); + + /* now skip to the next table */ + + if ( FILE_Skip( sub->length ) ) + return error; + + sub++; + } + + /* that's fine, leave now */ + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Kerning_Destroy + * + * Description : Destroys all kerning information. + * + * Input : kern pointer to the extension's kerning field + * + * Output : error code + * + * Notes : This function is a destructor; it must be able + * to destroy partially built tables. + * + ******************************************************************/ + + static TT_Error Kerning_Destroy( void* ext, + PFace face ) + { + TT_Kerning* kern = (TT_Kerning*)ext; + TT_Kern_Subtable* sub; + UShort n; + + + /* by convention */ + if ( !kern ) + return TT_Err_Ok; + + if ( kern->nTables == 0 ) + return TT_Err_Ok; /* no tables to release */ + + /* scan the table directory and release loaded entries */ + + sub = kern->tables; + for ( n = 0; n < kern->nTables; n++ ) + { + if ( sub->loaded ) + { + switch ( sub->format ) + { + case 0: + FREE( sub->t.kern0.pairs ); + sub->t.kern0.nPairs = 0; + sub->t.kern0.searchRange = 0; + sub->t.kern0.entrySelector = 0; + sub->t.kern0.rangeShift = 0; + break; + + case 2: + FREE( sub->t.kern2.leftClass.classes ); + sub->t.kern2.leftClass.firstGlyph = 0; + sub->t.kern2.leftClass.nGlyphs = 0; + + FREE( sub->t.kern2.rightClass.classes ); + sub->t.kern2.rightClass.firstGlyph = 0; + sub->t.kern2.rightClass.nGlyphs = 0; + + FREE( sub->t.kern2.array ); + sub->t.kern2.rowWidth = 0; + break; + + default: + ; /* invalid subtable format - do nothing */ + } + + sub->loaded = FALSE; + sub->version = 0; + sub->offset = 0; + sub->length = 0; + sub->coverage = 0; + sub->format = 0; + } + sub++; + } + + FREE( kern->tables ); + kern->nTables = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Kerning_Directory + * + * Description : Returns a given face's kerning directory. + * + * Input : face handle to the face object + * directory pointer to client's target directory + * + * Output : error code + * + * Notes : The kerning table directory is loaded with the face + * through the extension constructor. However, the kerning + * tables themselves are only loaded on demand, as they + * may represent a lot of data, unneeded by most uses of + * the engine. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Kerning_Directory( TT_Face face, + TT_Kerning* directory ) + { + PFace faze = HANDLE_Face( face ); + TT_Error error; + TT_Kerning* kerning; + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + /* copy directory header */ + error = TT_Extension_Get( faze, KERNING_ID, (void**)&kerning ); + if ( !error ) + *directory = *kerning; + + return error; + } + + +/******************************************************************* + * + * Function : TT_Load_Kerning_Table + * + * Description : Loads a kerning table intro memory. + * + * Input : face face handle + * kern_index index in the face's kerning directory + * + * Output : error code + * + * Notes : + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Load_Kerning_Table( TT_Face face, + TT_UShort kern_index ) + { + TT_Error error; + TT_Stream stream; + + TT_Kerning* kern; + TT_Kern_Subtable* sub; + + + PFace faze = HANDLE_Face( face ); + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + error = TT_Extension_Get( faze, KERNING_ID, (void**)&kern ); + if ( error ) + return error; + + if ( kern->nTables == 0 ) + return TT_Err_Table_Missing; + + if ( kern_index >= kern->nTables ) + return TT_Err_Invalid_Argument; + + sub = kern->tables + kern_index; + + if ( sub->format != 0 && sub->format != 2 ) + return TT_Err_Invalid_Kerning_Table_Format; + + /* now access stream */ + if ( USE_Stream( faze->stream, stream ) ) + return error; + + if ( FILE_Seek( sub->offset ) ) + goto Fail; + + if ( sub->format == 0 ) + error = Subtable_Load_0( &sub->t.kern0, faze ); + else if ( sub->format == 2 ) + error = Subtable_Load_2( &sub->t.kern2, faze ); + + if ( !error ) + sub->loaded = TRUE; + + Fail: + /* release stream */ + DONE_Stream( stream ); + + return error; + } + + + EXPORT_FUNC + TT_Error TT_Init_Kerning_Extension( TT_Engine engine ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + error = TT_Register_Extension( _engine, + KERNING_ID, + sizeof ( TT_Kerning ), + Kerning_Create, + Kerning_Destroy ); + return error; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ftxkern.h b/Driver/Font/TrueType/FreeType/ftxkern.h new file mode 100644 index 000000000..719ec6e51 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ftxkern.h @@ -0,0 +1,181 @@ +/******************************************************************* + * + * ftxkern.h 1.0 + * + * High-Level API Kerning extension + * + * 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. + * + * + * The kerning support is currently part of the engine extensions. + * + * This file should _not_ depend on engine internal types. + * + ******************************************************************/ + +#ifndef FTXKERN_H +#define FTXKERN_H + +#include "freetype.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* The kerning support in FreeType is minimal. This means that */ + /* we do not try to interpret the kerning data in any way to */ + /* `cook' it for a user application. This API lets you access */ + /* directly the kerning tables found in the TrueType file; it's */ + /* up to the client application to apply its own processing on */ + /* these. */ + + /* The reason for this is that we generally do not encourage */ + /* feature-bloat of the core engine. Moreover, not all */ + /* libraries or font servers really need kerning data, or all */ + /* formats of this data. */ + + /************** kerning error codes *****************************/ + + /* we choose the class 0x0A for our errors, this should not */ + /* match with any error code class used in any other extension */ + +#define TT_Err_Invalid_Kerning_Table_Format 0x0A00 +#define TT_Err_Invalid_Kerning_Table 0x0A01 + + + /********** structures definitions ******************************/ + + /* Remember that all types and function are accessible by client */ + /* applications in this section, and thus should have the `TT_' */ + /* prefix. */ + + /* format 0 kerning pair */ + + struct TT_Kern_0_Pair_ + { + TT_UShort left; /* index of left glyph in pair */ + TT_UShort right; /* index of right glyph in pair */ + TT_FWord value; /* kerning value */ + }; + + typedef struct TT_Kern_0_Pair_ TT_Kern_0_Pair; + + + /* format 0 kerning subtable */ + + struct TT_Kern_0_ + { + TT_UShort nPairs; /* number of kerning pairs */ + + TT_UShort searchRange; /* these values are defined by the TT spec */ + TT_UShort entrySelector; /* for table searchs. */ + TT_UShort rangeShift; + + TT_Kern_0_Pair* pairs; /* a table of nPairs `pairs' */ + }; + + typedef struct TT_Kern_0_ TT_Kern_0; + + + /* format 2 kerning glyph class */ + + struct TT_Kern_2_Class_ + { + TT_UShort firstGlyph; /* first glyph in range */ + TT_UShort nGlyphs; /* number of glyphs in range */ + TT_UShort* classes; /* a table giving for each ranged glyph */ + /* its class offset in the subtable pairs */ + /* two-dimensional array */ + }; + + typedef struct TT_Kern_2_Class_ TT_Kern_2_Class; + + + /* format 2 kerning subtable */ + + struct TT_Kern_2_ + { + TT_UShort rowWidth; /* length of one row in bytes */ + TT_Kern_2_Class leftClass; /* left class table */ + TT_Kern_2_Class rightClass; /* right class table */ + TT_FWord* array; /* 2-dimensional kerning values array */ + }; + + typedef struct TT_Kern_2_ TT_Kern_2; + + + /* kerning subtable */ + + struct TT_Kern_Subtable_ + { + TT_Bool loaded; /* boolean; indicates whether the table is */ + /* loaded */ + TT_UShort version; /* table version number */ + TT_Long offset; /* file offset of table */ + TT_UShort length; /* length of table, _excluding_ header */ + TT_Byte coverage; /* lower 8 bit of the coverage table entry */ + TT_Byte format; /* the subtable format, as found in the */ + /* higher 8 bits of the coverage table entry */ + union + { + TT_Kern_0 kern0; + TT_Kern_2 kern2; + } t; + }; + + typedef struct TT_Kern_Subtable_ TT_Kern_Subtable; + + + struct TT_Kerning_ + { + TT_UShort version; /* kern table version number. starts at 0 */ + TT_UShort nTables; /* number of tables */ + + TT_Kern_Subtable* tables; /* the kerning sub-tables */ + }; + + typedef struct TT_Kerning_ TT_Kerning; + + + + /***************** high-level API extension **************************/ + + /* Initialize Kerning extension, must be called after */ + /* TT_Init_FreeType(). There is no need for a finalizer */ + EXPORT_DEF + TT_Error TT_Init_Kerning_Extension( TT_Engine engine ); + + /* Note on the implemented mechanism: */ + + /* The kerning table directory is loaded with the face through the */ + /* extension constructor. However, the tables will only be loaded */ + /* on demand, as they may represent a lot of data, unnecessary to */ + /* most applications. */ + + /* Queries a pointer to the kerning directory for the face object */ + EXPORT_DEF + TT_Error TT_Get_Kerning_Directory( TT_Face face, + TT_Kerning* directory ); + + /* Load the kerning table number `kern_index' in the kerning */ + /* directory. The table will stay in memory until the `face' */ + /* face is destroyed. */ + EXPORT_DEF + TT_Error TT_Load_Kerning_Table( TT_Face face, + TT_UShort kern_index ); + +#ifdef __cplusplus +} +#endif + +#endif /* FTXKERN_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/header.h b/Driver/Font/TrueType/FreeType/header.h new file mode 100644 index 000000000..a7a493192 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/header.h @@ -0,0 +1,49 @@ +/******************************************************************* + * + * Function : + * + * Description : + * + * Input : + * + * Output : + * + * Notes : + * + ******************************************************************/ + +/******************************************************************* + * + * Function : + * + * Description : + * + * Input : None + * + * Output : Error code. + * + ******************************************************************/ + +/******************************************************************* + * + * Function : + * + * Description : + * + ******************************************************************/ + +/******************************************************************* + * + * Component Name (e.g. TTRaster.C) + eventually a version number. + * + * Component Short Description (e.g. Rasterizer). + * + * Copyright 1996 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. + * + ******************************************************************/ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c new file mode 100644 index 000000000..968fab911 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -0,0 +1,2217 @@ +/******************************************************************* + * + * ttapi.c + * + * High-level interface implementation + * + * 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. + * + * Notes: + * + * This file is used to implement most of the functions that are + * defined in the file "freetype.h". However, two functions are + * implemented elsewhere : + * + * TT_MulDiv and TT_MulFix are in ttcalc.h/ttcalc.c + * + ******************************************************************/ + +#include "ttconfig.h" + +#include "freetype.h" +#include "ttengine.h" +#include "ttcalc.h" +#include "ttmemory.h" +#include "ttcache.h" +#include "ttfile.h" +#include "ttobjs.h" +#include "ttload.h" +#include "ttgload.h" +#include "ttraster.h" +#include "ttextend.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_api + + +#ifdef TT_STATIC_RASTER +#define RAS_OPS /* void */ +#define RAS_OP /* void */ +#else +#define RAS_OPS ((TRaster_Instance*)_engine->raster_component), +#define RAS_OP ((TRaster_Instance*)_engine->raster_component) +#endif /* TT_STATIC_RASTER */ + + +#define RENDER_Glyph( glyph, target ) \ + Render_Glyph( RAS_OPS glyph, target ) + +#define RENDER_Gray_Glyph( glyph, target, palette ) \ + Render_Gray_Glyph( RAS_OPS glyph, target, palette ) + + + +/******************************************************************* + * + * Function : TT_FreeType_Version + * + * Description : Returns the major and minor version of the library. + * + * Input : major, minor addresses + * + * Output : Error code. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_FreeType_Version( int *major, int *minor ) + { + if ( !major || !minor ) + return TT_Err_Invalid_Argument; + + *major = TT_FREETYPE_MAJOR; + *minor = TT_FREETYPE_MINOR; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Init_FreeType + * + * Description : The library's engine initializer. This function + * must be called prior to any call. + * + * Input : engine pointer to a FreeType engine instance + * + * Output : Error code. + * + * MT-Note : This function should be called each time you want + * to create a TT_Engine. It is not necessarily thread + * safe depending on the implementations of ttmemory, + * ttfile and ttmutex, so take care. Their default + * implementations are safe, however. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Init_FreeType( TT_Engine* engine ) + { + PEngine_Instance _engine; + + TT_Error error; + int n; + + + /* first of all, initialize memory sub-system */ + error = TTMemory_Init(); + if ( error ) + return error; + + /* Allocate engine instance */ + if ( ALLOC( _engine, sizeof ( TEngine_Instance ) ) ) + return error; + +#undef TT_FAIL +#define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok + + /* Initalize components */ + if ( TT_FAIL( TTFile_Init ) || + TT_FAIL( TTCache_Init ) || +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + TT_FAIL( TTExtend_Init ) || +#endif + TT_FAIL( TTObjs_Init ) || + TT_FAIL( TTRaster_Init ) ) + goto Fail; + +#undef TT_FAIL + + /* set the gray palette defaults: 0 to 4 */ + for ( n = 0; n < 5; n++ ) + _engine->raster_palette[n] = (Byte)n; /* Conversion ok, some warn */ + + /* create the engine lock */ + MUTEX_Create( _engine->lock ); + + HANDLE_Set( *engine, _engine ); + return TT_Err_Ok; + + Fail: + TT_Done_FreeType( *engine ); + HANDLE_Set( *engine, NULL ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_FreeType + * + * Description : The library's engine finalizer. This function + * will discard all active face and glyph objects + * from the heap. + * + * Input : engine FreeType engine instance + * + * Output : Error code. + * + * MT-Note : Destroys an engine. Not necessarily thread-safe + * depending on the implementations of ttmemory, + * ttfile and ttmutex. The default implementations + * are safe, however. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_FreeType( TT_Engine engine ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + + if ( !_engine ) + return TT_Err_Ok; + + MUTEX_Destroy( _engine->lock ); + + TTRaster_Done( _engine ); + TTObjs_Done ( _engine ); +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + TTExtend_Done( _engine ); +#endif + TTCache_Done ( _engine ); + TTFile_Done ( _engine ); + FREE( _engine ); + + TTMemory_Done(); + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/******************************************************************* + * + * Function : TT_Set_Raster_Gray_Palette + * + * Description : Sets the gray-levels palette used for font + * smoothing. + * + * Input : engine FreeType engine instance + * palette address of palette (a 5 byte array) + * + * Output : Invalid argument if 'palette' is NULL. + * + * MT-Note: NO! Unprotected modification of an engine's palette. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, + Byte* palette ) + { + int i; + + + if ( !palette ) + return TT_Err_Invalid_Argument; + + for ( i = 0; i < 5; i++ ) + HANDLE_Engine( engine )->raster_palette[i] = (Byte)palette[i]; + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/******************************************************************* + * + * Function : TT_Open_Face + * + * Description : Creates a new face object from a given font file. + * + * Input : engine FreeType engine instance + * fontPathName the font file's pathname + * face adress of returned face handle + * + * Output : Error code. + * + * Note : The face handle is set to NULL in case of failure. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Open_Face( TT_Engine engine, + const TT_Text* fontPathName, + TT_Face* face ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + TFont_Input input; + TT_Error error; + TT_Stream stream; + PFace _face; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + /* open the file */ + error = TT_Open_Stream( fontPathName, &stream ); + if ( error ) + return error; + + input.stream = stream; + input.fontIndex = 0; + input.engine = _engine; + + /* Create and load the new face object - this is thread-safe */ + error = CACHE_New( _engine->objs_face_cache, + _face, + &input ); + + /* Set the handle */ + HANDLE_Set( *face, _face ); + + if ( error ) + goto Fail; + + return TT_Err_Ok; + + Fail: + TT_Close_Stream( &stream ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Open_Collection + * + * Description : Creates a new face object from a given font file. + * + * Input : engine FreeType engine instance + * collectionPathName the font file's pathname + * fontIndex index of font in TrueType collection + * face adress of returned face handle + * + * Output : Error code. + * + * Note : The face handle is set to NULL in case of failure. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Open_Collection( TT_Engine engine, + const TT_Text* collectionPathName, + TT_ULong fontIndex, + TT_Face* face ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + + TFont_Input input; + TT_Error error; + TT_Stream stream; + PFace _face; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + /* open the file */ + error = TT_Open_Stream( collectionPathName, &stream ); + if ( error ) + return error; + + input.stream = stream; + input.fontIndex = fontIndex; + input.engine = _engine; + + /* Create and load the new face object - this is thread-safe */ + error = CACHE_New( _engine->objs_face_cache, + _face, + &input ); + + /* Set the handle */ + HANDLE_Set( *face, _face ); + + if ( error ) + goto Fail; + + return TT_Err_Ok; + + Fail: + TT_Close_Stream( &stream ); + + return error; + } + + +/******************************************************************* + * + * Function : TT_Get_Face_Properties + * + * Description : Returns face properties. + * + * Input : face the face handle + * properties address of target properties record + * + * Output : Error code. + * + * Note : Currently, max_Faces is always set to 0. + * + * MT-Note : YES! Reads only permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Face_Properties( TT_Face face, + TT_Face_Properties* properties ) + { + PFace _face = HANDLE_Face( face ); + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + properties->num_Glyphs = _face->numGlyphs; + properties->max_Points = _face->maxPoints; + properties->max_Contours = _face->maxContours; + properties->num_CharMaps = _face->numCMaps; + properties->num_Names = _face->nameTable.numNameRecords; + + if ( _face->ttcHeader.DirCount == 0 ) + properties->num_Faces = 1; + else + properties->num_Faces = _face->ttcHeader.DirCount; + + properties->header = &_face->fontHeader; + properties->horizontal = &_face->horizontalHeader; + + if ( _face->verticalInfo ) + properties->vertical = &_face->verticalHeader; + else + properties->vertical = NULL; + + properties->os2 = &_face->os2; + properties->postscript = &_face->postscript; + properties->hdmx = &_face->hdmx; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Set_Face_Pointer + * + * Description : Each face object has one pointer, which use is + * reserved to client applications. The TrueType + * engine never accesses or uses this field. + * + * This function is used to set the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Note : NO! But this function is reserved to "enlightened" + * developers, so it shouldn't be a problem. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Face_Pointer( TT_Face face, + void* data ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + else + faze->generic = data; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Face_Pointer + * + * Description : Each face object has one pointer, which use is + * reserved to client applications. The TrueType + * engine never access or use this field. + * + * This function is used to read the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Note : NO! But this function is reserved to "enlightened" + * developers, so it shouldn't be a problem. + * + ******************************************************************/ + + EXPORT_FUNC + void* TT_Get_Face_Pointer( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return NULL; + else + return faze->generic; + } + + +/******************************************************************* + * + * Function : TT_Get_Face_Metrics + * + * Description : This function returns the original horizontal AND + * vertical metrics as found in the "hmtx" and "vmtx" + * tables. These are the glyphs' left-side-bearings + * and advance widths (horizontal), as well as top + * side bearings and advance heights (vertical). + * + * All are expressed in FONT UNITS, a.k.a. EM + * units. + * + * Input : face The given face handle. + * first Index of first glyph in table. + * last Index of last glyph in table. + * + * leftBearings A pointer to an array of TT_Shorts where the + * left side bearings for the glyphs 'first' + * to 'last' will be returned. If these metrics + * don't interest you, simply set it to NULL. + * + * widths A pointer to an array of TT_UShorts + * where the advance widths for the glyphs + * 'first' to 'last' will be returned. If these + * metrics don't interest you, simply set it + * to NULL. + * + * topBearings A pointer to an array of TT_Shorts where the + * top side bearings for the glyphs 'first' + * to 'last' will be returned. If these metrics + * don't interest you, simply set it to NULL. + * + * heights A pointer to an array of TT_UShorts + * where the advance heights for the glyphs + * 'first' to 'last' will be returned. If these + * metrics don't interest you, simply set it + * to NULL. + * + * Output : Error code. + * + * IMPORTANT NOTE : + * + * As vertical metrics are optional in a TrueType font, this + * function will return an error ( TT_Err_No_Vertical_Data ) + * whenever this function is called on such a face with non-NULL + * 'topBearings' or 'heights' arguments. + * + * When a font has no vertical data, the 'vertical' field in its + * properties structure is set to NULL. + * + * MT-Note : YES! Reads only permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Face_Metrics( TT_Face face, + TT_UShort firstGlyph, + TT_UShort lastGlyph, + TT_Short* leftBearings, + TT_UShort* widths, + TT_Short* topBearings, + TT_UShort* heights ) + { + PFace _face = HANDLE_Face( face ); + UShort num; + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + /* Check the glyph range */ + if ( lastGlyph >= _face->numGlyphs || firstGlyph > lastGlyph ) + return TT_Err_Invalid_Argument; + + num = lastGlyph - firstGlyph; /* number of elements-1 in each array */ + + /* store the left side bearings and advance widths first */ + { + UShort n; + Short left_bearing; + UShort advance_width; + + + for ( n = 0; n <= num; n++ ) + { + TT_Get_Metrics( &_face->horizontalHeader, + firstGlyph + n, &left_bearing, &advance_width ); + + if ( leftBearings ) leftBearings[n] = left_bearing; + if ( widths ) widths[n] = advance_width; + } + } + + /* check for vertical data if topBearings or heights is non-NULL */ + if ( !topBearings && !heights ) + return TT_Err_Ok; + + if ( !_face->verticalInfo ) + return TT_Err_No_Vertical_Data; + + /* store the top side bearings */ + { + UShort n; + Short top_bearing; + UShort advance_height; + + for ( n = 0; n <= num; n++ ) + { + TT_Get_Metrics( (TT_Horizontal_Header*)&_face->verticalHeader, + firstGlyph + n, &top_bearing, &advance_height ); + + if ( topBearings ) topBearings[n] = top_bearing; + if ( heights ) heights[n] = advance_height; + } + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Face + * + * Description : This function is used to close an active face's + * file handle or descriptor. This is useful to save + * system resources, if your application uses tons + * of fonts. + * + * Input : face the given face handle + * + * Output : Error code. + * + * MT-Note : YES! (If ttfile is.) + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Face( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + else + return TT_Flush_Stream( &faze->stream ); + } + + +/******************************************************************* + * + * Function : TT_Close_Face + * + * Description : Closes an opened face object. This function + * will destroy all objects associated to the + * face, except the glyphs. + * + * Input : face the given face handle + * + * Output : Error code. + * + * NOTE : The handle is set to NULL on exit. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Close_Face( TT_Face face ) + { + PFace _face = HANDLE_Face( face ); + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + TT_Close_Stream( &_face->stream ); + + /* delete the face object -- this is thread-safe */ + return CACHE_Done( _face->engine->objs_face_cache, _face ); + } + + +/******************************************************************* + * + * Function : TT_New_Instance + * + * Description : Creates a new instance from a given face. + * + * Input : face parent face handle + * instance address of instance handle + * + * Output : Error code. + * + * Note : The handle is set to NULL in case of failure. + * + * MT-Note : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_New_Instance( TT_Face face, + TT_Instance* instance ) + { + TT_Error error; + PFace _face = HANDLE_Face( face ); + PInstance _ins; + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + /* get a new instance from the face's cache -- this is thread-safe */ + error = CACHE_New( &_face->instances, _ins, _face ); + + HANDLE_Set( *instance, _ins ); + + if ( !error ) + { + error = Instance_Init( _ins ); + if ( error ) + { + HANDLE_Set( *instance, NULL ); + CACHE_Done( &_face->instances, _ins ); + } + } + + return error; + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_Resolutions + * + * Description : Resets an instance to a new device resolution. + * + * Input : instance the instance handle + * xResolution new horizontal device resolution in dpi + * yResolution new vertical device resolution in dpi + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolutions must have reasonable values. + * + * MT-Note : You should set the charsize or pixel size immediately + * after this call in multi-threaded programs. This will + * force the instance data to be resetted. Otherwise, you + * may encounter corruption when loading two glyphs from + * the same instance concurrently! + * + * Happily, 99.99% will do just that :-) + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, + TT_UShort xResolution, + TT_UShort yResolution ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + ins->metrics.x_resolution = xResolution; + ins->metrics.y_resolution = yResolution; + ins->valid = FALSE; + + /* In the case of a thread-safe implementation, we immediately */ + /* call Instance_Reset in order to change the instance's variable */ + + /* In the case of a non-threaded build, we simply set the 'valid' */ + /* flag to FALSE, which will force the instance's resetting at */ + /* the next glyph loading */ + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_CharSizes + * + * Description : Resets an instance to new point size. + * + * Input : instance the instance handle + * charWidth the new width in 26.6 char points + * charHeight the new height in 26.6 char points + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolution must have reasonable values. + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_CharSizes( TT_Instance instance, + TT_F26Dot6 charWidth, + TT_F26Dot6 charHeight ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( charWidth < 1 * 64 ) + charWidth = 1 * 64; + + if ( charHeight < 1 * 64 ) + charHeight = 1 * 64; + + ins->metrics.x_scale1 = ( charWidth * ins->metrics.x_resolution ) / 72; + ins->metrics.x_scale2 = ins->owner->fontHeader.Units_Per_EM; + + ins->metrics.y_scale1 = ( charHeight * ins->metrics.y_resolution ) / 72; + ins->metrics.y_scale2 = ins->owner->fontHeader.Units_Per_EM; + + if ( ins->owner->fontHeader.Flags & 8 ) + { + ins->metrics.x_scale1 = (ins->metrics.x_scale1+32) & -64; + ins->metrics.y_scale1 = (ins->metrics.y_scale1+32) & -64; + } + + ins->metrics.x_ppem = ins->metrics.x_scale1 / 64; + ins->metrics.y_ppem = ins->metrics.y_scale1 / 64; + + if ( charWidth > charHeight ) + ins->metrics.pointSize = charWidth; + else + ins->metrics.pointSize = charHeight; + + ins->valid = FALSE; + + return Instance_Reset( ins ); + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_CharSize + * + * Description : Resets an instance to new point size. + * + * Input : instance the instance handle + * charSize the new character size in 26.6 char points + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolution must have reasonable values. + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_CharSize( TT_Instance instance, + TT_F26Dot6 charSize ) + { + return TT_Set_Instance_CharSizes( instance, charSize, charSize ); + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_PixelSizes + * + * Description : Resets an instance to new pixel sizes + * + * Input : instance the instance handle + * pixelWidth the new width in pixels + * pixelHeight the new height in pixels + * + * Output : Error code. + * + * Note : There is no check for overflow; with other words, + * the product of glyph dimensions times the device + * resolution must have reasonable values. + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, + TT_UShort pixelWidth, + TT_UShort pixelHeight, + TT_F26Dot6 pointSize ) + { + PInstance ins = HANDLE_Instance( instance ); + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( pixelWidth < 1 ) pixelWidth = 1; + if ( pixelHeight < 1 ) pixelHeight = 1; + + ins->metrics.x_ppem = pixelWidth; + ins->metrics.y_ppem = pixelHeight; + ins->metrics.pointSize = pointSize; + + ins->metrics.x_scale1 = ins->metrics.x_ppem * 64L; + ins->metrics.x_scale2 = ins->owner->fontHeader.Units_Per_EM; + ins->metrics.y_scale1 = ins->metrics.y_ppem * 64L; + ins->metrics.y_scale2 = ins->owner->fontHeader.Units_Per_EM; + + ins->valid = FALSE; + + return Instance_Reset( ins ); + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_Transform_Flags + * + * Description : Informs the interpreter about the transformations + * that will be applied to the rendered glyphs. + * + * Input : instance the instance handle + * rotated set to TRUE if the glyph are rotated + * stretched set to TRUE if the glyph are stretched + * + * Output : Error code. + * + * Note : This function is deprecated! It's much better to + * control hinting manually when calling TT_Load_Glyph + * than relying on the font programs... + * + * Never use it, unless calling for trouble ;-) + * + * MT-Note : NO! This should be called only when setting/resetting + * instances, so there is no need to protect. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, + TT_Bool rotated, + TT_Bool stretched ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + ins->metrics.rotated = rotated; + ins->metrics.stretched = stretched; + ins->valid = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Instance_Metrics + * + * Description : Returns instance metrics. + * + * Input : instance the instance handle + * metrics address of target instance metrics record + * + * Output : Error code. + * + * MT-Note : YES! Reads only semi-permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Instance_Metrics( TT_Instance instance, + TT_Instance_Metrics* metrics ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( !ins->valid ) + Instance_Reset( ins ); + + metrics->pointSize = ins->metrics.pointSize; + + metrics->x_scale = TT_MulDiv( 0x10000, + ins->metrics.x_scale1, + ins->metrics.x_scale2 ); + + metrics->y_scale = TT_MulDiv( 0x10000, + ins->metrics.y_scale1, + ins->metrics.y_scale2 ); + + metrics->x_resolution = ins->metrics.x_resolution; + metrics->y_resolution = ins->metrics.y_resolution; + metrics->x_ppem = ins->metrics.x_ppem; + metrics->y_ppem = ins->metrics.y_ppem; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Set_Instance_Pointer + * + * Description : Each instance has one pointer, which use is + * reserved to client applications. The TrueType + * engine never accesses or uses this field. + * + * This function is used to set the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Note : NO! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Set_Instance_Pointer( TT_Instance instance, + void* data ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + else + ins->generic = data; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Instance_Pointer + * + * Description : Each instance has one pointer, which use is + * reserved to client applications. The TrueType + * engine never accesses or uses this field. + * + * This function is used to read the pointer. + * + * Input : face the given face handle + * data the generic pointer value + * + * Output : Error code. + * + * MT-Safe : NO! + * + ******************************************************************/ + + EXPORT_FUNC + void* TT_Get_Instance_Pointer( TT_Instance instance ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return NULL; + else + return ins->generic; + } + + +/******************************************************************* + * + * Function : TT_Done_Instance + * + * Description : Closes a given instance. + * + * Input : instance address of instance handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Instance( TT_Instance instance ) + { + PInstance ins = HANDLE_Instance( instance ); + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + /* delete the instance -- this is thread-safe */ + return CACHE_Done( &ins->owner->instances, ins ); + } + + +/******************************************************************* + * + * Function : TT_New_Glyph + * + * Description : Creates a new glyph object related to a given + * face. + * + * Input : face the face handle + * glyph address of target glyph handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_New_Glyph( TT_Face face, + TT_Glyph* glyph ) + { + TT_Error error; + PFace _face = HANDLE_Face( face ); + PGlyph _glyph; + + + if ( !_face ) + return TT_Err_Invalid_Face_Handle; + + /* get a new glyph from the face's cache -- this is thread-safe */ + error = CACHE_New( &_face->glyphs, _glyph, _face ); + + HANDLE_Set( *glyph, _glyph ); + + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_Glyph + * + * Description : Destroys a given glyph object. + * + * Input : glyph the glyph handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Glyph( TT_Glyph glyph ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + /* delete the engine -- this is thread-safe */ + return CACHE_Done( &_glyph->face->glyphs, _glyph ); + } + + +/******************************************************************* + * + * Function : TT_Load_Glyph + * + * Description : Loads a glyph. + * + * Input : instance the instance handle + * glyph the glyph handle + * glyphIndex the glyph index + * loadFlags flags controlling how to load the glyph + * (none, scaled, hinted, both) + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Load_Glyph( TT_Instance instance, + TT_Glyph glyph, + TT_UShort glyphIndex, + TT_UShort loadFlags ) + { + PInstance _ins; + PGlyph _glyph; + TT_Error error; + + + _ins = HANDLE_Instance( instance ); + + if ( !_ins ) + loadFlags &= ~(TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH); + + if ( (loadFlags & TTLOAD_SCALE_GLYPH) == 0 ) + _ins = 0; + + _glyph = HANDLE_Glyph( glyph ); + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + if ( _ins ) + { + if ( _ins->owner != _glyph->face ) + return TT_Err_Invalid_Face_Handle; + + if ( !_ins->valid ) + { + /* This code can only be called in non thread-safe builds */ + error = Instance_Reset( _ins ); + if ( error ) + return error; + } + } + + return Load_TrueType_Glyph( _ins, _glyph, glyphIndex, loadFlags ); + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Outline + * + * Description : Returns the glyph's outline data. + * + * Input : glyph the glyph handle + * outline address where the glyph outline will be returned + * + * Output : Error code. + * + * MT-Safe : YES! Reads only semi-permanent data. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Outline( TT_Glyph glyph, + TT_Outline* outline ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + *outline = _glyph->outline; + outline->owner = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Metrics + * + * Description : Extracts the glyph's horizontal metrics information. + * + * Input : glyph glyph object handle + * metrics address where metrics will be returned + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Metrics( TT_Glyph glyph, + TT_Glyph_Metrics* metrics ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + metrics->bbox = _glyph->metrics.bbox; + metrics->bearingX = _glyph->metrics.horiBearingX; + metrics->bearingY = _glyph->metrics.horiBearingY; + metrics->advance = _glyph->metrics.horiAdvance; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Big_Metrics + * + * Description : Extracts the glyph's big metrics information. + * + * Input : glyph glyph object handle + * metrics address where big metrics will be returned + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, + TT_Big_Glyph_Metrics* metrics ) + { + PGlyph _glyph = HANDLE_Glyph( glyph ); + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + *metrics = _glyph->metrics; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Glyph_Bitmap + * + * Description : Produces a bitmap from a glyph outline. + * + * Input : glyph the glyph container's handle + * map target pixmap description block + * xOffset x offset in fractional pixels (26.6 format) + * yOffset y offset in fractional pixels (26.6 format) + * + * Output : Error code. + * + * Note : Only use integer pixel offsets if you want to preserve + * the fine hints applied to the outline. This means that + * xOffset and yOffset must be multiples of 64! + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set( engine, _engine ); + + outline = _glyph->outline; + /* XXX : For now, use only dropout mode 2 */ + /* outline.dropout_mode = _glyph->scan_type; */ + outline.dropout_mode = 2; + + TT_Translate_Outline( &outline, xOffset, yOffset ); + error = TT_Get_Outline_Bitmap( engine, &outline, map ); + TT_Translate_Outline( &outline, -xOffset, -yOffset ); + + return error; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/******************************************************************* + * + * Function : TT_Get_Glyph_Pixmap + * + * Description : Produces a grayscaled pixmap from a glyph + * outline. + * + * Input : glyph the glyph container's handle + * map target pixmap description block + * xOffset x offset in fractional pixels (26.6 format) + * yOffset y offset in fractional pixels (26.6 format) + * + * Output : Error code. + * + * Note : Only use integer pixel offsets to preserve the fine + * hinting of the glyph and the 'correct' anti-aliasing + * (where vertical and horizontal stems aren't grayed). + * This means that xOffset and yOffset must be multiples + * of 64! + * + * You can experiment with offsets of +32 to get 'blurred' + * versions of the glyphs (a nice effect at large sizes that + * some graphic designers may appreciate :) + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + /* XXX : For now, use only dropout mode 2 */ + /* outline.dropout_mode = _glyph->scan_type; */ + outline.dropout_mode = 2; + + TT_Translate_Outline( &outline, xOffset, yOffset ); + error = TT_Get_Outline_Pixmap( engine, &outline, map ); + TT_Translate_Outline( &outline, -xOffset, -yOffset ); + + return error; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + static const TT_Outline null_outline + = { 0, 0, NULL, NULL, NULL, 0, 0, 0, 0 }; + + +/******************************************************************* + * + * Function : TT_New_Outline + * + * Description : Creates a new TrueType outline, reserving + * array space for a given number of points and + * contours. + * + * Input : numPoints number of points + * numContours number of contours + * outline address of target outline structure + * + * Output : Error code + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_New_Outline( TT_UShort numPoints, + TT_Short numContours, + TT_Outline* outline ) + { + TT_Error error; + + + if ( !outline ) + return TT_Err_Invalid_Argument; + + *outline = null_outline; + + if ( ALLOC( outline->points, numPoints*2*sizeof ( TT_F26Dot6 ) ) || + ALLOC( outline->flags, numPoints *sizeof ( Byte ) ) || + ALLOC( outline->contours, numContours*sizeof ( UShort ) ) ) + goto Fail; + + outline->n_points = numPoints; + outline->n_contours = numContours; + outline->owner = TRUE; + return TT_Err_Ok; + + Fail: + outline->owner = TRUE; + TT_Done_Outline( outline ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Done_Outline + * + * Description : Deletes an outline created through TT_New_Outline(). + * Calling this function for outlines returned + * by TT_Get_Glyph_Outline() yields an error. + * + * Input : outline address of outline + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Outline( TT_Outline* outline ) + { + if ( outline ) + { + if ( outline->owner ) + { + FREE( outline->points ); + FREE( outline->flags ); + FREE( outline->contours ); + } + *outline = null_outline; + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + +/******************************************************************* + * + * Function : TT_Get_Outline_Bitmap + * + * Description : Render a TrueType outline into a bitmap. + * Note that the bitmap must be created by the caller. + * + * Input : outline the outline to render + * map the target bitmap + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + if ( !outline || !map ) + return TT_Err_Invalid_Argument; + + MUTEX_Lock( _engine->raster_lock ); + error = RENDER_Glyph( outline, map ); + MUTEX_Release( _engine->raster_lock ); + + return error; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/******************************************************************* + * + * Function : TT_Get_Outline_Pixmap + * + * Description : Render a TrueType outline into a pixmap. + * Note that the pixmap must be created by the caller. + * + * Input : outline the outline to render + * map the target bitmap + * + * Output : Error code + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ) + { + PEngine_Instance _engine = HANDLE_Engine( engine ); + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + if ( !outline || !map ) + return TT_Err_Invalid_Argument; + + MUTEX_Lock( _engine->raster_lock ); + error = RENDER_Gray_Glyph( outline, map, _engine->raster_palette ); + MUTEX_Release( _engine->raster_lock ); + return error; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/******************************************************************* + * + * Function : TT_Copy_Outline + * + * Description : Copy an outline into another. The source and + * target outlines must have the same points and + * contours numbers. + * + * Input : source address of source outline + * target address of target outline + * + * Output : Error code + * + * Note : This function doesn't touch the target outline's 'owner' + * field. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Copy_Outline( TT_Outline* source, + TT_Outline* target ) + { + if ( !source || !target || + source->n_points != target->n_points || + source->n_contours != target->n_contours ) + return TT_Err_Invalid_Argument; + + MEM_Copy( target->points, source->points, + source->n_points * 2 * sizeof ( TT_F26Dot6 ) ); + + MEM_Copy( target->flags, source->flags, + source->n_points * sizeof ( Byte ) ); + + MEM_Copy( target->contours, source->contours, + source->n_contours * sizeof ( Short ) ); + + target->high_precision = source->high_precision; + target->second_pass = target->second_pass; + target->dropout_mode = source->dropout_mode; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Transform_Outline + * + * Description : Applies a simple transformation to an outline. + * + * Input : outline the glyph's outline. Can be extracted + * from a glyph container through + * TT_Get_Glyph_Outline(). + * + * matrix simple matrix with 16.16 fixed floats + * + * Output : Error code (always TT_Err_Ok). + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + void TT_Transform_Outline( TT_Outline* outline, + TT_Matrix* matrix ) + { + UShort n; + TT_F26Dot6 x, y; + TT_Vector* vec; + + + vec = outline->points; + for ( n = 0; n < outline->n_points; n++ ) + { + x = TT_MulFix( vec->x, matrix->xx ) + + TT_MulFix( vec->y, matrix->xy ); + + y = TT_MulFix( vec->x, matrix->yx ) + + TT_MulFix( vec->y, matrix->yy ); + + vec->x = x; + vec->y = y; + vec++; + } + } + + +/******************************************************************* + * + * Function : TT_Transform_Vector + * + * Description : Apply a simple transform to a vector + * + * Input : x, y the vector. + * + * matrix simple matrix with 16.16 fixed floats + * + * Output : None. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + void TT_Transform_Vector( TT_F26Dot6* x, + TT_F26Dot6* y, + TT_Matrix* matrix ) + { + TT_F26Dot6 xz, yz; + + + xz = TT_MulFix( *x, matrix->xx ) + + TT_MulFix( *y, matrix->xy ); + + yz = TT_MulFix( *x, matrix->yx ) + + TT_MulFix( *y, matrix->yy ); + + *x = xz; + *y = yz; + } + + +/******************************************************************* + * + * Function : TT_Translate_Outline + * + * Description : Applies a simple translation. + * + * Input : outline no comment :) + * xOffset + * yOffset + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + void TT_Translate_Outline( TT_Outline* outline, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + UShort n; + TT_Vector* vec = outline->points; + + + for ( n = 0; n < outline->n_points; n++ ) + { + vec->x += xOffset; + vec->y += yOffset; + vec++; + } + } + + +/******************************************************************* + * + * Function : TT_Get_Outline_BBox + * + * Description : Returns an outline's bounding box. + * + * Input : outline no comment :) + * bbox address where the bounding box is returned + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Outline_BBox( TT_Outline* outline, + TT_BBox* bbox ) + { + TT_F26Dot6 x, y; + UShort k; + + + if ( outline && bbox ) + { + if ( outline->n_points == 0 ) + { + bbox->xMin = 0; + bbox->yMin = 0; + bbox->xMax = 0; + bbox->yMax = 0; + } + else + { + TT_Vector* vec = outline->points; + + bbox->xMin = bbox->xMax = vec->x; + bbox->yMin = bbox->yMax = vec->y; + vec++; + + for ( k = 1; k < outline->n_points; k++ ) + { + x = vec->x; + if ( x < bbox->xMin ) bbox->xMin = x; + if ( x > bbox->xMax ) bbox->xMax = x; + y = vec->y; + if ( y < bbox->yMin ) bbox->yMin = y; + if ( y > bbox->yMax ) bbox->yMax = y; + vec++; + } + } + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + + + /* ----------------- character mappings support ------------- */ + +/******************************************************************* + * + * Function : TT_Get_CharMap_Count + * + * Description : Returns the number of charmaps in a given face. + * + * Input : face face object handle + * + * Output : Number of tables. -1 in case of error (bad handle). + * + * Note : DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! + * + * It is retained for backwards compatibility only and will + * fail on 16bit systems. + * + * MT-Safe : YES ! + * + ******************************************************************/ + + EXPORT_FUNC + int TT_Get_CharMap_Count( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + return ( faze ? faze->numCMaps : -1 ); + } + + +/******************************************************************* + * + * Function : TT_Get_CharMap_ID + * + * Description : Returns the ID of a given charmap. + * + * Input : face face object handle + * charmapIndex index of charmap in directory + * platformID address of returned platform ID + * encodingID address of returned encoding ID + * + * Output : error code + * + * MT-Safe : YES ! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_CharMap_ID( TT_Face face, + TT_UShort charmapIndex, + TT_UShort* platformID, + TT_UShort* encodingID ) + { + PCMapTable cmap; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( charmapIndex >= faze->numCMaps ) + return TT_Err_Invalid_Argument; + + cmap = faze->cMaps + charmapIndex; + + *platformID = cmap->platformID; + *encodingID = cmap->platformEncodingID; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_CharMap + * + * Description : Looks up a charmap. + * + * Input : face face object handle + * charmapIndex index of charmap in directory + * charMap address of returned charmap handle + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_CharMap( TT_Face face, + TT_UShort charmapIndex, + TT_CharMap* charMap ) + { + TT_Error error; + TT_Stream stream; + PCMapTable cmap; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( charmapIndex >= faze->numCMaps ) + return TT_Err_Invalid_Argument; + + cmap = faze->cMaps + charmapIndex; + + /* Load table if needed */ + error = TT_Err_Ok; + + /* MT-NOTE: We're modifying the face object, so protect it. */ + MUTEX_Lock( faze->lock ); + + if ( !cmap->loaded ) + { + (void)USE_Stream( faze->stream, stream ); + if ( !error ) + { + error = CharMap_Load( cmap, stream ); + DONE_Stream( stream ); + } + + if ( error ) + cmap = NULL; + else + cmap->loaded = TRUE; + } + MUTEX_Release( faze->lock ); + + HANDLE_Set( *charMap, cmap ); + + return error; + } + + +/******************************************************************* + * + * Function : TT_Char_Index + * + * Description : Returns the glyph index corresponding to + * a given character code defined for the 'charmap'. + * + * Input : charMap charmap handle + * charcode character code + * + * Output : glyph index. + * + * Notes : Character code 0 is the unknown glyph, which should never + * be displayed. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_UShort TT_Char_Index( TT_CharMap charMap, + TT_UShort charCode ) + { + PCMapTable cmap = HANDLE_CharMap( charMap ); + + + if ( !cmap ) + return 0; /* we return 0 in case of invalid char map */ + + return CharMap_Index( cmap, charCode ); + } + + +/******************************************************************* + * + * Function : TT_Get_Name_Count + * + * Description : Returns the number of strings found in the + * name table. + * + * Input : face face handle + * + * Output : number of strings. + * + * Notes : Returns -1 on error (invalid handle). + * + * DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! + * + * It is retained for backwards compatibility only and will + * fail on 16bit systems. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + int TT_Get_Name_Count( TT_Face face ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return -1; + + return faze->nameTable.numNameRecords; + } + + +/******************************************************************* + * + * Function : TT_Get_Name_ID + * + * Description : Returns the IDs of the string number 'nameIndex' + * in the name table of a given face. + * + * Input : face face handle + * nameIndex index of string. First is 0 + * platformID addresses of returned IDs + * encodingID + * languageID + * nameID + * + * Output : Error code. + * + * Notes : Some files have a corrupt or unusual name table, with some + * entries having a platformID > 3. These can usually + * be ignored by a client application. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Name_ID( TT_Face face, + TT_UShort nameIndex, + TT_UShort* platformID, + TT_UShort* encodingID, + TT_UShort* languageID, + TT_UShort* nameID ) + { + TNameRec* namerec; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( nameIndex >= faze->nameTable.numNameRecords ) + return TT_Err_Invalid_Argument; + + namerec = faze->nameTable.names + nameIndex; + + *platformID = namerec->platformID; + *encodingID = namerec->encodingID; + *languageID = namerec->languageID; + *nameID = namerec->nameID; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Name_String + * + * Description : Returns the address and length of a given + * string found in the name table. + * + * Input : face face handle + * nameIndex string index + * stringPtr address of returned pointer to string + * length address of returned string length + * + * Output : Error code. + * + * Notes : If the string's platformID is invalid, + * stringPtr is NULL, and length is 0. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Name_String( TT_Face face, + TT_UShort nameIndex, + TT_String** stringPtr, + TT_UShort* length ) + { + TNameRec* namerec; + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + if ( nameIndex >= faze->nameTable.numNameRecords ) + return TT_Err_Invalid_Argument; + + namerec = faze->nameTable.names + nameIndex; + + *stringPtr = (String*)namerec->string; + *length = namerec->stringLength; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Get_Font_Data + * + * Description : Loads any font table into client memory. + * + * Input : face Face object to look for. + * + * tag Tag of table to load. Use the value 0 if you + * want to access the whole font file, else set + * this parameter to a valid TrueType table tag + * that you can forge with the MAKE_TT_TAG + * macro. + * + * offset Starting offset in the table (or the file + * if tag == 0). + * + * buffer Address of target buffer + * + * length Address of decision variable: + * + * if length == NULL: + * Load the whole table. Returns an + * error if 'offset' != 0. + * + * if *length == 0 : + * Exit immediately, returning the + * length of the given table, or of + * the font file, depending on the + * value of 'tag'. + * + * if *length != 0 : + * Load the next 'length' bytes of + * table or font, starting at offset + * 'offset' (in table or font too). + * + * Output : Error code. + * + * MT-Safe : YES! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Font_Data( TT_Face face, + TT_ULong tag, + TT_Long offset, + void* buffer, + TT_Long* length ) + { + PFace faze = HANDLE_Face( face ); + + + if ( !faze ) + return TT_Err_Invalid_Face_Handle; + + return Load_TrueType_Any( faze, tag, offset, buffer, length ); + } + + + /************************ callback definition ******************/ + + /* Register a new callback to the TrueType engine -- this should */ + /* only be used by higher-level libraries, not typical clients */ + /* */ + /* This is not part of the current FreeType release, thus */ + /* undefined... */ + +#if 0 + EXPORT_FUNC + TT_Error TT_Register_Callback( TT_Engine engine, + int callback_id, + void* callback_ptr ) + { + PEngine_Instance eng = HANDLE_Engine( engine ); + + + if ( !eng ) + return TT_Err_Invalid_Argument; + + /* currently, we only support one callback */ + if (callback_id != TT_Callback_Glyph_Outline_Load) + return TT_Err_Invalid_Argument; + + eng->glCallback = (TT_Glyph_Loader_Callback)callback_ptr; + return TT_Err_Ok; + } +#endif /* 0 */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcache.c b/Driver/Font/TrueType/FreeType/ttcache.c new file mode 100644 index 000000000..719f74ac2 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttcache.c @@ -0,0 +1,483 @@ +/******************************************************************* + * + * ttcache.c 1.1 + * + * Generic object cache + * + * 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. + * + * Changes between 1.1 and 1.0: + * + * - introduced the refresher and finalizer in the cache class + * definition/implementation. + * + ******************************************************************/ + +#include "ttengine.h" +#include "ttmemory.h" +#include "ttcache.h" +#include "ttobjs.h" +#include "ttdebug.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_cache + +#define ZERO_List( list ) list = NULL + +/* The macro FREE_Elements aliases the current engine instance's */ +/* free list_elements recycle list. */ +#define FREE_Elements ( engine->list_free_elements ) + +/* Redefinition of LOCK and UNLOCK macros for New_Element and Done_Element */ +/* Note: The macros are redefined below for the cache functions */ + +#undef LOCK +#define LOCK() MUTEX_Lock ( engine->lock ) + +#undef UNLOCK +#define UNLOCK() MUTEX_Release( engine->lock ) + +/******************************************************************* + * + * Function : Element_New + * + * Description : Gets a new (either fresh or recycled) list + * element. The element is unlisted. + * + * Input : None + * + * Output : List element address. NULL if out of memory. + * + ******************************************************************/ + + static + PList_Element Element_New( PEngine_Instance engine ) + { + PList_Element element; + + + LOCK(); + if ( FREE_Elements ) + { + element = (PList_Element)FREE_Elements; + FREE_Elements = element->next; + } + else + { + if ( !MEM_Alloc( element, sizeof ( TList_Element ) ) ) + { + element->next = NULL; + element->data = NULL; + } + } + + /* Note: in case of failure, Alloc sets the pointer to NULL */ + UNLOCK(); + + return element; + } + + +/******************************************************************* + * + * Function : Element_Done + * + * Description : Recycles an unlinked list element. + * + * Input : The list element to recycle. It _must_ be unlisted. + * + * Output : none. + * + * Note : This function doesn't check the element. + * + ******************************************************************/ + + static + void Element_Done( PEngine_Instance engine, + PList_Element element ) + { + LOCK(); + /* Simply add the list element to the recycle list */ + element->next = (PList_Element)FREE_Elements; + FREE_Elements = element; + UNLOCK(); + } + + +/* Redefinition of LOCK and UNLOCK macros for the cache functions */ +/* Note: The macros are defined above for the list element functions */ + +#undef LOCK +#define LOCK() MUTEX_Lock( *cache->lock ) + +#undef UNLOCK +#define UNLOCK() MUTEX_Release( *cache->lock ) + + +/******************************************************************* + * + * Function : Cache_Create + * + * Description : Creates a new cache that will be used to list + * and recycle several objects of the same class. + * + * Input : clazz a pointer to the cache's class. This is + * a simple structure that describes the + * the cache's object types and recycling + * limits. + * + * cache address of cache to create + * + * lock address of the mutex to use for this + * cache. The mutex will be used to protect + * the cache's lists. Use NULL for unprotected + * cache. + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_Create( PEngine_Instance engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ) + { + cache->engine = engine; + cache->clazz = clazz; + cache->lock = lock; + cache->idle_count = 0; + + ZERO_List( cache->active ); + ZERO_List( cache->idle ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Cache_Destroy + * + * Description : Destroys a cache and all its idle and active + * objects. This will call each object's destructor + * before freeing it. + * + * Input : cache address of cache to destroy + * + * Output : error code. + * + * Note: This function is not MT-Safe, as we assume that a client + * isn't stupid enough to use an object while destroying it. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_Destroy( TCache* cache ) + { + PDestructor destroy; + PList_Element current; + PList_Element next; + + + /* now destroy all active and idle listed objects */ + + /* get the destructor function */ + destroy = cache->clazz->done; + + /* destroy all elements in active list */ + current = cache->active; + while ( current ) + { + next = current->next; +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( destroy, current->data ); +#else + destroy( current->data ); +#endif + FREE( current->data ); + + Element_Done( cache->engine, current ); + current = next; + } + ZERO_List(cache->active); + + /* destroy all elements in idle list */ + current = cache->idle; + while ( current ) + { + next = current->next; +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( destroy, current->data ); +#else + destroy( current->data ); +#endif + FREE( current->data ); + + Element_Done( cache->engine, current ); + current = next; + } + ZERO_List(cache->idle); + + cache->clazz = NULL; + cache->idle_count = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Cache_New + * + * Description : Extracts a new object from a cache. This will + * try to recycle an idle object, if any is found. + * Otherwise, a new object will be allocated and + * built (by calling its constructor). + * + * Input : cache address of cache to use + * new_object address of target pointer to the 'new' + * object + * parent_object this pointer is passed to a new object + * constructor (unused if object is + * recycled) + * + * Output : Error code. + * + * Notes: This function is thread-safe, each cache list is protected + * through the cache's mutex, if there is one... + * + * *new_object will be set to NULL in case of failure. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_New( TCache* cache, + void** new_object, + void* parent_object ) + { + TT_Error error; + PList_Element current; + PConstructor build; + PRefresher reset; + void* object; + + + LOCK(); + current = cache->idle; + if ( current ) + { + cache->idle = current->next; + cache->idle_count--; + } + UNLOCK(); + + if ( current ) + { + object = current->data; + reset = cache->clazz->reset; + if ( reset ) + { + error = reset( object, parent_object ); + if ( error ) + { + LOCK(); + current->next = cache->idle; + cache->idle = current; + cache->idle_count++; + UNLOCK(); + goto Exit; + } + } + } + else + { + /* if no object was found in the cache, create a new one */ + build = cache->clazz->init; + + if ( MEM_Alloc( object, cache->clazz->object_size ) ) + goto Memory_Fail; + + current = Element_New( cache->engine ); + if ( !current ) + goto Memory_Fail; + + current->data = object; + +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( build, object, parent_object ); +#else + error = build( object, parent_object ); +#endif /* ifdef __GEOS__ */ + if ( error ) + { + Element_Done( cache->engine, current ); + goto Fail; + } + } + + LOCK(); + current->next = cache->active; + cache->active = current; + UNLOCK(); + + *new_object = current->data; + return TT_Err_Ok; + + Exit: + *new_object = NULL; + return error; + + Memory_Fail: + error = TT_Err_Out_Of_Memory; + + Fail: + FREE( object ); + goto Exit; + } + + +/******************************************************************* + * + * Function : Cache_Done + * + * Description : Releases an object to the cache. This will either + * recycle or destroy the object, based on the cache's + * class and state. + * + * Input : cache the cache to use + * data the object to recycle/discard + * + * Output : error code. + * + * Notes : The object's destructor is called only when + * the objectwill be effectively destroyed by this + * function. This will not happen during recycling. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Cache_Done( TCache* cache, void* data ) + { + TT_Error error; + PList_Element element; + PList_Element prev; + PFinalizer finalize; + Long limit; + Bool destroy; + + + /* Look for object in active list */ + LOCK(); + + element = cache->active; + prev = NULL; + while ( element ) + { + if ( element->data == data ) + { + if ( prev ) + prev->next = element->next; + else + cache->active = element->next; + goto Suite; + } + prev = element; + element = element->next; + } + + UNLOCK(); + return TT_Err_Unlisted_Object; + + Suite: + + limit = cache->clazz->idle_limit; + destroy = (cache->idle_count >= limit); + UNLOCK(); + + if ( destroy ) + { + /* destroy the object when the cache is full */ +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( cache->clazz->done, element->data ); +#else + cache->clazz->done( element->data ); +#endif /* ifdef __GEOS__ */ + FREE( element->data ); + Element_Done( cache->engine, element ); + } + else + { + /* Finalize the object before adding it to the */ + /* idle list. Return the error if any is found. */ + + finalize = cache->clazz->finalize; + if ( finalize ) + { +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( finalize, element->data ); +#else + error = finalize( element->data ); +#endif /* ifdef __GEOS__ */ + if ( error ) + goto Exit; + + /* Note: a failure at finalize time is a severe bug in */ + /* the engine, which is why we allow ourselves to */ + /* lose the object in this case. A finalizer should */ + /* have its own error codes to spot this kind of */ + /* problems easily. */ + } + + LOCK(); + element->next = cache->idle; + cache->idle = element; + cache->idle_count++; + UNLOCK(); + } + + error = TT_Err_Ok; + + Exit: + return error; + } + + + LOCAL_FUNC + TT_Error TTCache_Init( PEngine_Instance engine ) + { + /* Create list elements mutex */ + FREE_Elements = NULL; + return TT_Err_Ok; + } + + + LOCAL_FUNC + TT_Error TTCache_Done( PEngine_Instance engine ) + { + /* We don't protect this function, as this is the end of the engine's */ + /* execution.. */ + PList_Element element, next; + + + /* frees the recycled list elements */ + element = FREE_Elements; + while ( element ) + { + next = element->next; + FREE( element ); + element = next; + } + return TT_Err_Ok; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcache.h b/Driver/Font/TrueType/FreeType/ttcache.h new file mode 100644 index 000000000..66d84bab0 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttcache.h @@ -0,0 +1,216 @@ +/******************************************************************* + * + * ttcache.h 1.1 + * + * Generic object cache + * + * 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. + * + * + * This component defines and implements object caches. + * + * An object class is a structure layout that encapsulate one + * given type of data used by the FreeType engine. Each object + * class is completely described by: + * + * - a 'root' or 'leading' structure containing the first + * important fields of the class. The root structure is + * always of fixed size. + * + * It is implemented as a simple C structure, and may + * contain several pointers to sub-tables that can be + * sized and allocated dynamically. + * + * Examples: TFace, TInstance, TGlyph & TExecution_Context + * (defined in 'ttobjs.h') + * + * - we make a difference between 'child' pointers and 'peer' + * pointers. A 'child' pointer points to a sub-table that is + * owned by the object, while a 'peer' pointer points to any + * other kind of data the object isn't responsible for. + * + * An object class is thus usually a 'tree' of 'child' tables. + * + * - each object class needs a constructor and a destructor. + * + * A constructor is a function which receives the address of + * freshly allocated and zeroed object root structure and + * 'builds' all the valid child data that must be associated + * to the object before it becomes 'valid'. + * + * A destructor does the inverse job: given the address of + * a valid object, it must discard all its child data and + * zero its main fields (essentially the pointers and array + * sizes found in the root fields). + * + * + * Important notes: + * + * When the constructor fails to allocate an object, it must + * return immediately with an error code, and not try to release + * what it has previously allocated before the error. The cache + * manager detects the error and calls the destructor on the + * partial object, before returning the error to the caller (along + * with a NULL pointer for the "new" object). + * + * The destructor must thus be able to deal with "partial objects", + * i.e., objects where only part of the child tables are allocated, + * and only release these ones. As the TT_Free() function accepts + * a NULL parameter (and returns successfuly in this case), no check + * is really necessary when using the macro 'FREE()'. + * + * Currently, there is no check in the cache manager to see if a + * destructor fails (double error state!). + * + * This scheme is more compact and more maintanable than the one + * where de-allocation code is duplicated in the constructor + * _and_ the destructor. + * + * + * + * Changes between 1.1 and 1.0: + * + * - introduced the refreshed and finalizer class definition/implementation + * - inserted an engine instance pointer in the cache structure + * + ******************************************************************/ + +#ifndef TTCACHE_H +#define TTCACHE_H + +#include "tttypes.h" +#include "ttconfig.h" +#include "ttmutex.h" + +#ifdef __cplusplus + extern "C" { +#endif + + typedef TT_Error TConstructor( void* object, + void* parent ); + + typedef TT_Error TDestructor ( void* object ); + + typedef TConstructor TRefresher; + typedef TDestructor TFinalizer; + + typedef TConstructor* PConstructor; + typedef TDestructor* PDestructor; + typedef TRefresher* PRefresher; + typedef TFinalizer* PFinalizer; + + + /* A Cache class record holds the data necessary to define */ + /* a cache kind. */ + struct TCache_Class_ + { + ULong object_size; + Long idle_limit; + PConstructor init; + PDestructor done; + PRefresher reset; + PFinalizer finalize; + }; + + typedef struct TCache_Class_ TCache_Class; + typedef TCache_Class* PCache_Class; + + + + /* Simple list node record. A list element is said to be 'unlinked' */ + /* when it doesn't belong to any list. */ + struct TList_Element_; + + typedef struct TList_Element_ TList_Element; + typedef TList_Element* PList_Element; + + struct TList_Element_ + { + PList_Element next; + void* data; + }; + + + /* Simple singly-linked list record - LIFO style, no tail field */ + typedef PList_Element TSingle_List; + + struct TCache_ + { + PEngine_Instance engine; + PCache_Class clazz; /* 'class' is a reserved word in C++ */ + TMutex* lock; + TSingle_List active; + TSingle_List idle; + Long idle_count; + }; + + typedef struct TCache_ TCache; + typedef TCache* PCache; + + /* Returns a new list element, either fresh or recycled. */ + /* Note: the returned element is unlinked. */ + + /* An object cache holds two lists tracking the active and */ + /* idle objects that are currently created and used by the */ + /* engine. It can also be 'protected' by a mutex. */ + + /* Initializes a new cache, of class 'clazz', pointed by 'cache', */ + /* protected by the 'lock' mutex. Set 'lock' to NULL if the cache */ + /* doesn't need protection */ + + LOCAL_DEF + TT_Error Cache_Create( PEngine_Instance engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ); + + /* Destroys a cache and all its listed objects */ + + LOCAL_DEF + TT_Error Cache_Destroy( TCache* cache ); + + + /* Extracts a new object from the cache */ + + LOCAL_DEF + TT_Error Cache_New( TCache* cache, + void** new_object, + void* parent_object ); + + + /* Returns an object to the cache, or discards it depending */ + /* on the cache class' 'idle_limit' field */ + + LOCAL_DEF + TT_Error Cache_Done( TCache* cache, void* data ); + +#define CACHE_New( _cache, _newobj, _parent ) \ + Cache_New( (TCache*)_cache, (void**)&_newobj, (void*)_parent ) + +#define CACHE_Done( _cache, _obj ) \ + Cache_Done( (TCache*)_cache, (void*)_obj ) + + + + LOCAL_DEF + TT_Error TTCache_Init( PEngine_Instance engine ); + + LOCAL_DEF + TT_Error TTCache_Done( PEngine_Instance engine ); + + +#ifdef __cplusplus + } +#endif + +#endif /* TTCACHE_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcalc.c b/Driver/Font/TrueType/FreeType/ttcalc.c new file mode 100644 index 000000000..0d7fcbc51 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttcalc.c @@ -0,0 +1,403 @@ +/******************************************************************* + * + * ttcalc.c + * + * Arithmetic Computations (body). + * + * 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 "ttcalc.h" +#include "ttdebug.h" +#include "tttables.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_calc + + +/* Support for 1-complement arithmetic has been totally dropped in this */ +/* release. You can still write your own code if you need it... */ + + static const Long Roots[63] = + { + 1, 1, 2, 3, 4, 5, 8, 11, + 16, 22, 32, 45, 64, 90, 128, 181, + 256, 362, 512, 724, 1024, 1448, 2048, 2896, + 4096, 5892, 8192, 11585, 16384, 23170, 32768, 46340, + + 65536, 92681, 131072, 185363, 262144, 370727, + 524288, 741455, 1048576, 1482910, 2097152, 2965820, + 4194304, 5931641, 8388608, 11863283, 16777216, 23726566, + + 33554432, 47453132, 67108864, 94906265, + 134217728, 189812531, 268435456, 379625062, + 536870912, 759250125, 1073741824, 1518500250, + 2147483647 + }; + + +#ifdef LONG64 + + EXPORT_FUNC + TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ) + { + Long s; + + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + s ^= c; c = ABS( c ); + + a = ((TT_Int64)a * b + c/2) / c; + return ( s < 0 ) ? -a : a; + } + + + EXPORT_FUNC + TT_Long TT_MulFix( TT_Long a, TT_Long b ) + { + Long s; + + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + + a = ((TT_Int64)a * b + 0x8000) / 0x10000; + return ( s < 0 ) ? -a : a; + } + + + LOCAL_FUNC + Int Order64( TT_Int64 z ) + { + Int j = 0; + + + while ( z ) + { + z = (unsigned INT64)z >> 1; + j++; + } + return j - 1; + } + + + LOCAL_FUNC + TT_Int32 Sqrt64( TT_Int64 l ) + { + TT_Int64 r, s; + + + if ( l <= 0 ) return 0; + if ( l == 1 ) return 1; + + r = Roots[Order64( l )]; + + do + { + s = r; + r = ( r + l/r ) >> 1; + } + while ( r > s || r*r > l ); + + return r; + } + +#else /* LONG64 */ + + + /* The TT_MulDiv function has been optimized thanks to ideas from */ + /* Graham Asher. The trick is to optimize computation when everything */ + /* fits within 32-bits (a rather common case). */ + /* */ + /* we compute 'a*b+c/2', then divide it by 'c'. (positive values) */ + /* */ + /* 46340 is FLOOR(SQRT(2^31-1)). */ + /* */ + /* if ( a <= 46340 && b <= 46340 ) then ( a*b <= 0x7FFEA810 ) */ + /* */ + /* 0x7FFFFFFF - 0x7FFEA810 = 0x157F0 */ + /* */ + /* if ( c < 0x157F0*2 ) then ( a*b+c/2 <= 0x7FFFFFFF ) */ + /* */ + /* and 2*0x157F0 = 176096 */ + /* */ + + EXPORT_FUNC + TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ) + { + long s; + + + if ( a == 0 || b == c ) + return a; + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + s ^= c; c = ABS( c ); + + if ( a <= 46340 && b <= 46340 && c <= 176095 ) + { + a = ( a*b + c/2 )/c; + } + else + { + TT_Int64 temp, temp2; + + MulTo64( a, b, &temp ); + temp2.hi = (TT_Int32)(c >> 31); + temp2.lo = (TT_Word32)(c / 2); + Add64( &temp, &temp2, &temp ); + a = Div64by32( &temp, c ); + } + + return ( s < 0 ) ? -a : a; + } + + /* The optimization for TT_MulFix is different. We could simply be */ + /* happy by applying the same principles than with TT_MulDiv, because */ + /* */ + /* c = 0x10000 < 176096 */ + /* */ + /* however, in most cases, we have a 'b' with a value around 0x10000 */ + /* which is greater than 46340. */ + /* */ + /* According to Graham's testing, most cases have 'a' < 100, so a good */ + /* idea is to use bounds like 1024 and 2097151 (= floor(2^31-1)/1024 ) */ + /* for 'a' and 'b' respectively.. */ + /* */ + + EXPORT_FUNC + TT_Long TT_MulFix( TT_Long a, TT_Long b ) + { + long s; + + if ( a == 0 || b == 0x10000 ) + return a; + + s = a; a = ABS( a ); + s ^= b; b = ABS( b ); + + if ( a <= 1024 && b <= 2097151 ) + { + a = ( a*b + 0x8000 ) >> 16; + } + else + { + TT_Int64 temp, temp2; + + MulTo64( a, b, &temp ); + temp2.hi = 0; + temp2.lo = 0x8000; + Add64( &temp, &temp2, &temp ); + a = Div64by32( &temp, 0x10000 ); + } + + return ( s < 0 ) ? -a : a; + } + + + LOCAL_FUNC + void Neg64( TT_Int64* x ) + { + /* Remember that -(0x80000000) == 0x80000000 with 2-complement! */ + /* We take care of that here. */ + + x->hi ^= 0xFFFFFFFFUL; + x->lo ^= 0xFFFFFFFFUL; + x->lo++; + + if ( !x->lo ) + { + x->hi++; + if ( x->hi == 0x80000000UL ) /* Check -MaxInt32 - 1 */ + { + x->lo--; + x->hi--; /* We return 0x7FFFFFFF! */ + } + } + } + + + LOCAL_FUNC + void Add64( TT_Int64* x, TT_Int64* y, TT_Int64* z ) + { + register TT_Word32 lo, hi; + + + lo = x->lo + y->lo; + hi = x->hi + y->hi + ( lo < x->lo ); + + z->lo = lo; + z->hi = hi; + } + + + LOCAL_FUNC + void Sub64( TT_Int64* x, TT_Int64* y, TT_Int64* z ) + { + register TT_Word32 lo, hi; + + + lo = x->lo - y->lo; + hi = x->hi - y->hi - ( (TT_Int32)lo < 0 ); + + z->lo = lo; + z->hi = hi; + } + + + LOCAL_FUNC + void MulTo64( TT_Int32 x, TT_Int32 y, TT_Int64* z ) + { + TT_Int32 s; + TT_Word32 lo1, hi1, lo2, hi2, lo, hi, i1, i2; + + + s = x; x = ABS( x ); + s ^= y; y = ABS( y ); + + lo1 = x & 0x0000FFFF; hi1 = x >> 16; + lo2 = y & 0x0000FFFF; hi2 = y >> 16; + + lo = lo1*lo2; + i1 = lo1*hi2; + i2 = lo2*hi1; + hi = hi1*hi2; + + /* Check carry overflow of i1 + i2 */ + + if ( i2 ) + { + if ( i1 >= (TT_Word32)-(TT_Int32)i2 ) hi += 1L << 16; + i1 += i2; + } + + i2 = i1 >> 16; + i1 = i1 << 16; + + /* Check carry overflow of i1 + lo */ + if ( i1 ) + { + if ( lo >= (TT_Word32)-(TT_Int32)i1 ) hi++; + lo += i1; + } + + hi += i2; + + z->lo = lo; + z->hi = hi; + + if ( s < 0 ) Neg64( z ); + } + + + LOCAL_FUNC + TT_Int32 Div64by32( TT_Int64* x, TT_Int32 y ) + { + TT_Int32 s; + TT_Word32 q, r, i, lo; + + + s = x->hi; if ( s < 0 ) Neg64( x ); + s ^= y; y = ABS( y ); + + /* Shortcut */ + if ( x->hi == 0 ) + { + q = x->lo / y; + return ( s < 0 ) ? -(TT_Int32)q : (TT_Int32)q; + } + + r = x->hi; + lo = x->lo; + + if ( r >= (TT_Word32)y ) /* we know y is to be treated as unsigned here */ + return ( s < 0 ) ? 0x80000001UL : 0x7FFFFFFFUL; + /* Return Max/Min Int32 if divide overflow */ + /* This includes division by zero! */ + q = 0; + for ( i = 0; i < 32; i++ ) + { + r <<= 1; + q <<= 1; + r |= lo >> 31; + + if ( r >= (TT_Word32)y ) + { + r -= y; + q |= 1; + } + lo <<= 1; + } + + return ( s < 0 ) ? -(TT_Int32)q : (TT_Int32)q; + } + + + LOCAL_FUNC + Int Order64( TT_Int64* z ) + { + TT_Word32 i; + Int j; + + + if ( z->hi ) + { + i = z->hi; + j = 32; + } + else + { + i = z->lo; + j = 0; + } + + while ( i > 0 ) + { + i >>= 1; + j++; + } + return j-1; + } + + + LOCAL_FUNC + TT_Int32 Sqrt64( TT_Int64* l ) + { + TT_Int64 l2; + TT_Int32 r, s; + + + if ( (TT_Int32)l->hi < 0 || + (l->hi == 0 && l->lo == 0) ) return 0; + + s = Order64( l ); + if ( s == 0 ) return 1; + + r = Roots[s]; + do + { + s = r; + r = ( r + Div64by32(l,r) ) >> 1; + MulTo64( r, r, &l2 ); + Sub64 ( l, &l2, &l2 ); + } + while ( r > s || (TT_Int32)l2.hi < 0 ); + + return r; + } + +#endif /* LONG64 */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcalc.h b/Driver/Font/TrueType/FreeType/ttcalc.h new file mode 100644 index 000000000..0aec33850 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttcalc.h @@ -0,0 +1,97 @@ +/******************************************************************* + * + * ttcalc.h + * + * Arithmetic Computations (specification). + * + * 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 TTCALC_H +#define TTCALC_H + +#include "ttconfig.h" +#include "freetype.h" + + +#ifdef __cplusplus + extern "C" { +#endif + +#ifdef LONG64 + + typedef INT64 TT_Int64; + +#define ADD_64( x, y, z ) z = x + y +#define SUB_64( x, y, z ) z = x - y +#define MUL_64( x, y, z ) z = (TT_Int64)(x) * (y) + +#define DIV_64( x, y ) ( (x) / (y) ) + +#define SQRT_64( x ) Sqrt64( x ) +#define SQRT_32( x ) Sqrt32( x ) + + LOCAL_DEF TT_Int32 Sqrt64( TT_Int64 l ); + +#else /* LONG64 */ + + struct TT_Int64_ + { + TT_Word32 lo; + TT_Word32 hi; + }; + + typedef struct TT_Int64_ TT_Int64; + +#define ADD_64( x, y, z ) Add64( &x, &y, &z ) +#define SUB_64( x, y, z ) Sub64( &x, &y, &z ) +#define MUL_64( x, y, z ) MulTo64( x, y, &z ) + +#define DIV_64( x, y ) Div64by32( &x, y ) + +#define SQRT_64( x ) Sqrt64( &x ) +#define SQRT_32( x ) Sqrt32( x ) + + LOCAL_DEF void Add64( TT_Int64* x, TT_Int64* y, TT_Int64* z ); + LOCAL_DEF void Sub64( TT_Int64* x, TT_Int64* y, TT_Int64* z ); + + LOCAL_DEF void MulTo64( TT_Int32 x, TT_Int32 y, TT_Int64* z ); + + LOCAL_DEF TT_Int32 Div64by32( TT_Int64* x, TT_Int32 y ); + + LOCAL_DEF int Order64( TT_Int64* z ); + + LOCAL_DEF TT_Int32 Sqrt64( TT_Int64* l ); + +#endif /* LONG64 */ + + /* The two following functions are now part of the API! */ + + /* TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ); */ + /* TT_Long TT_MulFix( TT_Long a, TT_Long b ); */ + + +#define INT_TO_F26DOT6( x ) ( (Long)(x) << 6 ) +#define INT_TO_F2DOT14( x ) ( (Long)(x) << 14 ) +#define INT_TO_FIXED( x ) ( (Long)(x) << 16 ) +#define F2DOT14_TO_FIXED( x ) ( (Long)(x) << 2 ) +#define FLOAT_TO_FIXED( x ) ( (Long)(x * 65536.0) ) + +#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ((x) + 32) & -64) \ + : ( -((32 - (x)) & -64) ) ) + +#ifdef __cplusplus + } +#endif + +#endif /* TTCALC_H */ + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcmap.c b/Driver/Font/TrueType/FreeType/ttcmap.c new file mode 100644 index 000000000..13d06c679 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttcmap.c @@ -0,0 +1,503 @@ +/******************************************************************* + * + * ttcmap.c 1.0 + * + * TrueType Character Mappings + * + * 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 "ttobjs.h" +#include "ttdebug.h" +#include "ttfile.h" +#include "ttmemory.h" +#include "ttload.h" +#include "ttcmap.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_cmap + + +/******************************************************************* + * + * Function : CharMap_Load + * + * Description : Loads a given charmap into memory. + * + * Input : cmap pointer to cmap table + * + * Output : Error code. + * + * Notes : - Assumes the the stream is already used (opened). + * + * - In case of error, releases all partially allocated + * tables. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error CharMap_Load( PCMapTable cmap, + TT_Stream input ) + { + DEFINE_LOAD_LOCALS( input ); + + UShort num_SH, num_Seg, i; + + UShort u, l; + + PCMap0 cmap0; + PCMap2 cmap2; + PCMap4 cmap4; + PCMap6 cmap6; + + PCMap2SubHeader cmap2sub; + PCMap4Segment segments; + + + if ( cmap->loaded ) + return TT_Err_Ok; + + if ( FILE_Seek( cmap->offset ) ) + return error; + + switch ( cmap->format ) + { + case 0: + cmap0 = &cmap->c.cmap0; + + if ( ALLOC( cmap0->glyphIdArray, 256L ) || + FILE_Read( (void*)cmap0->glyphIdArray, 256L ) ) + goto Fail; + + break; + + case 2: + num_SH = 0; + cmap2 = &cmap->c.cmap2; + + /* allocate subheader keys */ + + if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, UShort ) || + ACCESS_Frame( 512L ) ) + goto Fail; + + for ( i = 0; i < 256; i++ ) + { + u = GET_UShort() / 8; + cmap2->subHeaderKeys[i] = u; + + if ( num_SH < u ) + num_SH = u; + } + + FORGET_Frame(); + + /* load subheaders */ + + cmap2->numGlyphId = l = + ( ( cmap->length - 2L * (256 + 3) - num_SH * 8L ) & 0xffff) / 2; + + if ( ALLOC_ARRAY( cmap2->subHeaders, + num_SH + 1, + TCMap2SubHeader ) || + ACCESS_Frame( ( num_SH + 1 ) * 8L ) ) + goto Fail; + + cmap2sub = cmap2->subHeaders; + + for ( i = 0; i <= num_SH; i++ ) + { + cmap2sub->firstCode = GET_UShort(); + cmap2sub->entryCount = GET_UShort(); + cmap2sub->idDelta = GET_Short(); + /* we apply the location offset immediately */ + cmap2sub->idRangeOffset = GET_UShort() - ( num_SH - i ) * 8 - 2; + + cmap2sub++; + } + + FORGET_Frame(); + + /* load glyph ids */ + + if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, UShort ) || + ACCESS_Frame( l * 2L ) ) + goto Fail; + + for ( i = 0; i < l; i++ ) + cmap2->glyphIdArray[i] = GET_UShort(); + + FORGET_Frame(); + break; + + case 4: + cmap4 = &cmap->c.cmap4; + + /* load header */ + + if ( ACCESS_Frame( 8L ) ) + goto Fail; + + cmap4->segCountX2 = GET_UShort(); + cmap4->searchRange = GET_UShort(); + cmap4->entrySelector = GET_UShort(); + cmap4->rangeShift = GET_UShort(); + + num_Seg = cmap4->segCountX2 / 2; + + FORGET_Frame(); + + /* load segments */ + + if ( ALLOC_ARRAY( cmap4->segments, + num_Seg, + TCMap4Segment ) || + ACCESS_Frame( (num_Seg * 4 + 1) * 2L ) ) + goto Fail; + + segments = cmap4->segments; + + for ( i = 0; i < num_Seg; i++ ) + segments[i].endCount = GET_UShort(); + + (void)GET_UShort(); + + for ( i = 0; i < num_Seg; i++ ) + segments[i].startCount = GET_UShort(); + + for ( i = 0; i < num_Seg; i++ ) + segments[i].idDelta = GET_Short(); + + for ( i = 0; i < num_Seg; i++ ) + segments[i].idRangeOffset = GET_UShort(); + + FORGET_Frame(); + + cmap4->numGlyphId = l = + ( ( cmap->length - ( 16L + 8L * num_Seg ) ) & 0xffff ) / 2; + + /* load ids */ + + if ( ALLOC_ARRAY( cmap4->glyphIdArray, l , UShort ) || + ACCESS_Frame( l * 2L ) ) + goto Fail; + + for ( i = 0; i < l; i++ ) + cmap4->glyphIdArray[i] = GET_UShort(); + + FORGET_Frame(); + break; + + case 6: + cmap6 = &cmap->c.cmap6; + + if ( ACCESS_Frame( 4L ) ) + goto Fail; + + cmap6->firstCode = GET_UShort(); + cmap6->entryCount = GET_UShort(); + + FORGET_Frame(); + + l = cmap6->entryCount; + + if ( ALLOC_ARRAY( cmap6->glyphIdArray, + cmap6->entryCount, + Short ) || + ACCESS_Frame( l * 2L ) ) + goto Fail; + + for ( i = 0; i < l; i++ ) + cmap6->glyphIdArray[i] = GET_UShort(); + + FORGET_Frame(); + break; + + default: /* corrupt character mapping table */ + return TT_Err_Invalid_CharMap_Format; + + } + return TT_Err_Ok; + + Fail: + CharMap_Free( cmap ); + return error; + } + + +/******************************************************************* + * + * Function : CharMap_Free + * + * Description : Releases a given charmap table. + * + * Input : cmap pointer to cmap table + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error CharMap_Free( PCMapTable cmap ) + { + if ( !cmap ) + return TT_Err_Ok; + + switch ( cmap->format ) + { + case 0: + FREE( cmap->c.cmap0.glyphIdArray ); + break; + + case 2: + FREE( cmap->c.cmap2.subHeaderKeys ); + FREE( cmap->c.cmap2.subHeaders ); + FREE( cmap->c.cmap2.glyphIdArray ); + break; + + case 4: + FREE( cmap->c.cmap4.segments ); + FREE( cmap->c.cmap4.glyphIdArray ); + cmap->c.cmap4.segCountX2 = 0; + break; + + case 6: + FREE( cmap->c.cmap6.glyphIdArray ); + cmap->c.cmap6.entryCount = 0; + break; + + default: + /* invalid table format, do nothing */ + ; + } + + cmap->loaded = FALSE; + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : CharMap_Index + * + * Description : Performs charcode->glyph index translation. + * + * Input : cmap pointer to cmap table + * + * Output : Glyph index, 0 in case of failure. + * + ******************************************************************/ + + static UShort code_to_index0( UShort charCode, PCMap0 cmap0 ); + static UShort code_to_index2( UShort charCode, PCMap2 cmap2 ); + static UShort code_to_index4( UShort charCode, PCMap4 cmap4 ); + static UShort code_to_index6( UShort charCode, PCMap6 cmap6 ); + + + LOCAL_FUNC + UShort CharMap_Index( PCMapTable cmap, + UShort charcode ) + { + switch ( cmap->format ) + { + case 0: + return code_to_index0( charcode, &cmap->c.cmap0 ); + case 2: + return code_to_index2( charcode, &cmap->c.cmap2 ); + case 4: + return code_to_index4( charcode, &cmap->c.cmap4 ); + case 6: + return code_to_index6( charcode, &cmap->c.cmap6 ); + default: + return 0; + } + } + + +/******************************************************************* + * + * Function : code_to_index0 + * + * Description : Converts the character code into a glyph index. + * Uses format 0. + * charCode will be masked to get a value in the range + * 0x00-0xFF. + * + * Input : charCode the wanted character code + * cmap0 a pointer to a cmap table in format 0 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist. + * + ******************************************************************/ + + static UShort code_to_index0( UShort charCode, + PCMap0 cmap0 ) + { + if ( charCode <= 0xFF ) + return cmap0->glyphIdArray[charCode]; + else + return 0; + } + + +/******************************************************************* + * + * Function : code_to_index2 + * + * Description : Converts the character code into a glyph index. + * Uses format 2. + * + * Input : charCode the wanted character code + * cmap2 a pointer to a cmap table in format 2 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist. + * + ******************************************************************/ + + static UShort code_to_index2( UShort charCode, + PCMap2 cmap2 ) + { + UShort index1, idx, offset; + TCMap2SubHeader sh2; + + + index1 = cmap2->subHeaderKeys[charCode <= 0xFF ? + charCode : (charCode >> 8)]; + + if ( index1 == 0 ) + { + if ( charCode <= 0xFF ) + return cmap2->glyphIdArray[charCode]; /* 8bit character code */ + else + return 0; + } + else /* 16bit character code */ + { + if ( charCode <= 0xFF ) + return 0; + + sh2 = cmap2->subHeaders[index1]; + + if ( (charCode & 0xFF) < sh2.firstCode ) + return 0; + + if ( (charCode & 0xFF) >= (sh2.firstCode + sh2.entryCount) ) + return 0; + + offset = sh2.idRangeOffset / 2 + (charCode & 0xFF) - sh2.firstCode; + if ( offset < cmap2->numGlyphId ) + idx = cmap2->glyphIdArray[offset]; + else + return 0; + + if ( idx ) + return (idx + sh2.idDelta) & 0xFFFF; + else + return 0; + } + } + + +/******************************************************************* + * + * Function : code_to_index4 + * + * Description : Converts the character code into a glyph index. + * Uses format 4. + * + * Input : charCode the wanted character code + * cmap4 a pointer to a cmap table in format 4 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist. + * + ******************************************************************/ + + static UShort code_to_index4( UShort charCode, + PCMap4 cmap4 ) + { + UShort index1, segCount; + UShort i; + TCMap4Segment seg4; + + + segCount = cmap4->segCountX2 / 2; + + for ( i = 0; i < segCount; i++ ) + if ( charCode <= cmap4->segments[i].endCount ) + break; + + /* Safety check - even though the last endCount should be 0xFFFF */ + if ( i >= segCount ) + return 0; + + seg4 = cmap4->segments[i]; + + if ( charCode < seg4.startCount ) + return 0; + + if ( seg4.idRangeOffset == 0 ) + return ( charCode + seg4.idDelta ) & 0xFFFF; + else + { + index1 = seg4.idRangeOffset / 2 + (charCode - seg4.startCount) - + (segCount - i); + + if ( index1 < cmap4->numGlyphId ) + { + if ( cmap4->glyphIdArray[index1] == 0 ) + return 0; + else + return ( cmap4->glyphIdArray[index1] + seg4.idDelta ) & 0xFFFF; + } + else + return 0; + } + } + + +/******************************************************************* + * + * Function : code_to_index6 + * + * Description : Converts the character code into a glyph index. + * Uses format 6. + * + * Input : charCode the wanted character code + * cmap6 a pointer to a cmap table in format 6 + * + * Output : Glyph index into the glyphs array. + * 0 if the glyph does not exist (`missing character glyph'). + * + ******************************************************************/ + + static UShort code_to_index6( UShort charCode, + PCMap6 cmap6 ) + { + UShort firstCode; + + + firstCode = cmap6->firstCode; + + if ( charCode < firstCode ) + return 0; + + if ( charCode >= (firstCode + cmap6->entryCount) ) + return 0; + + return cmap6->glyphIdArray[charCode - firstCode]; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcmap.h b/Driver/Font/TrueType/FreeType/ttcmap.h new file mode 100644 index 000000000..43ca7887c --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttcmap.h @@ -0,0 +1,169 @@ +/******************************************************************* + * + * ttcmap.h 1.0 + * + * TrueType Character Mappings + * + * 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 TTCMAP_H +#define TTCMAP_H + +#include "ttconfig.h" +#include "tttypes.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* format 0 */ + + struct TCMap0_ + { + PByte glyphIdArray; + }; + + typedef struct TCMap0_ TCMap0; + typedef TCMap0* PCMap0; + + + /* format 2 */ + + struct TCMap2SubHeader_ + { + UShort firstCode; /* first valid low byte */ + UShort entryCount; /* number of valid low bytes */ + Short idDelta; /* delta value to glyphIndex */ + UShort idRangeOffset; /* offset from here to 1st code */ + }; + + typedef struct TCMap2SubHeader_ TCMap2SubHeader; + typedef TCMap2SubHeader* PCMap2SubHeader; + + struct TCMap2_ + { + PUShort subHeaderKeys; + /* high byte mapping table */ + /* value = subHeader index * 8 */ + + PCMap2SubHeader subHeaders; + PUShort glyphIdArray; + UShort numGlyphId; /* control value */ + }; + + typedef struct TCMap2_ TCMap2; + typedef TCMap2* PCMap2; + + + /* format 4 */ + + struct TCMap4Segment_ + { + UShort endCount; + UShort startCount; + Short idDelta; /* in the specs defined as UShort but the + example there gives negative values... */ + UShort idRangeOffset; + }; + + typedef struct TCMap4Segment_ TCMap4Segment; + typedef TCMap4Segment* PCMap4Segment; + + struct TCMap4_ + { + UShort segCountX2; /* number of segments * 2 */ + UShort searchRange; /* these parameters can be used */ + UShort entrySelector; /* for a binary search */ + UShort rangeShift; + + PCMap4Segment segments; + PUShort glyphIdArray; + UShort numGlyphId; /* control value */ + }; + + typedef struct TCMap4_ TCMap4; + typedef TCMap4* PCMap4; + + + /* format 6 */ + + struct TCMap6_ + { + UShort firstCode; /* first character code of subrange */ + UShort entryCount; /* number of character codes in subrange */ + + PUShort glyphIdArray; + }; + + typedef struct TCMap6_ TCMap6; + typedef TCMap6* PCMap6; + + + /* charmap table */ + + struct TCMapTable_ + { + UShort platformID; + UShort platformEncodingID; + UShort format; + UShort length; + UShort version; + + Bool loaded; + ULong offset; + + union + { + TCMap0 cmap0; + TCMap2 cmap2; + TCMap4 cmap4; + TCMap6 cmap6; + } c; + }; + + typedef struct TCMapTable_ TCMapTable; + typedef TCMapTable* PCMapTable; + + + + /* Load character mappings directory when face is loaded. */ + /* The mappings themselves are only loaded on demand. */ + + LOCAL_DEF + TT_Error CharMap_Load( PCMapTable table, + TT_Stream input ); + + + /* Destroy one character mapping table */ + + LOCAL_DEF + TT_Error CharMap_Free( PCMapTable table ); + + + /* Use character mapping table to perform mapping */ + + LOCAL_DEF + UShort CharMap_Index( PCMapTable cmap, + UShort charCode ); + + /* NOTE: The PFace type isn't defined at this point */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTCMAP_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttconfig.h b/Driver/Font/TrueType/FreeType/ttconfig.h new file mode 100644 index 000000000..616a1a654 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttconfig.h @@ -0,0 +1,279 @@ +/******************************************************************* + * + * ttconfig.h 1.0 + * + * Configuration settings header file (spec only). + * + * 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. + * + * Notes: + * + * All the configuration #define statements have been gathered in + * this file to allow easy check and modification. + * + ******************************************************************/ + +#ifndef TTCONFIG_H +#define TTCONFIG_H + + + +/* ------------ auto configuration ------------------------------------- */ + + +/*************************************************************************/ +/* Here we include the file ft_conf.h for system dependent stuff. */ +/* The specific makefile is responsible for providing the right path to */ +/* this file. */ + +#include "ft_conf.h" + + +/**************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +#define TT_CONFIG_OPTION_THREAD_SAFE + + + +/* ------------ general debugging -------------------------------------- */ + + +/************************************************************************* + * + * There are now three debugging modes: + * + * - trace mode: + * + * Error and trace messages are sent to the log file + * (which can be the standard error output). Define + * DEBUG_LEVEL_TRACE to enable this mode. + * + * - error mode: + * + * Only error messages are generated. Define + * DEBUG_LEVEL_ERROR to enable this mode. + * + * - release mode: + * + * Error messages are neither sent nor generated. The code is + * free from any debugging parts. + * + * + * Note that you should link the engine with the 'ttdebug' component. + * in case either DEBUG_LEVEL_TRACE or DEBUG_LEVEL_ERROR is defined. + * + * Please consult ttdebug.h for more details. */ + +/* #define DEBUG_LEVEL_TRACE */ +/* #define DEBUG_LEVEL_ERROR */ + + + +/* ------------ special debugging -------------------------------------- */ + + +/*************************************************************************/ +/* Define this if you want to generate a special debug version of the */ +/* rasterizer. This will progressively draw the glyphs while the */ +/* computations are done directly on the graphics screen... (with */ +/* inverted glyphs). */ +/* */ +/* Use it at your own risk! It is not maintained currently. */ +/* */ +/* IMPORTANT: This is reserved to developers willing to debug the */ +/* rasterizer, which seems working very well in its */ +/* current state... */ + +/* #define DEBUG_RASTER */ + + +/*************************************************************************/ +/* Define this to have a simple debugger version of RunIns(). */ +/* */ +/* Use it at your own risk! It is not maintained currently. */ + +/* #define DEBUG_INTERPRETER */ + + +/*************************************************************************/ +/* Define this to have some housekeeping of allocation and deallocation. */ +/* */ +/* Please note that probably not all OS-specific versions of ttmemory.c */ +/* provide this functionality. */ + +/* #define DEBUG_MEMORY */ + + +/*************************************************************************/ +/* Define this to have bounds checking for file buffer frames. */ +/* */ +/* Please note that probably not all OS-specific versions of ttfile.c */ +/* provide this functionality. */ + +/* #define DEBUG_FILE */ + + + +/* ------------ arithmetic and processor support ----------------------- */ + + +/*************************************************************************/ +/* Define TT_USE_LONG_LONG if you want to enable the use of the */ +/* 'long long' 64-bit type provided by gcc and other compilers. Note */ +/* that : */ +/* */ +/* 1. The type isn't ANSI, and thus will produce many warnings */ +/* during library compilation. */ +/* */ +/* 2. Though the generated object files are slightly smaller, the */ +/* resulting executables are bigger of about 4Kb! gcc must be */ +/* linking some extra code in there! */ +/* */ +/* 3. There is really no speed gain in doing so (but it may help */ +/* debug the ttcalc component). */ +/* */ +/* IMPORTANT NOTE: You don't need to define it on 64-bits machines! */ +/* */ +/* NOTE 2 : This flag used to be _GNUC_LONG64_ */ + +/* #define TT_USE_LONG_LONG */ + + +/*************************************************************************/ +/* define ALIGNMENT to your processor/environment preferred alignment */ +/* size. A value of 8 should work on all current processors, even */ +/* 64-bits ones. */ + +#define ALIGNMENT 8 + + + +/* --------------- miscellaneous ----------------------------------- */ + + +/*********************************************************************/ +/* The number of extensions available. Don't change this value */ +/* except if you add new extensions to the engine. */ + +#define TT_MAX_EXTENSIONS 8 + + + +/* --------------- automatic setup -- don't touch ------------------ */ + + +/*********************************************************************/ +/* If HAVE_TT_TEXT is defined we don't provide a default typedef for */ +/* defining TT_Text. */ + +#ifndef HAVE_TT_TEXT +#define HAVE_TT_TEXT + typedef char TT_Text; +#endif + + +/*********************************************************************/ +/* We define NULL in case it's not defined yet. The default */ +/* location is stdlib.h. */ + +#ifdef HAVE_STDLIB_H +#include +#endif + + +/*********************************************************************/ +/* Some systems can't use vfprintf for error messages on stderr; if */ +/* HAVE_PRINT_FUNCTION is defined, the Print macro must be supplied */ +/* externally (having the same parameters). */ +/* */ +/* This is only used by the "ttdebug" component, which should be */ +/* linked to the engine only in debug mode. */ + +#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) +#ifndef HAVE_PRINT_FUNCTION +#define Print( format, ap ) vfprintf( stderr, (format), (ap) ) +#endif +#endif + + +/********************************************************************/ +/* */ +/* I have added the ability to compile the library into a single */ +/* object file. This gets rids of all the external symbols defined */ +/* in each component interface, and de-pollutes the name-space. */ +/* */ +/* I use two macros, namely LOCAL_FUNC and LOCAL_DEF, which only */ +/* apply to functions that are internal to the engine, and */ +/* should never be seen or linked by a client application. */ +/* */ +/* LOCAL_DEF used in header (.h) files, to define a function */ +/* that will be seen by other components. This */ +/* translates to "extern" in normal mode, and to */ +/* "static" in single-object mode. */ +/* */ +/* LOCAL_FUNC used in implementation (.c) files, just before */ +/* the function body. This translates to nothing */ +/* in normal mode, and to "static" in single-object */ +/* mode. */ +/* */ +/* Getting rid of un-necessary symbols makes the "ttcommon" */ +/* renaming macros hack unnecessary. Moreover, the stripped */ +/* single object file (freetype.o) is 52 Kb, instead of the */ +/* previous 57 Kb (size of all combined .o files), and gives */ +/* a better idea of the engine's real code size. */ +/* */ +/* It is called a "MAKE_OPTION" because the macro must be */ +/* defined in the Makefile, rather than this one. It allows */ +/* any developer to quickly switch from one mode to the other */ +/* without messing with "ttconfig.h" each time. */ +/* */ +//#ifndef TT_MAKE_OPTION_SINGLE_OBJECT +#define LOCAL_FUNC /* void */ +#define LOCAL_DEF extern +// #else +// #define LOCAL_FUNC static +// #define LOCAL_DEF static +// #endif + + +/*************************************************************************/ +/* Define EXPORT_DEF and EXPORT_FUNC as needed to build e.g. a DLL. All */ +/* variables and functions visible from outside have these prefixes. */ + +#ifndef EXPORT_DEF +#define EXPORT_DEF extern +#endif + +#ifndef EXPORT_FUNC +#define EXPORT_FUNC /* void */ +#endif + + + +/* -------------- internal (developer) configuration toggles ------------ */ + + +#undef TT_STATIC_INTERPRETER +/* Do not undefine this configuration macro. It is now a default that */ +/* must be kept in all release builds. */ + + +#undef TT_STATIC_RASTER +/* Define this if you want to generate a static raster. This makes */ +/* a non re-entrant version of the scan-line converter, which is */ +/* about 10% faster and 50% bigger than an indirect one! */ + + +#endif /* TTCONFIG_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttdebug.c b/Driver/Font/TrueType/FreeType/ttdebug.c new file mode 100644 index 000000000..6b65154a7 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttdebug.c @@ -0,0 +1,404 @@ +/* Simple debugging component. Temporary */ + +#include "ttdebug.h" +#include "tttables.h" +#include "ttobjs.h" + + +#ifdef DEBUG_LEVEL_TRACE + char tt_trace_levels[trace_max]; +#endif + +#if defined( DEBUG_LEVEL_ERROR ) || defined( DEBUG_LEVEL_TRACE ) + +#include +#include +#include + + + static String tempStr[128]; + + static const String* OpStr[256] = + { + "SVTCA y", /* Set vectors to coordinate axis y */ + "SVTCA x", /* Set vectors to coordinate axis x */ + "SPvTCA y", /* Set Proj. vec. to coord. axis y */ + "SPvTCA x", /* Set Proj. vec. to coord. axis x */ + "SFvTCA y", /* Set Free. vec. to coord. axis y */ + "SFvTCA x", /* Set Free. vec. to coord. axis x */ + "SPvTL //", /* Set Proj. vec. parallel to segment */ + "SPvTL +", /* Set Proj. vec. normal to segment */ + "SFvTL //", /* Set Free. vec. parallel to segment */ + "SFvTL +", /* Set Free. vec. normal to segment */ + "SPvFS", /* Set Proj. vec. from stack */ + "SFvFS", /* Set Free. vec. from stack */ + "GPV", /* Get projection vector */ + "GFV", /* Get freedom vector */ + "SFvTPv", /* Set free. vec. to proj. vec. */ + "ISECT", /* compute intersection */ + + "SRP0", /* Set reference point 0 */ + "SRP1", /* Set reference point 1 */ + "SRP2", /* Set reference point 2 */ + "SZP0", /* Set Zone Pointer 0 */ + "SZP1", /* Set Zone Pointer 1 */ + "SZP2", /* Set Zone Pointer 2 */ + "SZPS", /* Set all zone pointers */ + "SLOOP", /* Set loop counter */ + "RTG", /* Round to Grid */ + "RTHG", /* Round to Half-Grid */ + "SMD", /* Set Minimum Distance */ + "ELSE", /* Else */ + "JMPR", /* Jump Relative */ + "SCvTCi", /* Set CVT */ + "SSwCi", /* */ + "SSW", /* */ + + "DUP", + "POP", + "CLEAR", + "SWAP", + "DEPTH", + "CINDEX", + "MINDEX", + "AlignPTS", + "INS_$28", + "UTP", + "LOOPCALL", + "CALL", + "FDEF", + "ENDF", + "MDAP[-]", + "MDAP[r]", + + "IUP[y]", + "IUP[x]", + "SHP[0]", + "SHP[1]", + "SHC[0]", + "SHC[1]", + "SHZ[0]", + "SHZ[1]", + "SHPIX", + "IP", + "MSIRP[0]", + "MSIRP[1]", + "AlignRP", + "RTDG", + "MIAP[-]", + "MIAP[r]", + + "NPushB", + "NPushW", + "WS", + "RS", + "WCvtP", + "RCvt", + "GC[0]", + "GC[1]", + "SCFS", + "MD[0]", + "MD[1]", + "MPPEM", + "MPS", + "FlipON", + "FlipOFF", + "DEBUG", + + "LT", + "LTEQ", + "GT", + "GTEQ", + "EQ", + "NEQ", + "ODD", + "EVEN", + "IF", + "EIF", + "AND", + "OR", + "NOT", + "DeltaP1", + "SDB", + "SDS", + + "ADD", + "SUB", + "DIV", + "MUL", + "ABS", + "NEG", + "FLOOR", + "CEILING", + "ROUND[G]", + "ROUND[B]", + "ROUND[W]", + "ROUND[?]", + "NROUND[G]", + "NROUND[B]", + "NROUND[W]", + "NROUND[?]", + + "WCvtF", + "DeltaP2", + "DeltaP3", + "DeltaC1", + "DeltaC2", + "DeltaC3", + "SROUND", + "S45Round", + "JROT", + "JROF", + "ROFF", + "INS_$7B", + "RUTG", + "RDTG", + "SANGW", + "AA", + + "FlipPT", + "FlipRgON", + "FlipRgOFF", + "INS_$83", + "INS_$84", + "ScanCTRL", + "SDPVTL[0]", + "SDPVTL[1]", + "GetINFO", + "IDEF", + "ROLL", + "MAX", + "MIN", + "ScanTYPE", + "IntCTRL", + "INS_$8F", + + "INS_$90", + "INS_$91", + "INS_$92", + "INS_$93", + "INS_$94", + "INS_$95", + "INS_$96", + "INS_$97", + "INS_$98", + "INS_$99", + "INS_$9A", + "INS_$9B", + "INS_$9C", + "INS_$9D", + "INS_$9E", + "INS_$9F", + + "INS_$A0", + "INS_$A1", + "INS_$A2", + "INS_$A3", + "INS_$A4", + "INS_$A5", + "INS_$A6", + "INS_$A7", + "INS_$A8", + "INS_$A9", + "INS_$AA", + "INS_$AB", + "INS_$AC", + "INS_$AD", + "INS_$AE", + "INS_$AF", + + "PushB[0]", + "PushB[1]", + "PushB[2]", + "PushB[3]", + "PushB[4]", + "PushB[5]", + "PushB[6]", + "PushB[7]", + "PushW[0]", + "PushW[1]", + "PushW[2]", + "PushW[3]", + "PushW[4]", + "PushW[5]", + "PushW[6]", + "PushW[7]", + + "MDRP[G]", + "MDRP[B]", + "MDRP[W]", + "MDRP[?]", + "MDRP[rG]", + "MDRP[rB]", + "MDRP[rW]", + "MDRP[r?]", + "MDRP[mG]", + "MDRP[mB]", + "MDRP[mW]", + "MDRP[m?]", + "MDRP[mrG]", + "MDRP[mrB]", + "MDRP[mrW]", + "MDRP[mr?]", + "MDRP[pG]", + "MDRP[pB]", + + "MDRP[pW]", + "MDRP[p?]", + "MDRP[prG]", + "MDRP[prB]", + "MDRP[prW]", + "MDRP[pr?]", + "MDRP[pmG]", + "MDRP[pmB]", + "MDRP[pmW]", + "MDRP[pm?]", + "MDRP[pmrG]", + "MDRP[pmrB]", + "MDRP[pmrW]", + "MDRP[pmr?]", + + "MIRP[G]", + "MIRP[B]", + "MIRP[W]", + "MIRP[?]", + "MIRP[rG]", + "MIRP[rB]", + "MIRP[rW]", + "MIRP[r?]", + "MIRP[mG]", + "MIRP[mB]", + "MIRP[mW]", + "MIRP[m?]", + "MIRP[mrG]", + "MIRP[mrB]", + "MIRP[mrW]", + "MIRP[mr?]", + "MIRP[pG]", + "MIRP[pB]", + + "MIRP[pW]", + "MIRP[p?]", + "MIRP[prG]", + "MIRP[prB]", + "MIRP[prW]", + "MIRP[pr?]", + "MIRP[pmG]", + "MIRP[pmB]", + "MIRP[pmW]", + "MIRP[pm?]", + "MIRP[pmrG]", + "MIRP[pmrB]", + "MIRP[pmrW]", + "MIRP[pmr?]" + }; + + + const String* Cur_U_Line( void* _exec ) + { + String s[32]; + + Int op, i, n; + + PExecution_Context exec; + + + exec = _exec; + + op = exec->code[exec->IP]; + + sprintf( tempStr, "%s", OpStr[op] ); + + if ( op == 0x40 ) + { + n = exec->code[exec->IP + 1]; + sprintf( s, "(%d)", n ); + strncat( tempStr, s, 8 ); + + if ( n > 20 ) n = 20; /* limit output */ + + for ( i = 0; i < n; i++ ) + { + sprintf( s, " $%02hx", exec->code[exec->IP + i + 2] ); + strncat( tempStr, s, 8 ); + } + } + else if ( op == 0x41 ) + { + n = exec->code[exec->IP + 1]; + sprintf( s, "(%d)", n ); + strncat( tempStr, s, 8 ); + + if ( n > 20 ) n = 20; /* limit output */ + + for ( i = 0; i < n; i++ ) + { + sprintf( s, " $%02hx%02hx", exec->code[exec->IP + i*2 + 2], + exec->code[exec->IP + i*2 + 3] ); + strncat( tempStr, s, 8 ); + } + } + else if ( (op & 0xF8) == 0xB0 ) + { + n = op - 0xB0; + + for ( i = 0; i <= n; i++ ) + { + sprintf( s, " $%02hx", exec->code[exec->IP + i + 1] ); + strncat( tempStr, s, 8 ); + } + } + else if ( (op & 0xF8) == 0xB8 ) + { + n = op-0xB8; + + for ( i = 0; i <= n; i++ ) + { + sprintf( s, " $%02hx%02hx", exec->code[exec->IP + i*2 + 1], + exec->code[exec->IP + i*2 + 2] ); + strncat( tempStr, s, 8 ); + } + } + + return (String*)tempStr; + } + + + /* the Print() function is defined in ttconfig.h; */ + /* it defaults to vprintf on systems which have it */ + + void TT_Message( const String* fmt, ... ) + { + va_list ap; + + va_start( ap, fmt ); + Print( fmt, ap ); + va_end( ap ); + } + + + void TT_Panic( const String* fmt, ... ) + { + va_list ap; + + va_start( ap, fmt ); + Print( fmt, ap ); + va_end( ap ); + + exit( EXIT_FAILURE ); + } + +#endif /* defined( DEBUG_LEVEL_ERROR ) || defined( DEBUG_LEVEL_TRACE ) */ + +#if defined( DEBUG_LEVEL_TRACE ) + + /* use this function to set the values of tt_trace_levels */ + + void set_tt_trace_levels( int index, char value ) + { + tt_trace_levels[index] = value; + } + +#endif + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttdebug.h b/Driver/Font/TrueType/FreeType/ttdebug.h new file mode 100644 index 000000000..ac132512b --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttdebug.h @@ -0,0 +1,170 @@ +/******************************************************************* + * + * ttdebug.h + * + * Debugging and Logging component (specification) + * + * 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. + * + * + * This component contains various macros and functions used to + * ease the debugging of the FreeType engine. Its main purpose + * is in assertion checking, tracing, and error detection. + * + * There are now three debugging modes: + * + * - trace mode: + * + * Error and trace messages are sent to the log file + * (which can be the standard error output). Define + * DEBUG_LEVEL_TRACE to enable this mode. + * + * - error mode: + * + * Only error messages are generated. Define + * DEBUG_LEVEL_ERROR to enable this mode. + * + * - release mode: + * + * Error messages are neither sent nor generated. The code is + * free from any debugging parts. + * + ******************************************************************/ + +#ifndef TTDEBUG_H +#define TTDEBUG_H + +#include "ttconfig.h" +#include "tttypes.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + +#if defined( DEBUG_LEVEL_TRACE ) + + typedef enum Trace_Component_ + { + trace_any = 0, + trace_api, + trace_interp, + trace_load, + trace_gload, + trace_memory, + trace_file, + trace_mutex, + trace_cache, + trace_calc, + trace_cmap, + trace_extend, + trace_objs, + trace_raster, + + trace_bitmap, + trace_max + + } Trace_Component; + + + /* Here we define an array to hold the trace levels per component. */ + /* Since it is globally defined, all array members are set to 0. */ + /* You should set the values in this array either in your program */ + /* or with your debugger. */ + /* */ + /* Currently, up to eight levels (PTRACE0-PTRACE7, see below) are */ + /* used in some parts of the engine. */ + /* */ + /* For example, to have all tracing messages in the raster */ + /* component, say */ + /* */ + /* #define DEBUG_LEVEL_TRACE */ + /* #include "ttdebug.h" */ + /* */ + /* ... */ + /* set_tt_trace_levels( trace_raster, 7 ) */ + /* */ + /* in your code before initializing the FreeType engine. */ + /* */ + /* Maybe it is better to define DEBUG_LEVEL_TRACE in ttconfig.h... */ + + extern char tt_trace_levels[trace_max]; + + /* IMPORTANT: */ + /* */ + /* Each component must define the macro TT_COMPONENT */ + /* to a valid Trace_Component value before using any */ + /* PTRACEx macro. */ + /* */ + +#define PTRACE( level, varformat ) \ + if ( tt_trace_levels[TT_COMPONENT] >= level ) TT_Message##varformat + +#elif defined( DEBUG_LEVEL_ERROR ) + +#define PTRACE( level, varformat ) /* nothing */ + +#else /* RELEASE MODE */ + +#define TT_Assert( condition, action ) /* nothing */ + +#define PTRACE( level, varformat ) /* nothing */ +#define PERROR( varformat ) /* nothing */ +#define PANIC( varformat ) /* nothing */ + +#endif + + +/************************************************************************/ +/* */ +/* Define macros and fuctions that are common to the debug and trace */ +/* modes. */ +/* */ + +#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) + + +#define TT_Assert( condition, action ) if ( !(condition) ) ( action ) + + void TT_Message( const String* fmt, ... ); + void TT_Panic ( const String* fmt, ... ); + /* print a message and exit */ + + const String* Cur_U_Line( void* exec ); + +#define PERROR( varformat ) TT_Message##varformat +#define PANIC( varformat ) TT_Panic##varformat + +#endif + +#if defined( DEBUG_LEVEL_TRACE ) + + void set_tt_trace_levels( int index, char value ); + +#endif + + +#define PTRACE0( varformat ) PTRACE( 0, varformat ) +#define PTRACE1( varformat ) PTRACE( 1, varformat ) +#define PTRACE2( varformat ) PTRACE( 2, varformat ) +#define PTRACE3( varformat ) PTRACE( 3, varformat ) +#define PTRACE4( varformat ) PTRACE( 4, varformat ) +#define PTRACE5( varformat ) PTRACE( 5, varformat ) +#define PTRACE6( varformat ) PTRACE( 6, varformat ) +#define PTRACE7( varformat ) PTRACE( 7, varformat ) + + +#ifdef __cplusplus + } +#endif + + +#endif /* TTDEBUG_H */ diff --git a/Driver/Font/TrueType/FreeType/ttengine.h b/Driver/Font/TrueType/FreeType/ttengine.h new file mode 100644 index 000000000..c4945839f --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttengine.h @@ -0,0 +1,115 @@ +/******************************************************************* + * + * ttengine.h 1.1 + * + * Engine instance structure definition. + * + * 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. + * + * New in 1.1 : + * + * - added the 'raster_lock' mutex field to synchronize + * scan-line conversion in thread-safe and re-entrant builds. + * + ******************************************************************/ + +#ifndef TTENGINE_H +#define TTENGINE_H + +#include "tttypes.h" +#include "ttconfig.h" +#include "freetype.h" +#include "ttmutex.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /********************************************************************/ + /* */ + /* The freetype engine instance structure. */ + /* */ + /* This structure holds all the data that is necessary to run */ + /* one instance of the freetype engine. It is needed to get a */ + /* completely re-entrant version of the library. */ + /* */ + /* The goal is to move _all_ component-specific variables, either */ + /* static or global in the structure; the component initializers */ + /* and finalizers will all be called with the address of a valid */ + /* TEngine_Instance. */ + /* */ + /********************************************************************/ + + struct TEngine_Instance_ + { + TMutex lock; /* engine lock */ + + void* list_free_elements; + + void* objs_face_class; /* the face cache class */ + void* objs_instance_class; /* the instance cache class */ + void* objs_execution_class; /* the context cache class */ + void* objs_glyph_class; /* the glyph cache class */ + + void* objs_face_cache; /* these caches are used to track */ + void* objs_exec_cache; /* the current face and execution */ + /* context objects */ + + void* file_component; /* ttfile implementation dependent */ + + TMutex raster_lock; /* mutex for this engine's render pool */ + void* raster_component; /* ttraster implementation depedent */ + Byte raster_palette[5]; /* gray-levels palette for anti-aliasing */ + + void* extension_component; /* extensions dependent */ + +#if 0 + TT_Glyph_Loader_Callback glCallback; /* glyph loader callback, if any */ +#endif + }; + + /* NOTE : The raster's lock is only acquired by the Render_Glyph and */ + /* Render_Gray_Glyph functions, which always release it on exit */ + /* They do not lock the engine mutex. This means you shouldn't */ + /* be concerned about deadlocks between the two mutexes, as these */ + /* should never appear.. */ + + typedef struct TEngine_Instance_ TEngine_Instance; + typedef TEngine_Instance* PEngine_Instance; + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* for re-entrant builds */ + +#define ENGINE_ARG TEngine_Instance* _engine +#define ENGINE_ARGS TEngine_Instance* _engine, + +#define ENGINE_VAR _engine +#define ENGINE_VARS _engine, + +#define ENGINE _engine + +#else /* for thread-safe builds */ + +#define ENGINE_ARG /* void */ +#define ENGINE_ARGS + +#define ENGINE_VAR +#define ENGINE_VARS + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTENGINE_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttextend.c b/Driver/Font/TrueType/FreeType/ttextend.c new file mode 100644 index 000000000..d0a1d384d --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttextend.c @@ -0,0 +1,212 @@ +/******************************************************************* + * + * ttextend.h 2.0 + * + * Extensions Interface + * + * 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. + * + * This is an updated version of the extension component, now + * located in the main library's source directory. It allows + * the dynamic registration/use of various face object extensions + * through a simple API. + * + ******************************************************************/ + +#include "ttextend.h" +#include "ttengine.h" +#include "ttmemory.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_extend + + + struct TExtension_Registry_ + { + Int num_extensions; + Long cur_offset; + TExtension_Class classes[TT_MAX_EXTENSIONS]; + }; + + typedef struct TExtension_Registry_ TExtension_Registry; + typedef TExtension_Registry* PExtension_Registry; + + + + /* Initialize the extension component */ + + LOCAL_FUNC + TT_Error TTExtend_Init( PEngine_Instance engine ) + { + TT_Error error; + PExtension_Registry exts; + + + if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) + return error; + + exts->num_extensions = 0; + exts->cur_offset = 0; + engine->extension_component = (void*)exts; + + return TT_Err_Ok; + } + + + /* Finalize the extension component */ + + LOCAL_FUNC + TT_Error TTExtend_Done( PEngine_Instance engine ) + { + FREE( engine->extension_component ); + return TT_Err_Ok; + } + + + /* Register a new extension */ + + EXPORT_FUNC + TT_Error TT_Register_Extension( PEngine_Instance engine, + Long id, + Long size, + PExt_Constructor create, + PExt_Destructor destroy ) + { + PExtension_Registry exts; + PExtension_Class clazz; + Int p; + + + exts = (PExtension_Registry)engine->extension_component; + if ( !exts ) + return TT_Err_Ok; + + p = exts->num_extensions; + + if ( p >= TT_MAX_EXTENSIONS ) + return TT_Err_Too_Many_Extensions; + + clazz = exts->classes + p; + clazz->id = id; + clazz->size = size; + clazz->build = create; + clazz->destroy = destroy; + + clazz->offset = exts->cur_offset; + + exts->num_extensions++; + exts->cur_offset += ( size + ALIGNMENT-1 ) & -ALIGNMENT; + + return TT_Err_Ok; + } + + + /* Query an extension block by extension_ID */ + + EXPORT_FUNC + TT_Error TT_Extension_Get( PFace face, + Long extension_id, + void** extension_block ) + { + PExtension_Registry registry; + PExtension_Class clazz; + Int n; + + + if ( !face->extension ) + return TT_Err_Extensions_Unsupported; + + registry = (PExtension_Registry)face->engine->extension_component; + + for ( n = 0; n < face->n_extensions; n++ ) + { + clazz = registry->classes + n; + if ( clazz->id == extension_id ) + { + *extension_block = (PByte)face->extension + clazz->offset; + return TT_Err_Ok; + } + } + + return TT_Err_Invalid_Extension_Id; + } + + + /* Destroy all extensions within a face object. Called by the */ + /* face object destructor. */ + + LOCAL_FUNC + TT_Error Extension_Destroy( PFace face ) + { + PEngine_Instance engine = face->engine; + PExtension_Registry registry; + PExtension_Class clazz; + Int n; + PByte ext; + + + registry = (PExtension_Registry)engine->extension_component; + + for ( n = 0; n < face->n_extensions; n++ ) + { + clazz = registry->classes + n; + ext = (PByte)face->extension + clazz->offset; + + /* the destructor is optional */ + if ( clazz->destroy ) + clazz->destroy( (void*)ext, face ); + } + + /* destroy the face's extension block too */ + FREE( face->extension ); + face->n_extensions = 0; + + return TT_Err_Ok; + } + + + /* Create an extension within a face object. Called by the */ + /* face object constructor. */ + + LOCAL_FUNC + TT_Error Extension_Create( PFace face ) + { + PEngine_Instance engine = face->engine; + PExtension_Registry registry; + PExtension_Class clazz; + TT_Error error; + Int n; + PByte ext; + + + registry = (PExtension_Registry)engine->extension_component; + + face->n_extensions = registry->num_extensions; + if ( ALLOC( face->extension, registry->cur_offset ) ) + return error; + + for ( n = 0; n < face->n_extensions; n++ ) + { + clazz = registry->classes + n; + ext = (PByte)face->extension + clazz->offset; + error = clazz->build( (void*)ext, face ); + if ( error ) + goto Fail; + } + return TT_Err_Ok; + + Fail: + Extension_Destroy( face ); + return error; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttextend.h b/Driver/Font/TrueType/FreeType/ttextend.h new file mode 100644 index 000000000..c922efed3 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttextend.h @@ -0,0 +1,168 @@ +/******************************************************************* + * + * ttextend.h 2.0 + * + * Extensions Interface. + * + * 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. + * + * This is an updated version of the extension component, now + * located in the main library's source directory. It allows + * the dynamic registration/use of various face object extensions + * through a simple API. + * + ******************************************************************/ + +#ifndef TTEXTEND_H +#define TTEXTEND_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* The extensions don't need to be integrated at compile time into */ + /* the engine, only at link time. */ + + + /* When a new face object is created, the face constructor calls */ + /* the extension constructor with the following arguments: */ + /* */ + /* ext : typeless pointer to the face's extension block. */ + /* Its size is the one given at registration time */ + /* in the extension class's 'size' field. */ + /* */ + /* face : the parent face object. Note that the extension */ + /* constructor is called when the face object is */ + /* built. */ + + typedef TT_Error TExt_Constructor( void* ext, PFace face ); + + + /* When a face object is destroyed, the face destructor calls */ + /* the extension destructor with the following arguments. */ + /* */ + /* ext : typeless pointer to the face's extension block. */ + /* Its size is the one given at registration time */ + /* in the extension class's 'size' field. */ + /* */ + /* face : the parent face object. Note that the extension */ + /* destructor is called before the actual face object */ + /* is destroyed. */ + + typedef TT_Error TExt_Destructor ( void* ext, PFace face ); + + typedef TExt_Constructor* PExt_Constructor; + typedef TExt_Destructor* PExt_Destructor; + + + struct TExtension_Class_ + { + Long id; /* extension id */ + Long size; /* size in bytes of extension record */ + PExt_Constructor build; /* the extension's class constructor */ + PExt_Destructor destroy; /* the extension's class destructor */ + + Long offset; /* offset of ext. record in face obj */ + /* (set by the engine) */ + }; + + typedef struct TExtension_Class_ TExtension_Class; + typedef TExtension_Class* PExtension_Class; + + +#define Build_Extension_ID( a, b, c, d ) \ + ( ((ULong)(a) << 24) | \ + ((ULong)(b) << 16) | \ + ((ULong)(c) << 8 ) | \ + (ULong)(d) ) + + /* A note regarding extensions and the single-object compilation */ + /* mode : */ + /* */ + /* When the engine is compiled as a single object file, extensions */ + /* must remain linkable *after* compile time. In order to do this, */ + /* we need to export the functions that an extension may need. */ + /* Fortunately, we can limit ourselves to : */ + /* */ + /* o TT_Register_Extension (previously called Extension_Register) */ + /* which is to be called by each extension on within */ + /* it TT_Init_XXXX_Extension initializer. */ + /* */ + /* o File and frame access functions. Fortunately, these already */ + /* have their names prefixed by "TT_", so no change was needed */ + /* except replacing the LOCAL_DEF keyword with EXPORT_DEF */ + /* */ + /* o Memory access functions, i.e. TT_Alloc and TT_Free. Again, */ + /* the change is minimal */ + /* */ + /* o the table-lookup function : TT_LookUp_Table, formerly known */ + /* as Load_TrueType_Table in ttload.c. */ + /* */ + /* */ + /* Other than that, an extension should be able to #include all */ + /* relevant header files to get access to internal types, but */ + /* should not call engine internal functions.. */ + /* */ + /* If there is a need for a specific internal function call, let */ + /* me known to see if we need to export it by default.. */ + /* - DavidT */ + /* */ + + /* Register a new extension. Called by extension */ + /* service initializers. */ + EXPORT_DEF + TT_Error TT_Register_Extension( PEngine_Instance engine, + Long id, + Long size, + PExt_Constructor create, + PExt_Destructor destroy ); + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + /* Initialize the extension component */ + LOCAL_DEF + TT_Error TTExtend_Init( PEngine_Instance engine ); + + /* Finalize the extension component */ + LOCAL_DEF + TT_Error TTExtend_Done( PEngine_Instance engine ); + + /* Create an extension within a face object. Called by the */ + /* face object constructor. */ + LOCAL_DEF + TT_Error Extension_Create( PFace face ); + + /* Destroy all extensions within a face object. Called by the */ + /* face object destructor. */ + LOCAL_DEF + TT_Error Extension_Destroy( PFace face ); +#endif + + /* Query an extension block by extension_ID. Called by extension */ + /* service routines. */ + EXPORT_DEF + TT_Error TT_Extension_Get( PFace face, + Long extension_id, + void** extension_block ); + +#ifdef __cplusplus + } +#endif + + +#endif /* TTEXTEND_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttfile.c b/Driver/Font/TrueType/FreeType/ttfile.c new file mode 100644 index 000000000..f748aea15 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttfile.c @@ -0,0 +1,1227 @@ +/******************************************************************* + * + * ttfile.c (extended version) 2.1 + * + * File I/O Component (body). + * + * 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. + * + * NOTES: + * + * This implementation relies on the ANSI libc. You may wish to + * modify it to get rid of libc and go straight to the your + * platform's stream routines. + * + * The same source code can be used for thread-safe and re-entrant + * builds of the library. + * + * Changes between 2.0 and 2.1 : + * + * - it is now possible to close a stream's file handle explicitely + * through the new API "TT_Flush_Stream". This will simply close + * a stream's file handle (useful to save system resources when + * dealing with lots of opened fonts). Of course, the function + * "TT_Use_Stream" will automatically re-open a stream's handle if + * necessary. + * + * - added "TT_Stream_Size" to replace "TT_File_Size" which wasn't + * used anyway. This one returns the size of any stream, even + * flushed one (when the previous TT_File_Size could only return + * the size of the current working stream). This is used by the + * new "Load_TrueType_Any" function in the tables loader. + * + ******************************************************************/ + +#include "ttconfig.h" + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttmemory.h" +#include "ttfile.h" /* our prototypes */ + +#ifdef __GEOS__ +#include +#include +#endif /* ifdef __GEOS__ */ + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_file + + +/* For now, we don't define additional error messages in the core library */ +/* to report open-on demand errors. Define these error as standard ones */ + +#define TT_Err_Could_Not_ReOpen_File TT_Err_Could_Not_Open_File +#define TT_Err_Could_Not_ReSeek_File TT_Err_Could_Not_Open_File + + /* This definition is mandatory for each file component! */ + EXPORT_FUNC + const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; + +/* It has proven useful to do some bounds checks during development phase. */ +/* They should probably be undefined for speed reasons in a later release. */ + +#if DEBUG_FILE +#define CHECK_FRAME( frame, n ) \ + do { \ + if ( frame.cursor + n > frame.address + frame.size ) \ + Panic( "Frame boundary error!\n" ); \ + } while ( 0 ) +#else +#define CHECK_FRAME( frame, n ) /* nothing */ +#endif + + /* Because a stream can be flushed, i.e. its file handle can be */ + /* closed to save system resources, we must keep the stream's file */ + /* pathname to be able to re-open it on demand when it is flushed */ + + struct TStream_Rec_; + typedef struct TStream_Rec_ TStream_Rec; + typedef TStream_Rec* PStream_Rec; + + struct TStream_Rec_ + { + Bool opened; /* is the stream handle opened ? */ + TT_Text* name; /* the file's pathname */ + Long position; /* current position within the file */ + +#ifdef __GEOS__ + FileHandle file; /* FreeGEOS file handle */ +#else + FILE* file; /* file handle */ +#endif /* ifdef __GEOS__ */ + Long base; /* stream base in file */ + Long size; /* stream size in file */ + }; + + /* We support embedded TrueType files by allowing them to be */ + /* inside any file, at any location, hence the 'base' argument. */ + /* Note however that the current implementation does not allow you */ + /* to specify a 'base' index when opening a file. */ + /* (will come later) */ + /* I still don't know if this will turn out useful ?? - DavidT */ + +#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) + + static TT_Error Stream_Activate ( PStream_Rec stream ); + static TT_Error Stream_Deactivate( PStream_Rec stream ); + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /**** ****/ + /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ + /**** ****/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + + /* in non-rentrant builds, we allocate a single block where we'll */ + /* place all the frames smaller than FRAME_CACHE_SIZE, rather than */ + /* allocating a new block on each access. Bigger frames will be */ + /* malloced normally in the heap. */ + /* */ + /* See TT_Access_Frame() and TT_Forget_Frame() for details. */ + +#define FRAME_CACHE_SIZE 2048 + + /* The TFile_Component structure holds all the data that was */ + /* previously declared static or global in this component. */ + /* */ + /* It is accessible through the 'engine.file_component' */ + /* variable in re-entrant builds, or directly through the */ + /* static 'files' variable in other builds. */ + + struct TFile_Component_ + { + TMutex lock; /* used by the thread-safe build only */ + Byte* frame_cache; /* frame cache */ + PStream_Rec stream; /* current stream */ + TFileFrame frame; /* current frame */ + }; + + typedef struct TFile_Component_ TFile_Component; + + static TFile_Component files; + +#define CUR_Stream files.stream +#define CUR_Frame files.frame + +#define STREAM_VARS /* void */ +#define STREAM_VAR /* void */ + +/* The macro CUR_Stream denotes the current input stream. */ +/* Note that for the re-entrant version, the 'stream' name has been */ +/* chosen according to the macro STREAM_ARGS. */ + +/* The macro CUR_Frame denotes the current file frame. */ +/* Note that for the re-entrant version, the 'frame' name has been */ +/* chosen according to the macro FRAME_ARGS. */ + +/* The macro STREAM_VAR is used when calling public functions */ +/* that need an 'optional' stream argument. */ + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + TT_Error error; + + + MUTEX_Create( files.lock ); + files.stream = NULL; + ZERO_Frame( files.frame ); + + if ( ALLOC( files.frame_cache, FRAME_CACHE_SIZE ) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + FREE( files.frame_cache ); + MUTEX_Destroy( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Copies or duplicates a given stream. + * + * Input : org_stream original stream + * stream target stream (copy or duplicate) + * + * Output : Error code. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ) + { + MUTEX_Lock( files.lock ); /* lock file mutex */ + + *stream = org_stream; /* copy the stream */ + files.stream = STREAM2REC(org_stream); /* set current stream */ + + Stream_Activate( files.stream ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream target stream + * + * Output : Error code. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + HANDLE_Set( *stream, NULL ); + MUTEX_Release( files.lock ); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( size <= FRAME_CACHE_SIZE ) + { + /* use the cache */ + CUR_Frame.address = files.frame_cache; + CUR_Frame.size = FRAME_CACHE_SIZE; + } + else + { + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + } + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if (error) + { + if ( size > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + CUR_Frame.address = NULL; + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * `size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function truncates `size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes, requested; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( size <= FRAME_CACHE_SIZE ) + { + /* use the cache */ + CUR_Frame.address = files.frame_cache; + CUR_Frame.size = FRAME_CACHE_SIZE; + } + else + { + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + } + + requested = size; + readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); + if ( size > readBytes ) + size = readBytes; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if (error) + { + if ( requested > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + CUR_Frame.address = NULL; + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + if ( CUR_Frame.size > FRAME_CACHE_SIZE ) + FREE( CUR_Frame.address ); + + ZERO_Frame( CUR_Frame ); + + return TT_Err_Ok; + } + + +#else /* TT_CONFIG_OPTION_THREAD_SAFE */ + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /******** ********/ + /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ + /******** ********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/* a simple macro to access the file component's data */ +#define files ( *((TFile_Component*)engine.file_component) ) + +#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ +#define CUR_Frame (*frame) + +#define STREAM_VARS stream, +#define STREAM_VAR stream + + +/******************************************************************* + * + * Function : TTFile_Init + * + * Description : Initializes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Init( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTFile_Done + * + * Description : Finalizes the File component. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTFile_Done( PEngine_Instance engine ) + { + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Use_Stream + * + * Description : Duplicates a stream for a new usage. + * + * Input : input_stream source stream to duplicate + * copy address of target duplicate stream + * + * Output : error code. + * The target stream is set to NULL in case of failure. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Use_Stream( TT_Stream input_stream, + TT_Stream* copy ) + { + PStream_Rec rec = STREAM2REC( input_stream ); + + return TT_Open_Stream( rec->name, copy ); + } + + +/******************************************************************* + * + * Function : TT_Done_Stream + * + * Description : Releases a given stream. + * + * Input : stream target stream + * + * Output : + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Done_Stream( TT_Stream* stream ) + { + return TT_Close_Stream( stream ); + } + + +/******************************************************************* + * + * Function : TT_Access_Frame + * + * Description : Notifies the component that we're going to read + * 'size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function fails if the byte range is not within the + * the file, or if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big in both cases). + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + FREE( CUR_Frame.address ); + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Check_And_Access_Frame + * + * Description : Notifies the component that we're going to read + * `size' bytes from the current file position. + * This function should load/cache/map these bytes + * so that they will be addressed by the GET_xxx + * functions easily. + * + * Input : size number of bytes to access. + * + * Output : SUCCESS on success. FAILURE on error. + * + * Notes: The function truncates `size' if the byte range is not + * within the file. + * + * It will fail if there is not enough memory to cache + * the bytes properly (which usually means that `size' is + * too big). + * + * It will fail if you make two consecutive calls + * to TT_Access_Frame(), without a TT_Forget_Frame() between + * them. + * + * The only difference with TT_Access_Frame() is that we + * check that the frame is within the current file. We + * otherwise truncate it. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) + { + TT_Error error; + Long readBytes; + + + if ( CUR_Frame.address != NULL ) + return TT_Err_Nested_Frame_Access; + + if ( ALLOC( CUR_Frame.address, size ) ) + return error; + CUR_Frame.size = size; + + readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); + if ( size > readBytes ) + size = readBytes; + + error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); + if ( error ) + { + FREE( CUR_Frame.address ); + CUR_Frame.size = 0; + } + + CUR_Frame.cursor = CUR_Frame.address; + return error; + } + + +/******************************************************************* + * + * Function : TT_Forget_Frame + * + * Description : Releases a cached frame after reading. + * + * Input : None + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Forget_Frame( FRAME_ARG ) + { + if ( CUR_Frame.address == NULL ) + return TT_Err_Nested_Frame_Access; + + FREE( CUR_Frame.address ); + ZERO_Frame( CUR_Frame ); + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + /*********** ***********/ + /*********** C O M M O N I M P L E M E N T A T I O N ***********/ + /*********** ***********/ + /*******************************************************************/ + /*******************************************************************/ + /*******************************************************************/ + +/******************************************************************* + * + * Function : Stream_Activate + * + * Description : activates a stream, this will either: + * - open a new file handle if the stream is closed + * - move the stream to the head of the linked list + * + * Input : stream the stream to activate + * + * Output : error condition. + * + * Note : This function is also called with fresh new streams + * created by TT_Open_Stream(). They have their 'size' + * field set to -1. + * + ******************************************************************/ + + TT_Error Stream_Activate( PStream_Rec stream ) + { + if ( !stream->opened ) + { +#ifdef __GEOS__ + if ( (stream->file = FileOpen( (TT_Text*)stream->name, FILE_ACCESS_R | FILE_DENY_W)) == NullHandle ) +#else + if ( (stream->file = fopen( (TT_Text*)stream->name, "rb" )) == 0 ) +#endif /* ifdef __GEOS__ */ + return TT_Err_Could_Not_ReOpen_File; + + stream->opened = TRUE; + + /* A newly created stream has a size field of -1 */ + if ( stream->size < 0 ) + { +#ifdef __GEOS__ + stream->size = FileSize( stream->file ); +#else + fseek( stream->file, 0, SEEK_END ); + stream->size = ftell( stream->file ); + fseek( stream->file, 0, SEEK_SET ); +#endif /* ifdef __GEOS__ */ + } + + /* Reset cursor in file */ + if ( stream->position ) + { +#ifdef __GEOS__ + FilePos( stream->file, stream->position, FILE_POS_START); + if ( ThreadGetError() != NO_ERROR_RETURNED ) + { + /* error during seek */ + FileClose( stream->file, FALSE ); +#else + if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 ) + { + /* error during seek */ + fclose( stream->file ); +#endif /* ifdef __GEOS__ */ + stream->opened = FALSE; + return TT_Err_Could_Not_ReSeek_File; + } + } + } + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Stream_DeActivate + * + * Description : deactivates a stream, this will : + * - close its file handle if it was opened + * - remove it from the opened list if necessary + * + * Input : stream the stream to deactivate + * + * Output : Error condition + * + * Note : the function is called whenever a stream is deleted + * (_not_ when a stream handle's is closed due to an + * activation). However, the stream record isn't + * destroyed by it.. + * + ******************************************************************/ + + static TT_Error Stream_Deactivate( PStream_Rec stream ) + { + if ( stream->opened ) + { + /* Save its current position within the file */ +#ifdef __GEOS__ + stream->position = FilePos( stream->file, 0, FILE_POS_RELATIVE ); + FileClose( stream->file, FALSE ); +#else + stream->position = ftell( stream->file ); + fclose( stream->file ); +#endif /* ifdef __GEOS__ */ + stream->file = 0; + stream->opened = FALSE; + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Stream_Size + * + * Description : Returns the length of a given stream, even if it + * is flushed. + * + * Input : stream the stream + * + * Output : Length of stream in bytes. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Stream_Size( TT_Stream stream ) + { + PStream_Rec rec = STREAM2REC( stream ); + + + if ( rec ) + return rec->size; + else + return 0; /* invalid stream - return 0 */ + } + + +/******************************************************************* + * + * Function : TT_Open_Stream + * + * Description : Opens the font file and saves the total file size. + * + * Input : error address of stream's error variable + * (re-entrant build only) + * filepathname pathname of the file to open + * stream address of target TT_Stream structure + * + * Output : SUCCESS on sucess, FAILURE on error. + * The target stream is set to -1 in case of failure. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Open_Stream( const TT_Text* filepathname, + TT_Stream* stream ) + { + Int len; + TT_Error error; + PStream_Rec stream_rec; + + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) + return error; + + stream_rec = STREAM2REC( *stream ); + +#ifdef __GEOS__ + stream_rec->file = NullHandle; +#else + stream_rec->file = NULL; +#endif /* ifdef __GEOS__ */ + stream_rec->size = -1L; + stream_rec->base = 0; + stream_rec->opened = FALSE; + stream_rec->position = 0; + + len = strlen( filepathname ) + 1; + if ( ALLOC( stream_rec->name, len ) ) + goto Fail; + + strncpy( stream_rec->name, filepathname, len ); + + error = Stream_Activate( stream_rec ); + if ( error ) + goto Fail_Activate; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + CUR_Stream = stream_rec; +#endif + + return TT_Err_Ok; + + Fail_Activate: + FREE( stream_rec->name ); + Fail: + FREE( stream_rec ); + return error; + } + + +/******************************************************************* + * + * Function : TT_Close_Stream + * + * Description : Closes a stream. + * + * Input : stream address of target TT_Stream structure + * + * Output : SUCCESS (always). + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TT_Close_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + Stream_Deactivate( rec ); + FREE( rec->name ); + FREE( rec ); + + HANDLE_Set( *stream, NULL ); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Flush_Stream + * + * Description : Flushes a stream, i.e., closes its file handle. + * + * Input : stream address of target TT_Stream structure + * + * Output : Error code + * + * NOTE : Never flush the current opened stream. This means that + * you should _never_ call this function between a + * TT_Use_Stream() and a TT_Done_Stream()! + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Flush_Stream( TT_Stream* stream ) + { + PStream_Rec rec = STREAM2REC( *stream ); + + + if ( rec ) + { + Stream_Deactivate( rec ); + return TT_Err_Ok; + } + else + return TT_Err_Invalid_Argument; + } + + +/******************************************************************* + * + * Function : TT_Seek_File + * + * Description : Seeks the file cursor to a different position. + * + * Input : position new position in file + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Seek_File( STREAM_ARGS Long position ) + { + position += CUR_Stream->base; + +#ifdef __GEOS__ + FilePos( CUR_Stream->file, position, FILE_POS_START ); + if ( ThreadGetError() != NO_ERROR_RETURNED ) +#else + if ( fseek( CUR_Stream->file, position, SEEK_SET ) ) +#endif /* ifdef __GEOS__ */ + return TT_Err_Invalid_File_Offset; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Skip_File + * + * Description : Skips forward the file cursor. + * + * Input : distance number of bytes to skip + * + * Output : see TT_Seek_File() + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Skip_File( STREAM_ARGS Long distance ) + { +#ifdef __GEOS__ + return TT_Seek_File( STREAM_VARS FilePos( CUR_Stream->file, 0, FILE_POS_RELATIVE ) - + CUR_Stream->base + distance ); +#else + return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) - + CUR_Stream->base + distance ); +#endif /* ifdef __GEOS__ */ + } + + +/******************************************************************* + * + * Function : TT_Read_File + * + * Description : Reads a chunk of the file and copies it to memory. + * + * Input : buffer target buffer + * count length in bytes to read + * + * Output : SUCCESS on success. FAILURE if out of range. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) + { + #ifdef __GEOS__ + if ( FileRead( CUR_Stream->file, buffer, count, FALSE ) != (ULong)count ) + #else + if ( fread( buffer, 1, count, CUR_Stream->file ) != (ULong)count ) + #endif /* ifdef __GEOS__ */ + return TT_Err_Invalid_File_Read; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_Read_At_File + * + * Description : Reads file at a specified position. + * + * Input : position position to seek to before read + * buffer target buffer + * count number of bytes to read + * + * Output : SUCCESS on success. FAILURE if error. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ) + { + TT_Error error; + + + if ( (error = TT_Seek_File( STREAM_VARS position )) != TT_Err_Ok || + (error = TT_Read_File( STREAM_VARS buffer, count )) != TT_Err_Ok ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TT_File_Pos + * + * Description : Returns current file seek pointer. + * + * Input : none + * + * Output : Current file position. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_File_Pos( STREAM_ARG ) + { + #ifdef __GEOS__ + return FilePos( CUR_Stream->file, 0, FILE_POS_RELATIVE ) - CUR_Stream->base; + #else + return ftell( CUR_Stream->file ) - CUR_Stream->base; + #endif /* ifdef __GEOS__ */ + } + + +/******************************************************************* + * + * Function : GET_Byte + * + * Description : Extracts a byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted Byte. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + Byte TT_Get_Byte( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Byte)(*CUR_Frame.cursor++); + } +#endif + + +/******************************************************************* + * + * Function : GET_Char + * + * Description : Extracts a signed byte from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted char. + * + ******************************************************************/ + EXPORT_FUNC + Char TT_Get_Char( FRAME_ARG ) + { + CHECK_FRAME( CUR_Frame, 1 ); + + return (Char)(*CUR_Frame.cursor++); + } + + +/******************************************************************* + * + * Function : GET_Short + * + * Description : Extracts a short from the current file frame. + * + * Input : None or current frame + * + * Output : Extracted short. + * + ******************************************************************/ + + EXPORT_FUNC + Short TT_Get_Short( FRAME_ARG ) + { + Short getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = (Short)((CUR_Frame.cursor[0] << 8) | + CUR_Frame.cursor[1]); + + CUR_Frame.cursor += 2; + + return getshort; + } + + +/******************************************************************* + * + * Function : GET_UShort + * + * Description : Extracts an unsigned short from the frame. + * + * Input : None or current frame + * + * Output : Extracted ushort. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + UShort TT_Get_UShort( FRAME_ARG ) + { + UShort getshort; + + + CHECK_FRAME( CUR_Frame, 2 ); + + getshort = (UShort)((CUR_Frame.cursor[0] << 8) | + CUR_Frame.cursor[1]); + + CUR_Frame.cursor += 2; + + return getshort; + } +#endif + + +/******************************************************************* + * + * Function : GET_Long + * + * Description : Extracts a long from the frame. + * + * Input : None or current frame + * + * Output : Extracted long. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_Get_Long( FRAME_ARG ) + { + Long getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ((Long)CUR_Frame.cursor[0] << 24) | + ((Long)CUR_Frame.cursor[1] << 16) | + ((Long)CUR_Frame.cursor[2] << 8 ) | + (Long)CUR_Frame.cursor[3]; + + CUR_Frame.cursor += 4; + + return getlong; + } + + +/******************************************************************* + * + * Function : GET_ULong + * + * Description : Extracts an unsigned long from the frame. + * + * Input : None or current frame + * + * Output : Extracted ulong. + * + ******************************************************************/ +#if 0 + EXPORT_FUNC + ULong TT_Get_ULong( FRAME_ARG ) + { + ULong getlong; + + + CHECK_FRAME( CUR_Frame, 4 ); + + getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | + ((ULong)CUR_Frame.cursor[1] << 16) | + ((ULong)CUR_Frame.cursor[2] << 8 ) | + (ULong)CUR_Frame.cursor[3] ); + + CUR_Frame.cursor += 4; + + return getlong; + } +#endif + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttfile.h b/Driver/Font/TrueType/FreeType/ttfile.h new file mode 100644 index 000000000..64fb233c1 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttfile.h @@ -0,0 +1,271 @@ +/******************************************************************* + * + * ttfile.h 1.3 + * + * File I/O Component (specification). + * + * 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. + * + * Changes between 1.3 and 1.2: + * + * - all functions report error values now + * + * - the stream semantics have also changed + * + * Changes between 1.2 and 1.1: + * + * - added macros to support re-entrant builds + * + * - added the TT_Duplicate_File function to duplicate streams + * (re-entrant builds only) + * + ******************************************************************/ + +#ifndef TTFILE_H +#define TTFILE_H + +#include "ttconfig.h" +#include "freetype.h" +#include "ttengine.h" +#include "ttdebug.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /* Initialize file component */ + LOCAL_DEF + TT_Error TTFile_Init( PEngine_Instance engine ); + + /* Done with file component */ + LOCAL_DEF + TT_Error TTFile_Done( PEngine_Instance engine ); + + + /**********************************************************************/ + /* */ + /* Stream functions. */ + /* */ + /**********************************************************************/ + + /* Open a file and return a stream handle for it. */ + /* Should only be used for a new face object's main stream. */ + + LOCAL_DEF + TT_Error TT_Open_Stream( const TT_Text* name, + TT_Stream* stream ); + + + /* Closes, then discards, a stream when it's no longer needed. */ + /* Should only be used for a stream opend with TT_Open_Stream(). */ + + LOCAL_DEF + TT_Error TT_Close_Stream( TT_Stream* stream ); + + + /* Informs the component that we're going to use the file */ + /* opened in 'org_stream', and report errors to the 'error' */ + /* variable. */ + + /* in non re-entrant builds, 'org_stream' is simply copied */ + /* to 'stream'. Otherwise, the latter is a duplicate handle */ + /* for the file opened with 'org_stream' */ + + EXPORT_DEF + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ); + + /* Informs the component that we don't need to perform file */ + /* operations on the stream 'stream' anymore. This must be */ + /* used with streams "opened" with TT_Use_Stream() only! */ + + /* in re-entrant builds, this will really discard the stream */ + + EXPORT_DEF + TT_Error TT_Done_Stream( TT_Stream* stream ); + + /* Closes the stream's file handle to release system resources */ + /* The function TT_Use_Stream automatically re-activates a */ + /* flushed stream when it uses one */ + + EXPORT_DEF + TT_Error TT_Flush_Stream( TT_Stream* stream ); + +/* The macros STREAM_ARGS and STREAM_ARG let us build a thread-safe */ +/* or re-entrant implementation depending on a single configuration */ +/*define. */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define STREAM_ARGS TT_Stream stream, +#define STREAM_ARG TT_Stream stream + +#else + +#define STREAM_ARGS /* void */ +#define STREAM_ARG void + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /****************************************************************/ + /* */ + /* File Functions. */ + /* */ + /* The following functions perform file operations on the */ + /* currently 'used' stream. In thread-safe builds, only one */ + /* stream can be used at a time. Synchronisation is performed */ + /* through the Use_Stream()/Done_Stream() functions. */ + /* */ + /****************************************************************/ + + /* Read 'count' bytes from file into 'buffer' */ + + EXPORT_DEF + TT_Error TT_Read_File( STREAM_ARGS void* buffer, + Long count ); + + + /* Seek file cursor to a given position */ + + EXPORT_DEF + TT_Error TT_Seek_File( STREAM_ARGS Long position ); + + + /* Skip the next 'distance' bytes in file */ + + EXPORT_DEF + TT_Error TT_Skip_File( STREAM_ARGS Long distance ); + + + /* Read the 'count' bytes at 'position' into 'buffer' */ + + EXPORT_DEF + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ); + + /* Return current file position */ + + EXPORT_DEF + Long TT_File_Pos( STREAM_ARG ); + + /* Return length of a given stream, even if it is flushed */ + + EXPORT_DEF + Long TT_Stream_Size( TT_Stream stream ); + + + /********************************************************************/ + /* */ + /* Frame operations. */ + /* */ + /* For a comprehensive explanation of frames, please refer to the */ + /* documentation files. */ + /* */ + /********************************************************************/ + + /* Frame type declaration.*/ + + struct TFileFrame_ + { + Byte* address; /* frame buffer */ + Byte* cursor; /* current cursor position in frame */ + Long size; /* frame size */ + }; + + typedef struct TFileFrame_ TFileFrame; + + EXPORT_DEF + const TFileFrame TT_Null_FileFrame; + + +/* The macro ZERO_Frame is used to define and init a frame. */ +/* It is important to have a default frame of { NULL, NULL, 0 } */ +/* before a call to TT_Access_Frame(). Otherwise, the call will */ +/* fail with a TT_Err_Nested_Frame_Accesses error. */ + +#define ZERO_Frame( frame ) \ + { \ + (frame).address = NULL; \ + (frame).cursor = NULL; \ + (frame).size = 0; \ + } + + +/* The macros FRAME_ARGS and FRAME_ARG let us build a thread-safe */ +/* or re-entrant implementation depending on a single configuration */ +/* define */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define FRAME_ARGS TFileFrame* frame, +#define FRAME_ARG TFileFrame* frame + +#else + +#define FRAME_ARGS /* void */ +#define FRAME_ARG void + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /* Access the next 'size' bytes from current position. */ + /* Fails if all bytes cannot be read/accessed. */ + + EXPORT_DEF + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ); + + + /* Access the bytes located in the next 'size' bytes of the file. */ + /* Doesn't fail if less than 'size' bytes are accessible (like */ + /* at the end of the file). */ + + EXPORT_DEF + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ); + + /* Forget frame */ + + EXPORT_DEF + TT_Error TT_Forget_Frame( FRAME_ARG ); + + + /* primitive routines for data accessing */ + + EXPORT_DEF + Char TT_Get_Char ( FRAME_ARG ); + EXPORT_DEF + Short TT_Get_Short( FRAME_ARG ); + EXPORT_DEF + Long TT_Get_Long ( FRAME_ARG ); + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define TT_Get_Byte( frame ) ( (Byte )TT_Get_Char ( frame ) ) +#define TT_Get_UShort( frame ) ( (UShort)TT_Get_Short( frame ) ) +#define TT_Get_ULong( frame ) ( (ULong )TT_Get_Long ( frame ) ) + +#else + +#define TT_Get_Byte() ( (Byte )TT_Get_Char () ) +#define TT_Get_UShort() ( (UShort)TT_Get_Short() ) +#define TT_Get_ULong() ( (ULong )TT_Get_Long () ) + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + +#ifdef __cplusplus + } +#endif + +#endif /* TTFILE_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttgload.c b/Driver/Font/TrueType/FreeType/ttgload.c new file mode 100644 index 000000000..a10418e51 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttgload.c @@ -0,0 +1,1351 @@ +/******************************************************************* + * + * ttgload.c 1.0 + * + * TrueType Glyph Loader. + * + * 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 "tttypes.h" +#include "ttdebug.h" +#include "ttcalc.h" +#include "ttfile.h" + +#include "tttables.h" +#include "ttobjs.h" +#include "ttgload.h" + +#include "ttmemory.h" +#include "tttags.h" +#include "ttload.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_gload + + +/* composite font flags */ + +#define ARGS_ARE_WORDS 0x001 +#define ARGS_ARE_XY_VALUES 0x002 +#define ROUND_XY_TO_GRID 0x004 +#define WE_HAVE_A_SCALE 0x008 +/* reserved 0x010 */ +#define MORE_COMPONENTS 0x020 +#define WE_HAVE_AN_XY_SCALE 0x040 +#define WE_HAVE_A_2X2 0x080 +#define WE_HAVE_INSTR 0x100 +#define USE_MY_METRICS 0x200 + + +/********************************************************/ +/* Return horizontal or vertical metrics in font units */ +/* for a given glyph. The metrics are the left side */ +/* bearing (resp. top side bearing) and advance width */ +/* (resp. advance height). */ +/* */ +/* This function will much probably move to another */ +/* component in the short future, but I haven't decided */ +/* which yet... */ + + LOCAL_FUNC + void TT_Get_Metrics( TT_Horizontal_Header* header, + UShort index, + Short* bearing, + UShort* advance ) + { + PLongMetrics longs_m; + + UShort k = header->number_Of_HMetrics; + + + if ( index < k ) + { + longs_m = (PLongMetrics)header->long_metrics + index; + *bearing = longs_m->bearing; + *advance = longs_m->advance; + } + else + { + *bearing = ((PShortMetrics)header->short_metrics)[index - k]; + *advance = ((PLongMetrics)header->long_metrics)[k - 1].advance; + } + } + + +/********************************************************/ +/* Return horizontal metrics in font units for a given */ +/* glyph. If `check' is true, take care of mono-spaced */ +/* fonts by returning the advance width max. */ + + static void Get_HMetrics( PFace face, + UShort index, + Bool check, + Short* lsb, + UShort* aw ) + { + TT_Get_Metrics( &face->horizontalHeader, index, lsb, aw ); + + if ( check && face->postscript.isFixedPitch ) + *aw = face->horizontalHeader.advance_Width_Max; + } + + +/********************************************************/ +/* Return advance width table for a given pixel size */ +/* if it is found in the font's `hdmx' table (if any). */ + + static PByte Get_Advance_Widths( PFace face, + UShort ppem ) + { + UShort n; + + + for ( n = 0; n < face->hdmx.num_records; n++ ) + if ( face->hdmx.records[n].ppem == ppem ) + return face->hdmx.records[n].widths; + + return NULL; + } + + +/********************************************************/ +/* Copy current glyph into original one. */ + +#define cur_to_org( n, zone ) \ + MEM_Copy( (zone)->org, (zone)->cur, (n) * sizeof ( TT_Vector ) ) + +/********************************************************/ +/* copy original glyph into current one */ + +#define org_to_cur( n, zone ) \ + MEM_Copy( (zone)->cur, (zone)->org, (n) * sizeof ( TT_Vector ) ) + +/********************************************************/ +/* translate an array of coordinates */ + + static void translate_array( UShort n, + TT_Vector* coords, + TT_Pos delta_x, + TT_Pos delta_y ) + { + UShort k; + + + if ( delta_x ) + for ( k = 0; k < n; k++ ) + coords[k].x += delta_x; + + if ( delta_y ) + for ( k = 0; k < n; k++ ) + coords[k].y += delta_y; + } + + +/********************************************************/ +/* mount one zone on top of another */ + + static void mount_zone( PGlyph_Zone source, + PGlyph_Zone target ) + { + UShort np; + Short nc; + + np = source->n_points; + nc = source->n_contours; + + target->org = source->org + np; + target->cur = source->cur + np; + target->touch = source->touch + np; + + target->contours = source->contours + nc; + + target->n_points = 0; + target->n_contours = 0; + } + + +/******************************************************************* + * + * Function: Load_Simple_Glyph + * + ******************************************************************/ + + static TT_Error Load_Simple_Glyph( PExecution_Context exec, + TT_Stream input, + Short n_contours, + Short left_contours, + UShort left_points, + UShort load_flags, + PSubglyph_Record subg ) + { + DEFINE_LOAD_LOCALS( input ); + + PGlyph_Zone pts; + Short k; + UShort j; + UShort n_points, n_ins; + PFace face; + Byte* flag; + TT_Vector* vec; + TT_F26Dot6 x, y; + + + face = exec->face; + + /* simple check */ + if ( n_contours > left_contours ) + { + PTRACE0(( "ERROR: Glyph index %ld has %d contours > left %d\n", + subg->index, n_contours, left_contours )); + return TT_Err_Too_Many_Contours; + } + + + /* preparing the execution context */ + mount_zone( &subg->zone, &exec->pts ); + + /* reading the contours endpoints */ + if ( ACCESS_Frame( (n_contours + 1) * 2L ) ) + return error; + + PTRACE4(( " Contour endpoints:" )); + + for ( k = 0; k < n_contours; k++ ) + { + exec->pts.contours[k] = GET_UShort(); + PTRACE4(( " %d", exec->pts.contours[k] )); + } + PTRACE4(( "\n" )); + + if ( n_contours > 0 ) + n_points = exec->pts.contours[n_contours - 1] + 1; + else + n_points = 0; + + n_ins = GET_UShort(); + + FORGET_Frame(); + + if ( n_points > left_points ) + { + PTRACE0(( "ERROR: Too many points in glyph %ld\n", subg->index )); + return TT_Err_Too_Many_Points; + } + + /* loading instructions */ + + PTRACE4(( " Instructions size: %d\n", n_ins )); + + if ( n_ins > face->maxProfile.maxSizeOfInstructions ) + { + PTRACE0(( "ERROR: Too many instructions!\n" )); + return TT_Err_Too_Many_Ins; + } + + if ( FILE_Read( exec->glyphIns, n_ins ) ) + return error; + + if ( (error = Set_CodeRange( exec, + TT_CodeRange_Glyph, + exec->glyphIns, + n_ins )) != TT_Err_Ok ) + return error; + + + /* read the flags */ + + if ( CHECK_ACCESS_Frame( n_points * 5L ) ) + return error; + + j = 0; + flag = exec->pts.touch; + + while ( j < n_points ) + { + Byte c, cnt; + + flag[j] = c = GET_Byte(); + j++; + + if ( c & 8 ) + { + cnt = GET_Byte(); + while( cnt > 0 ) + { + flag[j++] = c; + cnt--; + } + } + } + + /* read the X */ + + x = 0; + vec = exec->pts.org; + + for ( j = 0; j < n_points; j++ ) + { + if ( flag[j] & 2 ) + { + if ( flag[j] & 16 ) + x += GET_Byte(); + else + x -= GET_Byte(); + } + else + { + if ( (flag[j] & 16) == 0 ) + x += GET_Short(); + } + + vec[j].x = x; + } + + + /* read the Y */ + + y = 0; + + for ( j = 0; j < n_points; j++ ) + { + if ( flag[j] & 4 ) + { + if ( flag[j] & 32 ) + y += GET_Byte(); + else + y -= GET_Byte(); + } + else + { + if ( (flag[j] & 32) == 0 ) + y += GET_Short(); + } + + vec[j].y = y; + } + + FORGET_Frame(); + + /* Now add the two shadow points at n and n + 1. */ + /* We need the left side bearing and advance width. */ + + /* pp1 = xMin - lsb */ + vec[n_points].x = subg->metrics.bbox.xMin - subg->metrics.horiBearingX; + vec[n_points].y = 0; + + /* pp2 = pp1 + aw */ + vec[n_points+1].x = vec[n_points].x + subg->metrics.horiAdvance; + vec[n_points+1].y = 0; + + /* clear the touch flags */ + + for ( j = 0; j < n_points; j++ ) + exec->pts.touch[j] &= TT_Flag_On_Curve; + + exec->pts.touch[n_points ] = 0; + exec->pts.touch[n_points + 1] = 0; + + /* Note that we return two more points that are not */ + /* part of the glyph outline. */ + + n_points += 2; + + /* now eventually scale and hint the glyph */ + + pts = &exec->pts; + pts->n_points = n_points; + pts->n_contours = n_contours; + + if ( (load_flags & TTLOAD_SCALE_GLYPH) == 0 ) + { + /* no scaling, just copy the orig arrays into the cur ones */ + org_to_cur( n_points, pts ); + } + else + { + /* first scale the glyph points */ + + for ( j = 0; j < n_points; j++ ) + { + pts->org[j].x = Scale_X( &exec->metrics, pts->org[j].x ); + pts->org[j].y = Scale_Y( &exec->metrics, pts->org[j].y ); + } + + /* if hinting, round pp1, and shift the glyph accordingly */ + if ( subg->is_hinted ) + { + x = pts->org[n_points - 2].x; + x = ((x+32) & -64) - x; + translate_array( n_points, pts->org, x, 0 ); + + org_to_cur( n_points, pts ); + + pts->cur[n_points - 1].x = (pts->cur[n_points - 1].x + 32) & -64; + + /* now consider hinting */ + if ( n_ins > 0 ) + { + exec->is_composite = FALSE; + exec->pedantic_hinting = load_flags & TTLOAD_PEDANTIC; + + error = Context_Run( exec, FALSE ); + if (error && exec->pedantic_hinting) + return error; + } + } + else + org_to_cur( n_points, pts ); + } + + /* save glyph phantom points */ + if (!subg->preserve_pps) + { + subg->pp1 = pts->cur[n_points - 2]; + subg->pp2 = pts->cur[n_points - 1]; + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_Composite_End + * + ******************************************************************/ + + static + TT_Error Load_Composite_End( UShort n_points, + Short n_contours, + PExecution_Context exec, + PSubglyph_Record subg, + UShort load_flags, + TT_Stream input ) + { + DEFINE_LOAD_LOCALS( input ); + + UShort k, n_ins; + PGlyph_Zone pts; + + + if ( subg->is_hinted && + subg->element_flag & WE_HAVE_INSTR ) + { + if ( ACCESS_Frame( 2L ) ) + return error; + + n_ins = GET_UShort(); /* read size of instructions */ + FORGET_Frame(); + + PTRACE4(( " Instructions size: %d\n", n_ins )); + + if ( n_ins > exec->face->maxProfile.maxSizeOfInstructions ) + { + PTRACE0(( "ERROR: Too many instructions in composite glyph %ld\n", + subg->index )); + return TT_Err_Too_Many_Ins; + } + + if ( FILE_Read( exec->glyphIns, n_ins ) ) + return error; + + error = Set_CodeRange( exec, + TT_CodeRange_Glyph, + exec->glyphIns, + n_ins ); + + if ( error ) + return error; + } + else + n_ins = 0; + + + /* prepare the execution context */ + n_points += 2; + exec->pts = subg->zone; + pts = &exec->pts; + + pts->n_points = n_points; + pts->n_contours = n_contours; + + /* add phantom points */ + pts->cur[n_points - 2] = subg->pp1; + pts->cur[n_points - 1] = subg->pp2; + + pts->touch[n_points - 1] = 0; + pts->touch[n_points - 2] = 0; + + /* if hinting, round the phantom points */ + if ( subg->is_hinted ) + { + pts->cur[n_points - 2].x = (subg->pp1.x + 32) & -64; + pts->cur[n_points - 1].x = (subg->pp2.x + 32) & -64; + } + + for ( k = 0; k < n_points; k++ ) + pts->touch[k] &= TT_Flag_On_Curve; + + cur_to_org( n_points, pts ); + + /* now consider hinting */ + if ( subg->is_hinted && n_ins > 0 ) + { + exec->is_composite = TRUE; + exec->pedantic_hinting = load_flags & TTLOAD_PEDANTIC; + + error = Context_Run( exec, FALSE ); + if (error && exec->pedantic_hinting) + return error; + } + + /* save glyph origin and advance points */ + subg->pp1 = pts->cur[n_points - 2]; + subg->pp2 = pts->cur[n_points - 1]; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Init_Glyph_Component + * + ******************************************************************/ + + static + void Init_Glyph_Component( PSubglyph_Record element, + PSubglyph_Record original, + PExecution_Context exec ) + { + element->index = -1; + element->is_scaled = FALSE; + element->is_hinted = FALSE; + + if ( original ) + mount_zone( &original->zone, &element->zone ); + else + element->zone = exec->pts; + + element->zone.n_contours = 0; + element->zone.n_points = 0; + + element->arg1 = 0; + element->arg2 = 0; + + element->element_flag = 0; + element->preserve_pps = FALSE; + + element->transform.xx = 1L << 16; + element->transform.xy = 0; + element->transform.yx = 0; + element->transform.yy = 1L << 16; + + element->transform.ox = 0; + element->transform.oy = 0; + + element->metrics.horiBearingX = 0; + element->metrics.horiAdvance = 0; + } + + + + LOCAL_FUNC + TT_Error Load_TrueType_Glyph( PInstance instance, + PGlyph glyph, + UShort glyph_index, + UShort load_flags ) + { + enum TPhases_ + { + Load_Exit, + Load_Glyph, + Load_Header, + Load_Simple, + Load_Composite, + Load_End + }; + + typedef enum TPhases_ TPhases; + + DEFINE_ALL_LOCALS; + + PFace face; + + UShort num_points; + Short num_contours; + UShort left_points; + Short left_contours; + UShort num_elem_points; + + Long table; + UShort load_top; + Long k, l; + UShort new_flags; + Long index; + UShort u, v; + + Long glyph_offset, offset; + + TT_F26Dot6 x, y, nx, ny; + + Fixed xx, xy, yx, yy; + + PExecution_Context exec; + + PSubglyph_Record subglyph, subglyph2; + + TGlyph_Zone base_pts; + + TPhases phase; + PByte widths; + +/* TT_Glyph_Loader_Callback cacheCb; */ +/* TT_Outline cached_outline; */ + + + /* first of all, check arguments */ + if ( !glyph ) + return TT_Err_Invalid_Glyph_Handle; + + face = glyph->face; + if ( !face ) + return TT_Err_Invalid_Glyph_Handle; + + if ( glyph_index >= face->numGlyphs ) + return TT_Err_Invalid_Glyph_Index; + + if ( instance && (load_flags & TTLOAD_SCALE_GLYPH) == 0 ) + { + instance = 0; + load_flags &= ~( TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH ); + } + + table = TT_LookUp_Table( face, TTAG_glyf ); + if ( table < 0 ) + { + PTRACE0(( "ERROR: There is no glyph table in this font file!\n" )); + return TT_Err_Glyf_Table_Missing; + } + + glyph_offset = face->dirTables[table].Offset; + + /* query new execution context */ + + if ( instance && instance->debug ) + exec = instance->context; + else + exec = New_Context( face ); + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + Context_Load( exec, face, instance ); + + if ( instance ) + { + if ( instance->GS.instruct_control & 2 ) + exec->GS = Default_GraphicsState; + else + exec->GS = instance->GS; + /* load default graphics state */ + + glyph->outline.high_precision = ( instance->metrics.y_ppem < 24 ); + } + + /* save its critical pointers, as they'll be modified during load */ + base_pts = exec->pts; + + /* init variables */ + left_points = face->maxPoints; + left_contours = face->maxContours; + + num_points = 0; + num_contours = 0; + + load_top = 0; + subglyph = exec->loadStack; + + Init_Glyph_Component( subglyph, NULL, exec ); + + subglyph->index = glyph_index; + subglyph->is_hinted = load_flags & TTLOAD_HINT_GLYPH; + + /* when the cvt program has disabled hinting, the argument */ + /* is ignored. */ + if ( instance && instance->GS.instruct_control & 1 ) + subglyph->is_hinted = FALSE; + + + /* now access stream */ + + if ( USE_Stream( face->stream, stream ) ) + goto Fin; + + /* Main loading loop */ + + phase = Load_Glyph; + index = 0; + + while ( phase != Load_Exit ) + { + subglyph = exec->loadStack + load_top; + + switch ( phase ) + { + /************************************************************/ + /* */ + /* Load_Glyph state */ + /* */ + /* reading a glyph's generic header to determine */ + /* whether it's simple or composite */ + /* */ + /* exit states: Load_Header and Load_End */ + + case Load_Glyph: + /* check glyph index and table */ + + index = subglyph->index; + if ( index < 0 || index >= face->numGlyphs ) + { + error = TT_Err_Invalid_Glyph_Index; + goto Fail; + } + + /* get horizontal metrics */ + + { + Short left_bearing; + UShort advance_width; + + + Get_HMetrics( face, (UShort)index, + !(load_flags & TTLOAD_IGNORE_GLOBAL_ADVANCE_WIDTH), + &left_bearing, + &advance_width ); + + subglyph->metrics.horiBearingX = left_bearing; + subglyph->metrics.horiAdvance = advance_width; + } + + phase = Load_Header; + + + /* The cache callback isn't part of the FreeType release yet */ + /* It is discarded for the moment.. */ + /* */ +#if 0 + if ( instance ) + { + /* is the glyph in an outline cache ? */ + cacheCb = instance->owner->engine->glCallback; + if ( cacheCb && 0 ) /* disabled */ + { + /* we have a callback */ + error = cacheCb( instance->generic, + index, &cached_outline, &x, &y ); + if ( !error ) + { + /* no error, then append the outline to the current subglyph */ + /* error = Append_Outline( subglyph, + &left_points, + &left_contours, + &cached_outline ); */ + phase = Load_End; + } + } + } +#endif + break; + + + /************************************************************/ + /* */ + /* Load_Header state */ + /* */ + /* reading a glyph's generic header to determine */ + /* wether it's simple or composite */ + /* */ + /* exit states: Load_Simple and Load_Composite */ + /* */ + + case Load_Header: /* load glyph */ + + if ( index + 1 < face->numLocations && + face->glyphLocations[index] == face->glyphLocations[index + 1] ) + { + /* as described by Frederic Loyer, these are spaces, and */ + /* not the unknown glyph. */ + + num_contours = 0; + num_points = 0; + + subglyph->metrics.bbox.xMin = 0; + subglyph->metrics.bbox.xMax = 0; + subglyph->metrics.bbox.yMin = 0; + subglyph->metrics.bbox.yMax = 0; + + subglyph->pp1.x = 0; + subglyph->pp2.x = subglyph->metrics.horiAdvance; + if (load_flags & TTLOAD_SCALE_GLYPH) + subglyph->pp2.x = Scale_X( &exec->metrics, subglyph->pp2.x ); + + exec->glyphSize = 0; + phase = Load_End; + break; + } + + offset = glyph_offset + face->glyphLocations[index]; + + /* read first glyph header */ + if ( FILE_Seek( offset ) || + ACCESS_Frame( 10L ) ) + goto Fail_File; + + num_contours = GET_Short(); + + subglyph->metrics.bbox.xMin = GET_Short(); + subglyph->metrics.bbox.yMin = GET_Short(); + subglyph->metrics.bbox.xMax = GET_Short(); + subglyph->metrics.bbox.yMax = GET_Short(); + + FORGET_Frame(); + + PTRACE6(( "Glyph %ld:\n", index )); + PTRACE6(( " # of contours: %d\n", num_contours )); + PTRACE6(( " xMin: %4d xMax: %4d\n", + subglyph->metrics.bbox.xMin, + subglyph->metrics.bbox.xMax )); + PTRACE6(( " yMin: %4d yMax: %4d\n", + subglyph->metrics.bbox.yMin, + subglyph->metrics.bbox.yMax )); + + if ( num_contours > left_contours ) + { + PTRACE0(( "ERROR: Too many contours for glyph %ld\n", index )); + error = TT_Err_Too_Many_Contours; + goto Fail; + } + + subglyph->pp1.x = subglyph->metrics.bbox.xMin - + subglyph->metrics.horiBearingX; + subglyph->pp1.y = 0; + subglyph->pp2.x = subglyph->pp1.x + subglyph->metrics.horiAdvance; + if (load_flags & TTLOAD_SCALE_GLYPH) + { + subglyph->pp1.x = Scale_X( &exec->metrics, subglyph->pp1.x ); + subglyph->pp2.x = Scale_X( &exec->metrics, subglyph->pp2.x ); + } + + /* is it a simple glyph ? */ + if ( num_contours > 0 ) + phase = Load_Simple; + else + phase = Load_Composite; + + break; + + + /************************************************************/ + /* */ + /* Load_Simple state */ + /* */ + /* reading a simple glyph (num_contours must be set to */ + /* the glyph's number of contours.) */ + /* */ + /* exit states : Load_End */ + /* */ + + case Load_Simple: + new_flags = load_flags; + + /* disable hinting when scaling */ + if ( !subglyph->is_hinted ) + new_flags &= ~TTLOAD_HINT_GLYPH; + + error = Load_Simple_Glyph( exec, + stream, + num_contours, + left_contours, + left_points, + new_flags, + subglyph ); + if ( error ) + goto Fail; + + /* Note: We could have put the simple loader source there */ + /* but the code is fat enough already :-) */ + + num_points = exec->pts.n_points - 2; + + phase = Load_End; + + break; + + + /************************************************************/ + /* */ + /* Load_Composite state */ + /* */ + /* reading a composite glyph header a pushing a new */ + /* load element on the stack. */ + /* */ + /* exit states: Load_Glyph */ + /* */ + + case Load_Composite: + + /* create a new element on the stack */ + load_top++; + + if ( load_top > face->maxComponents ) + { + error = TT_Err_Invalid_Composite; + goto Fail; + } + + subglyph2 = exec->loadStack + load_top; + + Init_Glyph_Component( subglyph2, subglyph, NULL ); + subglyph2->is_hinted = subglyph->is_hinted; + + /* now read composite header */ + + if ( ACCESS_Frame( 4L ) ) + goto Fail_File; + + subglyph->element_flag = new_flags = GET_UShort(); + + subglyph2->index = GET_UShort(); + + FORGET_Frame(); + + k = 1 + 1; + + if ( new_flags & ARGS_ARE_WORDS ) + k *= 2; + + if ( new_flags & WE_HAVE_A_SCALE ) + k += 2; + + else if ( new_flags & WE_HAVE_AN_XY_SCALE ) + k += 4; + + else if ( new_flags & WE_HAVE_A_2X2 ) + k += 8; + + if ( ACCESS_Frame( k ) ) + goto Fail_File; + + if ( new_flags & ARGS_ARE_WORDS ) + { + k = GET_Short(); + l = GET_Short(); + } + else + { + k = GET_Char(); + l = GET_Char(); + } + + subglyph->arg1 = k; + subglyph->arg2 = l; + + if ( new_flags & ARGS_ARE_XY_VALUES ) + { + subglyph->transform.ox = k; + subglyph->transform.oy = l; + } + + xx = 1L << 16; + xy = 0; + yx = 0; + yy = 1L << 16; + + if ( new_flags & WE_HAVE_A_SCALE ) + { + xx = (Fixed)GET_Short() << 2; + yy = xx; + subglyph2->is_scaled = TRUE; + } + else if ( new_flags & WE_HAVE_AN_XY_SCALE ) + { + xx = (Fixed)GET_Short() << 2; + yy = (Fixed)GET_Short() << 2; + subglyph2->is_scaled = TRUE; + } + else if ( new_flags & WE_HAVE_A_2X2 ) + { + xx = (Fixed)GET_Short() << 2; + xy = (Fixed)GET_Short() << 2; + yx = (Fixed)GET_Short() << 2; + yy = (Fixed)GET_Short() << 2; + subglyph2->is_scaled = TRUE; + } + + FORGET_Frame(); + + subglyph->transform.xx = xx; + subglyph->transform.xy = xy; + subglyph->transform.yx = yx; + subglyph->transform.yy = yy; + + k = TT_MulFix( xx, yy ) - TT_MulFix( xy, yx ); + + /* disable hinting in case of scaling/slanting */ + if ( ABS( k ) != (1L << 16) ) + subglyph2->is_hinted = FALSE; + + subglyph->file_offset = FILE_Pos(); + + phase = Load_Glyph; + + break; + + + /************************************************************/ + /* */ + /* Load_End state */ + /* */ + /* after loading a glyph, apply transformation and offset */ + /* where necessary, pops element and continue or */ + /* stop process. */ + /* */ + /* exit states : Load_Composite and Load_Exit */ + /* */ + + case Load_End: + if ( load_top > 0 ) + { + subglyph2 = subglyph; + + load_top--; + subglyph = exec->loadStack + load_top; + + /* check advance width and left side bearing */ + + if ( !subglyph->preserve_pps && + subglyph->element_flag & USE_MY_METRICS ) + { + subglyph->metrics.horiBearingX = subglyph2->metrics.horiBearingX; + subglyph->metrics.horiAdvance = subglyph2->metrics.horiAdvance; + + subglyph->pp1 = subglyph2->pp1; + subglyph->pp2 = subglyph2->pp2; + + subglyph->preserve_pps = TRUE; + } + + /* apply scale */ + + if ( subglyph2->is_scaled ) + { + TT_Vector* cur = subglyph2->zone.cur; + TT_Vector* org = subglyph2->zone.org; + + for ( u = 0; u < num_points; u++ ) + { + nx = TT_MulFix( cur->x, subglyph->transform.xx ) + + TT_MulFix( cur->y, subglyph->transform.yx ); + + ny = TT_MulFix( cur->x, subglyph->transform.xy ) + + TT_MulFix( cur->y, subglyph->transform.yy ); + + cur->x = nx; + cur->y = ny; + + nx = TT_MulFix( org->x, subglyph->transform.xx ) + + TT_MulFix( org->y, subglyph->transform.yx ); + + ny = TT_MulFix( org->x, subglyph->transform.xy ) + + TT_MulFix( org->y, subglyph->transform.yy ); + + org->x = nx; + org->y = ny; + + cur++; + org++; + } + } + + /* adjust counts */ + + num_elem_points = subglyph->zone.n_points; + + for ( k = 0; k < num_contours; k++ ) + subglyph2->zone.contours[k] += num_elem_points; + + subglyph->zone.n_points += num_points; + subglyph->zone.n_contours += num_contours; + + left_points -= num_points; + left_contours -= num_contours; + + if ( !(subglyph->element_flag & ARGS_ARE_XY_VALUES) ) + { + /* move second glyph according to control points */ + /* the attach points are relative to the specific component */ + + u = (UShort)subglyph->arg1; + v = (UShort)subglyph->arg2; + + if ( u >= num_elem_points || + v >= num_points ) + { + error = TT_Err_Invalid_Composite; + goto Fail; + } + + /* adjust count */ + v += num_elem_points; + + x = subglyph->zone.cur[u].x - subglyph->zone.cur[v].x; + y = subglyph->zone.cur[u].y - subglyph->zone.cur[v].y; + } + else + { + /* apply offset */ + + x = subglyph->transform.ox; + y = subglyph->transform.oy; + + if ( load_flags & TTLOAD_SCALE_GLYPH ) + { + x = Scale_X( &exec->metrics, x ); + y = Scale_Y( &exec->metrics, y ); + + if ( subglyph->element_flag & ROUND_XY_TO_GRID ) + { + x = (x+32) & -64; + y = (y+32) & -64; + } + } + } + + translate_array( num_points, subglyph2->zone.cur, x, y ); + + cur_to_org( num_points, &subglyph2->zone ); + + num_points = subglyph->zone.n_points; + num_contours = subglyph->zone.n_contours; + + /* check for last component */ + + if ( FILE_Seek( subglyph->file_offset ) ) + goto Fail_File; + + if ( subglyph->element_flag & MORE_COMPONENTS ) + phase = Load_Composite; + else + { + error = Load_Composite_End( num_points, + num_contours, + exec, + subglyph, + load_flags, + stream ); + if ( error ) + goto Fail; + + phase = Load_End; + } + } + else + phase = Load_Exit; + + break; + + + case Load_Exit: + break; + } + } + + /* finally, copy the points arrays to the glyph object */ + + exec->pts = base_pts; + + for ( u = 0; u < num_points + 2; u++ ) + { + glyph->outline.points[u] = exec->pts.cur[u]; + glyph->outline.flags [u] = exec->pts.touch[u]; + } + + for ( k = 0; k < num_contours; k++ ) + glyph->outline.contours[k] = exec->pts.contours[k]; + + glyph->outline.n_points = num_points; + glyph->outline.n_contours = num_contours; + glyph->outline.second_pass = TRUE; + + /* translate array so that (0,0) is the glyph's origin */ + translate_array( num_points + 2, + glyph->outline.points, + -subglyph->pp1.x, + 0 ); + + TT_Get_Outline_BBox( &glyph->outline, &glyph->metrics.bbox ); + + if ( subglyph->is_hinted ) + { + /* grid-fit the bounding box */ + glyph->metrics.bbox.xMin &= -64; + glyph->metrics.bbox.yMin &= -64; + glyph->metrics.bbox.xMax = (glyph->metrics.bbox.xMax+63) & -64; + glyph->metrics.bbox.yMax = (glyph->metrics.bbox.yMax+63) & -64; + } + + /* get the device-independent scaled horizontal metrics */ + /* take care of fixed-pitch fonts... */ + { + TT_Pos left_bearing; + TT_Pos advance; + + + left_bearing = subglyph->metrics.horiBearingX; + advance = subglyph->metrics.horiAdvance; + + if ( face->postscript.isFixedPitch ) + advance = face->horizontalHeader.advance_Width_Max; + + if ( load_flags & TTLOAD_SCALE_GLYPH ) + { + left_bearing = Scale_X( &exec->metrics, left_bearing ); + advance = Scale_X( &exec->metrics, advance ); + } + + glyph->metrics.linearHoriBearingX = left_bearing; + glyph->metrics.linearHoriAdvance = advance; + } + + glyph->metrics.horiBearingX = glyph->metrics.bbox.xMin; + glyph->metrics.horiBearingY = glyph->metrics.bbox.yMax; + glyph->metrics.horiAdvance = subglyph->pp2.x - subglyph->pp1.x; + + /* Now take care of vertical metrics. In the case where there is */ + /* no vertical information within the font (relatively common), make */ + /* up some metrics `by hand' ... */ + + { + Short top_bearing; /* vertical top side bearing (EM units) */ + UShort advance_height; /* vertical advance height (EM units) */ + + TT_Pos left; /* scaled vertical left side bearing */ + TT_Pos Top; /* scaled original vertical top side bearing */ + TT_Pos top; /* scaled vertical top side bearing */ + TT_Pos advance; /* scaled vertical advance height */ + + + /* Get the unscaled `tsb' and `ah' values */ + if ( face->verticalInfo && + face->verticalHeader.number_Of_VMetrics > 0 ) + { + /* Don't assume that both the vertical header and vertical */ + /* metrics are present in the same font :-) */ + + TT_Get_Metrics( (TT_Horizontal_Header*)&face->verticalHeader, + glyph_index, + &top_bearing, + &advance_height ); + } + else + { + /* Make up the distances from the horizontal header.. */ + + /* NOTE: The OS/2 values are the only `portable' ones, */ + /* which is why we use them... */ + /* */ + /* NOTE2: The sTypoDescender is negative, which is why */ + /* we compute the baseline-to-baseline distance */ + /* here with : */ + /* ascender - descender + linegap */ + /* */ + top_bearing = (Short) (face->os2.sTypoLineGap / 2); + advance_height = (UShort)(face->os2.sTypoAscender - + face->os2.sTypoDescender + + face->os2.sTypoLineGap); + } + + /* We must adjust the top_bearing value from the bounding box given + in the glyph header to te bounding box calculated with + TT_Get_Outline_BBox() */ + + /* scale the metrics */ + if ( load_flags & TTLOAD_SCALE_GLYPH ) + { + Top = Scale_Y( &exec->metrics, top_bearing ); + top = Scale_Y( &exec->metrics, + top_bearing + subglyph->metrics.bbox.yMax ) - + glyph->metrics.bbox.yMax; + advance = Scale_Y( &exec->metrics, advance_height ); + } + else + { + Top = top_bearing; + top = top_bearing + subglyph->metrics.bbox.yMax - + glyph->metrics.bbox.yMax; + advance = advance_height; + } + + glyph->metrics.linearVertBearingY = Top; + glyph->metrics.linearVertAdvance = advance; + + /* XXX : for now, we have no better algo for the lsb, but it should */ + /* work ok.. */ + /* */ + left = ( glyph->metrics.bbox.xMin - glyph->metrics.bbox.xMax ) / 2; + + /* grid-fit them if necessary */ + if ( subglyph->is_hinted ) + { + left &= -64; + top = (top + 63) & -64; + advance = (advance + 32) & -64; + } + + glyph->metrics.vertBearingX = left; + glyph->metrics.vertBearingY = top; + glyph->metrics.vertAdvance = advance; + } + + /* Adjust advance width to the value contained in the hdmx table. */ + if ( !exec->face->postscript.isFixedPitch && instance && + subglyph->is_hinted ) + { + widths = Get_Advance_Widths( exec->face, + exec->instance->metrics.x_ppem ); + if ( widths ) + glyph->metrics.horiAdvance = widths[glyph_index] << 6; + } + + glyph->outline.dropout_mode = (Char)exec->GS.scan_type; + + error = TT_Err_Ok; + + Fail_File: + Fail: + DONE_Stream( stream ); + + Fin: + + /* reset the execution context */ + exec->pts = base_pts; + + if ( !instance || !instance->debug ) + Done_Context( exec ); + + return error; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttgload.h b/Driver/Font/TrueType/FreeType/ttgload.h new file mode 100644 index 000000000..10759abf6 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttgload.h @@ -0,0 +1,51 @@ +/******************************************************************* + * + * ttgload.h 1.0 + * + * TrueType Glyph Loader. + * + * 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 TTGLOAD_H +#define TTGLOAD_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + +#ifdef __cplusplus + extern "C" { +#endif + + + LOCAL_DEF + void TT_Get_Metrics( TT_Horizontal_Header* header, + UShort index, + Short* bearing, + UShort* advance ); + + + LOCAL_DEF + TT_Error Load_TrueType_Glyph( PInstance instance, + PGlyph glyph, + UShort glyph_index, + UShort load_flags ); + +#ifdef __cplusplus + } +#endif + + +#endif /* TTGLOAD_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttinterp.c b/Driver/Font/TrueType/FreeType/ttinterp.c new file mode 100644 index 000000000..a8e8ff510 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttinterp.c @@ -0,0 +1,6687 @@ +/******************************************************************* + * + * ttinterp.c 3.1 + * + * TrueType bytecode intepreter. + * + * 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. + * + * + * Changes between 3.1 and 3.0: + * + * - A more relaxed version of the interpreter. It is now able to + * ignore errors like out-of-bound array access and writes in order + * to silently support broken glyphs (even if the results are not + * always pretty). + * + * Note that one can use the flag TTLOAD_PEDANTIC to force + * TrueType-compliant interpretation. + * + * - A big #if used to completely disable the interpreter, which + * is due to the Apple patents issues which emerged recently. + * + ******************************************************************/ + +#include "freetype.h" +#include "tttypes.h" +#include "ttdebug.h" +#include "ttcalc.h" +#include "ttmemory.h" +#include "ttinterp.h" + + +#ifdef TT_CONFIG_OPTION_NO_INTERPRETER + + LOCAL_FUNC + TT_Error RunIns( PExecution_Context exc ) + { + /* do nothing - always successful */ + (void)exc; + return TT_Err_Ok; + } + +#else + + +#ifdef DEBUG_INTERPRETER +#include +#include "ttdebug.h" + +/* Define the `getch()' function. On Unix systems, it is an alias */ +/* for `getchar()', and the debugger front end must ensure that the */ +/* `stdin' file descriptor is not in line-by-line input mode. */ +#ifdef OS2 +#include +#else +#define getch getchar +#endif + +#endif /* DEBUG_INTEPRETER */ + + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_interp + + +/* In order to detect infinite loops in the code, we set-up */ +/* a counter within the run loop. a singly stroke of interpretation */ +/* is now limited to a maximum number of opcodes defined below.. */ +/* */ +#define MAX_RUNNABLE_OPCODES 1000000 + + +/* There are two kinds of implementations there: */ +/* */ +/* a. static implementation: */ +/* */ +/* The current execution context is a static variable, */ +/* which fields are accessed directly by the interpreter */ +/* during execution. The context is named 'cur'. */ +/* */ +/* This version is non-reentrant, of course. */ +/* */ +/* */ +/* b. indirect implementation: */ +/* */ +/* The current execution context is passed to _each_ */ +/* function as its first argument, and each field is */ +/* thus accessed indirectly. */ +/* */ +/* This version is, however, fully re-entrant. */ +/* */ +/* */ +/* The idea is that an indirect implementation may be */ +/* slower to execute on the low-end processors that are */ +/* used in some systems (like 386s or even 486s). */ +/* */ +/* When the interpreter started, we had no idea of the */ +/* time that glyph hinting (i.e. executing instructions) */ +/* could take in the whole process of rendering a glyph, */ +/* and a 10 to 30% performance penalty on low-end systems */ +/* didn't seem much of a good idea. This question led us */ +/* to provide two distinct builds of the C version from */ +/* a single source, with the use of macros (again). */ +/* */ +/* Now that the engine is working (and working really */ +/* well!), it seems that the greatest time-consuming */ +/* factors are: file i/o, glyph loading, rasterizing and */ +/* _then_ glyph hinting! */ +/* */ +/* Tests performed with two versions of the 'fttimer' */ +/* program seem to indicate that hinting takes less than 5% */ +/* of the rendering process, which is dominated by glyph */ +/* loading and scan-line conversion by an high order of */ +/* magnitude. */ +/* */ +/* As a consequence, the indirect implementation is now the */ +/* default, as its performance costs can be considered */ +/* negligible in our context. Note, however, that we */ +/* kept the same source with macros because: */ +/* */ +/* - the code is kept very close in design to the */ +/* Pascal one used for development. */ +/* */ +/* - it's much more readable that way! */ +/* */ +/* - it's still open to later experimentation and tuning */ + + + +#ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */ + +#define CUR (*exc) /* see ttobjs.h */ + +#else /* static implementation */ + +#define CUR cur + + static TExecution_Context cur; /* static exec. context variable */ + + /* apparently, we have a _lot_ of direct indexing when accessing */ + /* the static 'cur', which makes the code bigger (due to all the */ + /* four bytes addresses). */ + +#endif /* !TT_CONFIG_OPTION_STATIC_INTERPRETER */ + + +#define INS_ARG EXEC_OPS PStorage args /* see ttobjs.h */ + +#define SKIP_Code() SkipCode( EXEC_ARG ) + +#define GET_ShortIns() GetShortIns( EXEC_ARG ) + +#define COMPUTE_Funcs() Compute_Funcs( EXEC_ARG ) + +#define NORMalize( x, y, v ) Normalize( EXEC_ARGS x, y, v ) + +#define SET_SuperRound( scale, flags ) \ + SetSuperRound( EXEC_ARGS scale, flags ) + +#define INS_Goto_CodeRange( range, ip ) \ + Ins_Goto_CodeRange( EXEC_ARGS range, ip ) + +#ifdef __GEOS__ +#define CUR_Func_project( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_project, EXEC_ARGS x, y ) +#else +#define CUR_Func_project( x, y ) CUR.func_project( EXEC_ARGS x, y ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_move( z, p, d ) ProcCallFixedOrMovable_cdecl( CUR.func_move, EXEC_ARGS z, p, d ) +#else +#define CUR_Func_move( z, p, d ) CUR.func_move( EXEC_ARGS z, p, d ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_dualproj( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_dualproj, EXEC_ARGS x, y ) +#else +#define CUR_Func_dualproj( x, y ) CUR.func_dualproj( EXEC_ARGS x, y ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_freeProj( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_freeProj, EXEC_ARGS x, y ) +#else +#define CUR_Func_freeProj( x, y ) CUR.func_freeProj( EXEC_ARGS x, y ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_round( d, c ) ProcCallFixedOrMovable_cdecl( CUR.func_round, EXEC_ARGS d, c ) +#else +#define CUR_Func_round( d, c ) CUR.func_round( EXEC_ARGS d, c ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_read_cvt( index ) ProcCallFixedOrMovable_cdecl( CUR.func_read_cvt, EXEC_ARGS index ) +#else +#define CUR_Func_read_cvt( index ) CUR.func_read_cvt( EXEC_ARGS index ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_write_cvt( index, val ) ProcCallFixedOrMovable_cdecl( CUR.func_write_cvt, EXEC_ARGS index, val ) +#else +#define CUR_Func_write_cvt( index, val ) CUR.func_write_cvt( EXEC_ARGS index, val ) +#endif /* ifdef __GEOS__ */ + +#ifdef __GEOS__ +#define CUR_Func_move_cvt( index, val ) ProcCallFixedOrMovable_cdecl( CUR.func_move_cvt, EXEC_ARGS index, val ) +#else +#define CUR_Func_move_cvt( index, val ) CUR.func_move_cvt( EXEC_ARGS index, val ) +#endif /* ifdef __GEOS__ */ + +#define CURRENT_Ratio() Current_Ratio( EXEC_ARG ) +#define CURRENT_Ppem() Current_Ppem( EXEC_ARG ) + +#define CALC_Length() Calc_Length( EXEC_ARG ) + +#define INS_SxVTL( a, b, c, d ) Ins_SxVTL( EXEC_ARGS a, b, c, d ) + +#define COMPUTE_Point_Displacement( a, b, c, d ) \ + Compute_Point_Displacement( EXEC_ARGS a, b, c, d ) + +#define MOVE_Zp2_Point( a, b, c, t ) Move_Zp2_Point( EXEC_ARGS a, b, c, t ) + +#define CUR_Ppem() Cur_PPEM( EXEC_ARG ) + + /* Instruction dispatch function, as used by the interpreter */ + typedef void (*TInstruction_Function)( INS_ARG ); + +#define BOUNDS( x, n ) ( (x) >= (n) ) + + + +/*********************************************************************/ +/* */ +/* Before an opcode is executed, the interpreter verifies that */ +/* there are enough arguments on the stack, with the help of */ +/* the Pop_Push_Count table. */ +/* */ +/* For each opcode, the first column gives the number of arguments */ +/* that are popped from the stack; the second one gives the number */ +/* of those that are pushed in result. */ +/* */ +/* Note that for opcodes with a varying number of parameters, */ +/* either 0 or 1 arg is verified before execution, depending */ +/* on the nature of the instruction: */ +/* */ +/* - if the number of arguments is given by the bytecode */ +/* stream or the loop variable, 0 is chosen. */ +/* */ +/* - if the first argument is a count n that is followed */ +/* by arguments a1..an, then 1 is chosen. */ +/* */ +/*********************************************************************/ + +#undef PACK +#define PACK( x, y ) ((x << 4) | y) + + static const Byte Pop_Push_Count[256] = + { + /* opcodes are gathered in groups of 16 */ + /* please keep the spaces as they are */ + + /* SVTCA y */ PACK( 0, 0 ), + /* SVTCA x */ PACK( 0, 0 ), + /* SPvTCA y */ PACK( 0, 0 ), + /* SPvTCA x */ PACK( 0, 0 ), + /* SFvTCA y */ PACK( 0, 0 ), + /* SFvTCA x */ PACK( 0, 0 ), + /* SPvTL // */ PACK( 2, 0 ), + /* SPvTL + */ PACK( 2, 0 ), + /* SFvTL // */ PACK( 2, 0 ), + /* SFvTL + */ PACK( 2, 0 ), + /* SPvFS */ PACK( 2, 0 ), + /* SFvFS */ PACK( 2, 0 ), + /* GPV */ PACK( 0, 2 ), + /* GFV */ PACK( 0, 2 ), + /* SFvTPv */ PACK( 0, 0 ), + /* ISECT */ PACK( 5, 0 ), + + /* SRP0 */ PACK( 1, 0 ), + /* SRP1 */ PACK( 1, 0 ), + /* SRP2 */ PACK( 1, 0 ), + /* SZP0 */ PACK( 1, 0 ), + /* SZP1 */ PACK( 1, 0 ), + /* SZP2 */ PACK( 1, 0 ), + /* SZPS */ PACK( 1, 0 ), + /* SLOOP */ PACK( 1, 0 ), + /* RTG */ PACK( 0, 0 ), + /* RTHG */ PACK( 0, 0 ), + /* SMD */ PACK( 1, 0 ), + /* ELSE */ PACK( 0, 0 ), + /* JMPR */ PACK( 1, 0 ), + /* SCvTCi */ PACK( 1, 0 ), + /* SSwCi */ PACK( 1, 0 ), + /* SSW */ PACK( 1, 0 ), + + /* DUP */ PACK( 1, 2 ), + /* POP */ PACK( 1, 0 ), + /* CLEAR */ PACK( 0, 0 ), + /* SWAP */ PACK( 2, 2 ), + /* DEPTH */ PACK( 0, 1 ), + /* CINDEX */ PACK( 1, 1 ), + /* MINDEX */ PACK( 1, 0 ), + /* AlignPTS */ PACK( 2, 0 ), + /* INS_$28 */ PACK( 0, 0 ), + /* UTP */ PACK( 1, 0 ), + /* LOOPCALL */ PACK( 2, 0 ), + /* CALL */ PACK( 1, 0 ), + /* FDEF */ PACK( 1, 0 ), + /* ENDF */ PACK( 0, 0 ), + /* MDAP[0] */ PACK( 1, 0 ), + /* MDAP[1] */ PACK( 1, 0 ), + + /* IUP[0] */ PACK( 0, 0 ), + /* IUP[1] */ PACK( 0, 0 ), + /* SHP[0] */ PACK( 0, 0 ), + /* SHP[1] */ PACK( 0, 0 ), + /* SHC[0] */ PACK( 1, 0 ), + /* SHC[1] */ PACK( 1, 0 ), + /* SHZ[0] */ PACK( 1, 0 ), + /* SHZ[1] */ PACK( 1, 0 ), + /* SHPIX */ PACK( 1, 0 ), + /* IP */ PACK( 0, 0 ), + /* MSIRP[0] */ PACK( 2, 0 ), + /* MSIRP[1] */ PACK( 2, 0 ), + /* AlignRP */ PACK( 0, 0 ), + /* RTDG */ PACK( 0, 0 ), + /* MIAP[0] */ PACK( 2, 0 ), + /* MIAP[1] */ PACK( 2, 0 ), + + /* NPushB */ PACK( 0, 0 ), + /* NPushW */ PACK( 0, 0 ), + /* WS */ PACK( 2, 0 ), + /* RS */ PACK( 1, 1 ), + /* WCvtP */ PACK( 2, 0 ), + /* RCvt */ PACK( 1, 1 ), + /* GC[0] */ PACK( 1, 1 ), + /* GC[1] */ PACK( 1, 1 ), + /* SCFS */ PACK( 2, 0 ), + /* MD[0] */ PACK( 2, 1 ), + /* MD[1] */ PACK( 2, 1 ), + /* MPPEM */ PACK( 0, 1 ), + /* MPS */ PACK( 0, 1 ), + /* FlipON */ PACK( 0, 0 ), + /* FlipOFF */ PACK( 0, 0 ), + /* DEBUG */ PACK( 1, 0 ), + + /* LT */ PACK( 2, 1 ), + /* LTEQ */ PACK( 2, 1 ), + /* GT */ PACK( 2, 1 ), + /* GTEQ */ PACK( 2, 1 ), + /* EQ */ PACK( 2, 1 ), + /* NEQ */ PACK( 2, 1 ), + /* ODD */ PACK( 1, 1 ), + /* EVEN */ PACK( 1, 1 ), + /* IF */ PACK( 1, 0 ), + /* EIF */ PACK( 0, 0 ), + /* AND */ PACK( 2, 1 ), + /* OR */ PACK( 2, 1 ), + /* NOT */ PACK( 1, 1 ), + /* DeltaP1 */ PACK( 1, 0 ), + /* SDB */ PACK( 1, 0 ), + /* SDS */ PACK( 1, 0 ), + + /* ADD */ PACK( 2, 1 ), + /* SUB */ PACK( 2, 1 ), + /* DIV */ PACK( 2, 1 ), + /* MUL */ PACK( 2, 1 ), + /* ABS */ PACK( 1, 1 ), + /* NEG */ PACK( 1, 1 ), + /* FLOOR */ PACK( 1, 1 ), + /* CEILING */ PACK( 1, 1 ), + /* ROUND[0] */ PACK( 1, 1 ), + /* ROUND[1] */ PACK( 1, 1 ), + /* ROUND[2] */ PACK( 1, 1 ), + /* ROUND[3] */ PACK( 1, 1 ), + /* NROUND[0] */ PACK( 1, 1 ), + /* NROUND[1] */ PACK( 1, 1 ), + /* NROUND[2] */ PACK( 1, 1 ), + /* NROUND[3] */ PACK( 1, 1 ), + + /* WCvtF */ PACK( 2, 0 ), + /* DeltaP2 */ PACK( 1, 0 ), + /* DeltaP3 */ PACK( 1, 0 ), + /* DeltaCn[0] */ PACK( 1, 0 ), + /* DeltaCn[1] */ PACK( 1, 0 ), + /* DeltaCn[2] */ PACK( 1, 0 ), + /* SROUND */ PACK( 1, 0 ), + /* S45Round */ PACK( 1, 0 ), + /* JROT */ PACK( 2, 0 ), + /* JROF */ PACK( 2, 0 ), + /* ROFF */ PACK( 0, 0 ), + /* INS_$7B */ PACK( 0, 0 ), + /* RUTG */ PACK( 0, 0 ), + /* RDTG */ PACK( 0, 0 ), + /* SANGW */ PACK( 1, 0 ), + /* AA */ PACK( 1, 0 ), + + /* FlipPT */ PACK( 0, 0 ), + /* FlipRgON */ PACK( 2, 0 ), + /* FlipRgOFF */ PACK( 2, 0 ), + /* INS_$83 */ PACK( 0, 0 ), + /* INS_$84 */ PACK( 0, 0 ), + /* ScanCTRL */ PACK( 1, 0 ), + /* SDVPTL[0] */ PACK( 2, 0 ), + /* SDVPTL[1] */ PACK( 2, 0 ), + /* GetINFO */ PACK( 1, 1 ), + /* IDEF */ PACK( 1, 0 ), + /* ROLL */ PACK( 3, 3 ), + /* MAX */ PACK( 2, 1 ), + /* MIN */ PACK( 2, 1 ), + /* ScanTYPE */ PACK( 1, 0 ), + /* InstCTRL */ PACK( 2, 0 ), + /* INS_$8F */ PACK( 0, 0 ), + + /* INS_$90 */ PACK( 0, 0 ), + /* INS_$91 */ PACK( 0, 0 ), + /* INS_$92 */ PACK( 0, 0 ), + /* INS_$93 */ PACK( 0, 0 ), + /* INS_$94 */ PACK( 0, 0 ), + /* INS_$95 */ PACK( 0, 0 ), + /* INS_$96 */ PACK( 0, 0 ), + /* INS_$97 */ PACK( 0, 0 ), + /* INS_$98 */ PACK( 0, 0 ), + /* INS_$99 */ PACK( 0, 0 ), + /* INS_$9A */ PACK( 0, 0 ), + /* INS_$9B */ PACK( 0, 0 ), + /* INS_$9C */ PACK( 0, 0 ), + /* INS_$9D */ PACK( 0, 0 ), + /* INS_$9E */ PACK( 0, 0 ), + /* INS_$9F */ PACK( 0, 0 ), + + /* INS_$A0 */ PACK( 0, 0 ), + /* INS_$A1 */ PACK( 0, 0 ), + /* INS_$A2 */ PACK( 0, 0 ), + /* INS_$A3 */ PACK( 0, 0 ), + /* INS_$A4 */ PACK( 0, 0 ), + /* INS_$A5 */ PACK( 0, 0 ), + /* INS_$A6 */ PACK( 0, 0 ), + /* INS_$A7 */ PACK( 0, 0 ), + /* INS_$A8 */ PACK( 0, 0 ), + /* INS_$A9 */ PACK( 0, 0 ), + /* INS_$AA */ PACK( 0, 0 ), + /* INS_$AB */ PACK( 0, 0 ), + /* INS_$AC */ PACK( 0, 0 ), + /* INS_$AD */ PACK( 0, 0 ), + /* INS_$AE */ PACK( 0, 0 ), + /* INS_$AF */ PACK( 0, 0 ), + + /* PushB[0] */ PACK( 0, 1 ), + /* PushB[1] */ PACK( 0, 2 ), + /* PushB[2] */ PACK( 0, 3 ), + /* PushB[3] */ PACK( 0, 4 ), + /* PushB[4] */ PACK( 0, 5 ), + /* PushB[5] */ PACK( 0, 6 ), + /* PushB[6] */ PACK( 0, 7 ), + /* PushB[7] */ PACK( 0, 8 ), + /* PushW[0] */ PACK( 0, 1 ), + /* PushW[1] */ PACK( 0, 2 ), + /* PushW[2] */ PACK( 0, 3 ), + /* PushW[3] */ PACK( 0, 4 ), + /* PushW[4] */ PACK( 0, 5 ), + /* PushW[5] */ PACK( 0, 6 ), + /* PushW[6] */ PACK( 0, 7 ), + /* PushW[7] */ PACK( 0, 8 ), + + /* MDRP[00] */ PACK( 1, 0 ), + /* MDRP[01] */ PACK( 1, 0 ), + /* MDRP[02] */ PACK( 1, 0 ), + /* MDRP[03] */ PACK( 1, 0 ), + /* MDRP[04] */ PACK( 1, 0 ), + /* MDRP[05] */ PACK( 1, 0 ), + /* MDRP[06] */ PACK( 1, 0 ), + /* MDRP[07] */ PACK( 1, 0 ), + /* MDRP[08] */ PACK( 1, 0 ), + /* MDRP[09] */ PACK( 1, 0 ), + /* MDRP[10] */ PACK( 1, 0 ), + /* MDRP[11] */ PACK( 1, 0 ), + /* MDRP[12] */ PACK( 1, 0 ), + /* MDRP[13] */ PACK( 1, 0 ), + /* MDRP[14] */ PACK( 1, 0 ), + /* MDRP[15] */ PACK( 1, 0 ), + + /* MDRP[16] */ PACK( 1, 0 ), + /* MDRP[17] */ PACK( 1, 0 ), + /* MDRP[18] */ PACK( 1, 0 ), + /* MDRP[19] */ PACK( 1, 0 ), + /* MDRP[20] */ PACK( 1, 0 ), + /* MDRP[21] */ PACK( 1, 0 ), + /* MDRP[22] */ PACK( 1, 0 ), + /* MDRP[23] */ PACK( 1, 0 ), + /* MDRP[24] */ PACK( 1, 0 ), + /* MDRP[25] */ PACK( 1, 0 ), + /* MDRP[26] */ PACK( 1, 0 ), + /* MDRP[27] */ PACK( 1, 0 ), + /* MDRP[28] */ PACK( 1, 0 ), + /* MDRP[29] */ PACK( 1, 0 ), + /* MDRP[30] */ PACK( 1, 0 ), + /* MDRP[31] */ PACK( 1, 0 ), + + /* MIRP[00] */ PACK( 2, 0 ), + /* MIRP[01] */ PACK( 2, 0 ), + /* MIRP[02] */ PACK( 2, 0 ), + /* MIRP[03] */ PACK( 2, 0 ), + /* MIRP[04] */ PACK( 2, 0 ), + /* MIRP[05] */ PACK( 2, 0 ), + /* MIRP[06] */ PACK( 2, 0 ), + /* MIRP[07] */ PACK( 2, 0 ), + /* MIRP[08] */ PACK( 2, 0 ), + /* MIRP[09] */ PACK( 2, 0 ), + /* MIRP[10] */ PACK( 2, 0 ), + /* MIRP[11] */ PACK( 2, 0 ), + /* MIRP[12] */ PACK( 2, 0 ), + /* MIRP[13] */ PACK( 2, 0 ), + /* MIRP[14] */ PACK( 2, 0 ), + /* MIRP[15] */ PACK( 2, 0 ), + + /* MIRP[16] */ PACK( 2, 0 ), + /* MIRP[17] */ PACK( 2, 0 ), + /* MIRP[18] */ PACK( 2, 0 ), + /* MIRP[19] */ PACK( 2, 0 ), + /* MIRP[20] */ PACK( 2, 0 ), + /* MIRP[21] */ PACK( 2, 0 ), + /* MIRP[22] */ PACK( 2, 0 ), + /* MIRP[23] */ PACK( 2, 0 ), + /* MIRP[24] */ PACK( 2, 0 ), + /* MIRP[25] */ PACK( 2, 0 ), + /* MIRP[26] */ PACK( 2, 0 ), + /* MIRP[27] */ PACK( 2, 0 ), + /* MIRP[28] */ PACK( 2, 0 ), + /* MIRP[29] */ PACK( 2, 0 ), + /* MIRP[30] */ PACK( 2, 0 ), + /* MIRP[31] */ PACK( 2, 0 ) + }; + + static const TT_Vector Null_Vector = {0,0}; + +#undef NULL_Vector +#define NULL_Vector (TT_Vector*)&Null_Vector + +/******************************************************************* + * + * Function : Norm + * + * Description : Returns the norm (length) of a vector. + * + * Input : X, Y vector + * + * Output : Returns length in F26dot6. + * + *****************************************************************/ + + static TT_F26Dot6 Norm( TT_F26Dot6 X, TT_F26Dot6 Y ) + { + TT_Int64 T1, T2; + + + MUL_64( X, X, T1 ); + MUL_64( Y, Y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)SQRT_64( T1 ); + } + + +/******************************************************************* + * + * Function : FUnits_To_Pixels + * + * Description : Scale a distance in FUnits to pixel coordinates. + * + * Input : Distance in FUnits + * + * Output : Distance in 26.6 format. + * + *****************************************************************/ + + static TT_F26Dot6 FUnits_To_Pixels( EXEC_OPS Short distance ) + { + return TT_MulDiv( distance, + CUR.metrics.scale1, + CUR.metrics.scale2 ); + } + + +/******************************************************************* + * + * Function : Current_Ratio + * + * Description : Return the current aspect ratio scaling factor + * depending on the projection vector's state and + * device resolutions. + * + * Input : None + * + * Output : Aspect ratio in 16.16 format, always <= 1.0 . + * + *****************************************************************/ + + static Long Current_Ratio( EXEC_OP ) + { + if ( CUR.metrics.ratio ) + return CUR.metrics.ratio; + + if ( CUR.GS.projVector.y == 0 ) + CUR.metrics.ratio = CUR.metrics.x_ratio; + + else if ( CUR.GS.projVector.x == 0 ) + CUR.metrics.ratio = CUR.metrics.y_ratio; + + else + { + Long x, y; + + + x = TT_MulDiv( CUR.GS.projVector.x, CUR.metrics.x_ratio, 0x4000 ); + y = TT_MulDiv( CUR.GS.projVector.y, CUR.metrics.y_ratio, 0x4000 ); + CUR.metrics.ratio = Norm( x, y ); + } + + return CUR.metrics.ratio; + } + + + static Long Current_Ppem( EXEC_OP ) + { + return TT_MulFix( CUR.metrics.ppem, CURRENT_Ratio() ); + } + + + static TT_F26Dot6 Read_CVT( EXEC_OPS ULong index ) + { + return CUR.cvt[index]; + } + + + static TT_F26Dot6 Read_CVT_Stretched( EXEC_OPS ULong index ) + { + return TT_MulFix( CUR.cvt[index], CURRENT_Ratio() ); + } + + + static void Write_CVT( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] = value; + } + + static void Write_CVT_Stretched( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] = TT_MulDiv( value, 0x10000, CURRENT_Ratio() ); + } + + + static void Move_CVT( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] += value; + } + + static void Move_CVT_Stretched( EXEC_OPS ULong index, TT_F26Dot6 value ) + { + CUR.cvt[index] += TT_MulDiv( value, 0x10000, CURRENT_Ratio() ); + } + + +/****************************************************************** + * + * Function : Calc_Length + * + * Description : Computes the length in bytes of current opcode. + * + *****************************************************************/ + + static Bool Calc_Length( EXEC_OP ) + { + CUR.opcode = CUR.code[CUR.IP]; + + switch ( CUR.opcode ) + { + case 0x40: + if ( CUR.IP + 1 >= CUR.codeSize ) + return FAILURE; + + CUR.length = CUR.code[CUR.IP + 1] + 2; + break; + + case 0x41: + if ( CUR.IP + 1 >= CUR.codeSize ) + return FAILURE; + + CUR.length = CUR.code[CUR.IP + 1] * 2 + 2; + break; + + case 0xB0: + case 0xB1: + case 0xB2: + case 0xB3: + case 0xB4: + case 0xB5: + case 0xB6: + case 0xB7: + CUR.length = CUR.opcode - 0xB0 + 2; + break; + + case 0xB8: + case 0xB9: + case 0xBA: + case 0xBB: + case 0xBC: + case 0xBD: + case 0xBE: + case 0xBF: + CUR.length = (CUR.opcode - 0xB8) * 2 + 3; + break; + + default: + CUR.length = 1; + break; + } + + /* make sure result is in range */ + + if ( CUR.IP + CUR.length > CUR.codeSize ) + return FAILURE; + + return SUCCESS; + } + + +/******************************************************************* + * + * Function : GetShortIns + * + * Description : Returns a short integer taken from the instruction + * stream at address IP. + * + * Input : None + * + * Output : Short read at Code^[IP..IP+1] + * + * Notes : This one could become a Macro in the C version. + * + *****************************************************************/ + + static Short GetShortIns( EXEC_OP ) + { + /* Reading a byte stream so there is no endianess (DaveP) */ + CUR.IP += 2; + return (Short)((CUR.code[CUR.IP - 2] << 8) + CUR.code[CUR.IP - 1]); + } + + +/******************************************************************* + * + * Function : Ins_Goto_CodeRange + * + * Description : Goes to a certain code range in the instruction + * stream. + * + * + * Input : aRange + * aIP + * + * Output : SUCCESS or FAILURE. + * + *****************************************************************/ + + static Bool Ins_Goto_CodeRange( EXEC_OPS Int aRange, ULong aIP ) + { + TCodeRange* WITH; + + + if ( aRange < 1 || aRange > 3 ) + { + CUR.error = TT_Err_Bad_Argument; + return FAILURE; + } + + WITH = &CUR.codeRangeTable[aRange - 1]; + + if ( WITH->Base == NULL ) /* invalid coderange */ + { + CUR.error = TT_Err_Invalid_CodeRange; + return FAILURE; + } + + /* NOTE: Because the last instruction of a program may be a CALL */ + /* which will return to the first byte *after* the code */ + /* range, we test for aIP <= Size, instead of aIP < Size. */ + + if ( aIP > WITH->Size ) + { + CUR.error = TT_Err_Code_Overflow; + return FAILURE; + } + + CUR.code = WITH->Base; + CUR.codeSize = WITH->Size; + CUR.IP = aIP; + CUR.curRange = aRange; + + return SUCCESS; + } + + +/******************************************************************* + * + * Function : Direct_Move + * + * Description : Moves a point by a given distance along the + * freedom vector. The point will be touched. + * + * Input : point index of point to move + * distance distance to apply + * zone affected glyph zone + * + * Output : None + * + *****************************************************************/ + + static void Direct_Move( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ) + { + TT_F26Dot6 v; + + + v = CUR.GS.freeVector.x; + + if ( v != 0 ) + { + zone->cur[point].x += TT_MulDiv( distance, + v * 0x10000L, + CUR.F_dot_P ); + + zone->touch[point] |= TT_Flag_Touched_X; + } + + v = CUR.GS.freeVector.y; + + if ( v != 0 ) + { + zone->cur[point].y += TT_MulDiv( distance, + v * 0x10000L, + CUR.F_dot_P ); + + zone->touch[point] |= TT_Flag_Touched_Y; + } + } + + +/******************************************************************/ +/* */ +/* The following versions are used whenever both vectors are both */ +/* along one of the coordinate unit vectors, i.e. in 90% cases. */ +/* */ +/******************************************************************/ + +/******************************************************************* + * Direct_Move_X + * + *******************************************************************/ + + static void Direct_Move_X( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ) + { + zone->cur[point].x += distance; + zone->touch[point] |= TT_Flag_Touched_X; + } + + +/******************************************************************* + * Direct_Move_Y + * + *******************************************************************/ + + static void Direct_Move_Y( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ) + { + zone->cur[point].y += distance; + zone->touch[point] |= TT_Flag_Touched_Y; + } + + +/******************************************************************* + * + * Function : Round_None + * + * Description : Does not round, but adds engine compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : rounded distance. + * + * NOTE : The spec says very few about the relationship between + * rounding and engine compensation. However, it seems + * from the description of super round that we should + * should add the compensation before rounding. + * + ******************************************************************/ + + static TT_F26Dot6 Round_None( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation; + if ( val < 0 ) + val = 0; + } + else { + val = distance - compensation; + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_To_Grid + * + * Description : Rounds value to grid after adding engine + * compensation + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_To_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation + 32; + if ( val > 0 ) + val &= ~63; + else + val = 0; + } + else + { + val = -( (compensation - distance + 32) & (-64) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_To_Half_Grid + * + * Description : Rounds value to half grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_To_Half_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = ((distance + compensation) & (-64)) + 32; + if ( val < 0 ) + val = 0; + } + else + { + val = -( ((compensation - distance) & (-64)) + 32 ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Down_To_Grid + * + * Description : Rounds value down to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Down_To_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation; + if ( val > 0 ) + val &= ~63; + else + val = 0; + } + else + { + val = -( (compensation - distance) & (-64) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Up_To_Grid + * + * Description : Rounds value up to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Up_To_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation + 63; + if ( val > 0 ) + val &= ~63; + else + val = 0; + } + else + { + val = -( (compensation - distance + 63) & (-64) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_To_Double_Grid + * + * Description : Rounds value to double grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + *****************************************************************/ + + static TT_F26Dot6 Round_To_Double_Grid( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = distance + compensation + 16; + if ( val > 0 ) + val &= ~31; + else + val = 0; + } + else + { + val = -( (compensation - distance + 16) & (-32) ); + if ( val > 0 ) + val = 0; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Super + * + * Description : Super-rounds value to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + * NOTE : The spec says very few about the relationship between + * rounding and engine compensation. However, it seems + * from the description of super round that we should + * should add the compensation before rounding. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Super( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = (distance - CUR.phase + CUR.threshold + compensation) & + (-CUR.period); + if ( val < 0 ) + val = 0; + val += CUR.phase; + } + else + { + val = -( (CUR.threshold - CUR.phase - distance + compensation) & + (-CUR.period) ); + if ( val > 0 ) + val = 0; + val -= CUR.phase; + } + + return val; + } + + +/******************************************************************* + * + * Function : Round_Super_45 + * + * Description : Super-rounds value to grid after adding engine + * compensation. + * + * Input : distance : distance to round + * compensation : engine compensation + * + * Output : Rounded distance. + * + * NOTE : There is a separate function for Round_Super_45 as we + * may need a greater precision. + * + *****************************************************************/ + + static TT_F26Dot6 Round_Super_45( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ) + { + TT_F26Dot6 val; + + + if ( distance >= 0 ) + { + val = ( (distance - CUR.phase + CUR.threshold + compensation) / + CUR.period ) * CUR.period; + if ( val < 0 ) + val = 0; + val += CUR.phase; + } + else + { + val = -( ( (CUR.threshold - CUR.phase - distance + compensation) / + CUR.period ) * CUR.period ); + if ( val > 0 ) + val = 0; + val -= CUR.phase; + } + + return val; + } + + +/******************************************************************* + * Compute_Round + * + *****************************************************************/ + + static void Compute_Round( EXEC_OPS Byte round_mode ) + { + switch ( round_mode ) + { + case TT_Round_Off: + CUR.func_round = (TRound_Function)Round_None; + break; + + case TT_Round_To_Grid: + CUR.func_round = (TRound_Function)Round_To_Grid; + break; + + case TT_Round_Up_To_Grid: + CUR.func_round = (TRound_Function)Round_Up_To_Grid; + break; + + case TT_Round_Down_To_Grid: + CUR.func_round = (TRound_Function)Round_Down_To_Grid; + break; + + case TT_Round_To_Half_Grid: + CUR.func_round = (TRound_Function)Round_To_Half_Grid; + break; + + case TT_Round_To_Double_Grid: + CUR.func_round = (TRound_Function)Round_To_Double_Grid; + break; + + case TT_Round_Super: + CUR.func_round = (TRound_Function)Round_Super; + break; + + case TT_Round_Super_45: + CUR.func_round = (TRound_Function)Round_Super_45; + break; + } + } + + +/******************************************************************* + * + * Function : SetSuperRound + * + * Description : Sets Super Round parameters. + * + * Input : GridPeriod Grid period + * selector SROUND opcode + * + * Output : None. + * + *****************************************************************/ + + static void SetSuperRound( EXEC_OPS TT_F26Dot6 GridPeriod, + Long selector ) + { + switch ( (Int)(selector & 0xC0) ) + { + case 0: + CUR.period = GridPeriod / 2; + break; + + case 0x40: + CUR.period = GridPeriod; + break; + + case 0x80: + CUR.period = GridPeriod * 2; + break; + + /* This opcode is reserved, but... */ + + case 0xC0: + CUR.period = GridPeriod; + break; + } + + switch ( (Int)(selector & 0x30) ) + { + case 0: + CUR.phase = 0; + break; + + case 0x10: + CUR.phase = CUR.period / 4; + break; + + case 0x20: + CUR.phase = CUR.period / 2; + break; + + case 0x30: + CUR.phase = GridPeriod * 3 / 4; + break; + } + + if ( (selector & 0x0F) == 0 ) + CUR.threshold = CUR.period - 1; + else + CUR.threshold = ( (Int)(selector & 0x0F) - 4 ) * CUR.period / 8; + + CUR.period /= 256; + CUR.phase /= 256; + CUR.threshold /= 256; + } + + +/******************************************************************* + * + * Function : Project + * + * Description : Computes the projection of vector given by (v2-v1) + * along the current projection vector. + * + * Input : v1, v2 input vector + * + * Output : Returns distance in F26dot6 format. + * + *****************************************************************/ + + static TT_F26Dot6 Project( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + TT_Int64 T1, T2; + + + MUL_64( v1->x - v2->x, CUR.GS.projVector.x, T1 ); + MUL_64( v1->y - v2->y, CUR.GS.projVector.y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)DIV_64( T1, 0x4000L ); + } + + +/******************************************************************* + * + * Function : Dual_Project + * + * Description : Computes the projection of the vector given by + * (v2-v1) along the current dual vector. + * + * Input : v1, v2 input vector + * + * Output : Returns distance in F26dot6 format. + * + *****************************************************************/ + + static TT_F26Dot6 Dual_Project( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + TT_Int64 T1, T2; + + + MUL_64( v1->x - v2->x, CUR.GS.dualVector.x, T1 ); + MUL_64( v1->y - v2->y, CUR.GS.dualVector.y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)DIV_64( T1, 0x4000L ); + } + + +/******************************************************************* + * + * Function : Free_Project + * + * Description : Computes the projection of the vector given by + * (v2-v1) along the current freedom vector. + * + * Input : v1, v2 input vector + * + * Output : Returns distance in F26dot6 format. + * + *****************************************************************/ + + static TT_F26Dot6 Free_Project( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + TT_Int64 T1, T2; + + + MUL_64( v1->x - v2->x, CUR.GS.freeVector.x, T1 ); + MUL_64( v1->y - v2->y, CUR.GS.freeVector.y, T2 ); + + ADD_64( T1, T2, T1 ); + + return (TT_F26Dot6)DIV_64( T1, 0x4000L ); + } + + +/******************************************************************* + * + * Function : Project_x + * + * Input : Vx, Vy input vector + * + * Output : Returns Vx. + * + * Note : Used as a dummy function. + * + *****************************************************************/ + + static TT_F26Dot6 Project_x( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + return (v1->x - v2->x); + } + + +/******************************************************************* + * + * Function : Project_y + * + * Input : Vx, Vy input vector + * + * Output : Returns Vy. + * + * Note : Used as a dummy function. + * + *****************************************************************/ + + static TT_F26Dot6 Project_y( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ) + { + return (v1->y - v2->y); + } + + +/******************************************************************* + * + * Function : Compute_Funcs + * + * Description : Computes the projections and movement function + * pointers according to the current graphics state. + * + * Input : None + * + *****************************************************************/ + + static void Compute_Funcs( EXEC_OP ) + { + if ( CUR.GS.freeVector.x == 0x4000 ) + { + CUR.func_freeProj = (TProject_Function)Project_x; + CUR.F_dot_P = CUR.GS.projVector.x * 0x10000L; + } + else + { + if ( CUR.GS.freeVector.y == 0x4000 ) + { + CUR.func_freeProj = (TProject_Function)Project_y; + CUR.F_dot_P = CUR.GS.projVector.y * 0x10000L; + } + else + { + CUR.func_freeProj = (TProject_Function)Free_Project; + CUR.F_dot_P = (Long)CUR.GS.projVector.x * CUR.GS.freeVector.x * 4 + + (Long)CUR.GS.projVector.y * CUR.GS.freeVector.y * 4; + } + } + + CUR.cached_metrics = FALSE; + + if ( CUR.GS.projVector.x == 0x4000 ) + CUR.func_project = (TProject_Function)Project_x; + else + { + if ( CUR.GS.projVector.y == 0x4000 ) + CUR.func_project = (TProject_Function)Project_y; + else + CUR.func_project = (TProject_Function)Project; + } + + if ( CUR.GS.dualVector.x == 0x4000 ) + CUR.func_dualproj = (TProject_Function)Project_x; + else + { + if ( CUR.GS.dualVector.y == 0x4000 ) + CUR.func_dualproj = (TProject_Function)Project_y; + else + CUR.func_dualproj = (TProject_Function)Dual_Project; + } + + CUR.func_move = (TMove_Function)Direct_Move; + + if ( CUR.F_dot_P == 0x40000000L ) + { + if ( CUR.GS.freeVector.x == 0x4000 ) + CUR.func_move = (TMove_Function)Direct_Move_X; + else + { + if ( CUR.GS.freeVector.y == 0x4000 ) + CUR.func_move = (TMove_Function)Direct_Move_Y; + } + } + + /* at small sizes, F_dot_P can become too small, resulting */ + /* in overflows and 'spikes' in a number of glyphs like 'w'. */ + + if ( ABS( CUR.F_dot_P ) < 0x4000000L ) + CUR.F_dot_P = 0x40000000L; + + /* Disable cached aspect ratio */ + CUR.metrics.ratio = 0; + } + + +/******************************************************************* + * + * Function : Normalize + * + * Description : Norms a vector + * + * Input : Vx, Vy input vector + * R normed unit vector + * + * Output : Returns FAILURE if a vector parameter is zero. + * + *****************************************************************/ + + static Bool Normalize( EXEC_OPS TT_F26Dot6 Vx, + TT_F26Dot6 Vy, + TT_UnitVector* R ) + { + TT_F26Dot6 W; + Bool S1, S2; + + + if ( ABS( Vx ) < 0x10000L && ABS( Vy ) < 0x10000L ) + { + Vx *= 0x100; + Vy *= 0x100; + + W = Norm( Vx, Vy ); + + if ( W == 0 ) + { + /* XXX : UNDOCUMENTED! It seems that it's possible to try */ + /* to normalize the vector (0,0). Return immediately */ + return SUCCESS; + } + + R->x = (TT_F2Dot14)TT_MulDiv( Vx, 0x4000L, W ); + R->y = (TT_F2Dot14)TT_MulDiv( Vy, 0x4000L, W ); + + return SUCCESS; + } + + W = Norm( Vx, Vy ); + + Vx = TT_MulDiv( Vx, 0x4000L, W ); + Vy = TT_MulDiv( Vy, 0x4000L, W ); + + W = Vx * Vx + Vy * Vy; + + /* Now, we want that Sqrt( W ) = 0x4000 */ + /* Or 0x1000000 <= W < 0x1004000 */ + + if ( Vx < 0 ) + { + Vx = -Vx; + S1 = TRUE; + } + else + S1 = FALSE; + + if ( Vy < 0 ) + { + Vy = -Vy; + S2 = TRUE; + } + else + S2 = FALSE; + + while ( W < 0x1000000L ) + { + /* We need to increase W, by a minimal amount */ + if ( Vx < Vy ) + Vx++; + else + Vy++; + + W = Vx * Vx + Vy * Vy; + } + + while ( W >= 0x1004000L ) + { + /* We need to decrease W, by a minimal amount */ + if ( Vx < Vy ) + Vx--; + else + Vy--; + + W = Vx * Vx + Vy * Vy; + } + + /* Note that in various cases, we can only */ + /* compute a Sqrt(W) of 0x3FFF, eg. Vx = Vy */ + + if ( S1 ) + Vx = -Vx; + + if ( S2 ) + Vy = -Vy; + + R->x = (TT_F2Dot14)Vx; /* Type conversion */ + R->y = (TT_F2Dot14)Vy; /* Type conversion */ + + return SUCCESS; + } + + +/**************************************************************** + * + * Opcodes + * + ****************************************************************/ + + + static Bool Ins_SxVTL( EXEC_OPS UShort aIdx1, + UShort aIdx2, + Int aOpc, + TT_UnitVector* Vec ) + { + Long A, B, C; + TT_Vector* p1; + TT_Vector* p2; + + + if ( BOUNDS( aIdx1, CUR.zp2.n_points ) || + BOUNDS( aIdx2, CUR.zp1.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return FAILURE; + } + + p1 = CUR.zp1.cur + aIdx2; + p2 = CUR.zp2.cur + aIdx1; + + A = p1->x - p2->x; + B = p1->y - p2->y; + + if ( (aOpc & 1) != 0 ) + { + C = B; /* CounterClockwise rotation */ + B = A; + A = -C; + } + + NORMalize( A, B, Vec ); + return SUCCESS; + } + + +/* When not using the big switch statements, the interpreter uses a */ +/* call table defined later below in this source. Each opcode must */ +/* thus have a corresponding function, even trivial ones. */ +/* */ +/* They're all defined there. */ + +#define DO_SVTCA \ + { \ + Short A, B; \ + \ + \ + A = (Short)(CUR.opcode & 1) << 14; \ + B = A ^ (Short)0x4000; \ + \ + CUR.GS.freeVector.x = A; \ + CUR.GS.projVector.x = A; \ + CUR.GS.dualVector.x = A; \ + \ + CUR.GS.freeVector.y = B; \ + CUR.GS.projVector.y = B; \ + CUR.GS.dualVector.y = B; \ + \ + COMPUTE_Funcs(); \ + } + + +#define DO_SPVTCA \ + { \ + Short A, B; \ + \ + \ + A = (Short)(CUR.opcode & 1) << 14; \ + B = A ^ (Short)0x4000; \ + \ + CUR.GS.projVector.x = A; \ + CUR.GS.dualVector.x = A; \ + \ + CUR.GS.projVector.y = B; \ + CUR.GS.dualVector.y = B; \ + \ + COMPUTE_Funcs(); \ + } + + +#define DO_SFVTCA \ + { \ + Short A, B; \ + \ + \ + A = (Short)(CUR.opcode & 1) << 14; \ + B = A ^ (Short)0x4000; \ + \ + CUR.GS.freeVector.x = A; \ + CUR.GS.freeVector.y = B; \ + \ + COMPUTE_Funcs(); \ + } + + +#define DO_SPVTL \ + if ( INS_SxVTL( (UShort)args[1], \ + (UShort)args[0], \ + CUR.opcode, \ + &CUR.GS.projVector) == SUCCESS ) \ + { \ + CUR.GS.dualVector = CUR.GS.projVector; \ + COMPUTE_Funcs(); \ + } + + +#define DO_SFVTL \ + if ( INS_SxVTL( (UShort)args[1], \ + (UShort)args[0], \ + CUR.opcode, \ + &CUR.GS.freeVector) == SUCCESS ) \ + COMPUTE_Funcs(); + + +#define DO_SFVTPV \ + CUR.GS.freeVector = CUR.GS.projVector; \ + COMPUTE_Funcs(); + + +#define DO_SPVFS \ + { \ + Short S; \ + Long X, Y; \ + \ + \ + /* Only use low 16bits, then sign extend */ \ + S = (Short)args[1]; \ + Y = (Long)S; \ + S = (Short)args[0]; \ + X = (Long)S; \ + \ + NORMalize( X, Y, &CUR.GS.projVector ); \ + \ + CUR.GS.dualVector = CUR.GS.projVector; \ + COMPUTE_Funcs(); \ + } + + +#define DO_SFVFS \ + { \ + Short S; \ + Long X, Y; \ + \ + \ + /* Only use low 16bits, then sign extend */ \ + S = (Short)args[1]; \ + Y = (Long)S; \ + S = (Short)args[0]; \ + X = S; \ + \ + NORMalize( X, Y, &CUR.GS.freeVector ); \ + COMPUTE_Funcs(); \ + } + + +#define DO_GPV \ + args[0] = CUR.GS.projVector.x; \ + args[1] = CUR.GS.projVector.y; + + +#define DO_GFV \ + args[0] = CUR.GS.freeVector.x; \ + args[1] = CUR.GS.freeVector.y; + + +#define DO_SRP0 \ + CUR.GS.rp0 = (UShort)args[0]; + + +#define DO_SRP1 \ + CUR.GS.rp1 = (UShort)args[0]; + + +#define DO_SRP2 \ + CUR.GS.rp2 = (UShort)args[0]; + + +#define DO_RTHG \ + CUR.GS.round_state = TT_Round_To_Half_Grid; \ + CUR.func_round = (TRound_Function)Round_To_Half_Grid; + + +#define DO_RTG \ + CUR.GS.round_state = TT_Round_To_Grid; \ + CUR.func_round = (TRound_Function)Round_To_Grid; + + +#define DO_RTDG \ + CUR.GS.round_state = TT_Round_To_Double_Grid; \ + CUR.func_round = (TRound_Function)Round_To_Double_Grid; + + +#define DO_RUTG \ + CUR.GS.round_state = TT_Round_Up_To_Grid; \ + CUR.func_round = (TRound_Function)Round_Up_To_Grid; + + +#define DO_RDTG \ + CUR.GS.round_state = TT_Round_Down_To_Grid; \ + CUR.func_round = (TRound_Function)Round_Down_To_Grid; + + +#define DO_ROFF \ + CUR.GS.round_state = TT_Round_Off; \ + CUR.func_round = (TRound_Function)Round_None; + + +#define DO_SROUND \ + SET_SuperRound( 0x4000L, args[0] ); \ + CUR.GS.round_state = TT_Round_Super; \ + CUR.func_round = (TRound_Function)Round_Super; + + +#define DO_S45ROUND \ + SET_SuperRound( 0x2D41L, args[0] ); \ + CUR.GS.round_state = TT_Round_Super_45; \ + CUR.func_round = (TRound_Function)Round_Super_45; + + +#define DO_SLOOP \ + if ( args[0] < 0 ) \ + CUR.error = TT_Err_Bad_Argument; \ + else \ + CUR.GS.loop = args[0]; + + +#define DO_SMD \ + CUR.GS.minimum_distance = (TT_F26Dot6)args[0]; + + +#define DO_SCVTCI \ + CUR.GS.control_value_cutin = (TT_F26Dot6)args[0]; + + +#define DO_SSWCI \ + CUR.GS.single_width_cutin = (TT_F26Dot6)args[0]; + + + /* XXX : UNDOCUMENTED! or bug in the Windows engine? */ + /* */ + /* It seems that the value that is read here is */ + /* expressed in 16.16 format, rather than in */ + /* font units.. */ + /* */ +#define DO_SSW \ + CUR.GS.single_width_value = (TT_F26Dot6)(args[0] >> 10); + + +#define DO_FLIPON \ + CUR.GS.auto_flip = TRUE; + + +#define DO_FLIPOFF \ + CUR.GS.auto_flip = FALSE; + + +#define DO_SDB \ + CUR.GS.delta_base = (Short)args[0]; + + +#define DO_SDS \ + CUR.GS.delta_shift = (Short)args[0]; + + +#define DO_MD /* nothing */ + + +#define DO_MPPEM \ + args[0] = CURRENT_Ppem(); + + +#define DO_MPS \ + args[0] = CUR.metrics.pointSize; + + +#define DO_DUP \ + args[1] = args[0]; + + +#define DO_CLEAR \ + CUR.new_top = 0; + + +#define DO_SWAP \ + { \ + Long L; \ + \ + L = args[0]; \ + args[0] = args[1]; \ + args[1] = L; \ + } + + +#define DO_DEPTH \ + args[0] = CUR.top; + + +#define DO_CINDEX \ + { \ + Long L; \ + \ + \ + L = args[0]; \ + \ + if ( L <= 0 || L > CUR.args ) \ + CUR.error = TT_Err_Invalid_Reference; \ + else \ + args[0] = CUR.stack[CUR.args - L]; \ + } + + +#define DO_JROT \ + if ( args[1] != 0 ) \ + { \ + CUR.IP += args[0]; \ + CUR.step_ins = FALSE; \ + } + + +#define DO_JMPR \ + CUR.IP += args[0]; \ + CUR.step_ins = FALSE; + + +#define DO_JROF \ + if ( args[1] == 0 ) \ + { \ + CUR.IP += args[0]; \ + CUR.step_ins = FALSE; \ + } + + +#define DO_LT \ + args[0] = (args[0] < args[1]); + + +#define DO_LTEQ \ + args[0] = (args[0] <= args[1]); + + +#define DO_GT \ + args[0] = (args[0] > args[1]); + + +#define DO_GTEQ \ + args[0] = (args[0] >= args[1]); + + +#define DO_EQ \ + args[0] = (args[0] == args[1]); + + +#define DO_NEQ \ + args[0] = (args[0] != args[1]); + + +#define DO_ODD \ + args[0] = ( (CUR_Func_round( args[0], 0 ) & 127) == 64 ); + + +#define DO_EVEN \ + args[0] = ( (CUR_Func_round( args[0], 0 ) & 127) == 0 ); + + +#define DO_AND \ + args[0] = ( args[0] && args[1] ); + + +#define DO_OR \ + args[0] = ( args[0] || args[1] ); + + +#define DO_NOT \ + args[0] = !args[0]; + + +#define DO_ADD \ + args[0] += args[1]; + + +#define DO_SUB \ + args[0] -= args[1]; + + +#define DO_DIV \ + if ( args[1] == 0 ) \ + CUR.error = TT_Err_Divide_By_Zero; \ + else \ + args[0] = TT_MulDiv( args[0], 64L, args[1] ); + + +#define DO_MUL \ + args[0] = TT_MulDiv( args[0], args[1], 64L ); + + +#define DO_ABS \ + args[0] = ABS( args[0] ); + + +#define DO_NEG \ + args[0] = -args[0]; + + +#define DO_FLOOR \ + args[0] &= -64; + + +#define DO_CEILING \ + args[0] = (args[0] + 63) & (-64); + + +#define DO_RS \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.storeSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + else \ + args[0] = 0; \ + } \ + else \ + args[0] = CUR.storage[I]; \ + } + + +#define DO_WS \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.storeSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + } \ + else \ + CUR.storage[I] = args[1]; \ + } + + + +#define DO_RCVT \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.cvtSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + else \ + args[0] = 0; \ + } \ + else \ + args[0] = CUR_Func_read_cvt(I); \ + } + + +#define DO_WCVTP \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.cvtSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + } \ + else \ + CUR_Func_write_cvt( I, args[1] ); \ + } + + +#define DO_WCVTF \ + { \ + ULong I = (ULong)args[0]; \ + if ( BOUNDS( I, CUR.cvtSize ) ) \ + { \ + if ( CUR.pedantic_hinting ) \ + { \ + ARRAY_BOUND_ERROR; \ + } \ + } \ + else \ + CUR.cvt[I] = FUnits_To_Pixels( EXEC_ARGS (Short)args[1] ); \ + } + + +#define DO_DEBUG \ + CUR.error = TT_Err_Debug_OpCode; + + +#define DO_ROUND \ + args[0] = CUR_Func_round( args[0], \ + CUR.metrics.compensations[CUR.opcode-0x68] ); + + +#define DO_NROUND \ + args[0] = Round_None( EXEC_ARGS \ + args[0], \ + CUR.metrics.compensations[CUR.opcode - 0x6C] ); + + +#define DO_MAX \ + if ( args[1] > args[0] ) \ + args[0] = args[1]; + + +#define DO_MIN \ + if ( args[1] < args[0] ) \ + args[0] = args[1]; + + +#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH + + +#undef ARRAY_BOUND_ERROR +#define ARRAY_BOUND_ERROR \ + { \ + CUR.error = TT_Err_Invalid_Reference; \ + return; \ + } + + +/*******************************************/ +/* SVTCA[a] : Set F and P vectors to axis */ +/* CodeRange : $00-$01 */ +/* Stack : --> */ + + static void Ins_SVTCA( INS_ARG ) + { + DO_SVTCA + } + + +/*******************************************/ +/* SPVTCA[a] : Set PVector to Axis */ +/* CodeRange : $02-$03 */ +/* Stack : --> */ + + static void Ins_SPVTCA( INS_ARG ) + { + DO_SPVTCA + } + + +/*******************************************/ +/* SFVTCA[a] : Set FVector to Axis */ +/* CodeRange : $04-$05 */ +/* Stack : --> */ + + static void Ins_SFVTCA( INS_ARG ) + { + DO_SFVTCA + } + +/*******************************************/ +/* SPVTL[a] : Set PVector to Line */ +/* CodeRange : $06-$07 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_SPVTL( INS_ARG ) + { + DO_SPVTL + } + + +/*******************************************/ +/* SFVTL[a] : Set FVector to Line */ +/* CodeRange : $08-$09 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_SFVTL( INS_ARG ) + { + DO_SFVTL + } + + +/*******************************************/ +/* SFVTPV[] : Set FVector to PVector */ +/* CodeRange : $0E */ +/* Stack : --> */ + + static void Ins_SFVTPV( INS_ARG ) + { + DO_SFVTPV + } + + +/*******************************************/ +/* SPVFS[] : Set PVector From Stack */ +/* CodeRange : $0A */ +/* Stack : f2.14 f2.14 --> */ + + static void Ins_SPVFS( INS_ARG ) + { + DO_SPVFS + } + + +/*******************************************/ +/* SFVFS[] : Set FVector From Stack */ +/* CodeRange : $0B */ +/* Stack : f2.14 f2.14 --> */ + + static void Ins_SFVFS( INS_ARG ) + { + DO_SFVFS + } + + +/*******************************************/ +/* GPV[] : Get Projection Vector */ +/* CodeRange : $0C */ +/* Stack : ef2.14 --> ef2.14 */ + + static void Ins_GPV( INS_ARG ) + { + DO_GPV + } + + +/*******************************************/ +/* GFV[] : Get Freedom Vector */ +/* CodeRange : $0D */ +/* Stack : ef2.14 --> ef2.14 */ + + static void Ins_GFV( INS_ARG ) + { + DO_GFV + } + + +/*******************************************/ +/* SRP0[] : Set Reference Point 0 */ +/* CodeRange : $10 */ +/* Stack : uint32 --> */ + + static void Ins_SRP0( INS_ARG ) + { + DO_SRP0 + } + + +/*******************************************/ +/* SRP1[] : Set Reference Point 1 */ +/* CodeRange : $11 */ +/* Stack : uint32 --> */ + + static void Ins_SRP1( INS_ARG ) + { + DO_SRP1 + } + + +/*******************************************/ +/* SRP2[] : Set Reference Point 2 */ +/* CodeRange : $12 */ +/* Stack : uint32 --> */ + + static void Ins_SRP2( INS_ARG ) + { + DO_SRP2 + } + + +/*******************************************/ +/* RTHG[] : Round To Half Grid */ +/* CodeRange : $19 */ +/* Stack : --> */ + + static void Ins_RTHG( INS_ARG ) + { + DO_RTHG + } + + +/*******************************************/ +/* RTG[] : Round To Grid */ +/* CodeRange : $18 */ +/* Stack : --> */ + + static void Ins_RTG( INS_ARG ) + { + DO_RTG + } + + +/*******************************************/ +/* RTDG[] : Round To Double Grid */ +/* CodeRange : $3D */ +/* Stack : --> */ + + static void Ins_RTDG( INS_ARG ) + { + DO_RTDG + } + + +/*******************************************/ +/* RUTG[] : Round Up To Grid */ +/* CodeRange : $7C */ +/* Stack : --> */ + + static void Ins_RUTG( INS_ARG ) + { + DO_RUTG + } + + +/*******************************************/ +/* RDTG[] : Round Down To Grid */ +/* CodeRange : $7D */ +/* Stack : --> */ + + static void Ins_RDTG( INS_ARG ) + { + DO_RDTG + } + + +/*******************************************/ +/* ROFF[] : Round OFF */ +/* CodeRange : $7A */ +/* Stack : --> */ + + static void Ins_ROFF( INS_ARG ) + { + DO_ROFF + } + + +/*******************************************/ +/* SROUND[] : Super ROUND */ +/* CodeRange : $76 */ +/* Stack : Eint8 --> */ + + static void Ins_SROUND( INS_ARG ) + { + DO_SROUND + } + + +/*******************************************/ +/* S45ROUND[]: Super ROUND 45 degrees */ +/* CodeRange : $77 */ +/* Stack : uint32 --> */ + + static void Ins_S45ROUND( INS_ARG ) + { + DO_S45ROUND + } + + +/*******************************************/ +/* SLOOP[] : Set LOOP variable */ +/* CodeRange : $17 */ +/* Stack : int32? --> */ + + static void Ins_SLOOP( INS_ARG ) + { + DO_SLOOP + } + + +/*******************************************/ +/* SMD[] : Set Minimum Distance */ +/* CodeRange : $1A */ +/* Stack : f26.6 --> */ + + static void Ins_SMD( INS_ARG ) + { + DO_SMD + } + + +/**********************************************/ +/* SCVTCI[] : Set Control Value Table Cut In */ +/* CodeRange : $1D */ +/* Stack : f26.6 --> */ + + static void Ins_SCVTCI( INS_ARG ) + { + DO_SCVTCI + } + + +/**********************************************/ +/* SSWCI[] : Set Single Width Cut In */ +/* CodeRange : $1E */ +/* Stack : f26.6 --> */ + + static void Ins_SSWCI( INS_ARG ) + { + DO_SSWCI + } + + +/**********************************************/ +/* SSW[] : Set Single Width */ +/* CodeRange : $1F */ +/* Stack : int32? --> */ + + static void Ins_SSW( INS_ARG ) + { + DO_SSW + } + + +/**********************************************/ +/* FLIPON[] : Set Auto_flip to On */ +/* CodeRange : $4D */ +/* Stack : --> */ + + static void Ins_FLIPON( INS_ARG ) + { + DO_FLIPON + } + + +/**********************************************/ +/* FLIPOFF[] : Set Auto_flip to Off */ +/* CodeRange : $4E */ +/* Stack : --> */ + + static void Ins_FLIPOFF( INS_ARG ) + { + DO_FLIPOFF + } + + +/**********************************************/ +/* SANGW[] : Set Angle Weight */ +/* CodeRange : $7E */ +/* Stack : uint32 --> */ + + static void Ins_SANGW( INS_ARG ) + { + /* instruction not supported anymore */ + } + + +/**********************************************/ +/* SDB[] : Set Delta Base */ +/* CodeRange : $5E */ +/* Stack : uint32 --> */ + + static void Ins_SDB( INS_ARG ) + { + DO_SDB + } + + +/**********************************************/ +/* SDS[] : Set Delta Shift */ +/* CodeRange : $5F */ +/* Stack : uint32 --> */ + + static void Ins_SDS( INS_ARG ) + { + DO_SDS + } + + +/**********************************************/ +/* MPPEM[] : Measure Pixel Per EM */ +/* CodeRange : $4B */ +/* Stack : --> Euint16 */ + + static void Ins_MPPEM( INS_ARG ) + { + DO_MPPEM + } + + +/**********************************************/ +/* MPS[] : Measure PointSize */ +/* CodeRange : $4C */ +/* Stack : --> Euint16 */ + + static void Ins_MPS( INS_ARG ) + { + DO_MPS + } + +/*******************************************/ +/* DUP[] : Duplicate top stack element */ +/* CodeRange : $20 */ +/* Stack : StkElt --> StkElt StkElt */ + + static void Ins_DUP( INS_ARG ) + { + DO_DUP + } + + +/*******************************************/ +/* POP[] : POPs the stack's top elt. */ +/* CodeRange : $21 */ +/* Stack : StkElt --> */ + + static void Ins_POP( INS_ARG ) + { + /* nothing to do */ + } + + +/*******************************************/ +/* CLEAR[] : Clear the entire stack */ +/* CodeRange : $22 */ +/* Stack : StkElt... --> */ + + static void Ins_CLEAR( INS_ARG ) + { + DO_CLEAR + } + + +/*******************************************/ +/* SWAP[] : Swap the top two elements */ +/* CodeRange : $23 */ +/* Stack : 2 * StkElt --> 2 * StkElt */ + + static void Ins_SWAP( INS_ARG ) + { + DO_SWAP + } + + +/*******************************************/ +/* DEPTH[] : return the stack depth */ +/* CodeRange : $24 */ +/* Stack : --> uint32 */ + + static void Ins_DEPTH( INS_ARG ) + { + DO_DEPTH + } + + +/*******************************************/ +/* CINDEX[] : copy indexed element */ +/* CodeRange : $25 */ +/* Stack : int32 --> StkElt */ + + static void Ins_CINDEX( INS_ARG ) + { + DO_CINDEX + } + + +/*******************************************/ +/* EIF[] : End IF */ +/* CodeRange : $59 */ +/* Stack : --> */ + + static void Ins_EIF( INS_ARG ) + { + /* nothing to do */ + } + + +/*******************************************/ +/* JROT[] : Jump Relative On True */ +/* CodeRange : $78 */ +/* Stack : StkElt int32 --> */ + + static void Ins_JROT( INS_ARG ) + { + DO_JROT + } + + +/*******************************************/ +/* JMPR[] : JuMP Relative */ +/* CodeRange : $1C */ +/* Stack : int32 --> */ + + static void Ins_JMPR( INS_ARG ) + { + DO_JMPR + } + + +/*******************************************/ +/* JROF[] : Jump Relative On False */ +/* CodeRange : $79 */ +/* Stack : StkElt int32 --> */ + + static void Ins_JROF( INS_ARG ) + { + DO_JROF + } + + +/*******************************************/ +/* LT[] : Less Than */ +/* CodeRange : $50 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_LT( INS_ARG ) + { + DO_LT + } + + +/*******************************************/ +/* LTEQ[] : Less Than or EQual */ +/* CodeRange : $51 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_LTEQ( INS_ARG ) + { + DO_LTEQ + } + + +/*******************************************/ +/* GT[] : Greater Than */ +/* CodeRange : $52 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_GT( INS_ARG ) + { + DO_GT + } + + +/*******************************************/ +/* GTEQ[] : Greater Than or EQual */ +/* CodeRange : $53 */ +/* Stack : int32? int32? --> bool */ + + static void Ins_GTEQ( INS_ARG ) + { + DO_GTEQ + } + + +/*******************************************/ +/* EQ[] : EQual */ +/* CodeRange : $54 */ +/* Stack : StkElt StkElt --> bool */ + + static void Ins_EQ( INS_ARG ) + { + DO_EQ + } + + +/*******************************************/ +/* NEQ[] : Not EQual */ +/* CodeRange : $55 */ +/* Stack : StkElt StkElt --> bool */ + + static void Ins_NEQ( INS_ARG ) + { + DO_NEQ + } + + +/*******************************************/ +/* ODD[] : Odd */ +/* CodeRange : $56 */ +/* Stack : f26.6 --> bool */ + + static void Ins_ODD( INS_ARG ) + { + DO_ODD + } + + +/*******************************************/ +/* EVEN[] : Even */ +/* CodeRange : $57 */ +/* Stack : f26.6 --> bool */ + + static void Ins_EVEN( INS_ARG ) + { + DO_EVEN + } + + +/*******************************************/ +/* AND[] : logical AND */ +/* CodeRange : $5A */ +/* Stack : uint32 uint32 --> uint32 */ + + static void Ins_AND( INS_ARG ) + { + DO_AND + } + + +/*******************************************/ +/* OR[] : logical OR */ +/* CodeRange : $5B */ +/* Stack : uint32 uint32 --> uint32 */ + + static void Ins_OR( INS_ARG ) + { + DO_OR + } + + +/*******************************************/ +/* NOT[] : logical NOT */ +/* CodeRange : $5C */ +/* Stack : StkElt --> uint32 */ + + static void Ins_NOT( INS_ARG ) + { + DO_NOT + } + + +/*******************************************/ +/* ADD[] : ADD */ +/* CodeRange : $60 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_ADD( INS_ARG ) + { + DO_ADD + } + + +/*******************************************/ +/* SUB[] : SUBstract */ +/* CodeRange : $61 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_SUB( INS_ARG ) + { + DO_SUB + } + + +/*******************************************/ +/* DIV[] : DIVide */ +/* CodeRange : $62 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_DIV( INS_ARG ) + { + DO_DIV + } + + +/*******************************************/ +/* MUL[] : MULtiply */ +/* CodeRange : $63 */ +/* Stack : f26.6 f26.6 --> f26.6 */ + + static void Ins_MUL( INS_ARG ) + { + DO_MUL + } + + +/*******************************************/ +/* ABS[] : ABSolute value */ +/* CodeRange : $64 */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_ABS( INS_ARG ) + { + DO_ABS + } + + +/*******************************************/ +/* NEG[] : NEGate */ +/* CodeRange : $65 */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_NEG( INS_ARG ) + { + DO_NEG + } + + +/*******************************************/ +/* FLOOR[] : FLOOR */ +/* CodeRange : $66 */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_FLOOR( INS_ARG ) + { + DO_FLOOR + } + + +/*******************************************/ +/* CEILING[] : CEILING */ +/* CodeRange : $67 */ +/* f26.6 --> f26.6 */ + + static void Ins_CEILING( INS_ARG ) + { + DO_CEILING + } + +/*******************************************/ +/* RS[] : Read Store */ +/* CodeRange : $43 */ +/* Stack : uint32 --> uint32 */ + + static void Ins_RS( INS_ARG ) + { + DO_RS + } + + +/*******************************************/ +/* WS[] : Write Store */ +/* CodeRange : $42 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_WS( INS_ARG ) + { + DO_WS + } + + +/*******************************************/ +/* WCVTP[] : Write CVT in Pixel units */ +/* CodeRange : $44 */ +/* Stack : f26.6 uint32 --> */ + + static void Ins_WCVTP( INS_ARG ) + { + DO_WCVTP + } + + +/*******************************************/ +/* WCVTF[] : Write CVT in FUnits */ +/* CodeRange : $70 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_WCVTF( INS_ARG ) + { + DO_WCVTF + } + + +/*******************************************/ +/* RCVT[] : Read CVT */ +/* CodeRange : $45 */ +/* Stack : uint32 --> f26.6 */ + + static void Ins_RCVT( INS_ARG ) + { + DO_RCVT + } + + +/********************************************/ +/* AA[] : Adjust Angle */ +/* CodeRange : $7F */ +/* Stack : uint32 --> */ + + static void Ins_AA( INS_ARG ) + { + /* Intentional - no longer supported */ + } + + +/********************************************/ +/* DEBUG[] : DEBUG. Unsupported */ +/* CodeRange : $4F */ +/* Stack : uint32 --> */ + +/* NOTE : The original instruction pops a value from the stack */ + + static void Ins_DEBUG( INS_ARG ) + { + DO_DEBUG + } + +/*******************************************/ +/* ROUND[ab] : ROUND value */ +/* CodeRange : $68-$6B */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_ROUND( INS_ARG ) + { + DO_ROUND + } + +/*******************************************/ +/* NROUND[ab]: No ROUNDing of value */ +/* CodeRange : $6C-$6F */ +/* Stack : f26.6 --> f26.6 */ + + static void Ins_NROUND( INS_ARG ) + { + DO_NROUND + } + + + +/*******************************************/ +/* MAX[] : MAXimum */ +/* CodeRange : $68 */ +/* Stack : int32? int32? --> int32 */ + + static void Ins_MAX( INS_ARG ) + { + DO_MAX + } + + +/*******************************************/ +/* MIN[] : MINimum */ +/* CodeRange : $69 */ +/* Stack : int32? int32? --> int32 */ + + static void Ins_MIN( INS_ARG ) + { + DO_MIN + } + + +#endif /* !TT_CONFIG_OPTION_INTERPRETER_SWITCH */ + + +/* The following functions are called as is within the switch statement */ + +/*******************************************/ +/* MINDEX[] : move indexed element */ +/* CodeRange : $26 */ +/* Stack : int32? --> StkElt */ + + static void Ins_MINDEX( INS_ARG ) + { + Long L, K; + + + L = args[0]; + + if ( L <= 0 || L > CUR.args ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + K = CUR.stack[CUR.args - L]; + + MEM_Move( (&CUR.stack[CUR.args - L ]), + (&CUR.stack[CUR.args - L + 1]), + (L - 1) * sizeof ( Long ) ); + + CUR.stack[CUR.args - 1] = K; + } + + +/*******************************************/ +/* ROLL[] : roll top three elements */ +/* CodeRange : $8A */ +/* Stack : 3 * StkElt --> 3 * StkElt */ + + static void Ins_ROLL( INS_ARG ) + { + Long A, B, C; + + + A = args[2]; + B = args[1]; + C = args[0]; + + args[2] = C; + args[1] = A; + args[0] = B; + } + + + +/****************************************************************/ +/* */ +/* MANAGING THE FLOW OF CONTROL */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + + static Bool SkipCode( EXEC_OP ) + { + CUR.IP += CUR.length; + + if ( CUR.IP < CUR.codeSize ) + if ( CALC_Length() == SUCCESS ) + return SUCCESS; + + CUR.error = TT_Err_Code_Overflow; + return FAILURE; + } + + +/*******************************************/ +/* IF[] : IF test */ +/* CodeRange : $58 */ +/* Stack : StkElt --> */ + + static void Ins_IF( INS_ARG ) + { + Int nIfs; + Bool Out; + + + if ( args[0] != 0 ) + return; + + nIfs = 1; + Out = 0; + + do + { + if ( SKIP_Code() == FAILURE ) + return; + + switch ( CUR.opcode ) + { + case 0x58: /* IF */ + nIfs++; + break; + + case 0x1b: /* ELSE */ + Out = (nIfs == 1); + break; + + case 0x59: /* EIF */ + nIfs--; + Out = (nIfs == 0); + break; + } + } while ( Out == 0 ); + } + + +/*******************************************/ +/* ELSE[] : ELSE */ +/* CodeRange : $1B */ +/* Stack : --> */ + + static void Ins_ELSE( INS_ARG ) + { + Int nIfs; + + + nIfs = 1; + + do + { + if ( SKIP_Code() == FAILURE ) + return; + + switch ( CUR.opcode ) + { + case 0x58: /* IF */ + nIfs++; + break; + + case 0x59: /* EIF */ + nIfs--; + break; + } + } while ( nIfs != 0 ); + } + + +/****************************************************************/ +/* */ +/* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + + static PDefRecord Locate_FDef( EXEC_OPS Int n, Bool new_def ) + { + PDefRecord def; + UShort hash; + UShort cnt; + + /* The function table is interpreted as a simple hash table */ + /* with indexes computed modulo maxFDefs and the linear search */ + /* of free cells in the case of a collision. */ + /* Except for some old Apple fonts, all functions in a TrueType */ + /* font fit into 0..maxFDefs - 1 range and the lookup is */ + /* reduced to a single step. */ + + /* Minor optimization. */ + if ( !new_def && ( n < 0 || n > CUR.maxFunc ) ) + return NULL; + + for ( cnt = 0; cnt < CUR.maxFDefs; ++cnt ) + { + hash = ( (UShort)n + cnt ) % CUR.maxFDefs; + def = &CUR.FDefs[ hash ]; + if ( !def->Active ) + return new_def ? def : NULL; + if ( def->Opc == n ) + return def; + } + + /* The table is full and the entry has not been found. */ + return NULL; + } + + +/*******************************************/ +/* FDEF[] : Function DEFinition */ +/* CodeRange : $2C */ +/* Stack : uint32 --> */ + + static void Ins_FDEF( INS_ARG ) + { + Int n; + PDefRecord def; + + + /* check that there is enough room */ + if ( CUR.numFDefs >= CUR.maxFDefs ) + { + /* We could introduce a new error message, but we're too close */ + /* from the release to change all the 'po' files again.. */ + CUR.error = TT_Err_Too_Many_Ins; + return; + } + + n = (Int)args[0]; + if ( n < 0 || (ULong)n != args[0] ) + { + /* Gotcha. Function index is uint32 according to the specs */ + /* but TDefRecord.Opc is defined as Int. We cannot store */ + /* the definition of this function. */ + CUR.error = TT_Err_Bad_Argument; + return; + } + + def = Locate_FDef( EXEC_ARGS n, TRUE ); + if ( !def ) + { + /* Oh, oh. Something is wrong. Locate_FDef should never fail here. */ + CUR.error = TT_Err_Too_Many_Ins; + return; + } + + /* Some font programs are broken enough to redefine functions! */ + if ( !def->Active ) + CUR.numFDefs++; + + def->Range = CUR.curRange; + def->Opc = n; + def->Start = CUR.IP + 1; + def->Active = TRUE; + + if ( n > CUR.maxFunc ) + CUR.maxFunc = n; + + /* Now skip the whole function definition. */ + /* We don't allow nested IDEFS & FDEFs. */ + + while ( SKIP_Code() == SUCCESS ) + { + switch ( CUR.opcode ) + { + case 0x89: /* IDEF */ + case 0x2c: /* FDEF */ + CUR.error = TT_Err_Nested_DEFS; + return; + case 0x2d: /* ENDF */ + return; + } + } + } + + +/*******************************************/ +/* ENDF[] : END Function definition */ +/* CodeRange : $2D */ +/* Stack : --> */ + + static void Ins_ENDF( INS_ARG ) + { + PCallRecord pRec; + + + if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */ + { + CUR.error = TT_Err_ENDF_In_Exec_Stream; + return; + } + + CUR.callTop--; + + pRec = &CUR.callStack[CUR.callTop]; + + pRec->Cur_Count--; + + CUR.step_ins = FALSE; + + if ( pRec->Cur_Count > 0 ) + { + CUR.callTop++; + CUR.IP = pRec->Cur_Restart; + } + else + /* Loop through the current function */ + INS_Goto_CodeRange( pRec->Caller_Range, + pRec->Caller_IP ); + + /* Exit the current call frame. */ + + /* NOTE: When the last intruction of a program */ + /* is a CALL or LOOPCALL, the return address */ + /* is always out of the code range. This is */ + /* a valid address, and it's why we do not test */ + /* the result of Ins_Goto_CodeRange() here! */ + } + + +/*******************************************/ +/* CALL[] : CALL function */ +/* CodeRange : $2B */ +/* Stack : uint32? --> */ + + static void Ins_CALL( INS_ARG ) + { + Int n; + PDefRecord def; + PCallRecord pCrec; + + + n = (Int)args[0]; + def = Locate_FDef( EXEC_ARGS n, FALSE ); + if ( !def ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* check call stack */ + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + pCrec = CUR.callStack + CUR.callTop; + + pCrec->Caller_Range = CUR.curRange; + pCrec->Caller_IP = CUR.IP + 1; + pCrec->Cur_Count = 1; + pCrec->Cur_Restart = def->Start; + + CUR.callTop++; + + INS_Goto_CodeRange( def->Range, + def->Start ); + + CUR.step_ins = FALSE; + } + + +/*******************************************/ +/* LOOPCALL[]: LOOP and CALL function */ +/* CodeRange : $2A */ +/* Stack : uint32? Eint16? --> */ + + static void Ins_LOOPCALL( INS_ARG ) + { + Int n; + Long count; + PDefRecord def; + PCallRecord pTCR; + + + n = (Int)args[1]; + def = Locate_FDef( EXEC_ARGS n, FALSE ); + if ( !def ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + count = (Long)args[0]; + if ( count <= 0 ) + return; + + pTCR = &CUR.callStack[CUR.callTop]; + + pTCR->Caller_Range = CUR.curRange; + pTCR->Caller_IP = CUR.IP + 1; + pTCR->Cur_Count = count; + pTCR->Cur_Restart = def->Start; + + CUR.callTop++; + + INS_Goto_CodeRange( def->Range, + def->Start ); + + CUR.step_ins = FALSE; + } + + +/*******************************************/ +/* IDEF[] : Instruction DEFinition */ +/* CodeRange : $89 */ +/* Stack : Eint8 --> */ + + static void Ins_IDEF( INS_ARG ) + { + Byte opcode; + PDefRecord def; + PDefRecord limit; + + + opcode = (Byte)args[0]; + + /* First of all, look for the same instruction in our table */ + def = CUR.IDefs; + limit = def + CUR.numIDefs; + for ( ; def < limit; def++ ) + if ( def->Opc == opcode ) + break; + + if ( def == limit ) + { + /* check that there is enough room for a new instruction */ + if ( CUR.numIDefs >= CUR.maxIDefs ) + { + /* XXX Bad error code. See FDEF[]. */ + CUR.error = TT_Err_Too_Many_Ins; + return; + } + CUR.numIDefs++; + } + + def->Opc = opcode; + def->Start = CUR.IP + 1; + def->Range = CUR.curRange; + def->Active = TRUE; + + if ( opcode > CUR.maxIns ) + CUR.maxIns = opcode; + + /* Now skip the whole function definition */ + /* We don't allow nested IDEFs & FDEFs. */ + + while ( SKIP_Code() == SUCCESS ) + { + switch ( CUR.opcode ) + { + case 0x89: /* IDEF */ + case 0x2c: /* FDEF */ + CUR.error = TT_Err_Nested_DEFS; + return; + case 0x2d: /* ENDF */ + return; + } + } + } + + +/****************************************************************/ +/* */ +/* PUSHING DATA ONTO THE INTERPRETER STACK */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + +/*******************************************/ +/* NPUSHB[] : PUSH N Bytes */ +/* CodeRange : $40 */ +/* Stack : --> uint32... */ + + static void Ins_NPUSHB( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.code[CUR.IP + 1]; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + for ( K = 1; K <= L; K++ ) + args[K - 1] = CUR.code[CUR.IP + K + 1]; + + CUR.new_top += L; + } + + +/*******************************************/ +/* NPUSHW[] : PUSH N Words */ +/* CodeRange : $41 */ +/* Stack : --> int32... */ + + static void Ins_NPUSHW( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.code[CUR.IP + 1]; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + CUR.IP += 2; + + for ( K = 0; K < L; K++ ) + args[K] = GET_ShortIns(); + + CUR.step_ins = FALSE; + CUR.new_top += L; + } + + +/*******************************************/ +/* PUSHB[abc]: PUSH Bytes */ +/* CodeRange : $B0-$B7 */ +/* Stack : --> uint32... */ + + static void Ins_PUSHB( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.opcode - 0xB0 + 1; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + for ( K = 1; K <= L; K++ ) + args[K - 1] = CUR.code[CUR.IP + K]; + } + + +/*******************************************/ +/* PUSHW[abc]: PUSH Words */ +/* CodeRange : $B8-$BF */ +/* Stack : --> int32... */ + + static void Ins_PUSHW( INS_ARG ) + { + UShort L, K; + + + L = (UShort)CUR.opcode - 0xB8 + 1; + + if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + CUR.IP++; + + for ( K = 0; K < L; K++ ) + args[K] = GET_ShortIns(); + + CUR.step_ins = FALSE; + } + + + +/****************************************************************/ +/* */ +/* MANAGING THE GRAPHICS STATE */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + +/**********************************************/ +/* GC[a] : Get Coordinate projected onto */ +/* CodeRange : $46-$47 */ +/* Stack : uint32 --> f26.6 */ + +/* BULLSHIT: Measures from the original glyph must be taken */ +/* along the dual projection vector! */ + + static void Ins_GC( INS_ARG ) + { + ULong L; + TT_F26Dot6 R; + + + L = (ULong)args[0]; + + if ( BOUNDS( L, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + else + R = 0; + } + else + { + if ( CUR.opcode & 1 ) + R = CUR_Func_dualproj( CUR.zp2.org + L, NULL_Vector ); + else + R = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector ); + } + + args[0] = R; + } + + +/**********************************************/ +/* SCFS[] : Set Coordinate From Stack */ +/* CodeRange : $48 */ +/* Stack : f26.6 uint32 --> */ +/* */ +/* Formula: */ +/* */ +/* OA := OA + ( value - OA.p )/( f.p ) * f */ +/* */ + + static void Ins_SCFS( INS_ARG ) + { + Long K; + UShort L; + + + L = (UShort)args[0]; + + if ( BOUNDS( L, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + K = CUR_Func_project( CUR.zp2.cur + L, NULL_Vector ); + + CUR_Func_move( &CUR.zp2, L, args[1] - K ); + + /* not part of the specs, but here for safety */ + + if ( CUR.GS.gep2 == 0 ) + CUR.zp2.org[L] = CUR.zp2.cur[L]; + } + + +/**********************************************/ +/* MD[a] : Measure Distance */ +/* CodeRange : $49-$4A */ +/* Stack : uint32 uint32 --> f26.6 */ + +/* BULLSHIT: Measure taken in the original glyph must be along */ +/* the dual projection vector. */ + +/* Second BULLSHIT: Flag attributes are inverted! */ +/* 0 => measure distance in original outline */ +/* 1 => measure distance in grid-fitted outline */ + +/* Third one !! : zp0 - zp1, and not "zp2 - zp1" !!! */ +/* */ + + static void Ins_MD( INS_ARG ) + { + UShort K, L; + TT_F26Dot6 D; + + + K = (UShort)args[1]; + L = (UShort)args[0]; + + if( BOUNDS( L, CUR.zp0.n_points ) || + BOUNDS( K, CUR.zp1.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + else + D = 0; + } + else + { + if ( CUR.opcode & 1 ) + D = CUR_Func_project( CUR.zp0.cur + L, CUR.zp1.cur + K ); + else + D = CUR_Func_dualproj( CUR.zp0.org + L, CUR.zp1.org + K ); + } + + args[0] = D; + } + + +/*******************************************/ +/* SDPVTL[a] : Set Dual PVector to Line */ +/* CodeRange : $86-$87 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_SDPVTL( INS_ARG ) + { + Long A, B, C; + UShort p1, p2; /* was Int in pas type ERROR */ + + + p1 = (UShort)args[1]; + p2 = (UShort)args[0]; + + if ( BOUNDS( p2, CUR.zp1.n_points ) || + BOUNDS( p1, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + { + TT_Vector* v1 = CUR.zp1.org + p2; + TT_Vector* v2 = CUR.zp2.org + p1; + + + A = v1->x - v2->x; + B = v1->y - v2->y; + } + + if ( (CUR.opcode & 1) != 0 ) + { + C = B; /* CounterClockwise rotation */ + B = A; + A = -C; + } + + NORMalize( A, B, &CUR.GS.dualVector ); + + { + TT_Vector* v1 = CUR.zp1.cur + p2; + TT_Vector* v2 = CUR.zp2.cur + p1; + + + A = v1->x - v2->x; + B = v1->y - v2->y; + } + + if ( (CUR.opcode & 1) != 0 ) + { + C = B; /* CounterClockwise rotation */ + B = A; + A = -C; + } + + NORMalize( A, B, &CUR.GS.projVector ); + + COMPUTE_Funcs(); + } + + +/*******************************************/ +/* SZP0[] : Set Zone Pointer 0 */ +/* CodeRange : $13 */ +/* Stack : uint32 --> */ + + static void Ins_SZP0( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp0 = CUR.twilight; + break; + + case 1: + CUR.zp0 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.GS.gep0 = (UShort)args[0]; + } + + +/*******************************************/ +/* SZP1[] : Set Zone Pointer 1 */ +/* CodeRange : $14 */ +/* Stack : uint32 --> */ + + static void Ins_SZP1( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp1 = CUR.twilight; + break; + + case 1: + CUR.zp1 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.GS.gep1 = (UShort)args[0]; + } + + +/*******************************************/ +/* SZP2[] : Set Zone Pointer 2 */ +/* CodeRange : $15 */ +/* Stack : uint32 --> */ + + static void Ins_SZP2( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp2 = CUR.twilight; + break; + + case 1: + CUR.zp2 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.GS.gep2 = (UShort)args[0]; + } + + +/*******************************************/ +/* SZPS[] : Set Zone Pointers */ +/* CodeRange : $16 */ +/* Stack : uint32 --> */ + + static void Ins_SZPS( INS_ARG ) + { + switch ( (Int)args[0] ) + { + case 0: + CUR.zp0 = CUR.twilight; + break; + + case 1: + CUR.zp0 = CUR.pts; + break; + + default: + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + CUR.zp1 = CUR.zp0; + CUR.zp2 = CUR.zp0; + + CUR.GS.gep0 = (UShort)args[0]; + CUR.GS.gep1 = (UShort)args[0]; + CUR.GS.gep2 = (UShort)args[0]; + } + + +/*******************************************/ +/* INSTCTRL[]: INSTruction ConTRol */ +/* CodeRange : $8e */ +/* Stack : int32 int32 --> */ + + static void Ins_INSTCTRL( INS_ARG ) + { + Long K, L; + + + K = args[1]; + L = args[0]; + + if ( K < 1 || K > 2 ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( L != 0 ) + L = K; + + CUR.GS.instruct_control = + (Byte)( CUR.GS.instruct_control & ~(Byte)K ) | (Byte)L; + } + + +/*******************************************/ +/* SCANCTRL[]: SCAN ConTRol */ +/* CodeRange : $85 */ +/* Stack : uint32? --> */ + + static void Ins_SCANCTRL( INS_ARG ) + { + Int A; + + + /* Get Threshold */ + A = (Int)(args[0] & 0xFF); + + if ( A == 0xFF ) + { + CUR.GS.scan_control = TRUE; + return; + } + else if ( A == 0 ) + { + CUR.GS.scan_control = FALSE; + return; + } + + A *= 64; + + if ( (args[0] & 0x100) != 0 && CUR.metrics.pointSize <= A ) + CUR.GS.scan_control = TRUE; + + if ( (args[0] & 0x200) != 0 && CUR.metrics.rotated ) + CUR.GS.scan_control = TRUE; + + if ( (args[0] & 0x400) != 0 && CUR.metrics.stretched ) + CUR.GS.scan_control = TRUE; + + if ( (args[0] & 0x800) != 0 && CUR.metrics.pointSize > A ) + CUR.GS.scan_control = FALSE; + + if ( (args[0] & 0x1000) != 0 && CUR.metrics.rotated ) + CUR.GS.scan_control = FALSE; + + if ( (args[0] & 0x2000) != 0 && CUR.metrics.stretched ) + CUR.GS.scan_control = FALSE; +} + + +/*******************************************/ +/* SCANTYPE[]: SCAN TYPE */ +/* CodeRange : $8D */ +/* Stack : uint32? --> */ + + static void Ins_SCANTYPE( INS_ARG ) + { + /* For compatibility with future enhancements, */ + /* we must ignore new modes */ + + if ( args[0] >= 0 && args[0] <= 5 ) + { + if ( args[0] == 3 ) + args[0] = 2; + + CUR.GS.scan_type = (Int)args[0]; + } + } + + + +/****************************************************************/ +/* */ +/* MANAGING OUTLINES */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + +/**********************************************/ +/* FLIPPT[] : FLIP PoinT */ +/* CodeRange : $80 */ +/* Stack : uint32... --> */ + + static void Ins_FLIPPT( INS_ARG ) + { + UShort point; + + + if ( CUR.top < CUR.GS.loop ) + { + CUR.error = TT_Err_Too_Few_Arguments; + return; + } + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.pts.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + CUR.pts.touch[point] ^= TT_Flag_On_Curve; + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* FLIPRGON[]: FLIP RanGe ON */ +/* CodeRange : $81 */ +/* Stack : uint32 uint32 --> */ +/* (but UShorts are sufficient) */ + + static void Ins_FLIPRGON( INS_ARG ) + { + UShort I, K, L; + + + K = (UShort)args[1]; + L = (UShort)args[0]; + + if ( BOUNDS( K, CUR.pts.n_points ) || + BOUNDS( L, CUR.pts.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + for ( I = L; I <= K; I++ ) + CUR.pts.touch[I] |= TT_Flag_On_Curve; + } + + +/**********************************************/ +/* FLIPRGOFF : FLIP RanGe OFF */ +/* CodeRange : $82 */ +/* Stack : uint32 uint32 --> */ +/* (but UShorts are sufficient) */ + + static void Ins_FLIPRGOFF( INS_ARG ) + { + UShort I, K, L; + + + K = (UShort)args[1]; + L = (UShort)args[0]; + + if ( BOUNDS( K, CUR.pts.n_points ) || + BOUNDS( L, CUR.pts.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + for ( I = L; I <= K; I++ ) + CUR.pts.touch[I] &= ~TT_Flag_On_Curve; + } + + + static Bool Compute_Point_Displacement( EXEC_OPS + PCoordinates x, + PCoordinates y, + PGlyph_Zone zone, + UShort* refp ) + { + TGlyph_Zone zp; + UShort p; + TT_F26Dot6 d; + + + if ( CUR.opcode & 1 ) + { + zp = CUR.zp0; + p = CUR.GS.rp1; + } + else + { + zp = CUR.zp1; + p = CUR.GS.rp2; + } + + if ( BOUNDS( p, zp.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Displacement; + return FAILURE; + } + + *zone = zp; + *refp = p; + + d = CUR_Func_project( zp.cur + p, zp.org + p ); + + *x = TT_MulDiv(d, (Long)CUR.GS.freeVector.x * 0x10000L, CUR.F_dot_P ); + *y = TT_MulDiv(d, (Long)CUR.GS.freeVector.y * 0x10000L, CUR.F_dot_P ); + + return SUCCESS; + } + + + static void Move_Zp2_Point( EXEC_OPS + UShort point, + TT_F26Dot6 dx, + TT_F26Dot6 dy, + Bool touch ) + { + if ( CUR.GS.freeVector.x != 0 ) + { + CUR.zp2.cur[point].x += dx; + if ( touch ) + CUR.zp2.touch[point] |= TT_Flag_Touched_X; + } + + if ( CUR.GS.freeVector.y != 0 ) + { + CUR.zp2.cur[point].y += dy; + if ( touch ) + CUR.zp2.touch[point] |= TT_Flag_Touched_Y; + } + } + + +/**********************************************/ +/* SHP[a] : SHift Point by the last point */ +/* CodeRange : $32-33 */ +/* Stack : uint32... --> */ + + static void Ins_SHP( INS_ARG ) + { + TGlyph_Zone zp; + UShort refp; + + TT_F26Dot6 dx, + dy; + UShort point; + + + if ( CUR.top < CUR.GS.loop ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) + return; + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + /* UNDOCUMENTED! SHP touches the points */ + MOVE_Zp2_Point( point, dx, dy, TRUE ); + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* SHC[a] : SHift Contour */ +/* CodeRange : $34-35 */ +/* Stack : uint32 --> */ + + static void Ins_SHC( INS_ARG ) + { + TGlyph_Zone zp; + UShort refp; + TT_F26Dot6 dx, + dy; + + Short contour; + UShort first_point, last_point, i; + + + contour = (UShort)args[0]; + + if ( BOUNDS( contour, CUR.pts.n_contours ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) + return; + + if ( contour == 0 ) + first_point = 0; + else + first_point = CUR.pts.contours[contour - 1] + 1; + + last_point = CUR.pts.contours[contour]; + + /* XXX: this is probably wrong... at least it prevents memory */ + /* corruption when zp2 is the twilight zone */ + if ( last_point > CUR.zp2.n_points ) + { + if ( CUR.zp2.n_points > 0 ) + last_point = CUR.zp2.n_points - 1; + else + last_point = 0; + } + + /* UNDOCUMENTED! SHC doesn't touch the points */ + for ( i = first_point; i <= last_point; i++ ) + { + if ( zp.cur != CUR.zp2.cur || refp != i ) + MOVE_Zp2_Point( i, dx, dy, FALSE ); + } + } + + +/**********************************************/ +/* SHZ[a] : SHift Zone */ +/* CodeRange : $36-37 */ +/* Stack : uint32 --> */ + + static void Ins_SHZ( INS_ARG ) + { + TGlyph_Zone zp; + UShort refp; + TT_F26Dot6 dx, + dy; + + UShort last_point, i; + + + if ( BOUNDS( args[0], 2 ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) ) + return; + + if ( CUR.zp2.n_points > 0 ) + last_point = CUR.zp2.n_points - 1; + else + last_point = 0; + + /* UNDOCUMENTED! SHZ doesn't touch the points */ + for ( i = 0; i <= last_point; i++ ) + { + if ( zp.cur != CUR.zp2.cur || refp != i ) + MOVE_Zp2_Point( i, dx, dy, FALSE ); + } + } + + +/**********************************************/ +/* SHPIX[] : SHift points by a PIXel amount */ +/* CodeRange : $38 */ +/* Stack : f26.6 uint32... --> */ + + static void Ins_SHPIX( INS_ARG ) + { + TT_F26Dot6 dx, dy; + UShort point; + + + if ( CUR.top < CUR.GS.loop + 1 ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + dx = TT_MulDiv( args[0], + (Long)CUR.GS.freeVector.x, + 0x4000 ); + dy = TT_MulDiv( args[0], + (Long)CUR.GS.freeVector.y, + 0x4000 ); + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + MOVE_Zp2_Point( point, dx, dy, TRUE ); + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* MSIRP[a] : Move Stack Indirect Relative */ +/* CodeRange : $3A-$3B */ +/* Stack : f26.6 uint32 --> */ + + static void Ins_MSIRP( INS_ARG ) + { + UShort point; + TT_F26Dot6 distance; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp1.n_points ) || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: UNDOCUMENTED! behaviour */ + if ( CUR.GS.gep0 == 0 ) /* if in twilight zone */ + { + CUR.zp1.org[point] = CUR.zp0.org[CUR.GS.rp0]; + CUR.zp1.cur[point] = CUR.zp1.org[point]; + } + + distance = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + CUR_Func_move( &CUR.zp1, point, args[1] - distance ); + + CUR.GS.rp1 = CUR.GS.rp0; + CUR.GS.rp2 = point; + + if ( (CUR.opcode & 1) != 0 ) + CUR.GS.rp0 = point; + } + + +/**********************************************/ +/* MDAP[a] : Move Direct Absolute Point */ +/* CodeRange : $2E-$2F */ +/* Stack : uint32 --> */ + + static void Ins_MDAP( INS_ARG ) + { + UShort point; + TT_F26Dot6 cur_dist, + distance; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: Is there some undocumented feature while in the */ + /* twilight zone? ? */ + if ( (CUR.opcode & 1) != 0 ) + { + cur_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector ); + distance = CUR_Func_round( cur_dist, + CUR.metrics.compensations[0] ) - cur_dist; + } + else + distance = 0; + + CUR_Func_move( &CUR.zp0, point, distance ); + + CUR.GS.rp0 = point; + CUR.GS.rp1 = point; + } + + +/**********************************************/ +/* MIAP[a] : Move Indirect Absolute Point */ +/* CodeRange : $3E-$3F */ +/* Stack : uint32 uint32 --> */ + + static void Ins_MIAP( INS_ARG ) + { + ULong cvtEntry; + UShort point; + TT_F26Dot6 distance, + org_dist; + + + cvtEntry = (ULong)args[1]; + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp0.n_points ) || + BOUNDS( cvtEntry, CUR.cvtSize ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* UNDOCUMENTED! */ + /* */ + /* The behaviour of an MIAP instruction is quite */ + /* different when used in the twilight zone. */ + /* */ + /* First, no control value cutin test is performed */ + /* as it would fail anyway. Second, the original */ + /* point, i.e. (org_x,org_y) of zp0.point, is set */ + /* to the absolute, unrounded distance found in */ + /* the CVT. */ + /* */ + /* This is used in the CVT programs of the Microsoft */ + /* fonts Arial, Times, etc., in order to re-adjust */ + /* some key font heights. It allows the use of the */ + /* IP instruction in the twilight zone, which */ + /* otherwise would be "illegal" according to the */ + /* specs :) */ + /* */ + /* We implement it with a special sequence for the */ + /* twilight zone. This is a bad hack, but it seems */ + /* to work. */ + + distance = CUR_Func_read_cvt( cvtEntry ); + + if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */ + { + CUR.zp0.org[point].x = TT_MulDiv( CUR.GS.freeVector.x, + distance, 0x4000L ); + CUR.zp0.org[point].y = TT_MulDiv( CUR.GS.freeVector.y, + distance, 0x4000L ); + CUR.zp0.cur[point] = CUR.zp0.org[point]; + } + + org_dist = CUR_Func_project( CUR.zp0.cur + point, NULL_Vector ); + + if ( (CUR.opcode & 1) != 0 ) /* rounding and control cutin flag */ + { + if ( ABS( distance - org_dist ) > CUR.GS.control_value_cutin ) + distance = org_dist; + + distance = CUR_Func_round( distance, CUR.metrics.compensations[0] ); + } + + CUR_Func_move( &CUR.zp0, point, distance - org_dist ); + + CUR.GS.rp0 = point; + CUR.GS.rp1 = point; + } + + +/**********************************************/ +/* MDRP[abcde] : Move Direct Relative Point */ +/* CodeRange : $C0-$DF */ +/* Stack : uint32 --> */ + + static void Ins_MDRP( INS_ARG ) + { + UShort point; + TT_F26Dot6 org_dist, distance; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp1.n_points ) || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: Is there some undocumented feature while in the */ + /* twilight zone? */ + + org_dist = CUR_Func_dualproj( CUR.zp1.org + point, + CUR.zp0.org + CUR.GS.rp0 ); + + /* single width cutin test */ + + if ( ABS( org_dist ) < CUR.GS.single_width_cutin ) + { + if ( org_dist >= 0 ) + org_dist = CUR.GS.single_width_value; + else + org_dist = -CUR.GS.single_width_value; + } + + /* round flag */ + + if ( (CUR.opcode & 4) != 0 ) + distance = CUR_Func_round( org_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + else + distance = Round_None( EXEC_ARGS + org_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + + /* minimum distance flag */ + + if ( (CUR.opcode & 8) != 0 ) + { + if ( org_dist >= 0 ) + { + if ( distance < CUR.GS.minimum_distance ) + distance = CUR.GS.minimum_distance; + } + else + { + if ( distance > -CUR.GS.minimum_distance ) + distance = -CUR.GS.minimum_distance; + } + } + + /* now move the point */ + + org_dist = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + CUR_Func_move( &CUR.zp1, point, distance - org_dist ); + + CUR.GS.rp1 = CUR.GS.rp0; + CUR.GS.rp2 = point; + + if ( (CUR.opcode & 16) != 0 ) + CUR.GS.rp0 = point; + } + + +/**********************************************/ +/* MIRP[abcde] : Move Indirect Relative Point */ +/* CodeRange : $E0-$FF */ +/* Stack : int32? uint32 --> */ + + static void Ins_MIRP( INS_ARG ) + { + UShort point; + ULong cvtEntry; + + TT_F26Dot6 cvt_dist, + distance, + cur_dist, + org_dist; + + + point = (UShort)args[0]; + cvtEntry = (ULong)(args[1] + 1); + + /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */ + + if ( BOUNDS( point, CUR.zp1.n_points ) || + BOUNDS( cvtEntry, CUR.cvtSize + 1 ) || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + if ( !cvtEntry ) + cvt_dist = 0; + else + cvt_dist = CUR_Func_read_cvt( cvtEntry - 1 ); + + /* single width test */ + + if ( ABS( cvt_dist ) < CUR.GS.single_width_cutin ) + { + if ( cvt_dist >= 0 ) + cvt_dist = CUR.GS.single_width_value; + else + cvt_dist = -CUR.GS.single_width_value; + } + + /* XXX : UNDOCUMENTED! -- twilight zone */ + + if ( CUR.GS.gep1 == 0 ) + { + CUR.zp1.org[point].x = CUR.zp0.org[CUR.GS.rp0].x + + TT_MulDiv( cvt_dist, + CUR.GS.freeVector.x, + 0x4000 ); + + CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y + + TT_MulDiv( cvt_dist, + CUR.GS.freeVector.y, + 0x4000 ); + + CUR.zp1.cur[point] = CUR.zp1.org[point]; + } + + org_dist = CUR_Func_dualproj( CUR.zp1.org + point, + CUR.zp0.org + CUR.GS.rp0 ); + + cur_dist = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + /* auto-flip test */ + + if ( CUR.GS.auto_flip ) + { + if ( (org_dist ^ cvt_dist) < 0 ) + cvt_dist = -cvt_dist; + } + + /* control value cutin and round */ + + if ( (CUR.opcode & 4) != 0 ) + { + /* XXX: UNDOCUMENTED! Only perform cut-in test when both points */ + /* refer to the same zone. */ + + if ( CUR.GS.gep0 == CUR.GS.gep1 ) + if ( ABS( cvt_dist - org_dist ) >= CUR.GS.control_value_cutin ) + cvt_dist = org_dist; + + distance = CUR_Func_round( cvt_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + } + else + distance = Round_None( EXEC_ARGS + cvt_dist, + CUR.metrics.compensations[CUR.opcode & 3] ); + + /* minimum distance test */ + + if ( (CUR.opcode & 8) != 0 ) + { + if ( org_dist >= 0 ) + { + if ( distance < CUR.GS.minimum_distance ) + distance = CUR.GS.minimum_distance; + } + else + { + if ( distance > -CUR.GS.minimum_distance ) + distance = -CUR.GS.minimum_distance; + } + } + + CUR_Func_move( &CUR.zp1, point, distance - cur_dist ); + + CUR.GS.rp1 = CUR.GS.rp0; + + if ( (CUR.opcode & 16) != 0 ) + CUR.GS.rp0 = point; + + /* UNDOCUMENTED! */ + + CUR.GS.rp2 = point; + } + + +/**********************************************/ +/* ALIGNRP[] : ALIGN Relative Point */ +/* CodeRange : $3C */ +/* Stack : uint32 uint32... --> */ + + static void Ins_ALIGNRP( INS_ARG ) + { + UShort point; + TT_F26Dot6 distance; + + + if ( CUR.top < CUR.GS.loop || + BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + + if ( BOUNDS( point, CUR.zp1.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + { + distance = CUR_Func_project( CUR.zp1.cur + point, + CUR.zp0.cur + CUR.GS.rp0 ); + + CUR_Func_move( &CUR.zp1, point, -distance ); + } + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* ISECT[] : moves point to InterSECTion */ +/* CodeRange : $0F */ +/* Stack : 5 * uint32 --> */ + + static void Ins_ISECT( INS_ARG ) + { + UShort point, + a0, a1, + b0, b1; + + TT_F26Dot6 discriminant; + + TT_F26Dot6 dx, dy, + dax, day, + dbx, dby; + + TT_F26Dot6 val; + + TT_Vector R; + + + point = (UShort)args[0]; + + a0 = (UShort)args[1]; + a1 = (UShort)args[2]; + b0 = (UShort)args[3]; + b1 = (UShort)args[4]; + + if ( BOUNDS( b0, CUR.zp0.n_points ) || + BOUNDS( b1, CUR.zp0.n_points ) || + BOUNDS( a0, CUR.zp1.n_points ) || + BOUNDS( a1, CUR.zp1.n_points ) || + BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + dbx = CUR.zp0.cur[b1].x - CUR.zp0.cur[b0].x; + dby = CUR.zp0.cur[b1].y - CUR.zp0.cur[b0].y; + + dax = CUR.zp1.cur[a1].x - CUR.zp1.cur[a0].x; + day = CUR.zp1.cur[a1].y - CUR.zp1.cur[a0].y; + + dx = CUR.zp0.cur[b0].x - CUR.zp1.cur[a0].x; + dy = CUR.zp0.cur[b0].y - CUR.zp1.cur[a0].y; + + CUR.zp2.touch[point] |= TT_Flag_Touched_Both; + + discriminant = TT_MulDiv( dax, -dby, 0x40L ) + + TT_MulDiv( day, dbx, 0x40L ); + + if ( ABS( discriminant ) >= 0x40 ) + { + val = TT_MulDiv( dx, -dby, 0x40L ) + TT_MulDiv( dy, dbx, 0x40L ); + + R.x = TT_MulDiv( val, dax, discriminant ); + R.y = TT_MulDiv( val, day, discriminant ); + + CUR.zp2.cur[point].x = CUR.zp1.cur[a0].x + R.x; + CUR.zp2.cur[point].y = CUR.zp1.cur[a0].y + R.y; + } + else + { + /* else, take the middle of the middles of A and B */ + + CUR.zp2.cur[point].x = ( CUR.zp1.cur[a0].x + + CUR.zp1.cur[a1].x + + CUR.zp0.cur[b0].x + + CUR.zp0.cur[b1].x ) / 4; + CUR.zp2.cur[point].y = ( CUR.zp1.cur[a0].y + + CUR.zp1.cur[a1].y + + CUR.zp0.cur[b0].y + + CUR.zp0.cur[b1].y ) / 4; + } + } + + +/**********************************************/ +/* ALIGNPTS[] : ALIGN PoinTS */ +/* CodeRange : $27 */ +/* Stack : uint32 uint32 --> */ + + static void Ins_ALIGNPTS( INS_ARG ) + { + UShort p1, p2; + TT_F26Dot6 distance; + + + p1 = (UShort)args[0]; + p2 = (UShort)args[1]; + + if ( BOUNDS( args[0], CUR.zp1.n_points ) || + BOUNDS( args[1], CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + distance = CUR_Func_project( CUR.zp0.cur + p2, + CUR.zp1.cur + p1 ) / 2; + + CUR_Func_move( &CUR.zp1, p1, distance ); + CUR_Func_move( &CUR.zp0, p2, -distance ); + } + + +/**********************************************/ +/* IP[] : Interpolate Point */ +/* CodeRange : $39 */ +/* Stack : uint32... --> */ + + static void Ins_IP( INS_ARG ) + { + TT_F26Dot6 org_a, org_b, org_x, + cur_a, cur_b, cur_x, + distance; + UShort point; + + + if ( CUR.top < CUR.GS.loop ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + + /* XXX: there are some glyphs in some braindead but popular */ + /* fonts out there (e.g. [aeu]grave in monotype.ttf) */ + /* calling IP[] with bad values of rp[12] */ + /* do something sane when this odd thing happens */ + + if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) || + BOUNDS( CUR.GS.rp2, CUR.zp1.n_points ) ) + { + org_a = cur_a = 0; + org_b = cur_b = 0; + } + else + { + org_a = CUR_Func_dualproj( CUR.zp0.org + CUR.GS.rp1, NULL_Vector ); + org_b = CUR_Func_dualproj( CUR.zp1.org + CUR.GS.rp2, NULL_Vector ); + + cur_a = CUR_Func_project( CUR.zp0.cur + CUR.GS.rp1, NULL_Vector ); + cur_b = CUR_Func_project( CUR.zp1.cur + CUR.GS.rp2, NULL_Vector ); + } + + while ( CUR.GS.loop > 0 ) + { + CUR.args--; + + point = (UShort)CUR.stack[CUR.args]; + if ( BOUNDS( point, CUR.zp2.n_points ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + { + org_x = CUR_Func_dualproj( CUR.zp2.org + point, NULL_Vector ); + cur_x = CUR_Func_project ( CUR.zp2.cur + point, NULL_Vector ); + + if ( ( org_a <= org_b && org_x <= org_a ) || + ( org_a > org_b && org_x >= org_a ) ) + + distance = ( cur_a - org_a ) + ( org_x - cur_x ); + + else if ( ( org_a <= org_b && org_x >= org_b ) || + ( org_a > org_b && org_x < org_b ) ) + + distance = ( cur_b - org_b ) + ( org_x - cur_x ); + + else + /* note: it seems that rounding this value isn't a good */ + /* idea (cf. width of capital 'S' in Times) */ + + distance = TT_MulDiv( cur_b - cur_a, + org_x - org_a, + org_b - org_a ) + ( cur_a - cur_x ); + + CUR_Func_move( &CUR.zp2, point, distance ); + } + + CUR.GS.loop--; + } + + CUR.GS.loop = 1; + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* UTP[a] : UnTouch Point */ +/* CodeRange : $29 */ +/* Stack : uint32 --> */ + + static void Ins_UTP( INS_ARG ) + { + UShort point; + Byte mask; + + + point = (UShort)args[0]; + + if ( BOUNDS( point, CUR.zp0.n_points ) ) + { + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + return; + } + + mask = 0xFF; + + if ( CUR.GS.freeVector.x != 0 ) + mask &= ~TT_Flag_Touched_X; + + if ( CUR.GS.freeVector.y != 0 ) + mask &= ~TT_Flag_Touched_Y; + + CUR.zp0.touch[point] &= mask; + } + + + /* Local variables for Ins_IUP: */ + struct LOC_Ins_IUP + { + TT_Vector* orgs; /* original and current coordinate */ + TT_Vector* curs; /* arrays */ + }; + + + static void Shift( UShort p1, + UShort p2, + UShort p, + struct LOC_Ins_IUP* LINK ) + { + UShort i; + TT_F26Dot6 x; + + + x = LINK->curs[p].x - LINK->orgs[p].x; + + for ( i = p1; i < p; i++ ) + LINK->curs[i].x += x; + + for ( i = p + 1; i <= p2; i++ ) + LINK->curs[i].x += x; + } + + + static void Interp( UShort p1, + UShort p2, + UShort ref1, + UShort ref2, + struct LOC_Ins_IUP* LINK ) + { + UShort i; + TT_F26Dot6 x, x1, x2, d1, d2; + + + if ( p1 > p2 ) + return; + + x1 = LINK->orgs[ref1].x; + d1 = LINK->curs[ref1].x - LINK->orgs[ref1].x; + x2 = LINK->orgs[ref2].x; + d2 = LINK->curs[ref2].x - LINK->orgs[ref2].x; + + if ( x1 == x2 ) + { + for ( i = p1; i <= p2; i++ ) + { + x = LINK->orgs[i].x; + + if ( x <= x1 ) + x += d1; + else + x += d2; + + LINK->curs[i].x = x; + } + return; + } + + if ( x1 < x2 ) + { + for ( i = p1; i <= p2; i++ ) + { + x = LINK->orgs[i].x; + + if ( x <= x1 ) + x += d1; + else + { + if ( x >= x2 ) + x += d2; + else + x = LINK->curs[ref1].x + + TT_MulDiv( x - x1, + LINK->curs[ref2].x - LINK->curs[ref1].x, + x2 - x1 ); + } + LINK->curs[i].x = x; + } + return; + } + + /* x2 < x1 */ + + for ( i = p1; i <= p2; i++ ) + { + x = LINK->orgs[i].x; + if ( x <= x2 ) + x += d2; + else + { + if ( x >= x1 ) + x += d1; + else + x = LINK->curs[ref1].x + + TT_MulDiv( x - x1, + LINK->curs[ref2].x - LINK->curs[ref1].x, + x2 - x1 ); + } + LINK->curs[i].x = x; + } + } + + +/**********************************************/ +/* IUP[a] : Interpolate Untouched Points */ +/* CodeRange : $30-$31 */ +/* Stack : --> */ + + static void Ins_IUP( INS_ARG ) + { + struct LOC_Ins_IUP V; + Byte mask; + + UShort first_point; /* first point of contour */ + UShort end_point; /* end point (last+1) of contour */ + + UShort first_touched; /* first touched point in contour */ + UShort cur_touched; /* current touched point in contour */ + + UShort point; /* current point */ + Short contour; /* current contour */ + + + if ( CUR.opcode & 1 ) + { + mask = TT_Flag_Touched_X; + V.orgs = CUR.pts.org; + V.curs = CUR.pts.cur; + } + else + { + mask = TT_Flag_Touched_Y; + V.orgs = (TT_Vector*)( ((TT_F26Dot6*)CUR.pts.org) + 1 ); + V.curs = (TT_Vector*)( ((TT_F26Dot6*)CUR.pts.cur) + 1 ); + } + + contour = 0; + point = 0; + + do + { + end_point = CUR.pts.contours[contour]; + first_point = point; + + while ( point <= end_point && (CUR.pts.touch[point] & mask) == 0 ) + point++; + + if ( point <= end_point ) + { + first_touched = point; + cur_touched = point; + + point++; + + while ( point <= end_point ) + { + if ( (CUR.pts.touch[point] & mask) != 0 ) + { + if ( point > 0 ) + Interp( cur_touched + 1, + point - 1, + cur_touched, + point, + &V ); + cur_touched = point; + } + + point++; + } + + if ( cur_touched == first_touched ) + Shift( first_point, end_point, cur_touched, &V ); + else + { + Interp( cur_touched + 1, + end_point, + cur_touched, + first_touched, + &V ); + + if ( first_touched > 0 ) + Interp( first_point, + first_touched - 1, + cur_touched, + first_touched, + &V ); + } + } + contour++; + } while ( contour < CUR.pts.n_contours ); + } + + +/**********************************************/ +/* DELTAPn[] : DELTA Exceptions P1, P2, P3 */ +/* CodeRange : $5D,$71,$72 */ +/* Stack : uint32 (2 * uint32)... --> */ + + static void Ins_DELTAP( INS_ARG ) + { + ULong nump, k; + UShort A; + ULong C; + Long B; + + + nump = (ULong)args[0]; /* some points theoretically may occur more + than once, thus UShort isn't enough */ + + for ( k = 1; k <= nump; k++ ) + { + if ( CUR.args < 2 ) + { + CUR.error = TT_Err_Too_Few_Arguments; + return; + } + + CUR.args -= 2; + + A = (UShort)CUR.stack[CUR.args + 1]; + B = CUR.stack[CUR.args]; + + /* XXX : because some popular fonts contain some invalid DeltaP */ + /* instructions, we simply ignore them when the stacked */ + /* point reference is off limit, rather than returning an */ + /* error. As a delta instruction doesn't change a glyph */ + /* in great ways, this shouldn't be a problem.. */ + + if ( !BOUNDS( A, CUR.zp0.n_points ) ) + { + C = ((ULong)B & 0xF0) >> 4; + + switch ( CUR.opcode ) + { + case 0x5d: + break; + + case 0x71: + C += 16; + break; + + case 0x72: + C += 32; + break; + } + + C += CUR.GS.delta_base; + + if ( CURRENT_Ppem() == (Long)C ) + { + B = ((ULong)B & 0xF) - 8; + if ( B >= 0 ) + B++; + B = B * 64L / (1L << CUR.GS.delta_shift); + + CUR_Func_move( &CUR.zp0, A, B ); + } + } + else + if ( CUR.pedantic_hinting ) + CUR.error = TT_Err_Invalid_Reference; + } + + CUR.new_top = CUR.args; + } + + +/**********************************************/ +/* DELTACn[] : DELTA Exceptions C1, C2, C3 */ +/* CodeRange : $73,$74,$75 */ +/* Stack : uint32 (2 * uint32)... --> */ + + static void Ins_DELTAC( INS_ARG ) + { + ULong nump, k; + ULong A, C; + Long B; + + + nump = (ULong)args[0]; + + for ( k = 1; k <= nump; k++ ) + { + if ( CUR.args < 2 ) + { + CUR.error = TT_Err_Too_Few_Arguments; + return; + } + + CUR.args -= 2; + + A = (ULong)CUR.stack[CUR.args + 1]; + B = CUR.stack[CUR.args]; + + if ( BOUNDS( A, CUR.cvtSize ) ) + { + if ( CUR.pedantic_hinting ) + { + CUR.error = TT_Err_Invalid_Reference; + return; + } + } + else + { + C = ((ULong)B & 0xF0) >> 4; + + switch ( CUR.opcode ) + { + case 0x73: + break; + + case 0x74: + C += 16; + break; + + case 0x75: + C += 32; + break; + } + + C += CUR.GS.delta_base; + + if ( CURRENT_Ppem() == (Long)C ) + { + B = ((ULong)B & 0xF) - 8; + if ( B >= 0 ) + B++; + B = B * 64L / (1L << CUR.GS.delta_shift); + + CUR_Func_move_cvt( A, B ); + } + } + } + + CUR.new_top = CUR.args; + } + + + +/****************************************************************/ +/* */ +/* MISC. INSTRUCTIONS */ +/* */ +/****************************************************************/ + + +/**********************************************/ +/* GETINFO[] : GET INFOrmation */ +/* CodeRange : $88 */ +/* Stack : uint32 --> uint32 */ + +/* XXX According to Apple specs, bits 1 & 2 of the argument ought to be */ +/* consulted before rotated / stretched info is returned */ + + static void Ins_GETINFO( INS_ARG ) + { + Long K; + + + K = 0; + + /* We return then Windows 3.1 version number */ + /* for the font scaler */ + if ( (args[0] & 1) != 0 ) + K = 3; + + /* Has the glyph been rotated ? */ + if ( CUR.metrics.rotated ) + K |= 0x80; + + /* Has the glyph been stretched ? */ + if ( CUR.metrics.stretched ) + K |= 0x100; + + args[0] = K; + } + + + static void Ins_UNKNOWN( INS_ARG ) + { + /* look up the current instruction in our table */ + PDefRecord def, limit; + + def = CUR.IDefs; + limit = def + CUR.numIDefs; + for ( ; def < limit; def++ ) + { + if ( def->Opc == CUR.opcode && def->Active ) + { + PCallRecord pCrec; + + /* implement instruction as a function call */ + + /* check call stack */ + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Stack_Overflow; + return; + } + + pCrec = CUR.callStack + CUR.callTop; + + pCrec->Caller_Range = CUR.curRange; + pCrec->Caller_IP = CUR.IP + 1; + pCrec->Cur_Count = 1; + pCrec->Cur_Restart = def->Start; + + CUR.callTop++; + + INS_Goto_CodeRange( def->Range, + def->Start ); + + CUR.step_ins = FALSE; + return; + } + } + + CUR.error = TT_Err_Invalid_Opcode; + } + + +#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH + static TInstruction_Function Instruct_Dispatch[256] = + { + /* Opcodes are gathered in groups of 16. */ + /* Please keep the spaces as they are. */ + + /* SVTCA y */ Ins_SVTCA, + /* SVTCA x */ Ins_SVTCA, + /* SPvTCA y */ Ins_SPVTCA, + /* SPvTCA x */ Ins_SPVTCA, + /* SFvTCA y */ Ins_SFVTCA, + /* SFvTCA x */ Ins_SFVTCA, + /* SPvTL // */ Ins_SPVTL, + /* SPvTL + */ Ins_SPVTL, + /* SFvTL // */ Ins_SFVTL, + /* SFvTL + */ Ins_SFVTL, + /* SPvFS */ Ins_SPVFS, + /* SFvFS */ Ins_SFVFS, + /* GPV */ Ins_GPV, + /* GFV */ Ins_GFV, + /* SFvTPv */ Ins_SFVTPV, + /* ISECT */ Ins_ISECT, + + /* SRP0 */ Ins_SRP0, + /* SRP1 */ Ins_SRP1, + /* SRP2 */ Ins_SRP2, + /* SZP0 */ Ins_SZP0, + /* SZP1 */ Ins_SZP1, + /* SZP2 */ Ins_SZP2, + /* SZPS */ Ins_SZPS, + /* SLOOP */ Ins_SLOOP, + /* RTG */ Ins_RTG, + /* RTHG */ Ins_RTHG, + /* SMD */ Ins_SMD, + /* ELSE */ Ins_ELSE, + /* JMPR */ Ins_JMPR, + /* SCvTCi */ Ins_SCVTCI, + /* SSwCi */ Ins_SSWCI, + /* SSW */ Ins_SSW, + + /* DUP */ Ins_DUP, + /* POP */ Ins_POP, + /* CLEAR */ Ins_CLEAR, + /* SWAP */ Ins_SWAP, + /* DEPTH */ Ins_DEPTH, + /* CINDEX */ Ins_CINDEX, + /* MINDEX */ Ins_MINDEX, + /* AlignPTS */ Ins_ALIGNPTS, + /* INS_$28 */ Ins_UNKNOWN, + /* UTP */ Ins_UTP, + /* LOOPCALL */ Ins_LOOPCALL, + /* CALL */ Ins_CALL, + /* FDEF */ Ins_FDEF, + /* ENDF */ Ins_ENDF, + /* MDAP[0] */ Ins_MDAP, + /* MDAP[1] */ Ins_MDAP, + + /* IUP[0] */ Ins_IUP, + /* IUP[1] */ Ins_IUP, + /* SHP[0] */ Ins_SHP, + /* SHP[1] */ Ins_SHP, + /* SHC[0] */ Ins_SHC, + /* SHC[1] */ Ins_SHC, + /* SHZ[0] */ Ins_SHZ, + /* SHZ[1] */ Ins_SHZ, + /* SHPIX */ Ins_SHPIX, + /* IP */ Ins_IP, + /* MSIRP[0] */ Ins_MSIRP, + /* MSIRP[1] */ Ins_MSIRP, + /* AlignRP */ Ins_ALIGNRP, + /* RTDG */ Ins_RTDG, + /* MIAP[0] */ Ins_MIAP, + /* MIAP[1] */ Ins_MIAP, + + /* NPushB */ Ins_NPUSHB, + /* NPushW */ Ins_NPUSHW, + /* WS */ Ins_WS, + /* RS */ Ins_RS, + /* WCvtP */ Ins_WCVTP, + /* RCvt */ Ins_RCVT, + /* GC[0] */ Ins_GC, + /* GC[1] */ Ins_GC, + /* SCFS */ Ins_SCFS, + /* MD[0] */ Ins_MD, + /* MD[1] */ Ins_MD, + /* MPPEM */ Ins_MPPEM, + /* MPS */ Ins_MPS, + /* FlipON */ Ins_FLIPON, + /* FlipOFF */ Ins_FLIPOFF, + /* DEBUG */ Ins_DEBUG, + + /* LT */ Ins_LT, + /* LTEQ */ Ins_LTEQ, + /* GT */ Ins_GT, + /* GTEQ */ Ins_GTEQ, + /* EQ */ Ins_EQ, + /* NEQ */ Ins_NEQ, + /* ODD */ Ins_ODD, + /* EVEN */ Ins_EVEN, + /* IF */ Ins_IF, + /* EIF */ Ins_EIF, + /* AND */ Ins_AND, + /* OR */ Ins_OR, + /* NOT */ Ins_NOT, + /* DeltaP1 */ Ins_DELTAP, + /* SDB */ Ins_SDB, + /* SDS */ Ins_SDS, + + /* ADD */ Ins_ADD, + /* SUB */ Ins_SUB, + /* DIV */ Ins_DIV, + /* MUL */ Ins_MUL, + /* ABS */ Ins_ABS, + /* NEG */ Ins_NEG, + /* FLOOR */ Ins_FLOOR, + /* CEILING */ Ins_CEILING, + /* ROUND[0] */ Ins_ROUND, + /* ROUND[1] */ Ins_ROUND, + /* ROUND[2] */ Ins_ROUND, + /* ROUND[3] */ Ins_ROUND, + /* NROUND[0] */ Ins_NROUND, + /* NROUND[1] */ Ins_NROUND, + /* NROUND[2] */ Ins_NROUND, + /* NROUND[3] */ Ins_NROUND, + + /* WCvtF */ Ins_WCVTF, + /* DeltaP2 */ Ins_DELTAP, + /* DeltaP3 */ Ins_DELTAP, + /* DeltaCn[0] */ Ins_DELTAC, + /* DeltaCn[1] */ Ins_DELTAC, + /* DeltaCn[2] */ Ins_DELTAC, + /* SROUND */ Ins_SROUND, + /* S45Round */ Ins_S45ROUND, + /* JROT */ Ins_JROT, + /* JROF */ Ins_JROF, + /* ROFF */ Ins_ROFF, + /* INS_$7B */ Ins_UNKNOWN, + /* RUTG */ Ins_RUTG, + /* RDTG */ Ins_RDTG, + /* SANGW */ Ins_SANGW, + /* AA */ Ins_AA, + + /* FlipPT */ Ins_FLIPPT, + /* FlipRgON */ Ins_FLIPRGON, + /* FlipRgOFF */ Ins_FLIPRGOFF, + /* INS_$83 */ Ins_UNKNOWN, + /* INS_$84 */ Ins_UNKNOWN, + /* ScanCTRL */ Ins_SCANCTRL, + /* SDPVTL[0] */ Ins_SDPVTL, + /* SDPVTL[1] */ Ins_SDPVTL, + /* GetINFO */ Ins_GETINFO, + /* IDEF */ Ins_IDEF, + /* ROLL */ Ins_ROLL, + /* MAX */ Ins_MAX, + /* MIN */ Ins_MIN, + /* ScanTYPE */ Ins_SCANTYPE, + /* InstCTRL */ Ins_INSTCTRL, + /* INS_$8F */ Ins_UNKNOWN, + + /* INS_$90 */ Ins_UNKNOWN, + /* INS_$91 */ Ins_UNKNOWN, + /* INS_$92 */ Ins_UNKNOWN, + /* INS_$93 */ Ins_UNKNOWN, + /* INS_$94 */ Ins_UNKNOWN, + /* INS_$95 */ Ins_UNKNOWN, + /* INS_$96 */ Ins_UNKNOWN, + /* INS_$97 */ Ins_UNKNOWN, + /* INS_$98 */ Ins_UNKNOWN, + /* INS_$99 */ Ins_UNKNOWN, + /* INS_$9A */ Ins_UNKNOWN, + /* INS_$9B */ Ins_UNKNOWN, + /* INS_$9C */ Ins_UNKNOWN, + /* INS_$9D */ Ins_UNKNOWN, + /* INS_$9E */ Ins_UNKNOWN, + /* INS_$9F */ Ins_UNKNOWN, + + /* INS_$A0 */ Ins_UNKNOWN, + /* INS_$A1 */ Ins_UNKNOWN, + /* INS_$A2 */ Ins_UNKNOWN, + /* INS_$A3 */ Ins_UNKNOWN, + /* INS_$A4 */ Ins_UNKNOWN, + /* INS_$A5 */ Ins_UNKNOWN, + /* INS_$A6 */ Ins_UNKNOWN, + /* INS_$A7 */ Ins_UNKNOWN, + /* INS_$A8 */ Ins_UNKNOWN, + /* INS_$A9 */ Ins_UNKNOWN, + /* INS_$AA */ Ins_UNKNOWN, + /* INS_$AB */ Ins_UNKNOWN, + /* INS_$AC */ Ins_UNKNOWN, + /* INS_$AD */ Ins_UNKNOWN, + /* INS_$AE */ Ins_UNKNOWN, + /* INS_$AF */ Ins_UNKNOWN, + + /* PushB[0] */ Ins_PUSHB, + /* PushB[1] */ Ins_PUSHB, + /* PushB[2] */ Ins_PUSHB, + /* PushB[3] */ Ins_PUSHB, + /* PushB[4] */ Ins_PUSHB, + /* PushB[5] */ Ins_PUSHB, + /* PushB[6] */ Ins_PUSHB, + /* PushB[7] */ Ins_PUSHB, + /* PushW[0] */ Ins_PUSHW, + /* PushW[1] */ Ins_PUSHW, + /* PushW[2] */ Ins_PUSHW, + /* PushW[3] */ Ins_PUSHW, + /* PushW[4] */ Ins_PUSHW, + /* PushW[5] */ Ins_PUSHW, + /* PushW[6] */ Ins_PUSHW, + /* PushW[7] */ Ins_PUSHW, + + /* MDRP[00] */ Ins_MDRP, + /* MDRP[01] */ Ins_MDRP, + /* MDRP[02] */ Ins_MDRP, + /* MDRP[03] */ Ins_MDRP, + /* MDRP[04] */ Ins_MDRP, + /* MDRP[05] */ Ins_MDRP, + /* MDRP[06] */ Ins_MDRP, + /* MDRP[07] */ Ins_MDRP, + /* MDRP[08] */ Ins_MDRP, + /* MDRP[09] */ Ins_MDRP, + /* MDRP[10] */ Ins_MDRP, + /* MDRP[11] */ Ins_MDRP, + /* MDRP[12] */ Ins_MDRP, + /* MDRP[13] */ Ins_MDRP, + /* MDRP[14] */ Ins_MDRP, + /* MDRP[15] */ Ins_MDRP, + + /* MDRP[16] */ Ins_MDRP, + /* MDRP[17] */ Ins_MDRP, + /* MDRP[18] */ Ins_MDRP, + /* MDRP[19] */ Ins_MDRP, + /* MDRP[20] */ Ins_MDRP, + /* MDRP[21] */ Ins_MDRP, + /* MDRP[22] */ Ins_MDRP, + /* MDRP[23] */ Ins_MDRP, + /* MDRP[24] */ Ins_MDRP, + /* MDRP[25] */ Ins_MDRP, + /* MDRP[26] */ Ins_MDRP, + /* MDRP[27] */ Ins_MDRP, + /* MDRP[28] */ Ins_MDRP, + /* MDRP[29] */ Ins_MDRP, + /* MDRP[30] */ Ins_MDRP, + /* MDRP[31] */ Ins_MDRP, + + /* MIRP[00] */ Ins_MIRP, + /* MIRP[01] */ Ins_MIRP, + /* MIRP[02] */ Ins_MIRP, + /* MIRP[03] */ Ins_MIRP, + /* MIRP[04] */ Ins_MIRP, + /* MIRP[05] */ Ins_MIRP, + /* MIRP[06] */ Ins_MIRP, + /* MIRP[07] */ Ins_MIRP, + /* MIRP[08] */ Ins_MIRP, + /* MIRP[09] */ Ins_MIRP, + /* MIRP[10] */ Ins_MIRP, + /* MIRP[11] */ Ins_MIRP, + /* MIRP[12] */ Ins_MIRP, + /* MIRP[13] */ Ins_MIRP, + /* MIRP[14] */ Ins_MIRP, + /* MIRP[15] */ Ins_MIRP, + + /* MIRP[16] */ Ins_MIRP, + /* MIRP[17] */ Ins_MIRP, + /* MIRP[18] */ Ins_MIRP, + /* MIRP[19] */ Ins_MIRP, + /* MIRP[20] */ Ins_MIRP, + /* MIRP[21] */ Ins_MIRP, + /* MIRP[22] */ Ins_MIRP, + /* MIRP[23] */ Ins_MIRP, + /* MIRP[24] */ Ins_MIRP, + /* MIRP[25] */ Ins_MIRP, + /* MIRP[26] */ Ins_MIRP, + /* MIRP[27] */ Ins_MIRP, + /* MIRP[28] */ Ins_MIRP, + /* MIRP[29] */ Ins_MIRP, + /* MIRP[30] */ Ins_MIRP, + /* MIRP[31] */ Ins_MIRP + }; +#endif + + +/****************************************************************/ +/* */ +/* RUN */ +/* */ +/* This function executes a run of opcodes. It will exit */ +/* in the following cases: */ +/* */ +/* - Errors (in which case it returns FALSE) */ +/* */ +/* - Reaching the end of the main code range (returns TRUE). */ +/* Reaching the end of a code range within a function */ +/* call is an error. */ +/* */ +/* - After executing one single opcode, if the flag */ +/* 'Instruction_Trap' is set to TRUE (returns TRUE). */ +/* */ +/* On exit whith TRUE, test IP < CodeSize to know wether it */ +/* comes from a instruction trap or a normal termination. */ +/* */ +/* */ +/* Note: The documented DEBUG opcode pops a value from */ +/* the stack. This behaviour is unsupported, here */ +/* a DEBUG opcode is always an error. */ +/* */ +/* */ +/* THIS IS THE INTERPRETER'S MAIN LOOP */ +/* */ +/* Instructions appear in the specs' order. */ +/* */ +/****************************************************************/ + + LOCAL_FUNC +#ifndef DEBUG_INTERPRETER + TT_Error RunIns( PExecution_Context exc ) +#else + TT_Error RunIns2( PExecution_Context exc ) +#endif + { + UShort A; + PDefRecord WITH; + PCallRecord WITH1; + + Long ins_counter = 0; /* executed instructions counter */ + +#ifdef TT_CONFIG_OPTION_STATIC_INTERPRETER + cur = *exc; +#endif + + /* set CVT functions */ + CUR.metrics.ratio = 0; + if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem ) + { + /* non-square pixels, use the stretched routines */ + CUR.func_read_cvt = Read_CVT_Stretched; + CUR.func_write_cvt = Write_CVT_Stretched; + CUR.func_move_cvt = Move_CVT_Stretched; + } + else + { + /* square pixels, use normal routines */ + CUR.func_read_cvt = Read_CVT; + CUR.func_write_cvt = Write_CVT; + CUR.func_move_cvt = Move_CVT; + } + + COMPUTE_Funcs(); + Compute_Round( EXEC_ARGS (Byte)exc->GS.round_state ); + + do + { + if ( CALC_Length() != SUCCESS ) + { + CUR.error = TT_Err_Code_Overflow; + goto LErrorLabel_; + } + + /* First, let's check for empty stack and overflow */ + + CUR.args = CUR.top - (Pop_Push_Count[CUR.opcode] >> 4); + + /* `args' is the top of the stack once arguments have been popped. */ + /* One can also interpret it as the index of the last argument. */ + + if ( CUR.args < 0 ) + { + CUR.error = TT_Err_Too_Few_Arguments; + goto LErrorLabel_; + } + + CUR.new_top = CUR.args + (Pop_Push_Count[CUR.opcode] & 15); + + /* `new_top' is the new top of the stack, after the instruction's */ + /* execution. `top' will be set to `new_top' after the 'switch' */ + /* statement. */ + + if ( CUR.new_top > CUR.stackSize ) + { + CUR.error = TT_Err_Stack_Overflow; + goto LErrorLabel_; + } + + CUR.step_ins = TRUE; + CUR.error = TT_Err_Ok; + +#ifdef TT_CONFIG_OPTION_INTERPRETER_SWITCH + { + PStorage args = CUR.stack + CUR.args; + Byte opcode = CUR.opcode; + + +#undef ARRAY_BOUND_ERROR +#define ARRAY_BOUND_ERROR goto Set_Invalid_Ref + + switch ( opcode ) + { + case 0x00: /* SVTCA y */ + case 0x01: /* SVTCA x */ + case 0x02: /* SPvTCA y */ + case 0x03: /* SPvTCA x */ + case 0x04: /* SFvTCA y */ + case 0x05: /* SFvTCA x */ + { + Short AA, BB; + + + AA = (Short)(opcode & 1) << 14; + BB = AA ^ (Short)0x4000; + + if ( opcode < 4 ) + { + CUR.GS.projVector.x = AA; + CUR.GS.projVector.y = BB; + + CUR.GS.dualVector.x = AA; + CUR.GS.dualVector.y = BB; + } + + if ( (opcode & 2) == 0 ) + { + CUR.GS.freeVector.x = AA; + CUR.GS.freeVector.y = BB; + } + + COMPUTE_Funcs(); + } + break; + + case 0x06: /* SPvTL // */ + case 0x07: /* SPvTL + */ + DO_SPVTL + break; + + case 0x08: /* SFvTL // */ + case 0x09: /* SFvTL + */ + DO_SFVTL + break; + + case 0x0A: /* SPvFS */ + DO_SPVFS + break; + + case 0x0B: /* SFvFS */ + DO_SFVFS + break; + + case 0x0C: /* GPV */ + DO_GPV + break; + + case 0x0D: /* GFV */ + DO_GFV + break; + + case 0x0E: /* SFvTPv */ + DO_SFVTPV + break; + + case 0x0F: /* ISECT */ + Ins_ISECT( EXEC_ARGS args ); + break; + + case 0x10: /* SRP0 */ + DO_SRP0 + break; + + case 0x11: /* SRP1 */ + DO_SRP1 + break; + + case 0x12: /* SRP2 */ + DO_SRP2 + break; + + case 0x13: /* SZP0 */ + Ins_SZP0( EXEC_ARGS args ); + break; + + case 0x14: /* SZP1 */ + Ins_SZP1( EXEC_ARGS args ); + break; + + case 0x15: /* SZP2 */ + Ins_SZP2( EXEC_ARGS args ); + break; + + case 0x16: /* SZPS */ + Ins_SZPS( EXEC_ARGS args ); + break; + + case 0x17: /* SLOOP */ + DO_SLOOP + break; + + case 0x18: /* RTG */ + DO_RTG + break; + + case 0x19: /* RTHG */ + DO_RTHG + break; + + case 0x1A: /* SMD */ + DO_SMD + break; + + case 0x1B: /* ELSE */ + Ins_ELSE( EXEC_ARGS args ); + break; + + case 0x1C: /* JMPR */ + DO_JMPR + break; + + case 0x1D: /* SCVTCI */ + DO_SCVTCI + break; + + case 0x1E: /* SSWCI */ + DO_SSWCI + break; + + case 0x1F: /* SSW */ + DO_SSW + break; + + case 0x20: /* DUP */ + DO_DUP + break; + + case 0x21: /* POP */ + /* nothing :-) !! */ + break; + + case 0x22: /* CLEAR */ + DO_CLEAR + break; + + case 0x23: /* SWAP */ + DO_SWAP + break; + + case 0x24: /* DEPTH */ + DO_DEPTH + break; + + case 0x25: /* CINDEX */ + DO_CINDEX + break; + + case 0x26: /* MINDEX */ + Ins_MINDEX( EXEC_ARGS args ); + break; + + case 0x27: /* ALIGNPTS */ + Ins_ALIGNPTS( EXEC_ARGS args ); + break; + + case 0x28: /* ???? */ + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + case 0x29: /* UTP */ + Ins_UTP( EXEC_ARGS args ); + break; + + case 0x2A: /* LOOPCALL */ + Ins_LOOPCALL( EXEC_ARGS args ); + break; + + case 0x2B: /* CALL */ + Ins_CALL( EXEC_ARGS args ); + break; + + case 0x2C: /* FDEF */ + Ins_FDEF( EXEC_ARGS args ); + break; + + case 0x2D: /* ENDF */ + Ins_ENDF( EXEC_ARGS args ); + break; + + case 0x2E: /* MDAP */ + case 0x2F: /* MDAP */ + Ins_MDAP( EXEC_ARGS args ); + break; + + + case 0x30: /* IUP */ + case 0x31: /* IUP */ + Ins_IUP( EXEC_ARGS args ); + break; + + case 0x32: /* SHP */ + case 0x33: /* SHP */ + Ins_SHP( EXEC_ARGS args ); + break; + + case 0x34: /* SHC */ + case 0x35: /* SHC */ + Ins_SHC( EXEC_ARGS args ); + break; + + case 0x36: /* SHZ */ + case 0x37: /* SHZ */ + Ins_SHZ( EXEC_ARGS args ); + break; + + case 0x38: /* SHPIX */ + Ins_SHPIX( EXEC_ARGS args ); + break; + + case 0x39: /* IP */ + Ins_IP( EXEC_ARGS args ); + break; + + case 0x3A: /* MSIRP */ + case 0x3B: /* MSIRP */ + Ins_MSIRP( EXEC_ARGS args ); + break; + + case 0x3C: /* AlignRP */ + Ins_ALIGNRP( EXEC_ARGS args ); + break; + + case 0x3D: /* RTDG */ + DO_RTDG + break; + + case 0x3E: /* MIAP */ + case 0x3F: /* MIAP */ + Ins_MIAP( EXEC_ARGS args ); + break; + + case 0x40: /* NPUSHB */ + Ins_NPUSHB( EXEC_ARGS args ); + break; + + case 0x41: /* NPUSHW */ + Ins_NPUSHW( EXEC_ARGS args ); + break; + + case 0x42: /* WS */ + DO_WS + break; + + Set_Invalid_Ref: + CUR.error = TT_Err_Invalid_Reference; + break; + + case 0x43: /* RS */ + DO_RS + break; + + case 0x44: /* WCVTP */ + DO_WCVTP + break; + + case 0x45: /* RCVT */ + DO_RCVT + break; + + case 0x46: /* GC */ + case 0x47: /* GC */ + Ins_GC( EXEC_ARGS args ); + break; + + case 0x48: /* SCFS */ + Ins_SCFS( EXEC_ARGS args ); + break; + + case 0x49: /* MD */ + case 0x4A: /* MD */ + Ins_MD( EXEC_ARGS args ); + break; + + case 0x4B: /* MPPEM */ + DO_MPPEM + break; + + case 0x4C: /* MPS */ + DO_MPS + break; + + case 0x4D: /* FLIPON */ + DO_FLIPON + break; + + case 0x4E: /* FLIPOFF */ + DO_FLIPOFF + break; + + case 0x4F: /* DEBUG */ + DO_DEBUG + break; + + case 0x50: /* LT */ + DO_LT + break; + + case 0x51: /* LTEQ */ + DO_LTEQ + break; + + case 0x52: /* GT */ + DO_GT + break; + + case 0x53: /* GTEQ */ + DO_GTEQ + break; + + case 0x54: /* EQ */ + DO_EQ + break; + + case 0x55: /* NEQ */ + DO_NEQ + break; + + case 0x56: /* ODD */ + DO_ODD + break; + + case 0x57: /* EVEN */ + DO_EVEN + break; + + case 0x58: /* IF */ + Ins_IF( EXEC_ARGS args ); + break; + + case 0x59: /* EIF */ + /* do nothing */ + break; + + case 0x5A: /* AND */ + DO_AND + break; + + case 0x5B: /* OR */ + DO_OR + break; + + case 0x5C: /* NOT */ + DO_NOT + break; + + case 0x5D: /* DELTAP1 */ + Ins_DELTAP( EXEC_ARGS args ); + break; + + case 0x5E: /* SDB */ + DO_SDB + break; + + case 0x5F: /* SDS */ + DO_SDS + break; + + case 0x60: /* ADD */ + DO_ADD + break; + + case 0x61: /* SUB */ + DO_SUB + break; + + case 0x62: /* DIV */ + DO_DIV + break; + + case 0x63: /* MUL */ + DO_MUL + break; + + case 0x64: /* ABS */ + DO_ABS + break; + + case 0x65: /* NEG */ + DO_NEG + break; + + case 0x66: /* FLOOR */ + DO_FLOOR + break; + + case 0x67: /* CEILING */ + DO_CEILING + break; + + case 0x68: /* ROUND */ + case 0x69: /* ROUND */ + case 0x6A: /* ROUND */ + case 0x6B: /* ROUND */ + DO_ROUND + break; + + case 0x6C: /* NROUND */ + case 0x6D: /* NROUND */ + case 0x6E: /* NRRUND */ + case 0x6F: /* NROUND */ + DO_NROUND + break; + + case 0x70: /* WCVTF */ + DO_WCVTF + break; + + case 0x71: /* DELTAP2 */ + case 0x72: /* DELTAP3 */ + Ins_DELTAP( EXEC_ARGS args ); + break; + + case 0x73: /* DELTAC0 */ + case 0x74: /* DELTAC1 */ + case 0x75: /* DELTAC2 */ + Ins_DELTAC( EXEC_ARGS args ); + break; + + case 0x76: /* SROUND */ + DO_SROUND + break; + + case 0x77: /* S45Round */ + DO_S45ROUND + break; + + case 0x78: /* JROT */ + DO_JROT + break; + + case 0x79: /* JROF */ + DO_JROF + break; + + case 0x7A: /* ROFF */ + DO_ROFF + break; + + case 0x7B: /* ???? */ + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + case 0x7C: /* RUTG */ + DO_RUTG + break; + + case 0x7D: /* RDTG */ + DO_RDTG + break; + + case 0x7E: /* SANGW */ + case 0x7F: /* AA */ + /* nothing - obsolete */ + break; + + case 0x80: /* FLIPPT */ + Ins_FLIPPT( EXEC_ARGS args ); + break; + + case 0x81: /* FLIPRGON */ + Ins_FLIPRGON( EXEC_ARGS args ); + break; + + case 0x82: /* FLIPRGOFF */ + Ins_FLIPRGOFF( EXEC_ARGS args ); + break; + + case 0x83: /* UNKNOWN */ + case 0x84: /* UNKNOWN */ + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + case 0x85: /* SCANCTRL */ + Ins_SCANCTRL( EXEC_ARGS args ); + break; + + case 0x86: /* SDPVTL */ + case 0x87: /* SDPVTL */ + Ins_SDPVTL( EXEC_ARGS args ); + break; + + case 0x88: /* GETINFO */ + Ins_GETINFO( EXEC_ARGS args ); + break; + + case 0x89: /* IDEF */ + Ins_IDEF( EXEC_ARGS args ); + break; + + case 0x8A: /* ROLL */ + Ins_ROLL( EXEC_ARGS args ); + break; + + case 0x8B: /* MAX */ + DO_MAX + break; + + case 0x8C: /* MIN */ + DO_MIN + break; + + case 0x8D: /* SCANTYPE */ + Ins_SCANTYPE( EXEC_ARGS args ); + break; + + case 0x8E: /* INSTCTRL */ + Ins_INSTCTRL( EXEC_ARGS args ); + break; + + case 0x8F: + Ins_UNKNOWN( EXEC_ARGS args ); + break; + + default: + if ( opcode >= 0xE0 ) + Ins_MIRP( EXEC_ARGS args ); + else if ( opcode >= 0xC0 ) + Ins_MDRP( EXEC_ARGS args ); + else if ( opcode >= 0xB8 ) + Ins_PUSHW( EXEC_ARGS args ); + else if ( opcode >= 0xB0 ) + Ins_PUSHB( EXEC_ARGS args ); + else + Ins_UNKNOWN( EXEC_ARGS args ); + } + + } +#else + Instruct_Dispatch[CUR.opcode]( EXEC_ARGS &CUR.stack[CUR.args] ); +#endif + if ( CUR.error != TT_Err_Ok ) + { + switch ( (Int)(CUR.error) ) + { + case TT_Err_Invalid_Opcode: /* looking for redefined instructions */ + A = 0; + + while ( A < CUR.numIDefs ) + { + WITH = &CUR.IDefs[A]; + + if ( WITH->Active && CUR.opcode == WITH->Opc ) + { + if ( CUR.callTop >= CUR.callSize ) + { + CUR.error = TT_Err_Invalid_Reference; + goto LErrorLabel_; + } + + WITH1 = &CUR.callStack[CUR.callTop]; + + WITH1->Caller_Range = CUR.curRange; + WITH1->Caller_IP = CUR.IP + 1; + WITH1->Cur_Count = 1; + WITH1->Cur_Restart = WITH->Start; + + if ( INS_Goto_CodeRange( WITH->Range, WITH->Start ) == FAILURE ) + goto LErrorLabel_; + + goto LSuiteLabel_; + } + else + { + A++; + continue; + } + } + + CUR.error = TT_Err_Invalid_Opcode; + goto LErrorLabel_; +/* break; Unreachable code warning suppress. Leave in case a later + change to remind the editor to consider break; */ + + default: + goto LErrorLabel_; +/* break; */ + } + } + + CUR.top = CUR.new_top; + + if ( CUR.step_ins ) + CUR.IP += CUR.length; + + /* increment instruction counter and check if we didn't */ + /* run this program for too long ?? (e.g. infinite loops) */ + if ( ++ins_counter > MAX_RUNNABLE_OPCODES ) + { + CUR.error = TT_Err_Execution_Too_Long; + goto LErrorLabel_; + } + + LSuiteLabel_: + + if ( CUR.IP >= CUR.codeSize ) + { + if ( CUR.callTop > 0 ) + { + CUR.error = TT_Err_Code_Overflow; + goto LErrorLabel_; + } + else + goto LNo_Error_; + } + } while ( !CUR.instruction_trap ); + + LNo_Error_: + CUR.error = TT_Err_Ok; + + LErrorLabel_: + +#ifdef TT_CONFIG_OPTION_STATIC_INTERPRETER + *exc = cur; +#endif + + return CUR.error; + + + } + + +#ifdef DEBUG_INTERPRETER + + /* This function must be declared by the debugger front end */ + /* in order to specify which code range to debug. */ + + int debug_coderange = TT_CodeRange_Glyph; + + + LOCAL_FUNC + TT_Error RunIns( PExecution_Context exc ) + { + Int A, diff; + ULong next_IP; + Char ch, oldch; + char *temp; + int key; + + TT_Error error = 0; + + TGlyph_Zone save; + TGlyph_Zone pts; + +#define TT_Round_Off 5 +#define TT_Round_To_Half_Grid 0 +#define TT_Round_To_Grid 1 +#define TT_Round_To_Double_Grid 2 +#define TT_Round_Up_To_Grid 4 +#define TT_Round_Down_To_Grid 3 +#define TT_Round_Super 6 +#define TT_Round_Super_45 7 + + const String* round_str[8] = + { + "to half-grid", + "to grid", + "to double grid", + "down to grid", + "up to grid", + "off", + "super", + "super 45" + }; + + /* Check that we're running the code range that is effectively */ + /* asked by the debugger front end. */ + if ( exc->curRange != debug_coderange ) + return RunIns2( exc ); + + pts = exc->pts; + + save.n_points = pts.n_points; + save.n_contours = pts.n_contours; + + MEM_Alloc( save.org, sizeof ( TT_Vector ) * save.n_points ); + MEM_Alloc( save.cur, sizeof ( TT_Vector ) * save.n_points ); + MEM_Alloc( save.touch, sizeof ( Byte ) * save.n_points ); + + exc->instruction_trap = 1; + + oldch = '\0'; + + do + { + if ( exc->IP < exc->codeSize ) + { +#ifdef TT_CONFIG_OPTION_STATIC_INTERPRETER + cur = *exc; +#endif + CALC_Length(); + + exc->args = exc->top - (Pop_Push_Count[exc->opcode] >> 4); + + /* `args' is the top of the stack once arguments have been popped. */ + /* One can also interpret it as the index of the last argument. */ + + /* Print the current line. We use a 80-columns console with the */ + /* following formatting: */ + /* */ + /* [loc]:[addr] [opcode] [disassemby] [a][b]|[c][d] */ + /* */ + + { + char temp[80]; + int n, col, pop; + int args = CUR.args; + + + sprintf( temp, "%78c\n", ' ' ); + + /* first letter of location */ + switch ( CUR.curRange ) + { + case TT_CodeRange_Glyph: + temp[0] = 'g'; + break; + case TT_CodeRange_Cvt: + temp[0] = 'c'; + break; + default: + temp[0] = 'f'; + } + + /* current IP */ + sprintf( temp+1, "%04lx: %02x %-36.36s", + CUR.IP, + CUR.opcode, + Cur_U_Line(&CUR) ); + + strncpy( temp+46, " (", 2 ); + + args = CUR.top - 1; + pop = Pop_Push_Count[CUR.opcode] >> 4; + col = 48; + for ( n = 6; n > 0; n-- ) + { + if ( pop == 0 ) + temp[col-1] = (temp[col-1] == '(' ? ' ' : ')' ); + + if ( args < CUR.top && args >= 0 ) + sprintf( temp+col, "%04lx", CUR.stack[args] ); + else + sprintf( temp+col, " " ); + + temp[col+4] = ' '; + col += 5; + pop--; + args--; + } + temp[78] = '\n'; + temp[79] = '\0'; + PTRACE0(( temp )); + } + + /* First, check for empty stack and overflow */ + if ( CUR.args < 0 ) + { + PTRACE0(( "ERROR : Too few arguments\n" )); + exc->error = TT_Err_Too_Few_Arguments; + goto LErrorLabel_; + } + + CUR.new_top = CUR.args + (Pop_Push_Count[CUR.opcode] & 15); + + /* new_top is the new top of the stack, after the instruction's */ + /* execution. top will be set to new_top after the 'case' */ + + if ( CUR.new_top > CUR.stackSize ) + { + PTRACE0(( "ERROR : Stack overflow\n" )); + exc->error = TT_Err_Stack_Overflow; + goto LErrorLabel_; + } + } + else + PTRACE0(( "End of program reached.\n" )); + + key = 0; + do + { + /* read keyboard */ + + ch = getch(); + + switch ( ch ) + { + /* Help - show keybindings */ + case '?': + PTRACE0(( "FDebug Help\n\n" )); + PTRACE0(( "? Show this page\n" )); + PTRACE0(( "q Quit debugger\n" )); + PTRACE0(( "n Skip to next instruction\n" )); + PTRACE0(( "s Step into\n" )); + PTRACE0(( "v Show vector info\n" )); + PTRACE0(( "g Show graphics state\n" )); + PTRACE0(( "p Show points zone\n\n" )); + break; + + /* Show vectors */ + case 'v': + PTRACE0(( "freedom (%04hx,%04hx)\n", exc->GS.freeVector.x, + exc->GS.freeVector.y )); + PTRACE0(( "projection (%04hx,%04hx)\n", exc->GS.projVector.x, + exc->GS.projVector.y )); + PTRACE0(( "dual (%04hx,%04hx)\n\n", exc->GS.dualVector.x, + exc->GS.dualVector.y )); + break; + + /* Show graphics state */ + case 'g': + PTRACE0(( "rounding %s\n", round_str[exc->GS.round_state] )); + PTRACE0(( "min dist %04lx\n", exc->GS.minimum_distance )); + PTRACE0(( "cvt_cutin %04lx\n", exc->GS.control_value_cutin )); + break; + + /* Show points table */ + case 'p': + for ( A = 0; A < exc->pts.n_points; A++ ) + { + PTRACE0(( "%02hx ", A )); + PTRACE0(( "%08lx,%08lx - ", pts.org[A].x, pts.org[A].y )); + PTRACE0(( "%08lx,%08lx\n", pts.cur[A].x, pts.cur[A].y )); + } + PTRACE0(( "\n" )); + break; + + default: + key = 1; + } + } while ( !key ); + + MEM_Copy( save.org, pts.org, pts.n_points * sizeof ( TT_Vector ) ); + MEM_Copy( save.cur, pts.cur, pts.n_points * sizeof ( TT_Vector ) ); + MEM_Copy( save.touch, pts.touch, pts.n_points ); + + /* a return indicate the last command */ + if (ch == '\r') + ch = oldch; + + switch ( ch ) + { + /* Quit debugger */ + case 'q': + goto LErrorLabel_; + + /* Step over */ + case 'n': + if ( exc->IP < exc->codeSize ) + { + /* `step over' is equivalent to `step into' except if */ + /* the current opcode is a CALL or LOOPCALL */ + if ( CUR.opcode != 0x2a && CUR.opcode != 0x2b ) + goto Step_into; + + /* otherwise, loop execution until we reach the next opcode */ + next_IP = CUR.IP + CUR.length; + while ( exc->IP != next_IP ) + { + if ( ( error = RunIns2( exc ) ) ) + goto LErrorLabel_; + } + } + oldch = ch; + break; + + /* Step into */ + case 's': + if ( exc->IP < exc->codeSize ) + + Step_into: + if ( ( error = RunIns2( exc ) ) ) + goto LErrorLabel_; + oldch = ch; + break; + + default: + PTRACE0(( "unknown command. Press ? for help\n" )); + oldch = '\0'; + } + + for ( A = 0; A < pts.n_points; A++ ) + { + diff = 0; + if ( save.org[A].x != pts.org[A].x ) diff |= 1; + if ( save.org[A].y != pts.org[A].y ) diff |= 2; + if ( save.cur[A].x != pts.cur[A].x ) diff |= 4; + if ( save.cur[A].y != pts.cur[A].y ) diff |= 8; + if ( save.touch[A] != pts.touch[A] ) diff |= 16; + + if ( diff ) + { + PTRACE0(( "%02hx ", A )); + + if ( diff & 16 ) temp = "(%01hx)"; else temp = " %01hx "; + PTRACE0(( temp, save.touch[A] & 7 )); + + if ( diff & 1 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.org[A].x )); + + if ( diff & 2 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.org[A].y )); + + if ( diff & 4 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.cur[A].x )); + + if ( diff & 8 ) temp = "(%08lx)"; else temp = " %08lx "; + PTRACE0(( temp, save.cur[A].y )); + + PTRACE0(( "\n" )); + + PTRACE0(( "%02hx ", A )); + + if ( diff & 16 ) temp = "[%01hx]"; else temp = " %01hx "; + PTRACE0(( temp, pts.touch[A] & 7 )); + + if ( diff & 1 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.org[A].x )); + + if ( diff & 2 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.org[A].y )); + + if ( diff & 4 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.cur[A].x )); + + if ( diff & 8 ) temp = "[%08lx]"; else temp = " %08lx "; + PTRACE0(( temp, pts.cur[A].y )); + + PTRACE0(( "\n\n" )); + } + } + } while ( TRUE ); + + LErrorLabel_: + + return error; + } + +#endif /* DEBUG_INTERPRETER */ + + +#endif /* TT_CONFIG_OPTION_NO_INTERPRETER */ + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttinterp.h b/Driver/Font/TrueType/FreeType/ttinterp.h new file mode 100644 index 000000000..0bc3836f3 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttinterp.h @@ -0,0 +1,54 @@ +/******************************************************************* + * + * ttinterp.h 2.2 + * + * TrueType bytecode intepreter. + * + * 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. + * + * + * Changes between 2.2 and 2.1: + * + * - a small bugfix in the Push opcodes + * + * Changes between 2.1 and 2.0: + * + * - created the TTExec component to take care of all execution + * context management. The interpreter has now one single + * function. + * + * - made some changes to support re-entrancy. The re-entrant + * interpreter is smaller! + * + ******************************************************************/ + +#ifndef TTINTERP_H +#define TTINTERP_H + +#include "ttconfig.h" +#include "ttobjs.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* Run instructions in current execution context */ + + LOCAL_DEF TT_Error RunIns( PExecution_Context exc ); + +#ifdef __cplusplus + } +#endif + +#endif /* TTINTERP_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c new file mode 100644 index 000000000..981386995 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -0,0 +1,1574 @@ + +/******************************************************************* + * + * ttload.c 1.0 + * + * TrueType Tables Loader. + * + * 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 "tttypes.h" +#include "ttdebug.h" +#include "ttcalc.h" +#include "ttfile.h" + +#include "tttables.h" +#include "ttobjs.h" + +#include "ttmemory.h" +#include "tttags.h" +#include "ttload.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_load + +/* In all functions, the stream is taken from the 'face' object */ +#define DEFINE_LOCALS DEFINE_LOAD_LOCALS( face->stream ) +#define DEFINE_LOCALS_WO_FRAME DEFINE_LOAD_LOCALS_WO_FRAME( face->stream ) + + +/******************************************************************* + * + * Function : LookUp_TrueType_Table + * + * Description : Looks for a TrueType table by name. + * + * Input : face face table to look for + * tag searched tag + * + * Output : Index of table if found, -1 otherwise. + * + ******************************************************************/ + + EXPORT_FUNC + Long TT_LookUp_Table( PFace face, + ULong tag ) + { + UShort i; + + + PTRACE4(( "TT_LookUp_Table( %08lx, %c%c%c%c )\n", + (Long)face, + (Char)(tag >> 24), + (Char)(tag >> 16), + (Char)(tag >> 8), + (Char)(tag) )); + + for ( i = 0; i < face->numTables; i++ ) + if ( face->dirTables[i].Tag == tag ) + return i; + + PTRACE4(( " Could not find table!\n" )); + return -1; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Collection + * + * Description : Loads the TTC table directory into face table. + * + * Input : face face record to look for + * + * Output : Error code. + * + ******************************************************************/ + + static TT_Error Load_TrueType_Collection( PFace face ) + { + DEFINE_LOCALS; + + ULong n; + + + PTRACE3(( "Load_TrueType_Collection( %08lx )\n", (long)face )); + + if ( FILE_Seek ( 0L ) || + ACCESS_Frame( 12L ) ) + return error; + + face->ttcHeader.Tag = GET_Tag4(); + face->ttcHeader.version = GET_Long(); + face->ttcHeader.DirCount = GET_Long(); + + FORGET_Frame(); + + if ( face->ttcHeader.Tag != TTAG_ttcf ) + { + face->ttcHeader.Tag = 0; + face->ttcHeader.version = 0; + face->ttcHeader.DirCount = 0; + + face->ttcHeader.TableDirectory = NULL; + + PTRACE3(("skipped.\n")); + + return TT_Err_File_Is_Not_Collection; + } + + if ( ALLOC_ARRAY( face->ttcHeader.TableDirectory, + face->ttcHeader.DirCount, + ULong ) || + ACCESS_Frame( face->ttcHeader.DirCount * 4L ) ) + return error; + + for ( n = 0; n < face->ttcHeader.DirCount; n++ ) + face->ttcHeader.TableDirectory[n] = GET_ULong(); + + FORGET_Frame(); + + PTRACE3(( "collections directory loaded.\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Directory + * + * Description : Loads the table directory into face table. + * + * Input : face face record to look for + * + * faceIndex the index of the TrueType font, when + * we're opening a collection. + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Directory( PFace face, ULong faceIndex ) + { + DEFINE_LOCALS; + + UShort n, limit; + TTableDir tableDir; + + PTableDirEntry entry; + + + PTRACE2(("Load_TT_Directory( %08lx, %ld )\n", (long)face, faceIndex)); + + error = Load_TrueType_Collection( face ); + + if ( error ) + { + if ( error != TT_Err_File_Is_Not_Collection ) + return error; + + /* the file isn't a collection, exit if we're asking */ + /* for a collected font */ + if ( faceIndex != 0 ) + return error; + + /* Now skip to the beginning of the file */ + if ( FILE_Seek( 0L ) ) + return error; + } + else + { + /* The file is a collection. Check the font index */ + if ( faceIndex >= face->ttcHeader.DirCount ) + return TT_Err_Invalid_Argument; + + /* select a TrueType font in the ttc file */ + if ( FILE_Seek( face->ttcHeader.TableDirectory[faceIndex] ) ) + return error; + } + + if ( ACCESS_Frame( 12L ) ) + return error; + + tableDir.version = GET_Long(); + tableDir.numTables = GET_UShort(); + + tableDir.searchRange = GET_UShort(); + tableDir.entrySelector = GET_UShort(); + tableDir.rangeShift = GET_UShort(); + + FORGET_Frame(); + + PTRACE2(( "-- Tables count : %12u\n", tableDir.numTables )); + PTRACE2(( "-- Format version : %08lx\n", tableDir.version )); + + /* Check that we have a 'sfnt' format there */ + + if ( tableDir.version != 0x00010000 && /* MS fonts */ + tableDir.version != 0x74727565 && /* Mac fonts */ + tableDir.version != 0x00000000 ) /* some Korean fonts */ + { + PERROR(( "!! invalid file format" )); + return TT_Err_Invalid_File_Format; + } + + face->numTables = tableDir.numTables; + + if ( ALLOC_ARRAY( face->dirTables, + face->numTables, + TTableDirEntry ) ) + return error; + + if ( ACCESS_Frame( face->numTables * 16L ) ) + return error; + + limit = face->numTables; + entry = face->dirTables; + + for ( n = 0; n < limit; n++ ) + { /* loop through the tables and get all entries */ + entry->Tag = GET_Tag4(); + entry->CheckSum = GET_ULong(); + entry->Offset = GET_Long(); + entry->Length = GET_Long(); + + PTRACE2(( " %c%c%c%c - %08lx - %08lx\n", + (Char)(entry->Tag >> 24), + (Char)(entry->Tag >> 16), + (Char)(entry->Tag >> 8 ), + (Char)(entry->Tag), + entry->Offset, + entry->Length )); + entry++; + } + + FORGET_Frame(); + + PTRACE2(( "Directory loaded\n\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_MaxProfile + * + * Description : Loads the maxp table into face table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_MaxProfile( PFace face ) + { + DEFINE_LOCALS; + + Long i; + PMaxProfile maxProfile = &face->maxProfile; + + + PTRACE2(( "Load_TT_MaxProfile( %08lx )\n", (long)face )); + + if ( ( i = TT_LookUp_Table( face, TTAG_maxp ) ) < 0 ) + return TT_Err_Max_Profile_Missing; + + if ( FILE_Seek( face->dirTables[i].Offset ) ) /* seek to maxprofile */ + return error; + + if ( ACCESS_Frame( 32L ) ) /* read into frame */ + return error; + + /* read frame data into face table */ + maxProfile->version = GET_ULong(); + + maxProfile->numGlyphs = GET_UShort(); + + maxProfile->maxPoints = GET_UShort(); + maxProfile->maxContours = GET_UShort(); + maxProfile->maxCompositePoints = GET_UShort(); + maxProfile->maxCompositeContours = GET_UShort(); + + maxProfile->maxZones = GET_UShort(); + maxProfile->maxTwilightPoints = GET_UShort(); + + maxProfile->maxStorage = GET_UShort(); + maxProfile->maxFunctionDefs = GET_UShort(); + maxProfile->maxInstructionDefs = GET_UShort(); + maxProfile->maxStackElements = GET_UShort(); + maxProfile->maxSizeOfInstructions = GET_UShort(); + maxProfile->maxComponentElements = GET_UShort(); + maxProfile->maxComponentDepth = GET_UShort(); + + FORGET_Frame(); + + /* XXX : an adjustement that is necessary to load certain */ + /* broken fonts like "Keystrokes MT" :-( */ + /* */ + /* We allocate 64 function entries by default when */ + /* the maxFunctionDefs field is null. */ + + if (maxProfile->maxFunctionDefs == 0) + maxProfile->maxFunctionDefs = 64; + + face->numGlyphs = maxProfile->numGlyphs; + + face->maxPoints = MAX( maxProfile->maxCompositePoints, + maxProfile->maxPoints ); + face->maxContours = MAX( maxProfile->maxCompositeContours, + maxProfile->maxContours ); + face->maxComponents = maxProfile->maxComponentElements + + maxProfile->maxComponentDepth; + + /* XXX: Some fonts have maxComponents set to 0; we will */ + /* then use 16 of them by default. */ + if ( face->maxComponents == 0 ) + face->maxComponents = 16; + + /* We also increase maxPoints and maxContours in order to support */ + /* some broken fonts. */ + face->maxPoints += 8; + face->maxContours += 4; + + PTRACE2(( "GASP loaded.\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Gasp + * + * Description : Loads the TrueType Gasp table into the face + * table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Gasp( PFace face ) + { + DEFINE_LOCALS; + + Long i; + UShort j; + TGasp* gas; + GaspRange* gaspranges; + + + PTRACE2(( "Load_TT_Gasp( %08lx )\n", (long)face )); + + if ( ( i = TT_LookUp_Table( face, TTAG_gasp ) ) < 0 ) + return TT_Err_Ok; /* gasp table is not required */ + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 4L ) ) + return error; + + gas = &face->gasp; + + gas->version = GET_UShort(); + gas->numRanges = GET_UShort(); + + FORGET_Frame(); + + PTRACE3(( "number of ranges = %d\n", gas->numRanges )); + + if ( ALLOC_ARRAY( gaspranges, gas->numRanges, GaspRange ) || + ACCESS_Frame( gas->numRanges * 4L ) ) + goto Fail; + + face->gasp.gaspRanges = gaspranges; + + for ( j = 0; j < gas->numRanges; j++ ) + { + gaspranges[j].maxPPEM = GET_UShort(); + gaspranges[j].gaspFlag = GET_UShort(); + + PTRACE3(( " [max:%d flag:%d]", + gaspranges[j].maxPPEM, + gaspranges[j].gaspFlag )); + } + PTRACE3(("\n")); + + FORGET_Frame(); + + PTRACE2(( "GASP loaded\n" )); + return TT_Err_Ok; + + Fail: + FREE( gaspranges ); + gas->numRanges = 0; + return error; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Header + * + * Description : Loads the TrueType header table into the face + * table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Header( PFace face ) + { + DEFINE_LOCALS; + + Long i; + TT_Header* header; + + + PTRACE2(( "Load_TT_Header( %08lx )\n", (long)face )); + + if ( ( i = TT_LookUp_Table( face, TTAG_head ) ) < 0 ) + { + PTRACE0(( "Font Header is missing !!\n" )); + return TT_Err_Header_Table_Missing; + } + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 54L ) ) + return error; + + header = &face->fontHeader; + + header->Table_Version = GET_ULong(); + header->Font_Revision = GET_ULong(); + + header->CheckSum_Adjust = GET_Long(); + header->Magic_Number = GET_Long(); + + header->Flags = GET_UShort(); + header->Units_Per_EM = GET_UShort(); + + header->Created [0] = GET_Long(); + header->Created [1] = GET_Long(); + header->Modified[0] = GET_Long(); + header->Modified[1] = GET_Long(); + + header->xMin = GET_Short(); + header->yMin = GET_Short(); + header->xMax = GET_Short(); + header->yMax = GET_Short(); + + header->Mac_Style = GET_UShort(); + header->Lowest_Rec_PPEM = GET_UShort(); + + header->Font_Direction = GET_Short(); + header->Index_To_Loc_Format = GET_Short(); + header->Glyph_Data_Format = GET_Short(); + + FORGET_Frame(); + + PTRACE2(( " Units per EM : %8u\n", header->Units_Per_EM )); + PTRACE2(( " IndexToLoc : %8d\n", header->Index_To_Loc_Format )); + PTRACE2(( "Font Header Loaded.\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Metrics + * + * Description : Loads the horizontal or vertical metrics table + * into face object. + * + * Input : face + * vertical set to true when loading the vmtx table, + * or false for hmtx + * + * Output : Error code. + * + ******************************************************************/ + + static + TT_Error Load_TrueType_Metrics( PFace face, + Bool vertical ) + { + DEFINE_LOCALS; + + Long n, num_shorts, num_shorts_checked, num_longs; + + PLongMetrics* longs; + PShortMetrics* shorts; + + PLongMetrics long_metric; + + + PTRACE2(( "Load_TT_%s_Metrics( %08lx )\n", + vertical ? "Vertical" : "Horizontal", + (long)face )); + + if ( vertical ) + { + /* The table is optional, quit silently if it wasn't found */ + /* XXX : Some fonts have a valid vertical header with a non-null */ + /* "number_of_VMetrics" fields, but no corresponding */ + /* 'vmtx' table to get the metrics from (e.g. mingliu) */ + /* */ + /* For safety, we set the field to 0 ! */ + /* */ + n = TT_LookUp_Table( face, TTAG_vmtx ); + if ( n < 0 ) + { + /* Set the number_Of_VMetrics to 0! */ + PTRACE2(( " no vertical header in file.\n" )); + face->verticalHeader.number_Of_VMetrics = 0; + return TT_Err_Ok; + } + + num_longs = face->verticalHeader.number_Of_VMetrics; + longs = (PLongMetrics*)&face->verticalHeader.long_metrics; + shorts = (PShortMetrics*)&face->verticalHeader.short_metrics; + } + else + { + if ( ( n = TT_LookUp_Table( face, TTAG_hmtx ) ) < 0 ) + { + PERROR(( "!! No Horizontal metrics in file !!\n" )); + return TT_Err_Hmtx_Table_Missing; + } + + num_longs = face->horizontalHeader.number_Of_HMetrics; + longs = (PLongMetrics*)&face->horizontalHeader.long_metrics; + shorts = (PShortMetrics*)&face->horizontalHeader.short_metrics; + } + + /* never trust derived values! */ + + num_shorts = face->maxProfile.numGlyphs - num_longs; + num_shorts_checked = ( face->dirTables[n].Length - num_longs * 4 ) / 2; + + if ( num_shorts < 0 ) /* sanity check */ + { + PERROR(( "!! more metrics than glyphs!\n" )); + if ( vertical ) + return TT_Err_Invalid_Vert_Metrics; + else + return TT_Err_Invalid_Horiz_Metrics; + } + + if ( ALLOC_ARRAY( *longs, num_longs, TLongMetrics ) || + ALLOC_ARRAY( *shorts, num_shorts, TShortMetrics ) ) + return error; + + if ( FILE_Seek( face->dirTables[n].Offset ) || + ACCESS_Frame( face->dirTables[n].Length ) ) + return error; + + long_metric = *longs; + for ( n = 0; n < num_longs; n++ ) + { + long_metric->advance = GET_UShort(); + long_metric->bearing = GET_Short(); + long_metric++; + } + + /* do we have an inconsistent number of metric values? */ + + if ( num_shorts > num_shorts_checked ) + { + for ( n = 0; n < num_shorts_checked; n++ ) + (*shorts)[n] = GET_Short(); + + /* we fill up the missing left side bearings with the */ + /* last valid value. Since this will occur for buggy CJK */ + /* fonts usually, nothing serious will happen. */ + + for ( n = num_shorts_checked; n < num_shorts; n++ ) + (*shorts)[n] = (*shorts)[num_shorts_checked - 1]; + } + else + { + for ( n = 0; n < num_shorts; n++ ) + (*shorts)[n] = GET_Short(); + } + + FORGET_Frame(); + + PTRACE2(( "loaded\n" )); + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Metrics_Header + * + * Description : Loads either the "hhea" or "vhea" table in memory + * + * Input : face face table to look for + * vertical a boolean. When set, queries the optional + * "vhea" table. Otherwise, load the mandatory + * "hhea" horizontal header. + * + * Output : Error code. + * + * Note : This function now loads the corresponding metrics table + * (either hmtx or vmtx) and attaches it to the header. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Metrics_Header( PFace face, + Bool vertical ) + { + DEFINE_LOCALS; + + Long i; + + TT_Horizontal_Header* header; + + + PTRACE2(( vertical ? "Vertical header" : "Horizontal header " )); + + if ( vertical ) + { + face->verticalInfo = 0; + + /* The vertical header table is optional, so return quietly if */ + /* we don't find it.. */ + if ( ( i = TT_LookUp_Table( face, TTAG_vhea ) ) < 0 ) + return TT_Err_Ok; + + face->verticalInfo = 1; + header = (TT_Horizontal_Header*)&face->verticalHeader; + } + else + { + /* The orizontal header is mandatory, return an error if we */ + /* don't find it. */ + if ( ( i = TT_LookUp_Table( face, TTAG_hhea ) ) < 0 ) + return TT_Err_Horiz_Header_Missing; + + header = &face->horizontalHeader; + } + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 36L ) ) + return error; + + header->Version = GET_ULong(); + header->Ascender = GET_Short(); + header->Descender = GET_Short(); + header->Line_Gap = GET_Short(); + + header->advance_Width_Max = GET_UShort(); + + header->min_Left_Side_Bearing = GET_Short(); + header->min_Right_Side_Bearing = GET_Short(); + header->xMax_Extent = GET_Short(); + header->caret_Slope_Rise = GET_Short(); + header->caret_Slope_Run = GET_Short(); + + header->Reserved0 = GET_Short(); /* this is caret_Offset for + vertical headers */ + header->Reserved1 = GET_Short(); + header->Reserved2 = GET_Short(); + header->Reserved3 = GET_Short(); + header->Reserved4 = GET_Short(); + + header->metric_Data_Format = GET_Short(); + header->number_Of_HMetrics = GET_UShort(); + + FORGET_Frame(); + + header->long_metrics = NULL; + header->short_metrics = NULL; + + PTRACE2(( "loaded\n" )); + + /* Now try to load the corresponding metrics */ + + return Load_TrueType_Metrics( face, vertical ); + } + + +/******************************************************************* + * + * Function : Load_TrueType_Locations + * + * Description : Loads the location table into face table. + * + * Input : face face table to look for + * + * Output : Error code. + * + * NOTE: + * The Font Header *must* be loaded in the leading segment + * calling this function. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Locations( PFace face ) + { + DEFINE_LOCALS; + + Long n, limit; + Short LongOffsets; + + + PTRACE2(( "Locations " )); + + LongOffsets = face->fontHeader.Index_To_Loc_Format; + + if ( ( n = TT_LookUp_Table( face, TTAG_loca ) ) < 0 ) + return TT_Err_Locations_Missing; + + if ( FILE_Seek( face->dirTables[n].Offset ) ) + return error; + + if ( LongOffsets != 0 ) + { + face->numLocations = face->dirTables[n].Length >> 2; + + PTRACE2(( "(32 bit offsets): %12lu ", + face->numLocations )); + + if ( ALLOC_ARRAY( face->glyphLocations, + face->numLocations, + Long ) ) + return error; + + if ( ACCESS_Frame( face->numLocations * 4L ) ) + return error; + + limit = face->numLocations; + + for ( n = 0; n < limit; n++ ) + face->glyphLocations[n] = GET_Long(); + + FORGET_Frame(); + } + else + { + face->numLocations = face->dirTables[n].Length >> 1; + + PTRACE2(( "(16 bit offsets): %12lu ", + face->numLocations )); + + if ( ALLOC_ARRAY( face->glyphLocations, + face->numLocations, + Long ) ) + return error; + + if ( ACCESS_Frame( face->numLocations * 2L ) ) + return error; + + limit = face->numLocations; + + for ( n = 0; n < limit; n++ ) + face->glyphLocations[n] = + (Long)((ULong)GET_UShort() * 2); + + FORGET_Frame(); + } + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Names + * + * Description : Loads the name table into face table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Names( PFace face ) + { + DEFINE_LOCALS; + + UShort i, bytes; + Long n; + PByte storage; + + TName_Table* names; + TNameRec* namerec; + + + PTRACE2(( "Names " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_name ) ) < 0 ) + { + /* The name table is required so indicate failure. */ + PTRACE2(( "is missing!\n" )); + + return TT_Err_Name_Table_Missing; + } + + /* Seek to the beginning of the table and check the frame access. */ + /* The names table has a 6 byte header. */ + if ( FILE_Seek( face->dirTables[n].Offset ) || + ACCESS_Frame( 6L ) ) + return error; + + names = &face->nameTable; + + /* Load the initial names data. */ + names->format = GET_UShort(); + names->numNameRecords = GET_UShort(); + names->storageOffset = GET_UShort(); + + FORGET_Frame(); + + /* Allocate the array of name records. */ + if ( ALLOC_ARRAY( names->names, + names->numNameRecords, + TNameRec ) || + ACCESS_Frame( names->numNameRecords * 12L ) ) + { + names->numNameRecords = 0; + goto Fail; + } + + /* Load the name records and determine how much storage is needed */ + /* to hold the strings themselves. */ + + for ( i = bytes = 0; i < names->numNameRecords; i++ ) + { + namerec = names->names + i; + namerec->platformID = GET_UShort(); + namerec->encodingID = GET_UShort(); + namerec->languageID = GET_UShort(); + namerec->nameID = GET_UShort(); + namerec->stringLength = GET_UShort(); + namerec->stringOffset = GET_UShort(); + +#if 0 + /* check the ids */ + if ( namerec->platformID <= 3 ) + { +#endif + /* this test takes care of 'holes' in the names tables, as */ + /* reported by Erwin */ + if ( (namerec->stringOffset + namerec->stringLength) > bytes ) + bytes = namerec->stringOffset + namerec->stringLength; +#if 0 + } +#endif + } + + FORGET_Frame(); + + /* Allocate storage for the strings if they exist. */ + + names->storage = NULL; + + if ( bytes > 0 ) + { + if ( ALLOC( storage, bytes ) || + FILE_Read_At( face->dirTables[n].Offset + names->storageOffset, + (void*)storage, + bytes ) ) + goto Fail_Storage; + + names->storage = storage; + + /* Go through and assign the string pointers to the name records. */ + + for ( i = 0; i < names->numNameRecords; i++ ) + { + namerec = names->names + i; + namerec->string = storage + names->names[i].stringOffset; + +/* It is possible (but rather unlikely) that a new platform ID will be */ +/* added by Apple, so we can't rule out IDs > 3. */ + +#if 0 + if ( namerec->platformID <= 3 ) + namerec->string = storage + names->names[i].stringOffset; + else + { + namerec->string = NULL; + namerec->stringLength = 0; + } +#endif + } + } + +#ifdef DEBUG_LEVEL_TRACE + + for ( i = 0; i < names->numNameRecords; i++ ) + { + int j; + + + PTRACE2(( "%d %d %x %d ", + names->names[i].platformID, + names->names[i].encodingID, + names->names[i].languageID, + names->names[i].nameID )); + + /* I know that M$ encoded strings are Unicode, */ + /* but this works reasonable well for debugging purposes. */ + for ( j = 0; j < names->names[i].stringLength; j++ ) + { + if (names->names[i].string) + { + Char c = *(names->names[i].string + j); + + + if ( (Byte)c < 128 ) + PTRACE2(( "%c", c )); + } + } + + PTRACE2(( "\n" )); + } + +#endif /* DEBUG_LEVEL_TRACE */ + + PTRACE2(( "loaded\n" )); + return TT_Err_Ok; + + Fail_Storage: + FREE( storage ); + + Fail: + Free_TrueType_Names( face ); + return error; + } + + +/******************************************************************* + * + * Function : Free_TrueType_Names + * + * Description : Frees a name table. + * + * Input : face face table to look for + * + * Output : TT_Err_Ok. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Free_TrueType_Names( PFace face ) + { + TName_Table* names = &face->nameTable; + + + /* free strings table */ + FREE( names->names ); + + /* free strings storage */ + FREE( names->storage ); + + names->numNameRecords = 0; + names->format = 0; + names->storageOffset = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_CVT + * + * Description : Loads cvt table into resident table. + * + * Input : face face table to look for + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_CVT( PFace face ) + { + DEFINE_LOCALS; + + Long n, limit; + + + PTRACE2(( "CVT " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_cvt ) ) < 0 ) + { + PTRACE2(( "is missing!\n" )); + + face->cvtSize = 0; + face->cvt = NULL; + return TT_Err_Ok; + } + + face->cvtSize = face->dirTables[n].Length / 2; + + if ( ALLOC_ARRAY( face->cvt, + face->cvtSize, + Short ) ) + return error; + + if ( FILE_Seek( face->dirTables[n].Offset ) || + ACCESS_Frame( face->cvtSize * 2L ) ) + return error; + + limit = face->cvtSize; + + for ( n = 0; n < limit; n++ ) + face->cvt[n] = GET_Short(); + + FORGET_Frame(); + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_CMap + * + * Description : Loads the cmap directory in memory. + * The cmaps themselves are loaded in ttcmap.c . + * + * Input : face + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_CMap( PFace face ) + { + DEFINE_LOCALS; + + Long off, table_start; + Long n, limit; + + TCMapDir cmap_dir; + TCMapDirEntry entry_; + PCMapTable cmap; + + + PTRACE2(( "CMaps " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_cmap ) ) < 0 ) + return TT_Err_CMap_Table_Missing; + + table_start = face->dirTables[n].Offset; + + if ( ( FILE_Seek( table_start ) ) || + ( ACCESS_Frame( 4L ) ) ) /* 4 bytes cmap header */ + return error; + + cmap_dir.tableVersionNumber = GET_UShort(); + cmap_dir.numCMaps = GET_UShort(); + + FORGET_Frame(); + + off = FILE_Pos(); /* save offset to cmapdir[] which follows */ + + /* save space in face table for cmap tables */ + if ( ALLOC_ARRAY( face->cMaps, + cmap_dir.numCMaps, + TCMapTable ) ) + return error; + + face->numCMaps = cmap_dir.numCMaps; + + limit = face->numCMaps; + cmap = face->cMaps; + + for ( n = 0; n < limit; n++ ) + { + if ( FILE_Seek( off ) || + ACCESS_Frame( 8L ) ) + return error; + + /* extra code using entry_ for platxxx could be cleaned up later */ + cmap->loaded = FALSE; + cmap->platformID = entry_.platformID = GET_UShort(); + cmap->platformEncodingID = entry_.platformEncodingID = GET_UShort(); + + entry_.offset = GET_Long(); + + FORGET_Frame(); + + off = FILE_Pos(); + + if ( FILE_Seek( table_start + entry_.offset ) || + ACCESS_Frame( 6L ) ) + return error; + + cmap->format = GET_UShort(); + cmap->length = GET_UShort(); + cmap->version = GET_UShort(); + + FORGET_Frame(); + + cmap->offset = FILE_Pos(); + + cmap++; + } + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Programs + * + * Description : Loads the font (fpgm) and cvt programs into the + * face table. + * + * Input : face + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Programs( PFace face ) + { + DEFINE_LOCALS_WO_FRAME; + + Long n; + + + PTRACE2(( "Font program " )); + + /* The font program is optional */ + if ( ( n = TT_LookUp_Table( face, TTAG_fpgm ) ) < 0 ) + { + face->fontProgram = NULL; + face->fontPgmSize = 0; + + PTRACE2(( "is missing!\n" )); + } + else + { + face->fontPgmSize = face->dirTables[n].Length; + + if ( ALLOC( face->fontProgram, + face->fontPgmSize ) || + FILE_Read_At( face->dirTables[n].Offset, + (void*)face->fontProgram, + face->fontPgmSize ) ) + return error; + + PTRACE2(( "loaded, %12d bytes\n", face->fontPgmSize )); + } + + PTRACE2(( "Prep program " )); + + if ( ( n = TT_LookUp_Table( face, TTAG_prep ) ) < 0 ) + { + face->cvtProgram = NULL; + face->cvtPgmSize = 0; + + PTRACE2(( "is missing!\n" )); + } + else + { + face->cvtPgmSize = face->dirTables[n].Length; + + if ( ALLOC( face->cvtProgram, + face->cvtPgmSize ) || + FILE_Read_At( face->dirTables[n].Offset, + (void*)face->cvtProgram, + face->cvtPgmSize ) ) + return error; + + PTRACE2(( "loaded, %12d bytes\n", face->cvtPgmSize )); + } + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_OS2 + * + * Description : Loads the OS2 Table. + * + * Input : face + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_OS2( PFace face ) + { + DEFINE_LOCALS; + + Long i; + TT_OS2* os2; + + + PTRACE2(( "OS/2 Table " )); + + /* We now support old Mac fonts where the OS/2 table doesn't */ + /* exist. Simply put, we set the `version' field to 0xFFFF */ + /* and test this value each time we need to access the table. */ + if ( ( i = TT_LookUp_Table( face, TTAG_OS2 ) ) < 0 ) + { + PTRACE2(( "is missing\n!" )); + face->os2.version = 0xFFFF; + error = TT_Err_Ok; + return TT_Err_Ok; + } + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 78L ) ) + return error; + + os2 = &face->os2; + + os2->version = GET_UShort(); + os2->xAvgCharWidth = GET_Short(); + os2->usWeightClass = GET_UShort(); + os2->usWidthClass = GET_UShort(); + os2->fsType = GET_Short(); + os2->ySubscriptXSize = GET_Short(); + os2->ySubscriptYSize = GET_Short(); + os2->ySubscriptXOffset = GET_Short(); + os2->ySubscriptYOffset = GET_Short(); + os2->ySuperscriptXSize = GET_Short(); + os2->ySuperscriptYSize = GET_Short(); + os2->ySuperscriptXOffset = GET_Short(); + os2->ySuperscriptYOffset = GET_Short(); + os2->yStrikeoutSize = GET_Short(); + os2->yStrikeoutPosition = GET_Short(); + os2->sFamilyClass = GET_Short(); + + for ( i = 0; i < 10; i++ ) + os2->panose[i] = GET_Byte(); + + os2->ulUnicodeRange1 = GET_ULong(); + os2->ulUnicodeRange2 = GET_ULong(); + os2->ulUnicodeRange3 = GET_ULong(); + os2->ulUnicodeRange4 = GET_ULong(); + + for ( i = 0; i < 4; i++ ) + os2->achVendID[i] = GET_Byte(); + + os2->fsSelection = GET_UShort(); + os2->usFirstCharIndex = GET_UShort(); + os2->usLastCharIndex = GET_UShort(); + os2->sTypoAscender = GET_Short(); + os2->sTypoDescender = GET_Short(); + os2->sTypoLineGap = GET_Short(); + os2->usWinAscent = GET_UShort(); + os2->usWinDescent = GET_UShort(); + + FORGET_Frame(); + + if ( os2->version >= 0x0001 ) + { + /* only version 1 tables */ + + if ( ACCESS_Frame( 8L ) ) /* read into frame */ + return error; + + os2->ulCodePageRange1 = GET_ULong(); + os2->ulCodePageRange2 = GET_ULong(); + + FORGET_Frame(); + } + else + { + os2->ulCodePageRange1 = 0; + os2->ulCodePageRange2 = 0; + } + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_PostScript + * + * Description : Loads the post table into face table. + * + * Input : face face table to look for + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_PostScript( PFace face ) + { + DEFINE_LOCALS; + + Long i; + + TT_Postscript* post = &face->postscript; + + + PTRACE2(( "PostScript " )); + + if ( ( i = TT_LookUp_Table( face, TTAG_post ) ) < 0 ) + return TT_Err_Post_Table_Missing; + + if ( FILE_Seek( face->dirTables[i].Offset ) || + ACCESS_Frame( 32L ) ) + return error; + + /* read frame data into face table */ + + post->FormatType = GET_ULong(); + post->italicAngle = GET_ULong(); + post->underlinePosition = GET_Short(); + post->underlineThickness = GET_Short(); + post->isFixedPitch = GET_ULong(); + post->minMemType42 = GET_ULong(); + post->maxMemType42 = GET_ULong(); + post->minMemType1 = GET_ULong(); + post->maxMemType1 = GET_ULong(); + + FORGET_Frame(); + + /* we don't load the glyph names, we do that in a */ + /* library extension (ftxpost). */ + + PTRACE2(( "loaded\n" )); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Hdmx + * + * Description : Loads the horizontal device metrics table. + * + * Input : face face object to look for + * + * Output : SUCCESS on success. FAILURE on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Hdmx( PFace face ) + { + DEFINE_LOCALS; + + TT_Hdmx_Record* rec; + TT_Hdmx hdmx; + Long table; + UShort n, num_glyphs; + Long record_size; + + + hdmx.version = 0; + hdmx.num_records = 0; + hdmx.records = 0; + + face->hdmx = hdmx; + + if ( ( table = TT_LookUp_Table( face, TTAG_hdmx ) ) < 0 ) + return TT_Err_Ok; + + if ( FILE_Seek( face->dirTables[table].Offset ) || + ACCESS_Frame( 8L ) ) + return error; + + hdmx.version = GET_UShort(); + hdmx.num_records = GET_Short(); + record_size = GET_Long(); + + FORGET_Frame(); + + /* Only recognize format 0 */ + + if ( hdmx.version != 0 ) + return TT_Err_Ok; + + if ( ALLOC( hdmx.records, sizeof ( TT_Hdmx_Record ) * hdmx.num_records ) ) + return error; + + num_glyphs = face->numGlyphs; + record_size -= num_glyphs+2; + rec = hdmx.records; + + for ( n = 0; n < hdmx.num_records; n++ ) + { + /* read record */ + + if ( ACCESS_Frame( 2L ) ) + goto Fail; + + rec->ppem = GET_Byte(); + rec->max_width = GET_Byte(); + + FORGET_Frame(); + + if ( ALLOC( rec->widths, num_glyphs ) || + FILE_Read( rec->widths, num_glyphs ) ) + goto Fail; + + /* skip padding bytes */ + if ( record_size > 0 ) + if ( FILE_Skip( record_size ) ) + goto Fail; + + rec++; + } + + face->hdmx = hdmx; + + return TT_Err_Ok; + + Fail: + for ( n = 0; n < hdmx.num_records; n++ ) + FREE( hdmx.records[n].widths ); + + FREE( hdmx.records ); + return error; + } + + +/******************************************************************* + * + * Function : Free_TrueType_Hdmx + * + * Description : Frees the horizontal device metrics table. + * + * Input : face face object to look for + * + * Output : TT_Err_Ok. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Free_TrueType_Hdmx( PFace face ) + { + UShort n; + + + if ( !face ) + return TT_Err_Ok; + + for ( n = 0; n < face->hdmx.num_records; n++ ) + FREE( face->hdmx.records[n].widths ); + + FREE( face->hdmx.records ); + face->hdmx.num_records = 0; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Load_TrueType_Any + * + * Description : Loads any font table into client memory. Used by + * the TT_Get_Font_Data() API function. + * + * Input : face face object to look for + * + * tag tag of table to load. Use the value 0 if you + * want to access the whole font file, else set + * this parameter to a valid TrueType table tag + * that you can forge with the MAKE_TT_TAG + * macro. + * + * offset starting offset in the table (or the file + * if tag == 0 ) + * + * buffer address of target buffer + * + * length address of decision variable : + * + * if length == NULL : + * load the whole table. returns an + * an error if 'offset' == 0 !! + * + * if *length == 0 : + * exit immediately, returning the + * length of the given table, or of + * the font file, depending on the + * value of 'tag' + * + * if *length != 0 : + * load the next 'length' bytes of + * table or font, starting at offset + * 'offset' (in table or font too). + * + * Output : Error condition + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Load_TrueType_Any( PFace face, + ULong tag, + Long offset, + void* buffer, + Long* length ) + { + TT_Stream stream; + TT_Error error; + Long table; + ULong size; + + + if ( tag != 0 ) + { + /* look for tag in font directory */ + table = TT_LookUp_Table( face, tag ); + if ( table < 0 ) + return TT_Err_Table_Missing; + + offset += face->dirTables[table].Offset; + size = face->dirTables[table].Length; + } + else + /* tag = 0 -- the use want to access the font file directly */ + size = TT_Stream_Size( face->stream ); + + if ( length && *length == 0 ) + { + *length = size; + return TT_Err_Ok; + } + + if ( length ) + size = *length; + + if ( !USE_Stream( face->stream, stream ) ) + (void)FILE_Read_At( offset, buffer, size ); + DONE_Stream( stream ); + + return error; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttload.h b/Driver/Font/TrueType/FreeType/ttload.h new file mode 100644 index 000000000..6172fd965 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttload.h @@ -0,0 +1,217 @@ +/******************************************************************* + * + * ttload.h 1.1 + * + * TrueType Tables Loader. + * + * 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. + * + * + * Changes between 1.1 and 1.0 : + * + * - add function Load_TrueType_Any used by TT_Get_Font_Data + * + ******************************************************************/ + +#ifndef TTLOAD_H +#define TTLOAD_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + +#ifdef __cplusplus + extern "C" { +#endif + + EXPORT_DEF + Long TT_LookUp_Table( PFace face, ULong tag ); + + LOCAL_DEF TT_Error Load_TrueType_Directory ( PFace face, + ULong faceIndex ); + + LOCAL_DEF TT_Error Load_TrueType_MaxProfile ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Gasp ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Header ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Locations ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Names ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_CVT ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_CMap ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Programs ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_OS2 ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_PostScript ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Hdmx ( PFace face ); + + LOCAL_DEF TT_Error Load_TrueType_Metrics_Header( PFace face, + Bool vertical ); + + LOCAL_DEF TT_Error Load_TrueType_Any( PFace face, + ULong tag, + Long offset, + void* buffer, + Long* length ); + + LOCAL_DEF TT_Error Free_TrueType_Names( PFace face ); + LOCAL_DEF TT_Error Free_TrueType_Hdmx ( PFace face ); + + +/* The following macros are defined to simplify the writing of */ +/* the various table and glyph loaders. */ + +/* For examples see the code in ttload.c, ttgload.c etc. */ + +#define USE_Stream( original, duplicate ) \ + ( (error = TT_Use_Stream( original, &duplicate )) != TT_Err_Ok ) + +#define DONE_Stream( _stream ) \ + TT_Done_Stream( &_stream ) + +/* Define a file frame -- use it only when needed */ +#define DEFINE_A_FRAME TFileFrame frame = TT_Null_FileFrame + +/* Define a stream -- use it only when needed */ +#define DEFINE_A_STREAM TT_Stream stream + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* re-entrant implementation */ + +/* The following macros define the necessary local */ +/* variables used to access streams and frames. */ + +/* Define stream locals with frame */ +#define DEFINE_STREAM_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM; \ + DEFINE_A_FRAME + +/* Define stream locals without frame */ +#define DEFINE_STREAM_LOCALS_WO_FRAME \ + TT_Error error; \ + DEFINE_A_STREAM + +/* Define locals with a predefined stream in reentrant mode -- see ttload.c */ +#define DEFINE_LOAD_LOCALS( STREAM ) \ + TT_Error error; \ + DEFINE_A_STREAM = (STREAM); \ + DEFINE_A_FRAME + +/* Define locals without frame with a predefined stream - see ttload.c */ +#define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \ + TT_Error error; \ + DEFINE_A_STREAM = (STREAM) + +/* Define all locals necessary to access a font file */ +#define DEFINE_ALL_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM; \ + DEFINE_A_FRAME + + +#define ACCESS_Frame( _size_ ) \ + ( (error = TT_Access_Frame( stream, \ + &frame, \ + (Long)(_size_) )) != TT_Err_Ok ) +#define CHECK_ACCESS_Frame( _size_ ) \ + ( (error = TT_Check_And_Access_Frame( stream, \ + &frame, \ + (Long)(_size_) )) != TT_Err_Ok ) +#define FORGET_Frame() \ + ( (void)TT_Forget_Frame( &frame ) ) + +#define GET_Byte() TT_Get_Byte ( &frame ) +#define GET_Char() TT_Get_Char ( &frame ) +#define GET_UShort() TT_Get_UShort( &frame ) +#define GET_Short() TT_Get_Short ( &frame ) +#define GET_Long() TT_Get_Long ( &frame ) +#define GET_ULong() TT_Get_ULong ( &frame ) +#define GET_Tag4() TT_Get_ULong ( &frame ) + +#define FILE_Pos() TT_File_Pos ( stream ) + +#define FILE_Seek( _position_ ) \ + ( (error = TT_Seek_File( stream, \ + (Long)(_position_) )) != TT_Err_Ok ) +#define FILE_Skip( _distance_ ) \ + ( (error = TT_Skip_File( stream, \ + (Long)(_distance_) )) != TT_Err_Ok ) +#define FILE_Read( buffer, count ) \ + ( (error = TT_Read_File ( stream, \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) +#define FILE_Read_At( pos, buffer, count ) \ + ( (error = TT_Read_At_File( stream, \ + (Long)(pos), \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) + +#else /* thread-safe implementation */ + +/* Define stream locals with frame -- nothing in thread-safe mode */ +#define DEFINE_STREAM_LOCALS \ + TT_Error error + +/* Define stream locals without frame -- nothing in thread-safe mode */ +#define DEFINE_STREAM_LOCALS_WO_FRAME \ + TT_Error error + +/* Define locals with a predefined stream in reentrant mode -- see ttload.c */ +#define DEFINE_LOAD_LOCALS( STREAM ) \ + TT_Error error + + +/* Define locals without frame with a predefined stream - see ttload.c */ +#define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \ + TT_Error error + +/* Define all locals necessary to access a font file */ +#define DEFINE_ALL_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM + + +#define ACCESS_Frame( _size_ ) \ + ( (error = TT_Access_Frame( (Long)(_size_) )) != TT_Err_Ok ) +#define CHECK_ACCESS_Frame( _size_ ) \ + ( (error = TT_Check_And_Access_Frame( (Long)(_size_) )) != TT_Err_Ok ) +#define FORGET_Frame() \ + ( (void)TT_Forget_Frame() ) + +#define GET_Byte() TT_Get_Byte () +#define GET_Char() TT_Get_Char () +#define GET_UShort() TT_Get_UShort() +#define GET_Short() TT_Get_Short () +#define GET_Long() TT_Get_Long () +#define GET_ULong() TT_Get_ULong () +#define GET_Tag4() TT_Get_ULong () + +#define FILE_Pos() TT_File_Pos() + +#define FILE_Seek( _position_ ) \ + ( (error = TT_Seek_File( (Long)(_position_) )) != TT_Err_Ok ) +#define FILE_Skip( _distance_ ) \ + ( (error = TT_Skip_File( (Long)(_distance_) )) != TT_Err_Ok ) +#define FILE_Read( buffer, count ) \ + ( (error = TT_Read_File ( buffer, \ + (Long)(count) )) != TT_Err_Ok ) +#define FILE_Read_At( pos, buffer, count ) \ + ( (error = TT_Read_At_File( (Long)(pos), \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTLOAD_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c new file mode 100644 index 000000000..3687b5ca0 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -0,0 +1,397 @@ +/******************************************************************* + * + * ttmemory.c 1.2 + * + * Memory management component (body). + * + * 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. + * + * + * Changes between 1.1 and 1.2: + * + * - the font pool is gone. + * + * - introduced the FREE macro and the Free function for + * future use in destructors. + * + * - Init_FontPool() is now a macro to allow the compilation of + * 'legacy' applications (all four test programs have been updated). + * + ******************************************************************/ + +#include "ttdebug.h" +#include "ttmemory.h" +#include "ttengine.h" + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_memory + + +#ifdef DEBUG_MEMORY + +#include + +#define MAX_TRACKED_BLOCKS 1024 + + struct TMemRec_ + { + void* base; + Long size; + }; + + typedef struct TMemRec_ TMemRec; + + static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; + + static Int num_alloc; + static Int num_free; + static Int num_realloc; /* counts only `real' reallocations + (i.e., an existing buffer will be resized + to a value larger than zero */ + + static Int fail_alloc; + static Int fail_realloc; + static Int fail_free; + +#endif /* DEBUG_MEMORY */ + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + Long TTMemory_Allocated; + Long TTMemory_MaxAllocated; +#endif + + +/******************************************************************* + * + * Function : TT_Alloc + * + * Description : Allocates memory from the heap buffer. + * + * Input : Size size of the memory to be allocated + * P pointer to a buffer pointer + * + * Output : Error code. + * + * NOTE : The newly allocated block should _always_ be zeroed + * on return. Many parts of the engine rely on this to + * work properly. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Alloc( ULong Size, void** P ) + { +#ifdef DEBUG_MEMORY + Int i; +#endif + + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( Size > (size_t)-1 ) + return TT_Err_Out_Of_Memory; + if ( Size > 0 ) + { + *P = (void*)malloc( Size ); + if ( !*P ) + return TT_Err_Out_Of_Memory; + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated += Size; + TTMemory_MaxAllocated += Size; +#endif + +#ifdef DEBUG_MEMORY + + num_alloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_alloc++; + else + { + pointers[i].base = *P; + pointers[i].size = Size; + } + +#endif /* DEBUG_MEMORY */ + + MEM_Set( *P, 0, Size ); + } + else + *P = NULL; + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + +/******************************************************************* + * + * Function : TT_Realloc + * + * Description : Reallocates memory from the heap buffer. + * + * Input : Size new size of the memory to be allocated; + * if zero, TT_Free() will be called + * P pointer to a buffer pointer; if *P == NULL, + * TT_Alloc() will be called + * + * Output : Error code. + * + * NOTES : It's not necessary to zero the memory in case the + * reallocated buffer is larger than before -- the + * application has to take care of this. + * + * If the memory request fails, TT_Free() will be + * called on *P, and TT_Err_Out_Of_Memory returned. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Realloc( ULong Size, void** P ) + { + void* Q; + +#ifdef DEBUG_MEMORY + Int i; +#endif + + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( !*P ) + return TT_Alloc( Size, P ); + + if ( Size == 0 ) + return TT_Free( P ); + + if ( Size > (size_t)-1 ) + { + TT_Free( *P ); + return TT_Err_Out_Of_Memory; + } + + Q = (void*)realloc( *P, Size ); + if ( !Q ) + { + TT_Free( *P ); + return TT_Err_Out_Of_Memory; + } + +#ifdef DEBUG_MEMORY + + num_realloc++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_realloc++; + else + { +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated += Size - pointers[i].size; + if ( Size > pointers[i].size ) + TTMemory_MaxAllocated += Size - pointers[i].size; +#endif + + pointers[i].base = Q; + pointers[i].size = size; + } +#endif /* DEBUG_MEMORY */ + + *P = Q; + + return TT_Err_Ok; + } + + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + +/******************************************************************* + * + * Function : TT_Free + * + * Description : Releases a previously allocated block of memory. + * + * Input : P pointer to memory block + * + * Output : Always SUCCESS. + * + * Note : The pointer must _always_ be set to NULL by this function. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Free( void** P ) + { +#ifdef DEBUG_MEMORY + Int i; +#endif /* DEBUG_MEMORY */ + + + if ( !P || !*P ) + return TT_Err_Ok; + +#ifdef DEBUG_MEMORY + + num_free++; + + i = 0; + while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) + i++; + + if ( i >= MAX_TRACKED_BLOCKS ) + fail_free++; + else + { +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated -= pointers[i].size; +#endif + + pointers[i].base = NULL; + pointers[i].size = 0; + } +#endif /* DEBUG_MEMORY */ + + free( *P ); + + *P = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Init + * + * Description : Initializes the memory. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Init( void ) + { +#ifdef DEBUG_MEMORY + Int i; + + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + pointers[i].base = NULL; + pointers[i].size = 0; + } + + num_alloc = 0; + num_realloc = 0; + num_free = 0; + + fail_alloc = 0; + fail_realloc = 0; + fail_free = 0; +#endif + + +#ifndef TT_CONFIG_OPTION_THREAD_SAFE + TTMemory_Allocated = 0; + TTMemory_MaxAllocated = 0; +#endif + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : TTMemory_Done + * + * Description : Finalizes memory usage. + * + * Output : Always SUCCESS. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTMemory_Done( void ) + { +#ifdef DEBUG_MEMORY + Int i, num_leaked, tot_leaked; + + + num_leaked = 0; + tot_leaked = 0; + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + num_leaked ++; + tot_leaked += pointers[i].size; + } + } + + fprintf( stderr, + "%d memory allocations, of which %d failed\n", + num_alloc, + fail_alloc ); + + fprintf( stderr, + "%d memory reallocations, of which %d failed\n", + num_realloc, + fail_realloc ); + + fprintf( stderr, + "%d memory frees, of which %d failed\n", + num_free, + fail_free ); + + if ( num_leaked > 0 ) + { + fprintf( stderr, + "There are %d leaked memory blocks, totalizing %d bytes\n", + num_leaked, tot_leaked ); + + for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) + { + if ( pointers[i].base ) + { + fprintf( stderr, + "index: %4d (base: $%08lx, size: %08ld)\n", + i, + (long)pointers[i].base, + pointers[i].size ); + } + } + } + else + fprintf( stderr, "No memory leaks !\n" ); + +#endif /* DEBUG_MEMORY */ + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h new file mode 100644 index 000000000..54394ecc2 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -0,0 +1,125 @@ +/******************************************************************* + * + * ttmemory.h 1.2 + * + * Memory management component (specification). + * + * 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. + * + * Changes between 1.2 and 1.1: + * + * - the font pool is gone! All allocations are now performed + * with malloc() and free(). + * + * - introduced the FREE() macro and the Free() function for + * future use in destructors. + * + * - Init_FontPool() is now a macro to allow the compilation of + * 'legacy' applications (all four test programs have been updated). + * + ******************************************************************/ + +#ifndef TTMEMORY_H +#define TTMEMORY_H + +#include "ttconfig.h" +#include "tttypes.h" +#include + + +#ifdef __cplusplus + extern "C" { +#endif + +#define MEM_Set( dest, byte, count ) memset( dest, byte, count ) + +#ifdef HAVE_MEMCPY +#define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) +#else +#define MEM_Copy( dest, source, count ) bcopy( source, dest, count ) +#endif + +#ifdef HAVE_MEMMOVE +#define MEM_Move( dest, source, count ) memmove( dest, source, count ) +#else +#define MEM_Move( dest, source, count ) bcopy( source, dest, count ) +#endif + + +#define MEM_Alloc( _pointer_, _size_ ) \ + TT_Alloc( _size_, (void**)&(_pointer_) ) + +#define MEM_Realloc( _pointer_, _size_ ) \ + TT_Realloc( _size_, (void**)&(_pointer_) ) + +#define ALLOC( _pointer_, _size_ ) \ + ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok ) + +#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( ( error = MEM_Alloc( _pointer_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define REALLOC( _pointer_, _size_ ) \ + ( ( error = MEM_Realloc( _pointer_, _size_ ) ) != TT_Err_Ok ) + +#define REALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( (error = MEM_Realloc( _pointer_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define FREE( _pointer_ ) \ + TT_Free( (void**)&(_pointer_) ) + + + /* Allocate a block of memory of 'Size' bytes from the heap, and */ + /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ + /* case of error, the pointer is always set to NULL. */ + + EXPORT_DEF + TT_Error TT_Alloc( ULong Size, void** P ); + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + /* Reallocates a block of memory pointed to by '*P' to 'Size' */ + /* bytes from the heap, possibly changing '*P'. If 'Size' is 0, */ + /* TT_Free() is called, if '*P' is NULL, TT_Alloc() is called. */ + /* '*P' is freed (if it's non-NULL) in case of error. */ + + EXPORT_DEF + TT_Error TT_Realloc( ULong Size, void** P ); + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + /* Releases a block that was previously allocated through Alloc. */ + /* Note that the function returns successfully when P or *P are */ + /* already NULL. The pointer '*P' is set to NULL on exit in */ + /* case of success. */ + + EXPORT_DEF + TT_Error TT_Free( void** P ); + + + /* For "legacy" applications, that should be re-coded. */ + /* Note that this won't release the previously allocated font pool. */ + +#define Init_FontPool( x, y ) while( 0 ) { } + + + LOCAL_DEF TT_Error TTMemory_Init( void ); + LOCAL_DEF TT_Error TTMemory_Done( void ); + + +#ifdef __cplusplus + } +#endif + +#endif /* TTMEMORY_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttmutex.c b/Driver/Font/TrueType/FreeType/ttmutex.c new file mode 100644 index 000000000..95f71f801 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttmutex.c @@ -0,0 +1,85 @@ +/******************************************************************* + * + * ttmutex.c 1.0 + * + * Mutual exclusion object, single-threaded implementation + * + * 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. + * + * NOTE: This is a generic non-functional implementation + * that you are welcome to refine for your own system. + * + * Please name your system-specific source with a + * different name (like ttmutex-os2.c or ttmutex-linux.c) + * and change your makefile accordingly. + * + ******************************************************************/ + +#include "ttmutex.h" + + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_mutex + + +/* ANSI C prevents the compilation of empty units. We thus introduce */ +/* a dummy typedef to get rid of compiler warnings/errors. */ +/* Note that gcc's -ansi -pedantic does not report any error here. */ +/* Watcom, VC++ or Borland C++ do however. */ + + typedef void _ttmutex_to_satisfy_ANSI_C_; + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + + LOCAL_FUNC + void TT_Mutex_Create ( TMutex* mutex ) + { + *mutex = (void*)-1; + /* Replace this line with your own mutex creation code */ + } + + + LOCAL_FUNC + void TT_Mutex_Delete ( TMutex* mutex ) + { + *mutex = (void*)0; + /* Replace this line with your own mutex destruction code */ + } + + + LOCAL_FUNC + void TT_Mutex_Lock ( TMutex* mutex ) + { + /* NOTE: It is legal to call this function with a NULL argument */ + /* in which case an immediate return is appropriate. */ + if ( !mutex ) + return; + + ; /* Insert your own mutex locking code here */ + } + + + LOCAL_FUNC + void TT_Mutex_Release( TMutex* mutex ) + { + /* NOTE: It is legal to call this function with a NULL argument */ + /* in which case an immediate return is appropriate */ + if ( !mutex ) + return; + + ; /* Insert your own mutex release code here */ + } + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttmutex.h b/Driver/Font/TrueType/FreeType/ttmutex.h new file mode 100644 index 000000000..3223cbbc0 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttmutex.h @@ -0,0 +1,59 @@ +/******************************************************************* + * + * ttmutex.h 1.0 + * + * Mutual exclusion object / dummy generic interface. + * + * 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. + * + * Note: This file provides a generic interface. The implementation + * to compile depends on your system and the type of + * library you want to build (either singly-threaded, + * thread-safe or re-entrant). + * + * Please read the technical documentation for more details. + * + ******************************************************************/ + +#ifndef TTMUTEX_H +#define TTMUTEX_H + +#include "ttconfig.h" + + + typedef void* TMutex; /* typeless reference to a mutex */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* thread-safe and re-entrant builds */ + +#define MUTEX_Create( mutex ) TT_Mutex_Create ( &(mutex) ) +#define MUTEX_Destroy( mutex ) TT_Mutex_Delete ( &(mutex) ) +#define MUTEX_Lock( mutex ) TT_Mutex_Lock ( &(mutex) ) +#define MUTEX_Release( mutex ) TT_Mutex_Release( &(mutex) ) + + LOCAL_DEF void TT_Mutex_Create ( TMutex* mutex ); /* Create a new mutex */ + LOCAL_DEF void TT_Mutex_Delete ( TMutex* mutex ); /* Delete a mutex */ + LOCAL_DEF void TT_Mutex_Lock ( TMutex* mutex ); /* Lock a mutex. */ + LOCAL_DEF void TT_Mutex_Release( TMutex* mutex ); /* Release a mutex */ + +#else /* for the single-thread build */ + +#define MUTEX_Create( mutex ) /* nothing */ +#define MUTEX_Destroy( mutex ) /* nothing */ +#define MUTEX_Lock( mutex ) /* nothing */ +#define MUTEX_Release( mutex ) /* nothing */ + + /* No code will be generated for mutex operations */ + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#endif /* TTMUTEX_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c new file mode 100644 index 000000000..d51bd7f8c --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -0,0 +1,1494 @@ +/******************************************************************* + * + * ttobjs.c 1.0 + * + * Objects manager. + * + * 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 "ttobjs.h" +#include "ttfile.h" +#include "ttcalc.h" +#include "ttmemory.h" +#include "ttload.h" +#include "ttinterp.h" +#include "ttdebug.h" + + +/* Add extensions definition */ +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE +#include "ttextend.h" +#endif + +/* Required by tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_objs + +/******************************************************************* + * + * Function : New_Context + * + * Description : Creates a new execution context for a given + * face object. + * + ******************************************************************/ + + LOCAL_FUNC + PExecution_Context New_Context( PFace face ) + { + PEngine_Instance engine; + PExecution_Context exec; + + + if ( !face ) + return NULL; + + engine = face->engine; + CACHE_New( engine->objs_exec_cache, exec, face ); + return exec; + } + + +/******************************************************************* + * + * Function : Done_Context + * + * Description : Discards an execution context. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Done_Context( PExecution_Context exec ) + { + PEngine_Instance engine; + + + if ( !exec ) + return TT_Err_Ok; + + engine = exec->face->engine; + return CACHE_Done( engine->objs_exec_cache, exec ); + } + + +#if 0 + +/******************************************************************* + * + * Function : New_Instance + * + * Description : Creates a new instance for a given face object. + * + ******************************************************************/ + + LOCAL_FUNC + PInstance New_Instance( PFace face ) + { + PInstance ins; + + + if ( !face ) + return NULL; + + CACHE_New( &face->instances, ins, face ); + + return ins; + } + + +/******************************************************************* + * + * Function : Done_Instance + * + * Description : Discards an instance. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Done_Instance( PInstance instance ) + { + return CACHE_Done( &instance->owner->instances, instance ); + } + +#endif + + +/******************************************************************* + * * + * GLYPH ZONE FUNCTIONS * + * * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : New_Glyph_Zone + * + * Description : Allocates a new glyph zone + * + * Input : pts pointer to the target glyph zone record + * maxPoints capacity of glyph zone in points + * maxContours capacity of glyph zone in contours + * + * Return : Error code. + * + *****************************************************************/ + + static + TT_Error New_Glyph_Zone( PGlyph_Zone pts, + UShort maxPoints, + UShort maxContours ) + { + TT_Error error; + + + if ( ALLOC( pts->org, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || + ALLOC( pts->cur, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || + ALLOC( pts->touch, maxPoints * sizeof ( Byte ) ) || + ALLOC( pts->contours, maxContours * sizeof ( Short ) ) ) + return error; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Done_Glyph_Zone + * + * Description : Deallocates a glyph zone + * + * Input : pts pointer to the target glyph zone record + * + * Return : Error code. + * + *****************************************************************/ + + static + TT_Error Done_Glyph_Zone( PGlyph_Zone pts ) + { + FREE( pts->contours ); + FREE( pts->touch ); + FREE( pts->cur ); + FREE( pts->org ); + + return TT_Err_Ok; + } + + + +/******************************************************************* + * * + * CODERANGE FUNCTIONS * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Goto_CodeRange + * + * Description : Switch to a new code range (updates Code and IP). + * + * Input : exec target execution context + * range new execution code range + * IP new IP in new code range + * + * Output : SUCCESS on success. FAILURE on error (no code range). + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Goto_CodeRange( PExecution_Context exec, + Int range, + ULong IP ) + { + PCodeRange cr; + + + if ( range < 1 || range > 3 ) + return TT_Err_Bad_Argument; + + cr = &exec->codeRangeTable[range - 1]; + + if ( cr->Base == NULL ) + return TT_Err_Invalid_CodeRange; + + /* NOTE: Because the last instruction of a program may be a CALL */ + /* which will return to the first byte *after* the code */ + /* range, we test for IP <= Size, instead of IP < Size. */ + + if ( IP > cr->Size ) + return TT_Err_Code_Overflow; + + exec->code = cr->Base; + exec->codeSize = cr->Size; + exec->IP = IP; + exec->curRange = range; + + return TT_Err_Ok; + } + + +#if 0 + +/******************************************************************* + * + * Function : Get_CodeRange + * + * Description : Returns a pointer to a given code range. Should + * be used only by the debugger. Returns NULL if + * 'range' is out of current bounds. + * + * Input : exec target execution context + * range new execution code range + * + * Output : Pointer to the code range record. NULL on failure. + * + *****************************************************************/ + + LOCAL_FUNC + PCodeRange Get_CodeRange( PExecution_Context exec, Int range ) + { + if ( range < 1 || range > 3 ) + return NULL; + else /* arrays start with 1 in Pascal, and with 0 in C */ + return &exec->codeRangeTable[range - 1]; + } + +#endif + + +/******************************************************************* + * + * Function : Set_CodeRange + * + * Description : Sets a code range. + * + * Input : exec target execution context + * range code range index + * base new code base + * length range size in bytes + * + * Output : SUCCESS on success. FAILURE on error. + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Set_CodeRange( PExecution_Context exec, + Int range, + void* base, + ULong length ) + { + if ( range < 1 || range > 3 ) + return TT_Err_Bad_Argument; + + exec->codeRangeTable[range - 1].Base = (Byte*)base; + exec->codeRangeTable[range - 1].Size = length; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Clear_CodeRange + * + * Description : Clears a code range. + * + * Input : exec target execution context + * range code range index + * + * Output : SUCCESS on success. FAILURE on error. + * + * Note : Does not set the Error variable. + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Clear_CodeRange( PExecution_Context exec, Int range ) + { + if ( range < 1 || range > 3 ) + return TT_Err_Bad_Argument; + + exec->codeRangeTable[range - 1].Base = NULL; + exec->codeRangeTable[range - 1].Size = 0; + + return TT_Err_Ok; + } + + + +/******************************************************************* + * * + * EXECUTION CONTEXT ROUTINES * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Context_Destroy + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Destroy( void* _context ) + { + PExecution_Context exec = (PExecution_Context)_context; + + if ( !exec ) + return TT_Err_Ok; + + /* free composite load stack */ + FREE( exec->loadStack ); + exec->loadSize = 0; + + /* points zone */ + Done_Glyph_Zone( &exec->pts ); + exec->maxPoints = 0; + exec->maxContours = 0; + + /* free stack */ + FREE( exec->stack ); + exec->stackSize = 0; + + /* free call stack */ + FREE( exec->callStack ); + exec->callSize = 0; + exec->callTop = 0; + + /* free glyph code range */ + FREE( exec->glyphIns ); + exec->glyphSize = 0; + + exec->instance = NULL; + exec->face = NULL; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Context_Create + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Create( void* _context, void* _face ) + { + PExecution_Context exec = (PExecution_Context)_context; + + PFace face = (PFace)_face; + TT_Error error; + + + /* XXX : We don't reserve arrays anymore, this is done automatically */ + /* during a "Context_Load".. */ + + exec->callSize = 32; + if ( ALLOC_ARRAY( exec->callStack, exec->callSize, TCallRecord ) ) + goto Fail_Memory; + + /* all values in the context are set to 0 already, but this is */ + /* here as a remainder */ + exec->maxPoints = 0; + exec->maxContours = 0; + + exec->stackSize = 0; + exec->loadSize = 0; + exec->glyphSize = 0; + + exec->stack = NULL; + exec->loadStack = NULL; + exec->glyphIns = NULL; + + exec->face = face; + exec->instance = NULL; + + return TT_Err_Ok; + + Fail_Memory: + Context_Destroy( exec ); + return error; + } + + +/******************************************************************* + * + * Function : Context_Load + * + *****************************************************************/ + +/****************************************************************/ +/* */ +/* Update_Max : Reallocate a buffer if it needs to */ +/* */ +/* input: size address of buffer's current size */ +/* expressed in elements */ +/* */ +/* multiplier size in bytes of each element in the */ +/* buffer */ +/* */ +/* buff address of the buffer base pointer */ +/* */ +/* new_max new capacity (size) of the buffer */ + + static + TT_Error Update_Max( ULong* size, + ULong multiplier, + void** buff, + ULong new_max ) + { + TT_Error error; + + if ( *size < new_max ) + { + FREE( *buff ); + if ( ALLOC( *buff, new_max * multiplier ) ) + return error; + *size = new_max; + } + return TT_Err_Ok; + } + + +/****************************************************************/ +/* */ +/* Update_Zone: Reallocate a zone if it needs to */ +/* */ +/* input: zone address of the target zone */ +/* */ +/* maxPoints address of the zone's current capacity */ +/* in points */ +/* */ +/* maxContours address of the zone's current capacity */ +/* in contours */ +/* */ +/* newPoints new capacity in points */ +/* */ +/* newContours new capacity in contours */ +/* */ + + static + TT_Error Update_Zone( PGlyph_Zone zone, + UShort* maxPoints, + UShort* maxContours, + UShort newPoints, + UShort newContours ) + { + if ( *maxPoints < newPoints || *maxContours < newContours ) + { + TT_Error error; + + + Done_Glyph_Zone( zone ); + + error = New_Glyph_Zone( zone, newPoints, newContours ); + if ( error ) + return error; + + *maxPoints = newPoints; + *maxContours = newContours; + } + return TT_Err_Ok; + } + + + LOCAL_FUNC + TT_Error Context_Load( PExecution_Context exec, + PFace face, + PInstance ins ) + { + Int i; + TMaxProfile* maxp; + TT_Error error; + + exec->face = face; + maxp = &face->maxProfile; + + exec->instance = ins; + + if ( ins ) + { + exec->numFDefs = ins->numFDefs; + exec->numIDefs = ins->numIDefs; + exec->maxFDefs = ins->maxFDefs; + exec->maxIDefs = ins->maxIDefs; + exec->FDefs = ins->FDefs; + exec->IDefs = ins->IDefs; + exec->metrics = ins->metrics; + + exec->maxFunc = ins->maxFunc; + exec->maxIns = ins->maxIns; + + for ( i = 0; i < MAX_CODE_RANGES; i++ ) + exec->codeRangeTable[i] = ins->codeRangeTable[i]; + + /* set graphics state */ + exec->GS = ins->GS; + + exec->cvtSize = ins->cvtSize; + exec->cvt = ins->cvt; + + exec->storeSize = ins->storeSize; + exec->storage = ins->storage; + + exec->twilight = ins->twilight; + } + + error = Update_Max( &exec->loadSize, + sizeof ( TSubglyph_Record ), + (void**)&exec->loadStack, + face->maxComponents + 1 ); + if ( error ) + return error; + + error = Update_Max( &exec->stackSize, + sizeof ( TT_F26Dot6 ), + (void**)&exec->stack, + maxp->maxStackElements + 32 ); + /* XXX : We reserve a little more elements on the stack to deal safely */ + /* with broken fonts like arialbs, courbs, timesbs... */ + if ( error ) + return error; + + error = Update_Max( &exec->glyphSize, + sizeof ( Byte ), + (void**)&exec->glyphIns, + maxp->maxSizeOfInstructions ); + if ( error ) + return error; + + error = Update_Zone( &exec->pts, + &exec->maxPoints, + &exec->maxContours, + exec->face->maxPoints + 2, + exec->face->maxContours ); + /* XXX : We reserve two positions for the phantom points! */ + if ( error ) + return error; + + exec->pts.n_points = 0; + exec->pts.n_contours = 0; + + exec->instruction_trap = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Context_Save + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Save( PExecution_Context exec, + PInstance ins ) + { + Int i; + + /* XXXX : Will probably disappear soon with all the coderange */ + /* management, which is now rather obsolete. */ + + ins->numFDefs = exec->numFDefs; + ins->numIDefs = exec->numIDefs; + ins->maxFunc = exec->maxFunc; + ins->maxIns = exec->maxIns; + + for ( i = 0; i < MAX_CODE_RANGES; i++ ) + ins->codeRangeTable[i] = exec->codeRangeTable[i]; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Context_Run + * + *****************************************************************/ + + LOCAL_FUNC + TT_Error Context_Run( PExecution_Context exec, + Bool debug ) + { + TT_Error error; + + + if ( (error = Goto_CodeRange( exec, + TT_CodeRange_Glyph, 0 )) != TT_Err_Ok ) + return error; + + exec->zp0 = exec->pts; + exec->zp1 = exec->pts; + exec->zp2 = exec->pts; + + exec->GS.gep0 = 1; + exec->GS.gep1 = 1; + exec->GS.gep2 = 1; + + exec->GS.projVector.x = 0x4000; + exec->GS.projVector.y = 0x0000; + + exec->GS.freeVector = exec->GS.projVector; + exec->GS.dualVector = exec->GS.projVector; + + exec->GS.round_state = 1; + exec->GS.loop = 1; + + /* some glyphs leave something on the stack. so we clean it */ + /* before a new execution. */ + exec->top = 0; + exec->callTop = 0; + + if ( !debug ) + return RunIns( exec ); + else + return TT_Err_Ok; + } + + + LOCAL_FUNC + const TGraphicsState Default_GraphicsState = + { + 0, 0, 0, + { 0x4000, 0 }, + { 0x4000, 0 }, + { 0x4000, 0 }, + 1, 64, 1, + TRUE, 68, 0, 0, 9, 3, + 0, FALSE, 2, 1, 1, 1 + }; + + + +/******************************************************************* + * * + * INSTANCE FUNCTIONS * + * * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Instance_Destroy + * + * Description : + * + * Input : _instance the instance object to destroy + * + * Output : error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Destroy( void* _instance ) + { + PInstance ins = (PInstance)_instance; + + + if ( !_instance ) + return TT_Err_Ok; + + if ( ins->debug ) + { + /* the debug context must be deleted by the debugger itself */ + ins->context = NULL; + ins->debug = FALSE; + } + + FREE( ins->cvt ); + ins->cvtSize = 0; + + /* free storage area */ + FREE( ins->storage ); + ins->storeSize = 0; + + /* twilight zone */ + Done_Glyph_Zone( &ins->twilight ); + + FREE( ins->FDefs ); + FREE( ins->IDefs ); + ins->numFDefs = 0; + ins->numIDefs = 0; + ins->maxFDefs = 0; + ins->maxIDefs = 0; + ins->maxFunc = -1; + ins->maxIns = -1; + + ins->owner = NULL; + ins->valid = FALSE; + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Instance_Create + * + * Description : + * + * Input : _instance instance record to initialize + * _face parent face object + * + * Output : Error code. All partially built subtables are + * released on error. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Create( void* _instance, + void* _face ) + { + PInstance ins = (PInstance)_instance; + PFace face = (PFace)_face; + TT_Error error; + Int i; + UShort n_twilight; + + PMaxProfile maxp = &face->maxProfile; + + + ins->owner = face; + ins->valid = FALSE; + + ins->maxFDefs = maxp->maxFunctionDefs; + ins->maxIDefs = maxp->maxInstructionDefs; + ins->cvtSize = face->cvtSize; + ins->storeSize = maxp->maxStorage; + + /* Set default metrics */ + { + PIns_Metrics metrics = &ins->metrics; + + + metrics->pointSize = 10 * 64; /* default pointsize = 10pts */ + + metrics->x_resolution = 96; /* default resolution = 96dpi */ + metrics->y_resolution = 96; + + metrics->x_ppem = 0; + metrics->y_ppem = 0; + + metrics->rotated = FALSE; + metrics->stretched = FALSE; + + /* set default compensation ( all 0 ) */ + for ( i = 0; i < 4; i++ ) + metrics->compensations[i] = 0; + } + + /* allocate function defs, instruction defs, cvt and storage area */ + if ( ALLOC_ARRAY( ins->FDefs, ins->maxFDefs, TDefRecord ) || + ALLOC_ARRAY( ins->IDefs, ins->maxIDefs, TDefRecord ) || + ALLOC_ARRAY( ins->cvt, ins->cvtSize, Long ) || + ALLOC_ARRAY( ins->storage, ins->storeSize, Long ) ) + goto Fail_Memory; + + /* reserve twilight zone */ + n_twilight = maxp->maxTwilightPoints; + error = New_Glyph_Zone( &ins->twilight, n_twilight, 0 ); + if (error) + goto Fail_Memory; + + ins->twilight.n_points = n_twilight; + + return TT_Err_Ok; + + Fail_Memory: + Instance_Destroy( ins ); + return error; + } + + +/******************************************************************* + * + * Function : Instance_Init + * + * Description : Initialize a fresh new instance. + * Executes the font program if any is found. + * + * Input : _instance the instance object to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Init( PInstance ins ) + { + PExecution_Context exec; + + TT_Error error; + PFace face = ins->owner; + + + if ( ins->debug ) + exec = ins->context; + else + exec = New_Context( face ); + /* debugging instances have their own context */ + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + ins->GS = Default_GraphicsState; + + ins->numFDefs = 0; + ins->numIDefs = 0; + ins->maxFunc = -1; + ins->maxIns = -1; + + Context_Load( exec, face, ins ); + + exec->callTop = 0; + exec->top = 0; + + exec->period = 64; + exec->phase = 0; + exec->threshold = 0; + + { + PIns_Metrics metrics = &exec->metrics; + + + metrics->x_ppem = 0; + metrics->y_ppem = 0; + metrics->pointSize = 0; + metrics->x_scale1 = 0; + metrics->x_scale2 = 1; + metrics->y_scale1 = 0; + metrics->y_scale2 = 1; + + metrics->ppem = 0; + metrics->scale1 = 0; + metrics->scale2 = 1; + metrics->ratio = 1L << 16; + } + + exec->instruction_trap = FALSE; + + exec->cvtSize = ins->cvtSize; + exec->cvt = ins->cvt; + + exec->F_dot_P = 0x10000; + + /* allow font program execution */ + Set_CodeRange( exec, + TT_CodeRange_Font, + face->fontProgram, + face->fontPgmSize ); + + /* disable CVT and glyph programs coderange */ + Clear_CodeRange( exec, TT_CodeRange_Cvt ); + Clear_CodeRange( exec, TT_CodeRange_Glyph ); + + if ( face->fontPgmSize > 0 ) + { + error = Goto_CodeRange( exec, TT_CodeRange_Font, 0 ); + if ( error ) + goto Fin; + + error = RunIns( exec ); + } + else + error = TT_Err_Ok; + + Fin: + Context_Save( exec, ins ); + + if ( !ins->debug ) + Done_Context( exec ); + /* debugging instances keep their context */ + + ins->valid = FALSE; + + return error; + } + + +/******************************************************************* + * + * Function : Instance_Reset + * + * Description : Resets an instance to a new pointsize/transform. + * Executes the cvt program if any is found. + * + * Input : _instance the instance object to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Instance_Reset( PInstance ins ) + { + PExecution_Context exec; + + TT_Error error; + ULong i; + UShort j; + PFace face; + + + if ( !ins ) + return TT_Err_Invalid_Instance_Handle; + + if ( ins->valid ) + return TT_Err_Ok; + + face = ins->owner; + + if ( ins->metrics.x_ppem < 1 || + ins->metrics.y_ppem < 1 ) + return TT_Err_Invalid_PPem; + + /* compute new transformation */ + if ( ins->metrics.x_ppem >= ins->metrics.y_ppem ) + { + ins->metrics.scale1 = ins->metrics.x_scale1; + ins->metrics.scale2 = ins->metrics.x_scale2; + ins->metrics.ppem = ins->metrics.x_ppem; + ins->metrics.x_ratio = 1L << 16; + ins->metrics.y_ratio = TT_MulDiv( ins->metrics.y_ppem, + 0x10000, + ins->metrics.x_ppem ); + } + else + { + ins->metrics.scale1 = ins->metrics.y_scale1; + ins->metrics.scale2 = ins->metrics.y_scale2; + ins->metrics.ppem = ins->metrics.y_ppem; + ins->metrics.x_ratio = TT_MulDiv( ins->metrics.x_ppem, + 0x10000, + ins->metrics.y_ppem ); + ins->metrics.y_ratio = 1L << 16; + } + + /* Scale the cvt values to the new ppem. */ + /* We use by default the y ppem to scale the CVT. */ + + for ( i = 0; i < ins->cvtSize; i++ ) + ins->cvt[i] = TT_MulDiv( face->cvt[i], + ins->metrics.scale1, + ins->metrics.scale2 ); + + /* All twilight points are originally zero */ + for ( j = 0; j < ins->twilight.n_points; j++ ) + { + ins->twilight.org[j].x = 0; + ins->twilight.org[j].y = 0; + ins->twilight.cur[j].x = 0; + ins->twilight.cur[j].y = 0; + } + + /* clear storage area */ + for ( i = 0; i < ins->storeSize; i++ ) + ins->storage[i] = 0; + + ins->GS = Default_GraphicsState; + + /* get execution context and run prep program */ + + if ( ins->debug ) + exec = ins->context; + else + exec = New_Context(face); + /* debugging instances have their own context */ + + if ( !exec ) + return TT_Err_Could_Not_Find_Context; + + Context_Load( exec, face, ins ); + + Set_CodeRange( exec, + TT_CodeRange_Cvt, + face->cvtProgram, + face->cvtPgmSize ); + + Clear_CodeRange( exec, TT_CodeRange_Glyph ); + + exec->instruction_trap = FALSE; + + exec->top = 0; + exec->callTop = 0; + + if ( face->cvtPgmSize > 0 ) + { + error = Goto_CodeRange( exec, TT_CodeRange_Cvt, 0 ); + if ( error ) + goto Fin; + + if ( !ins->debug ) + error = RunIns( exec ); + } + else + error = TT_Err_Ok; + + ins->GS = exec->GS; + /* save default graphics state */ + + Fin: + Context_Save( exec, ins ); + + if ( !ins->debug ) + Done_Context( exec ); + /* debugging instances keep their context */ + + if ( !error ) + ins->valid = TRUE; + + return error; + } + + + +/******************************************************************* + * * + * FACE FUNCTIONS * + * * + * * + *******************************************************************/ + +/******************************************************************* + * + * Function : Face_Destroy + * + * Description : The face object destructor. + * + * Input : _face typeless pointer to the face object to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Face_Destroy( void* _face ) + { + PFace face = (PFace)_face; + UShort n; + + + if ( !face ) + return TT_Err_Ok; + + /* well, we assume that no other thread is using the face */ + /* at this moment, but one is never sure enough. */ + MUTEX_Lock( face->lock ); + + /* first of all, destroys the cached sub-objects */ + Cache_Destroy( &face->instances ); + Cache_Destroy( &face->glyphs ); + + /* destroy the extensions */ +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + Extension_Destroy( face ); +#endif + + /* freeing the collection table */ + FREE( face->ttcHeader.TableDirectory ); + face->ttcHeader.DirCount = 0; + + /* freeing table directory */ + FREE( face->dirTables ); + face->numTables = 0; + + /* freeing the locations table */ + FREE( face->glyphLocations ); + face->numLocations = 0; + + /* freeing the character mapping tables */ + for ( n = 0; n < face->numCMaps; n++ ) + CharMap_Free( face->cMaps + n ); + + FREE( face->cMaps ); + face->numCMaps = 0; + + /* freeing the CVT */ + FREE( face->cvt ); + face->cvtSize = 0; + + /* freeing the horizontal metrics */ + FREE( face->horizontalHeader.long_metrics ); + FREE( face->horizontalHeader.short_metrics ); + + /* freeing the vertical ones, if any */ + if (face->verticalInfo) + { + FREE( face->verticalHeader.long_metrics ); + FREE( face->verticalHeader.short_metrics ); + face->verticalInfo = 0; + } + + /* freeing the programs */ + FREE( face->fontProgram ); + FREE( face->cvtProgram ); + face->fontPgmSize = 0; + face->cvtPgmSize = 0; + + /* freeing the gasp table */ + FREE( face->gasp.gaspRanges ); + face->gasp.numRanges = 0; + + /* freeing the name table */ + Free_TrueType_Names( face ); + + /* freeing the hdmx table */ + Free_TrueType_Hdmx( face ); + + /* TT_Close_Stream( &face->stream ); -- this is performed by the API */ + + /* destroy the mutex */ + MUTEX_Destroy(face->lock); + + return TT_Err_Ok; + } + + +/******************************************************************* + * + * Function : Face_Create + * + * Description : The face object constructor. + * + * Input : _face face record to build + * _input input stream where to load font data + * + * Output : Error code. + * + * NOTE : The input stream is kept in the face object. The + * caller shouldn't destroy it after calling Face_Create(). + * + ******************************************************************/ + +#undef LOAD_ +#define LOAD_( table ) \ + (error = Load_TrueType_##table (face)) != TT_Err_Ok + + + /* LOCAL_FUNC */ + TT_Error Face_Create( void* _face, + void* _input ) + { + PEngine_Instance engine; + + TFont_Input* input = (TFont_Input*)_input; + PFace face = (PFace)_face; + TT_Error error; + + + face->stream = input->stream; + face->engine = input->engine; + + engine = face->engine; + + MUTEX_Create( face->lock ); + + Cache_Create( engine, + engine->objs_instance_class, + &face->instances, + &face->lock ); + + Cache_Create( engine, + engine->objs_glyph_class, + &face->glyphs, + &face->lock ); + + /* Load collection directory if present, then font directory */ + + error = Load_TrueType_Directory( face, input->fontIndex ); + if ( error ) + goto Fail; + + /* Load tables */ + + if ( LOAD_( Header ) || + LOAD_( MaxProfile ) || + LOAD_( Locations ) || + + (error = Load_TrueType_Metrics_Header( face, 0 )) != TT_Err_Ok || + /* load the 'hhea' & 'hmtx' tables at once */ + + LOAD_( CMap ) || + LOAD_( CVT ) || + LOAD_( Programs ) || + LOAD_( Gasp ) || + LOAD_( Names ) || + LOAD_( OS2 ) || + LOAD_( PostScript ) || + + (error = Load_TrueType_Metrics_Header( face, 1 )) != TT_Err_Ok || + /* try to load the 'vhea' & 'vmtx' at once if present */ + + LOAD_( Hdmx ) ) + + goto Fail; + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + if ( ( error = Extension_Create( face ) ) != TT_Err_Ok ) + return error; +#endif + + return TT_Err_Ok; + + Fail : + Face_Destroy( face ); + return error; + } + +#undef LOAD_ + + +/******************************************************************* + * + * Function : Glyph_Destroy + * + * Description : The glyph object destructor. + * + * Input : _glyph typeless pointer to the glyph record to destroy + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Glyph_Destroy( void* _glyph ) + { + PGlyph glyph = (PGlyph)_glyph; + + + if ( !glyph ) + return TT_Err_Ok; + + glyph->outline.owner = TRUE; + return TT_Done_Outline( &glyph->outline ); + } + + +/******************************************************************* + * + * Function : Glyph_Create + * + * Description : The glyph object constructor. + * + * Input : _glyph glyph record to build. + * _face the glyph's parent face. + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error Glyph_Create( void* _glyph, + void* _face ) + { + PFace face = (PFace)_face; + PGlyph glyph = (PGlyph)_glyph; + + + if ( !face ) + return TT_Err_Invalid_Face_Handle; + + if ( !glyph ) + return TT_Err_Invalid_Glyph_Handle; + + glyph->face = face; + + /* XXX: Don't forget the space for the 2 phantom points */ + return TT_New_Outline( glyph->face->maxPoints + 2, + glyph->face->maxContours, + &glyph->outline ); + } + + +/******************************************************************* + * + * Function : Scale_X + * + * Description : scale an horizontal distance from font + * units to 26.6 pixels + * + * Input : metrics pointer to metrics + * x value to scale + * + * Output : scaled value + * + ******************************************************************/ + + LOCAL_FUNC + TT_Pos Scale_X( PIns_Metrics metrics, TT_Pos x ) + { + return TT_MulDiv( x, metrics->x_scale1, metrics->x_scale2 ); + } + + +/******************************************************************* + * + * Function : Scale_Y + * + * Description : scale a vertical distance from font + * units to 26.6 pixels + * + * Input : metrics pointer to metrics + * y value to scale + * + * Output : scaled value + * + ******************************************************************/ + + LOCAL_FUNC + TT_Pos Scale_Y( PIns_Metrics metrics, TT_Pos y ) + { + return TT_MulDiv( y, metrics->y_scale1, metrics->y_scale2 ); + } + + +/******************************************************************* + * + * Function : TTObjs_Init + * + * Description : The TTObjs component initializer. Creates the + * object cache classes, as well as the face record + * cache. + * + * Input : engine engine instance + * + * Output : Error code. + * + ******************************************************************/ + + static + const TCache_Class objs_face_class = + { + sizeof ( TFace ), + -1, + Face_Create, + Face_Destroy, + NULL, + NULL + }; + + static + const TCache_Class objs_instance_class = + { + sizeof ( TInstance ), + -1, + Instance_Create, + Instance_Destroy, + NULL, + NULL + }; + + /* Note that we use a cache size of 1 for the execution context. */ + /* This is to avoid re-creating a new context each time we */ + /* change one instance's attribute (resolution and/or char sizes) */ + /* or when we load a glyph. */ + + static + const TCache_Class objs_exec_class = + { + sizeof ( TExecution_Context ), + 1, + Context_Create, + Context_Destroy, + NULL, + NULL + }; + + static + const TCache_Class objs_glyph_class = + { + sizeof ( TGlyph ), + -1, + Glyph_Create, + Glyph_Destroy, + NULL, + NULL + }; + + LOCAL_FUNC + TT_Error TTObjs_Init( PEngine_Instance engine ) + { + PCache face_cache, exec_cache; + TT_Error error; + + face_cache = 0; + exec_cache = 0; + + if ( ALLOC( face_cache, sizeof ( TCache ) ) || + ALLOC( exec_cache, sizeof ( TCache ) ) ) + goto Fail; + + /* create face cache */ + error = Cache_Create( engine, (PCache_Class)&objs_face_class, + face_cache, &engine->lock ); + + if ( error ) + goto Fail; + + engine->objs_face_cache = face_cache; + + error = Cache_Create( engine, (PCache_Class)&objs_exec_class, + exec_cache, &engine->lock ); + if ( error ) + goto Fail; + + engine->objs_exec_cache = exec_cache; + + engine->objs_face_class = (PCache_Class)&objs_face_class; + engine->objs_instance_class = (PCache_Class)&objs_instance_class; + engine->objs_execution_class = (PCache_Class)&objs_exec_class; + engine->objs_glyph_class = (PCache_Class)&objs_glyph_class; + + goto Exit; + + Fail: + FREE( face_cache ); + FREE( exec_cache ); + + Exit: + return error; + } + + +/******************************************************************* + * + * Function : TTObjs_Done + * + * Description : The TTObjs component finalizer. + * + * Input : engine engine instance + * + * Output : Error code. + * + ******************************************************************/ + + LOCAL_FUNC + TT_Error TTObjs_Done( PEngine_Instance engine ) + { + /* destroy all active faces and contexts before releasing the */ + /* caches */ + Cache_Destroy( (TCache*)engine->objs_exec_cache ); + Cache_Destroy( (TCache*)engine->objs_face_cache ); + + /* Now frees caches and cache classes */ + FREE( engine->objs_exec_cache ); + FREE( engine->objs_face_cache ); + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h new file mode 100644 index 000000000..2414c9fcf --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -0,0 +1,873 @@ +/******************************************************************* + * + * ttobjs.h 1.0 + * + * Objects definition unit. + * + * 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 TTOBJS_H +#define TTOBJS_H + +#include "ttconfig.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttcache.h" +#include "tttables.h" +#include "ttcmap.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* */ +/* This file contains the definitions and methods of the four */ +/* kinds of objects managed by the FreeType engine. These are: */ +/* */ +/* */ +/* Face objects: */ +/* */ +/* There is always one face object per opened TrueType font */ +/* file, and only one. The face object contains data that is */ +/* independent of current transform/scaling/rotation and */ +/* pointsize, or glyph index. This data is made of several */ +/* critical tables that are loaded on face object creation. */ +/* */ +/* A face object tracks all active and recycled objects of */ +/* the instance and execution context classes. Destroying a face */ +/* object will automatically destroy all associated instances. */ +/* */ +/* */ +/* Instance objects: */ +/* */ +/* An instance object always relates to a given face object, */ +/* known as its 'parent' or 'owner', and contains only the */ +/* data that is specific to one given pointsize/transform of */ +/* the face. You can only create an instance from a face object. */ +/* */ +/* An instance's current transform/pointsize can be changed */ +/* at any time using a single high-level API call, */ +/* TT_Reset_Instance(). */ +/* */ +/* Execution Context objects: */ +/* */ +/* An execution context (or context in short) relates to a face. */ +/* It contains the data and tables that are necessary to load */ +/* and hint (i.e. execute the glyph instructions of) one glyph. */ +/* A context is a transient object that is queried/created on */ +/* the fly: client applications never deal with them directly. */ +/* */ +/* */ +/* Glyph objects: */ +/* */ +/* A glyph object contains only the minimal glyph information */ +/* needed to render one glyph correctly. This means that a glyph */ +/* object really contains tables that are sized to hold the */ +/* contents of _any_ glyph of a given face. A client application */ +/* can usually create one glyph object for a given face, then use */ +/* it for all subsequent loads. */ +/* */ +/* Here is an example of a client application : */ +/* (NOTE: No error checking performed here!) */ +/* */ +/* */ +/* TT_Face face; -- face handle */ +/* TT_Instance ins1, ins2; -- two instance handles */ +/* TT_Glyph glyph; -- glyph handle */ +/* */ +/* TT_Init_FreeType(); */ +/* */ +/* -- Initialize the engine. This must be done prior to _any_ */ +/* operation. */ +/* */ +/* TT_Open_Face( "/some/face/name.ttf", &face ); */ +/* */ +/* -- create the face object. This call opens the font file */ +/* */ +/* TT_New_Instance( face, &ins1 ); */ +/* TT_New_Instance( face, &ins2 ); */ +/* */ +/* TT_Set_Instance_PointSize( ins1, 8 ); */ +/* TT_Set_Instance_PointSize( ins2, 12 ); */ +/* */ +/* -- create two distinct instances of the same face */ +/* -- ins1 is pointsize 8 at resolution 96 dpi */ +/* -- ins2 is pointsize 12 at resolution 96 dpi */ +/* */ +/* TT_New_Glyph( face, &glyph ); */ +/* */ +/* -- create a new glyph object which will receive the contents */ +/* of any glyph of 'face' */ +/* */ +/* TT_Load_Glyph( ins1, glyph, 64, DEFAULT_GLYPH_LOAD ); */ +/* */ +/* -- load glyph indexed 64 at pointsize 8 in the 'glyph' object */ +/* -- NOTE: This call will fail if the instance and the glyph */ +/* do not relate to the same face object. */ +/* */ +/* TT_Get_Outline( glyph, &outline ); */ +/* */ +/* -- extract the glyph outline from the object and copies it */ +/* to the 'outline' record */ +/* */ +/* TT_Get_Metrics( glyph, &metrics ); */ +/* */ +/* -- extract the glyph metrics and put them into the 'metrics' */ +/* record */ +/* */ +/* TT_Load_Glyph( ins2, glyph, 64, DEFAULT_GLYPH_LOAD ); */ +/* */ +/* -- load the same glyph at pointsize 12 in the 'glyph' object */ +/* */ +/* */ +/* TT_Close_Face( &face ); */ +/* */ +/* -- destroy the face object. This will destroy 'ins1' and */ +/* 'ins2'. However, the glyph object will still be available */ +/* */ +/* TT_Done_FreeType(); */ +/* */ +/* -- Finalize the engine. This will also destroy all pending */ +/* glyph objects (here 'glyph'). */ + + struct TFace_; + struct TInstance_; + struct TExecution_Context_; + struct TGlyph_; + + typedef struct TFace_ TFace; + typedef TFace* PFace; + + typedef struct TInstance_ TInstance; + typedef TInstance* PInstance; + + typedef struct TExecution_Context_ TExecution_Context; + typedef TExecution_Context* PExecution_Context; + + typedef struct TGlyph_ TGlyph; + typedef TGlyph* PGlyph; + + + /*************************************************************/ + /* */ + /* ADDITIONAL SUBTABLES */ + /* */ + /* These tables are not precisely defined by the specs */ + /* but their structures is implied by the TrueType font */ + /* file layout. */ + /* */ + /*************************************************************/ + + /* Graphics State */ + /* */ + /* The Graphics State (GS) is managed by the */ + /* instruction field, but does not come from */ + /* the font file. Thus, we can use 'int's */ + /* where needed. */ + + struct TGraphicsState_ + { + UShort rp0; + UShort rp1; + UShort rp2; + + TT_UnitVector dualVector; + TT_UnitVector projVector; + TT_UnitVector freeVector; + + Long loop; + TT_F26Dot6 minimum_distance; + Int round_state; + + Bool auto_flip; + TT_F26Dot6 control_value_cutin; + TT_F26Dot6 single_width_cutin; + TT_F26Dot6 single_width_value; + Short delta_base; + Short delta_shift; + + Byte instruct_control; + Bool scan_control; + Int scan_type; + + UShort gep0; + UShort gep1; + UShort gep2; + }; + + typedef struct TGraphicsState_ TGraphicsState; + + + LOCAL_DEF + const TGraphicsState Default_GraphicsState; + + + /*************************************************************/ + /* */ + /* EXECUTION SUBTABLES */ + /* */ + /* These sub-tables relate to instruction execution. */ + /* */ + /*************************************************************/ + +#define MAX_CODE_RANGES 3 + +/* There can only be 3 active code ranges at once: */ +/* - the Font Program */ +/* - the CVT Program */ +/* - a glyph's instructions set */ + +#define TT_CodeRange_Font 1 +#define TT_CodeRange_Cvt 2 +#define TT_CodeRange_Glyph 3 + + + struct TCodeRange_ + { + PByte Base; + ULong Size; + }; + + typedef struct TCodeRange_ TCodeRange; + typedef TCodeRange* PCodeRange; + + + /* Defintion of a code range */ + /* */ + /* Code ranges can be resident to a glyph (i.e. the Font Program) */ + /* while some others are volatile (Glyph instructions). */ + /* Tracking the state and presence of code ranges allows function */ + /* and instruction definitions within a code range to be forgotten */ + /* when the range is discarded. */ + + typedef TCodeRange TCodeRangeTable[MAX_CODE_RANGES]; + + /* defines a function/instruction definition record */ + + struct TDefRecord_ + { + Int Range; /* in which code range is it located ? */ + ULong Start; /* where does it start ? */ + Int Opc; /* function #, or instruction code */ + Bool Active; /* is it active ? */ + }; + + typedef struct TDefRecord_ TDefRecord; + typedef TDefRecord* PDefRecord; + typedef TDefRecord* PDefArray; + + /* defines a call record, used to manage function calls. */ + + struct TCallRecord_ + { + Int Caller_Range; + ULong Caller_IP; + Long Cur_Count; + ULong Cur_Restart; + }; + + typedef struct TCallRecord_ TCallRecord; + typedef TCallRecord* PCallRecord; + typedef TCallRecord* PCallStack; /* defines a simple call stack */ + + + /* This type defining a set of glyph points will be used to represent */ + /* each zone (regular and twilight) during instructions decoding. */ + struct TGlyph_Zone_ + { + UShort n_points; /* number of points in zone */ + Short n_contours; /* number of contours */ + + TT_Vector* org; /* original points coordinates */ + TT_Vector* cur; /* current points coordinates */ + + Byte* touch; /* current touch flags */ + UShort* contours; /* contour end points */ + }; + + typedef struct TGlyph_Zone_ TGlyph_Zone; + typedef TGlyph_Zone* PGlyph_Zone; + + + +#ifndef TT_STATIC_INTEPRETER /* indirect implementation */ + +#define EXEC_OPS PExecution_Context exc, +#define EXEC_OP PExecution_Context exc +#define EXEC_ARGS exc, +#define EXEC_ARG exc + +#else /* static implementation */ + +#define EXEC_OPS /* void */ +#define EXEC_OP /* void */ +#define EXEC_ARGS /* void */ +#define EXEC_ARG /* void */ + +#endif + + /* Rounding function, as used by the interpreter */ + typedef TT_F26Dot6 (*TRound_Function)( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ); + + /* Point displacement along the freedom vector routine, as */ + /* used by the interpreter */ + typedef void (*TMove_Function)( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ); + + /* Distance projection along one of the proj. vectors, as used */ + /* by the interpreter */ + typedef TT_F26Dot6 (*TProject_Function)( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ); + + /* reading a cvt value. Take care of non-square pixels when needed */ + typedef TT_F26Dot6 (*TGet_CVT_Function)( EXEC_OPS ULong index ); + + /* setting or moving a cvt value. Take care of non-square pixels */ + /* when needed */ + typedef void (*TSet_CVT_Function)( EXEC_OPS ULong index, + TT_F26Dot6 value ); + + /* subglyph transformation record */ + struct TTransform_ + { + TT_Fixed xx, xy; /* transformation */ + TT_Fixed yx, yy; /* matrix */ + TT_F26Dot6 ox, oy; /* offsets */ + }; + + typedef struct TTransform_ TTransform; + typedef TTransform* PTransform; + + /* subglyph loading record. Used to load composite components */ + struct TSubglyph_Record_ + { + Long index; /* subglyph index; initialized with -1 */ + Bool is_scaled; /* is the subglyph scaled? */ + Bool is_hinted; /* should it be hinted? */ + Bool preserve_pps; /* preserve phantom points? */ + + Long file_offset; + + TT_Big_Glyph_Metrics metrics; + + TGlyph_Zone zone; + + Long arg1; /* first argument */ + Long arg2; /* second argument */ + + UShort element_flag; /* current load element flag */ + + TTransform transform; /* transform */ + + TT_Vector pp1, pp2; /* phantom points */ + + }; + + typedef struct TSubglyph_Record_ TSubglyph_Record; + typedef TSubglyph_Record* PSubglyph_Record; + typedef TSubglyph_Record* PSubglyph_Stack; + + /* A note regarding non-squared pixels: */ + /* */ + /* (This text will probably go into some docs at some time, for */ + /* now, it is kept there to explain some definitions in the */ + /* TIns_Metrics record). */ + /* */ + /* The CVT is a one-dimensional array containing values that */ + /* control certain important characteristics in a font, like */ + /* the height of all capitals, all lowercase letter, default */ + /* spacing or stem width/height. */ + /* */ + /* These values are found in FUnits in the font file, and must be */ + /* scaled to pixel coordinates before being used by the CVT and */ + /* glyph programs. Unfortunately, when using distinct x and y */ + /* resolutions (or distinct x and y pointsizes), there are two */ + /* possible scalings. */ + /* */ + /* A first try was to implement a 'lazy' scheme where all values */ + /* were scaled when first used. However, while some values are always */ + /* used in the same direction, and some other are used in many */ + /* different circumstances and orientations. */ + /* */ + /* I have found a simpler way to do the same, and it even seems to */ + /* work in most of the cases: */ + /* */ + /* - all CVT values are scaled to the maximum ppem size */ + /* */ + /* - when performing a read or write in the CVT, a ratio factor */ + /* is used to perform adequate scaling. Example: */ + /* */ + /* x_ppem = 14 */ + /* y_ppem = 10 */ + /* */ + /* we choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */ + /* entries are scaled to it. */ + /* */ + /* x_ratio = 1.0 */ + /* y_ratio = y_ppem/ppem (< 1.0) */ + /* */ + /* we compute the current ratio like: */ + /* */ + /* - if projVector is horizontal, */ + /* ratio = x_ratio = 1.0 */ + /* - if projVector is vertical, */ + /* ratop = y_ratio */ + /* - else, */ + /* ratio = sqrt((proj.x*x_ratio)^2 + (proj.y*y_ratio)^2) */ + /* */ + /* reading a cvt value returns ratio * cvt[index] */ + /* writing a cvt value in pixels cvt[index] / ratio */ + /* */ + /* the current ppem is simply ratio * ppem */ + /* */ + + /* metrics used by the instance and execution context objects */ + struct TIns_Metrics_ + { + TT_F26Dot6 pointSize; /* point size. 1 point = 1/72 inch. */ + + UShort x_resolution; /* device horizontal resolution in dpi. */ + UShort y_resolution; /* device vertical resolution in dpi. */ + + UShort x_ppem; /* horizontal pixels per EM */ + UShort y_ppem; /* vertical pixels per EM */ + + Long x_scale1; + Long x_scale2; /* used to scale FUnits to fractional pixels */ + + Long y_scale1; + Long y_scale2; /* used to scale FUnits to fractional pixels */ + + /* for non-square pixels */ + Long x_ratio; + Long y_ratio; + + UShort ppem; /* maximum ppem size */ + Long ratio; /* current ratio */ + Long scale1; + Long scale2; /* scale for ppem */ + + TT_F26Dot6 compensations[4]; /* device-specific compensations */ + + Bool rotated; /* `is the glyph rotated?'-flag */ + Bool stretched; /* `is the glyph stretched?'-flag */ + }; + + typedef struct TIns_Metrics_ TIns_Metrics; + typedef TIns_Metrics* PIns_Metrics; + + + + /***********************************************************************/ + /* */ + /* FreeType Face Type */ + /* */ + /***********************************************************************/ + + struct TFace_ + { + /* parent engine instance for the face object */ + PEngine_Instance engine; + + /* i/o stream */ + TT_Stream stream; + + /* used only by the threaded builds of the library */ + TMutex lock; + + /* TrueType collection header, if any was found */ + TTTCHeader ttcHeader; + + /* maximum profile table, as found in the TrueType file */ + TMaxProfile maxProfile; + + /* Note: */ + /* it seems that some maximum values cannot be */ + /* taken directly from this table, but rather by */ + /* combining some of its fields; e.g. the max. */ + /* number of points seems to be given by */ + /* MAX( maxPoints, maxCompositePoints ) */ + /* */ + /* For this reason, we define later our own */ + /* max values that are used to load and allocate */ + /* further tables. */ + + TT_Header fontHeader; /* the font header, as */ + /* found in the TTF file */ + TT_Horizontal_Header horizontalHeader; /* the horizontal header */ + + Bool verticalInfo; /* True when vertical table */ + TT_Vertical_Header verticalHeader; /* is present in the font */ + + TT_OS2 os2; /* 'OS/2' table */ + + TT_Postscript postscript; /* 'Post' table */ + + TT_Hdmx hdmx; /* 'Hdmx' table */ + + TName_Table nameTable; /* name table */ + + TGasp gasp; /* the 'gasp' table */ + + /* The directory of TrueType tables for this typeface */ + UShort numTables; + PTableDirEntry dirTables; + + /* The directory of character mappings table for */ + /* this typeface */ + UShort numCMaps; + PCMapTable cMaps; + + /* The glyph locations table */ + ULong numLocations; /* UShort is not enough */ +#ifndef TT_HUGE_PTR + PStorage glyphLocations; +#else + Storage TT_HUGE_PTR * glyphLocations; +#endif + + /* NOTE : The "hmtx" is now part of the horizontal header */ + + /* the font program, if any */ + ULong fontPgmSize; + PByte fontProgram; + + /* the cvt program, if any */ + ULong cvtPgmSize; + PByte cvtProgram; + + /* the original, unscaled, control value table */ + ULong cvtSize; + PShort cvt; + + /* The following values _must_ be set by the */ + /* maximum profile loader */ + + UShort numGlyphs; /* the face's total number of glyphs */ + UShort maxPoints; /* max glyph points number, simple and composite */ + UShort maxContours; /* max glyph contours numb, simple and composite */ + UShort maxComponents; /* max components in a composite glyph */ + + /* the following are object caches to track active */ + /* and recycled instances and execution contexts */ + /* objects. See 'ttcache.h' */ + + TCache instances; /* current instances for this face */ + TCache glyphs; /* current glyph containers for this face */ + + + /* A typeless pointer to the face object extensions defined */ + /* in the 'ttextend.*' files. */ + void* extension; + Int n_extensions; /* number of extensions */ + + /* Use extensions to provide additional capabilities to the */ + /* engine. Read the developer's guide in the documentation */ + /* directory to know how to do that. */ + + /* a generic pointer for client use - see TT_Set/Get_Face_Pointer */ + void* generic; + }; + + + + /***********************************************************************/ + /* */ + /* FreeType Instance Type */ + /* */ + /***********************************************************************/ + + struct TInstance_ + { + PFace owner; /* face object */ + + Bool valid; + + TIns_Metrics metrics; + + UShort numFDefs; /* number of function definitions */ + UShort maxFDefs; + PDefArray FDefs; /* table of FDefs entries */ + + UShort numIDefs; /* number of instruction definitions */ + UShort maxIDefs; + PDefArray IDefs; /* table of IDefs entries */ + + Int maxFunc; /* maximum function definition id */ + Int maxIns; /* maximum instruction definition id */ + + TCodeRangeTable codeRangeTable; + + TGraphicsState GS; + TGraphicsState default_GS; + + ULong cvtSize; /* the scaled control value table */ + PLong cvt; + + ULong storeSize; /* The storage area is now part of the */ + PLong storage; /* instance */ + + TGlyph_Zone twilight; /* The instance's twilight zone */ + + /* debugging variables */ + + /* When using the debugger, we must keep the */ + /* execution context tied to the instance */ + /* object rather than asking it on demand */ + + Bool debug; + PExecution_Context context; + + /* a generic pointer for client use - see TT_Set/Get_Instance_Pointer */ + void* generic; + }; + + + /***********************************************************************/ + /* */ + /* FreeType Execution Context Type */ + /* */ + /***********************************************************************/ + + struct TExecution_Context_ + { + PFace face; + PInstance instance; + + /* instructions state */ + + TT_Error error; /* last execution error */ + + Long top; /* top of exec. stack */ + + ULong stackSize; /* size of exec. stack */ + PStorage stack; /* current exec. stack */ + + Long args; + ULong new_top; /* new top after exec. */ + + TGlyph_Zone zp0, /* zone records */ + zp1, + zp2, + pts, + twilight; + + TIns_Metrics metrics; /* instance metrics */ + + TGraphicsState GS; /* current graphics state */ + + Int curRange; /* current code range number */ + PByte code; /* current code range */ + ULong IP; /* current instruction pointer */ + ULong codeSize; /* size of current range */ + + Byte opcode; /* current opcode */ + Int length; /* length of current opcode */ + + Bool step_ins; /* true if the interpreter must */ + /* increment IP after ins. exec */ + ULong cvtSize; + PLong cvt; + + ULong glyphSize; /* glyph instructions buffer size */ + PByte glyphIns; /* glyph instructions buffer */ + + UShort numFDefs; /* number of function defs */ + UShort maxFDefs; /* maximum number of function defs */ + PDefRecord FDefs; /* table of FDefs entries */ + + UShort numIDefs; /* number of instruction defs */ + UShort maxIDefs; /* maximum number of instruction defs */ + PDefRecord IDefs; /* table of IDefs entries */ + + Int maxFunc; + Int maxIns; + + Int callTop, /* top of call stack during execution */ + callSize; /* size of call stack */ + PCallStack callStack; /* call stack */ + + UShort maxPoints; /* capacity of this context's "pts" */ + UShort maxContours; /* record, expressed in points and */ + /* contours.. */ + + TCodeRangeTable codeRangeTable; /* table of valid coderanges */ + /* useful for the debugger */ + + ULong storeSize; /* size of current storage */ + PLong storage; /* storage area */ + + TT_F26Dot6 period; /* values used for the */ + TT_F26Dot6 phase; /* 'SuperRounding' */ + TT_F26Dot6 threshold; + + /* this seems to be unused */ +#if 0 + Int cur_ppem; /* ppem along the current proj vector */ +#endif + Long scale1; /* scaling values along the current */ + Long scale2; /* projection vector too.. */ + Bool cached_metrics; /* the ppem is computed lazily. used */ + /* to trigger computation when needed */ + + Bool instruction_trap; /* If True, the interpreter will */ + /* exit after each instruction */ + + TGraphicsState default_GS; /* graphics state resulting from */ + /* the prep program */ + Bool is_composite; /* ture if the glyph is composite */ + + Bool pedantic_hinting; /* if true, read and write array */ + /* bounds faults halt the hinting */ + + /* latest interpreter additions */ + + Long F_dot_P; /* dot product of freedom and projection */ + /* vectors */ + TRound_Function func_round; /* current rounding function */ + + TProject_Function func_project, /* current projection function */ + func_dualproj, /* current dual proj. function */ + func_freeProj; /* current freedom proj. func */ + + TMove_Function func_move; /* current point move function */ + + TGet_CVT_Function func_read_cvt; /* read a cvt entry */ + TSet_CVT_Function func_write_cvt; /* write a cvt entry (in pixels) */ + TSet_CVT_Function func_move_cvt; /* incr a cvt entry (in pixels) */ + + ULong loadSize; + PSubglyph_Stack loadStack; /* loading subglyph stack */ + + }; + + + /***********************************************************************/ + /* */ + /* FreeType Glyph Object Type */ + /* */ + /***********************************************************************/ + + struct TGlyph_ + { + PFace face; + TT_Big_Glyph_Metrics metrics; + TT_Outline outline; + }; + + + /* The following type is used to load a font from a collection. */ + /* See Face_Create in ttobjs.c */ + + struct TFont_Input_ + { + TT_Stream stream; /* input stream */ + ULong fontIndex; /* index of font in collection */ + PEngine_Instance engine; /* parent engine instance */ + + }; + + typedef struct TFont_Input_ TFont_Input; + + + /********************************************************************/ + /* */ + /* Code Range Functions */ + /* */ + /********************************************************************/ + + /* Goto a specified coderange */ + LOCAL_DEF + TT_Error Goto_CodeRange( PExecution_Context exec, + Int range, + ULong IP ); + +#if 0 + /* Return a pointer to a given coderange record. */ + /* Used only by the debugger. */ + LOCAL_DEF + PCodeRange Get_CodeRange( PExecution_Context exec, + Int range ); +#endif + + /* Set a given code range properties */ + LOCAL_DEF + TT_Error Set_CodeRange( PExecution_Context exec, + Int range, + void* base, + ULong length ); + + /* Clear a given coderange */ + LOCAL_DEF + TT_Error Clear_CodeRange( PExecution_Context exec, Int range ); + + + LOCAL_DEF + PExecution_Context New_Context( PFace face ); + + LOCAL_DEF + TT_Error Done_Context( PExecution_Context exec ); + + + LOCAL_DEF + TT_Error Context_Load( PExecution_Context exec, + PFace face, + PInstance ins ); + + LOCAL_DEF + TT_Error Context_Save( PExecution_Context exec, + PInstance ins ); + + LOCAL_DEF + TT_Error Context_Run( PExecution_Context exec, + Bool debug ); + + LOCAL_DEF + TT_Error Instance_Init( PInstance ins ); + + LOCAL_DEF + TT_Error Instance_Reset( PInstance ins ); + + + /********************************************************************/ + /* */ + /* Handy scaling functions */ + /* */ + /********************************************************************/ + + LOCAL_DEF TT_Pos Scale_X( PIns_Metrics metrics, TT_Pos x ); + LOCAL_DEF TT_Pos Scale_Y( PIns_Metrics metrics, TT_Pos y ); + + /********************************************************************/ + /* */ + /* Component Initializer/Finalizer */ + /* */ + /* Called from 'freetype.c' */ + /* The component must create and register the face, instance and */ + /* execution context cache classes before any object can be */ + /* managed. */ + /* */ + /********************************************************************/ + + LOCAL_DEF TT_Error TTObjs_Init( PEngine_Instance engine ); + LOCAL_DEF TT_Error TTObjs_Done( PEngine_Instance engine ); + +#ifdef __cplusplus + } +#endif + +#endif /* TTOBJS_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c new file mode 100644 index 000000000..ad744b6da --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -0,0 +1,2751 @@ +/******************************************************************* + * + * ttraster.c 1.5 + * + * The FreeType glyph rasterizer (body). + * + * 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. + * + * NOTES: + * + * This version supports the following: + * + * - direct grayscaling + * - sub-banding + * - drop-out modes 4 and 5 + * - second pass for complete drop-out control (bitmap only) + * - variable precision + * + * Changes between 1.5 and 1.4: + * + * Performance tuning. + * + * Changes between 1.4 and 1.3: + * + * Mainly performance tunings: + * + * - Line_Down() and Bezier_Down() now use the functions Line_Up() + * and Bezier_Up() to do their work. + * - optimized Split_Bezier() + * - optimized linked lists used during sweeps + * + ******************************************************************/ + +#include "ttraster.h" +#include "ttdebug.h" +#include "tttypes.h" +#include "ttengine.h" +#include "ttcalc.h" /* for TT_MulDiv only */ + +#include "ttmemory.h" /* only used to allocate memory on engine init */ + +/* required by the tracing mode */ +#undef TT_COMPONENT +#define TT_COMPONENT trace_raster + + +/* The default render pool size */ +#define RASTER_RENDER_POOL 4096 + +/* The size of the two-lines intermediate bitmap used */ +/* for anti-aliasing */ +#define RASTER_GRAY_LINES 2048 + + +#define Raster_Err_None TT_Err_Ok +#define Raster_Err_Not_Ini TT_Err_Raster_Not_Initialized +#define Raster_Err_Overflow TT_Err_Raster_Pool_Overflow +#define Raster_Err_Neg_Height TT_Err_Raster_Negative_Height +#define Raster_Err_Invalid TT_Err_Raster_Invalid_Value +#define Raster_Err_Gray_Unsupported TT_Err_Raster_Gray_Unsupported + + +/* FMulDiv means "Fast MulDiv", it is uses in case where 'b' is typically */ +/* a small value and the result of (a*b) is known to fit in 32 bits. */ +#define FMulDiv( a, b, c ) ( (a) * (b) / (c) ) + +/* On the other hand, SMulDiv is for "Slow MulDiv", and is used typically */ +/* for clipping computations. It simply uses the TT_MulDiv() function */ +/* defined in "ttcalc.h" */ +/* */ +/* So, the following definition fits the bill nicely, and we don't need */ +/* to use the one in 'ttcalc' anymore, even for 16-bit systems... */ +#define SMulDiv TT_MulDiv + + +/* Define DEBUG_RASTER if you want to generate a debug version of the */ +/* rasterizer. This will progressively draw the glyphs while all the */ +/* computation are done directly on the graphics screen (the glyphs */ +/* will be inverted). */ + +/* Note that DEBUG_RASTER should only be used for debugging with b/w */ +/* rendering, not with gray levels. */ + +/* The definition of DEBUG_RASTER should appear in the file */ +/* "ttconfig.h". */ + +#ifdef DEBUG_RASTER + extern Char* Vio; /* A pointer to VRAM or display buffer */ +#endif + + +/* The rasterizer is a very general purpose component, please leave */ +/* the following redefinitions there (you never know your target */ +/* environment). */ + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + +#define MaxBezier 32 /* The maximum number of stacked Bezier curves. */ + /* Setting this constant to more than 32 is a */ + /* pure waste of space. */ + +#define Pixel_Bits 6 /* fractional bits of *input* coordinates */ + + /* States of each line, arc and profile */ + enum TStates_ + { + Unknown, + Ascending, + Descending, + Flat + }; + + typedef enum TStates_ TStates; + + struct TProfile_; + typedef struct TProfile_ TProfile; + typedef TProfile* PProfile; + + struct TProfile_ + { + TT_F26Dot6 X; /* current coordinate during sweep */ + PProfile link; /* link to next profile - various purpose */ + PStorage offset; /* start of profile's data in render pool */ + Int flow; /* Profile orientation: Asc/Descending */ + Long height; /* profile's height in scanlines */ + Long start; /* profile's starting scanline */ + + UShort countL; /* number of lines to step before this */ + /* profile becomes drawable */ + + PProfile next; /* next profile in same contour, used */ + /* during drop-out control */ + }; + + typedef PProfile TProfileList; + typedef PProfile* PProfileList; + + + /* I use the classic trick of two dummy records for the head and tail */ + /* of a linked list; this reduces tests in insertion/deletion/sorting. */ + /* NOTE: used during sweeps only. */ + + /* Simple record used to implement a stack of bands, required */ + /* by the sub-banding mechanism */ + + struct TBand_ + { + Short y_min; /* band's minimum */ + Short y_max; /* band's maximum */ + }; + + typedef struct TBand_ TBand; + + +#define AlignProfileSize \ + (( sizeof(TProfile)+sizeof(long)-1 ) / sizeof(long)) + + + /* Left fill bitmask */ + static const Byte LMask[8] = + { 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01 }; + + /* Right fill bitmask */ + static const Byte RMask[8] = + { 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; + + /* prototypes used for sweep function dispatch */ + typedef void Function_Sweep_Init( RAS_ARGS Short* min, + Short* max ); + + typedef void Function_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ); + + typedef void Function_Sweep_Step( RAS_ARG ); + + +/* NOTE: These operations are only valid on 2's complement processors */ + +#define FLOOR( x ) ( (x) & -ras.precision ) +#define CEILING( x ) ( ((x) + ras.precision - 1) & -ras.precision ) +#define TRUNC( x ) ( (signed long)(x) >> ras.precision_bits ) +#define FRAC( x ) ( (x) & (ras.precision - 1) ) +#define SCALED( x ) ( ((x) << ras.scale_shift) - ras.precision_half ) + +#ifdef DEBUG_RASTER +#define DEBUG_PSET Pset() +#else +#define DEBUG_PSET +#endif + + struct TPoint_ + { + Long x, y; + }; + + typedef struct TPoint_ TPoint; + + + /* Note that I have moved the location of some fields in the */ + /* structure to ensure that the most used variables are used */ + /* at the top. Thus, their offset can be coded with less */ + /* opcodes, and it results in a smaller executable. */ + + struct TRaster_Instance_ + { + Int precision_bits; /* precision related variables */ + Int precision; + Int precision_half; + Long precision_mask; + Int precision_shift; + Int precision_step; + Int precision_jitter; + + Int scale_shift; /* == precision_shift for bitmaps */ + /* == precision_shift+1 for pixmaps */ + + PStorage buff; /* The profiles buffer */ + PStorage sizeBuff; /* Render pool size */ + PStorage maxBuff; /* Profiles buffer size */ + PStorage top; /* Current cursor in buffer */ + + TT_Error error; + + PByte flags; /* current flags table */ + PUShort outs; /* current outlines table */ + + UShort nPoints; /* number of points in current glyph */ + Short nContours; /* number of contours in current glyph */ + Int numTurns; /* number of Y-turns in outline */ + + TPoint* arc; /* current Bezier arc pointer */ + + UShort bWidth; /* target bitmap width */ + PByte bTarget; /* target bitmap buffer */ + PByte gTarget; /* target pixmap buffer */ + + Long lastX, lastY, minY, maxY; + + UShort num_Profs; /* current number of profiles */ + + Bool fresh; /* signals a fresh new profile which */ + /* 'start' field must be completed */ + Bool joint; /* signals that the last arc ended */ + /* exactly on a scanline. Allows */ + /* removal of doublets */ + PProfile cProfile; /* current profile */ + PProfile fProfile; /* head of linked list of profiles */ + PProfile gProfile; /* contour's first profile in case */ + /* of impact */ + TStates state; /* rendering state */ + + TT_Raster_Map target; /* description of target bit/pixmap */ + + Long traceOfs; /* current offset in target bitmap */ + Long traceG; /* current offset in target pixmap */ + + Short traceIncr; /* sweep's increment in target bitmap */ + + Short gray_min_x; /* current min x during gray rendering */ + Short gray_max_x; /* current max x during gray rendering */ + + /* dispatch variables */ + + Function_Sweep_Init* Proc_Sweep_Init; + Function_Sweep_Span* Proc_Sweep_Span; + Function_Sweep_Span* Proc_Sweep_Drop; + Function_Sweep_Step* Proc_Sweep_Step; + + TT_Vector* coords; + + Byte dropOutControl; /* current drop_out control method */ + + Byte grays[5]; /* Palette of gray levels used for render */ + + Byte* gray_lines; /* Intermediate table used to render the */ + /* graylevels pixmaps. */ + /* gray_lines is a buffer holding two */ + /* monochrome scanlines */ + Short gray_width; /* width in bytes of one monochrome */ + /* intermediate scanline of gray_lines. */ + /* Each gray pixel takes 2 bits long there */ + + /* The gray_lines must hold 2 lines, thus with size */ + /* in bytes of at least 'gray_width*2' */ + + Bool second_pass; /* indicates wether a horizontal pass */ + /* should be performed to control drop-out */ + /* accurately when calling Render_Glyph. */ + /* Note that there is no horizontal pass */ + /* during gray rendering. */ + TPoint arcs[2 * MaxBezier + 1]; /* The Bezier stack */ + + TBand band_stack[16]; /* band stack used for sub-banding */ + Int band_top; /* band stack top */ + + Int count_table[256]; /* Look-up table used to quickly count */ + /* set bits in a gray 2x2 cell */ + }; + + +#ifdef TT_CONFIG_OPTION_STATIC_RASTER + + static TRaster_Instance cur_ras; +#define ras cur_ras + +#else + +#define ras (*raster) + +#endif /* TT_STATIC_RASTER */ + + +#ifdef DEBUG_RASTER + + /************************************************/ + /* */ + /* Pset: */ + /* */ + /* Used for debugging only. Plots a point */ + /* in VRAM during rendering (not afterwards). */ + /* */ + /* NOTE: This procedure relies on the value */ + /* of cProfile->start, which may not */ + /* be set when Pset is called sometimes. */ + /* This will usually result in a dot */ + /* plotted on the first screen scanline */ + /* (far away its original position). */ + /* */ + /* This "bug" reflects nothing wrong */ + /* in the current implementation, and */ + /* the bitmap is rendered correctly, */ + /* so don't panic if you see 'flying' */ + /* dots in debugging mode. */ + /* */ + /* - David */ + /* */ + /************************************************/ + + static void Pset( RAS_ARG ) + { + Long o; + Long x; + + + x = ras.top[-1]; + + switch ( ras.cProfile->flow ) + { + case TT_Flow_Up: + o = Vio_ScanLineWidth * + ( ras.top-ras.cProfile->offset + ras.cProfile->start ) + + ( x / (ras.precision*8) ); + break; + + case TT_Flow_Down: + o = Vio_ScanLineWidth * + ( ras.cProfile->start-ras.top + ras.cProfile->offset ) + + ( x / (ras.precision*8) ); + break; + } + + if ( o > 0 ) + Vio[o] |= (unsigned)0x80 >> ( (x/ras.precision) & 7 ); + } + + + static void Clear_Band( RAS_ARGS Int y1, Int y2 ) + { + MEM_Set( Vio + y1*Vio_ScanLineWidth, (y2-y1+1)*Vio_ScanLineWidth, 0 ); + } + +#endif /* DEBUG_RASTER */ + + +/************************************************************************/ +/* */ +/* Function: Set_High_Precision */ +/* */ +/* Description: Sets precision variables according to param flag. */ +/* */ +/* Input: High set to True for high precision (typically for */ +/* ppem < 18), false otherwise. */ +/* */ +/************************************************************************/ + + static void Set_High_Precision( RAS_ARGS Bool High ) + { + if ( High ) + { + ras.precision_bits = 10; + ras.precision_step = 128; + ras.precision_jitter = 24; + } + else + { + ras.precision_bits = 6; + ras.precision_step = 32; + ras.precision_jitter = 2; + } + + PTRACE7(( "Set_High_Precision(%s)\n", High ? "true" : "false" )); + + ras.precision = 1 << ras.precision_bits; + ras.precision_half = ras.precision / 2; + ras.precision_shift = ras.precision_bits - Pixel_Bits; + ras.precision_mask = -ras.precision; + } + + +/****************************************************************************/ +/* */ +/* Function: New_Profile */ +/* */ +/* Description: Creates a new Profile in the render pool. */ +/* */ +/* Input: aState state/orientation of the new Profile */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE in case of overflow or of incoherent Profile. */ +/* */ +/****************************************************************************/ + + static Bool New_Profile( RAS_ARGS TStates aState ) + { + if ( !ras.fProfile ) + { + ras.cProfile = (PProfile)ras.top; + ras.fProfile = ras.cProfile; + ras.top += AlignProfileSize; + } + + if ( ras.top >= ras.maxBuff ) + { + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + switch ( aState ) + { + case Ascending: + ras.cProfile->flow = TT_Flow_Up; + PTRACE7(( "New ascending profile = %lx\n", (long)ras.cProfile )); + break; + + case Descending: + ras.cProfile->flow = TT_Flow_Down; + PTRACE7(( "New descending profile = %lx\n", (long)ras.cProfile )); + break; + + default: + PTRACE0(( "Invalid profile direction in Raster:New_Profile !!\n" )); + ras.error = Raster_Err_Invalid; + return FAILURE; + } + + ras.cProfile->start = 0; + ras.cProfile->height = 0; + ras.cProfile->offset = ras.top; + ras.cProfile->link = (PProfile)0; + ras.cProfile->next = (PProfile)0; + + if ( !ras.gProfile ) + ras.gProfile = ras.cProfile; + + ras.state = aState; + ras.fresh = TRUE; + ras.joint = FALSE; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: End_Profile */ +/* */ +/* Description: Finalizes the current Profile. */ +/* */ +/* Input: None */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE in case of overflow or incoherency. */ +/* */ +/****************************************************************************/ + + static Bool End_Profile( RAS_ARG ) + { + Long h; + PProfile oldProfile; + + + h = ras.top - ras.cProfile->offset; + + if ( h < 0 ) + { + PTRACE0(( "Negative height encountered in End_Profile!\n" )); + ras.error = Raster_Err_Neg_Height; + return FAILURE; + } + + if ( h > 0 ) + { + PTRACE1(( "Ending profile %lx, start = %ld, height = %ld\n", + (long)ras.cProfile, ras.cProfile->start, h )); + + oldProfile = ras.cProfile; + ras.cProfile->height = h; + ras.cProfile = (PProfile)ras.top; + + ras.top += AlignProfileSize; + + ras.cProfile->height = 0; + ras.cProfile->offset = ras.top; + oldProfile->next = ras.cProfile; + ras.num_Profs++; + } + + if ( ras.top >= ras.maxBuff ) + { + PTRACE1(( "overflow in End_Profile\n" )); + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + ras.joint = FALSE; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Insert_Y_Turn */ +/* */ +/* Description: Insert a salient into the sorted list placed on top */ +/* of the render pool */ +/* */ +/* Input: New y scanline position */ +/* */ +/****************************************************************************/ + + static + Bool Insert_Y_Turn( RAS_ARGS Int y ) + { + PStorage y_turns; + Int y2, n; + + n = ras.numTurns-1; + y_turns = ras.sizeBuff - ras.numTurns; + + /* look for first y value that is <= */ + while ( n >= 0 && y < y_turns[n] ) + n--; + + /* if it is <, simply insert it, ignore if == */ + if ( n >= 0 && y > y_turns[n] ) + while ( n >= 0 ) + { + y2 = y_turns[n]; + y_turns[n] = y; + y = y2; + n--; + } + + if ( n < 0 ) + { + if (ras.maxBuff <= ras.top) + { + ras.error = Raster_Err_Overflow; + return FAILURE; + } + ras.maxBuff--; + ras.numTurns++; + ras.sizeBuff[-ras.numTurns] = y; + } + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Finalize_Profile_Table */ +/* */ +/* Description: Adjusts all links in the Profiles list. */ +/* */ +/* Input: None */ +/* */ +/* Returns: None. */ +/* */ +/****************************************************************************/ + + static + Bool Finalize_Profile_Table( RAS_ARG ) + { + Int bottom, top; + UShort n; + PProfile p; + + + n = ras.num_Profs; + + if ( n > 1 ) + { + p = ras.fProfile; + while ( n > 0 ) + { + if ( n > 1 ) + p->link = (PProfile)( p->offset + p->height ); + else + p->link = NULL; + + switch ( p->flow ) + { + case TT_Flow_Down: + bottom = p->start - p->height+1; + top = p->start; + p->start = bottom; + p->offset += p->height-1; + break; + + case TT_Flow_Up: + default: + bottom = p->start; + top = p->start + p->height-1; + } + + if ( Insert_Y_Turn( RAS_VARS bottom ) || + Insert_Y_Turn( RAS_VARS top+1 ) ) + return FAILURE; + + p = p->link; + n--; + } + } + else + ras.fProfile = NULL; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Split_Bezier */ +/* */ +/* Description: Subdivides one Bezier arc into two joint */ +/* sub-arcs in the Bezier stack. */ +/* */ +/* Input: None (subdivided bezier is taken from the top of the */ +/* stack). */ +/* */ +/* Returns: None. */ +/* */ +/* */ +/* Note: This routine is the 'beef' of this component. It is _the_ */ +/* inner loop that should be optimized to hell to get the */ +/* best performance. */ +/* */ +/****************************************************************************/ + + static void Split_Bezier( TPoint* base ) + { + Long a, b; + + + base[4].x = base[2].x; + b = base[1].x; + a = base[3].x = ( base[2].x + b ) / 2; + b = base[1].x = ( base[0].x + b ) / 2; + base[2].x = ( a + b ) / 2; + + base[4].y = base[2].y; + b = base[1].y; + a = base[3].y = ( base[2].y + b ) / 2; + b = base[1].y = ( base[0].y + b ) / 2; + base[2].y = ( a + b ) / 2; + + /* hand optimized. gcc doesn't seem too good at common expression */ + /* substitution and instruction scheduling ;-) */ + } + + +/****************************************************************************/ +/* */ +/* Function: Push_Bezier */ +/* */ +/* Description: Clears the Bezier stack and pushes a new arc on top of it. */ +/* */ +/* Input: x1,y1 x2,y2 x3,y3 new Bezier arc */ +/* */ +/* Returns: None. */ +/* */ +/****************************************************************************/ + + static void Push_Bezier( RAS_ARGS Long x1, Long y1, + Long x2, Long y2, + Long x3, Long y3 ) + { + ras.arc = ras.arcs; + ras.arc[2].x = x1; ras.arc[2].y = y1; + ras.arc[1].x = x2; ras.arc[1].y = y2; + ras.arc[0].x = x3; ras.arc[0].y = y3; + } + + +/****************************************************************************/ +/* */ +/* Function: Line_Up */ +/* */ +/* Description: Computes the x-coordinates of an ascending line segment */ +/* and stores them in the render pool. */ +/* */ +/* Input: x1,y1,x2,y2 Segment start (x1,y1) and end (x2,y2) points */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow. */ +/* */ +/****************************************************************************/ + + static Bool Line_Up( RAS_ARGS Long x1, Long y1, + Long x2, Long y2, + Long miny, Long maxy ) + { + Long Dx, Dy; + Int e1, e2, f1, f2, size; /* XXX: is `Short' sufficient? */ + Long Ix, Rx, Ax; + + PStorage top; + + + Dx = x2 - x1; + Dy = y2 - y1; + + if ( Dy <= 0 || y2 < miny || y1 > maxy ) + return SUCCESS; + + if ( y1 < miny ) + { + /* Take care : miny-y1 can be a very large value, we use */ + /* a slow MulDiv function to avoid clipping bugs */ + x1 += SMulDiv( Dx, miny - y1, Dy ); + e1 = TRUNC( miny ); + f1 = 0; + } + else + { + e1 = TRUNC( y1 ); + f1 = FRAC( y1 ); + } + + if ( y2 > maxy ) + { + /* x2 += FMulDiv( Dx, maxy - y2, Dy ); UNNECESSARY */ + e2 = TRUNC( maxy ); + f2 = 0; + } + else + { + e2 = TRUNC( y2 ); + f2 = FRAC( y2 ); + } + + if ( f1 > 0 ) + { + if ( e1 == e2 ) return SUCCESS; + else + { + x1 += FMulDiv( Dx, ras.precision - f1, Dy ); + e1 += 1; + } + } + else + if ( ras.joint ) + { + ras.top--; + ras.joint = FALSE; + } + + ras.joint = ( f2 == 0 ); + + if ( ras.fresh ) + { + ras.cProfile->start = e1; + ras.fresh = FALSE; + } + + size = e2 - e1 + 1; + if ( ras.top + size >= ras.maxBuff ) + { + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + if ( Dx > 0 ) + { + Ix = (ras.precision*Dx) / Dy; + Rx = (ras.precision*Dx) % Dy; + Dx = 1; + } + else + { + Ix = -( (ras.precision*-Dx) / Dy ); + Rx = (ras.precision*-Dx) % Dy; + Dx = -1; + } + + Ax = -Dy; + top = ras.top; + + while ( size > 0 ) + { + *top++ = x1; + + DEBUG_PSET; + + x1 += Ix; + Ax += Rx; + if ( Ax >= 0 ) + { + Ax -= Dy; + x1 += Dx; + } + size--; + } + + ras.top = top; + return SUCCESS; + } + + + static Bool Line_Down( RAS_ARGS Long x1, Long y1, + Long x2, Long y2, + Long miny, Long maxy ) + { + Bool result, fresh; + + + fresh = ras.fresh; + + result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny ); + + if ( fresh && !ras.fresh ) + ras.cProfile->start = -ras.cProfile->start; + + return result; + } + + +/****************************************************************************/ +/* */ +/* Function: Bezier_Up */ +/* */ +/* Description: Computes thes x-coordinates of an ascending bezier arc */ +/* and stores them in the render pool. */ +/* */ +/* Input: None. The arc is taken from the top of the Bezier stack. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow. */ +/* */ +/****************************************************************************/ + + static Bool Bezier_Up( RAS_ARGS Long miny, Long maxy ) + { + Long y1, y2, e, e2, e0; + Short f1; + + TPoint* arc; + TPoint* start_arc; + + PStorage top; + + + arc = ras.arc; + y1 = arc[2].y; + y2 = arc[0].y; + top = ras.top; + + if ( y2 < miny || y1 > maxy ) + goto Fin; + + e2 = FLOOR( y2 ); + + if ( e2 > maxy ) + e2 = maxy; + + e0 = miny; + + if ( y1 < miny ) + e = miny; + else + { + e = CEILING( y1 ); + f1 = FRAC( y1 ); + e0 = e; + + if ( f1 == 0 ) + { + if ( ras.joint ) + { + top--; + ras.joint = FALSE; + } + + *top++ = arc[2].x; + + DEBUG_PSET; + + e += ras.precision; + } + } + + if ( ras.fresh ) + { + ras.cProfile->start = TRUNC( e0 ); + ras.fresh = FALSE; + } + + if ( e2 < e ) + goto Fin; + + if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff ) + { + ras.top = top; + ras.error = Raster_Err_Overflow; + return FAILURE; + } + + start_arc = arc; + + while ( arc >= start_arc && e <= e2 ) + { + ras.joint = FALSE; + + y2 = arc[0].y; + + if ( y2 > e ) + { + y1 = arc[2].y; + if ( y2 - y1 >= ras.precision_step ) + { + Split_Bezier( arc ); + arc += 2; + } + else + { + *top++ = arc[2].x + FMulDiv( arc[0].x - arc[2].x, + e - y1, + y2 - y1 ); + DEBUG_PSET; + + arc -= 2; + e += ras.precision; + } + } + else + { + if ( y2 == e ) + { + ras.joint = TRUE; + *top++ = arc[0].x; + + DEBUG_PSET; + + e += ras.precision; + } + arc -= 2; + } + } + + Fin: + ras.top = top; + ras.arc -= 2; + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Bezier_Down */ +/* */ +/* Description: Computes the x-coordinates of a descending bezier arc */ +/* and stores them in the render pool. */ +/* */ +/* Input: None. Arc is taken from the top of the Bezier stack. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow. */ +/* */ +/****************************************************************************/ + + static Bool Bezier_Down( RAS_ARGS Long miny, Long maxy ) + { + TPoint* arc = ras.arc; + Bool result, fresh; + + + arc[0].y = -arc[0].y; + arc[1].y = -arc[1].y; + arc[2].y = -arc[2].y; + + fresh = ras.fresh; + + result = Bezier_Up( RAS_VARS -maxy, -miny ); + + if ( fresh && !ras.fresh ) + ras.cProfile->start = -ras.cProfile->start; + + arc[0].y = -arc[0].y; + return result; + } + + +/****************************************************************************/ +/* */ +/* Function: Line_To */ +/* */ +/* Description: Injects a new line segment and adjusts Profiles list. */ +/* */ +/* Input: x, y : segment endpoint (start point in LastX,LastY) */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow or Incorrect Profile. */ +/* */ +/****************************************************************************/ + + static Bool Line_To( RAS_ARGS Long x, Long y ) + { + /* First, detect a change of direction */ + + switch ( ras.state ) + { + case Unknown: + if ( y > ras.lastY ) + { + if ( New_Profile( RAS_VARS Ascending ) ) return FAILURE; + } + else + { + if ( y < ras.lastY ) + if ( New_Profile( RAS_VARS Descending ) ) return FAILURE; + } + break; + + case Ascending: + if ( y < ras.lastY ) + { + if ( End_Profile( RAS_VAR ) || + New_Profile( RAS_VARS Descending ) ) return FAILURE; + } + break; + + case Descending: + if ( y > ras.lastY ) + { + if ( End_Profile( RAS_VAR ) || + New_Profile( RAS_VARS Ascending ) ) return FAILURE; + } + break; + + default: + ; + } + + /* Then compute the lines */ + + switch ( ras.state ) + { + case Ascending: + if ( Line_Up ( RAS_VARS ras.lastX, ras.lastY, + x, y, ras.minY, ras.maxY ) ) + return FAILURE; + break; + + case Descending: + if ( Line_Down( RAS_VARS ras.lastX, ras.lastY, + x, y, ras.minY, ras.maxY ) ) + return FAILURE; + break; + + default: + ; + } + + ras.lastX = x; + ras.lastY = y; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Bezier_To */ +/* */ +/* Description: Injects a new bezier arc and adjusts the profile list. */ +/* */ +/* Input: x, y : arc endpoint (start point in LastX, LastY) */ +/* Cx, Cy : control point */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on Render Pool overflow or Incorrect Profile. */ +/* */ +/****************************************************************************/ + + static Bool Bezier_To( RAS_ARGS Long x, + Long y, + Long cx, + Long cy ) + { + Long y1, y2, y3, x3; + TStates state_bez; + + + Push_Bezier( RAS_VARS ras.lastX, ras.lastY, cx, cy, x, y ); + + do + { + y1 = ras.arc[2].y; + y2 = ras.arc[1].y; + y3 = ras.arc[0].y; + x3 = ras.arc[0].x; + + /* first, categorize the bezier arc */ + + if ( y1 == y2 ) + { + if ( y2 == y3 ) + state_bez = Flat; + else if ( y2 > y3 ) + state_bez = Descending; + else + state_bez = Ascending; + } + else if ( y1 > y2 ) + { + if ( y2 >= y3 ) + state_bez = Descending; + else + state_bez = Unknown; + } + else if ( y2 <= y3 ) + state_bez = Ascending; + else + state_bez = Unknown; + + /* split non-monotonic arcs, ignore flat ones, or */ + /* computes the up and down ones */ + + switch ( state_bez ) + { + case Flat: + ras.arc -= 2; + break; + + case Unknown: + Split_Bezier( ras.arc ); + ras.arc += 2; + break; + + default: + /* detect a change of direction */ + + if ( ras.state != state_bez ) + { + if ( ras.state != Unknown ) + if ( End_Profile( RAS_VAR ) ) return FAILURE; + + if ( New_Profile( RAS_VARS state_bez ) ) return FAILURE; + } + + /* compute */ + + switch ( ras.state ) + { + case Ascending: + if ( Bezier_Up ( RAS_VARS ras.minY, ras.maxY ) ) + return FAILURE; + break; + + case Descending: + if ( Bezier_Down( RAS_VARS ras.minY, ras.maxY ) ) + return FAILURE; + break; + + default: + ; + } + } + } while ( ras.arc >= ras.arcs ); + + ras.lastX = x3; + ras.lastY = y3; + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Decompose_Curve */ +/* */ +/* Description: Scans the outline arays in order to emit individual */ +/* segments and beziers by calling Line_To() and Bezier_To(). */ +/* It handles all weird cases, like when the first point */ +/* is off the curve, or when there are simply no 'on' */ +/* points in the contour! */ +/* */ +/* Input: first, last : indexes of first and last point in */ +/* contour. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE on error. */ +/* */ +/****************************************************************************/ + +#undef SWAP_ +#define SWAP_(x,y) { Long swap = x; x = y; y = swap; } + + static Bool Decompose_Curve( RAS_ARGS UShort first, + UShort last, + Bool flipped ) + { + Long x, y; /* current point */ + Long cx, cy; /* current Bezier control point */ + Long mx, my; /* current middle point */ + + Long x_first, y_first; /* first point's coordinates */ + Long x_last, y_last; /* last point's coordinates */ + + UShort index; /* current point's index */ + Bool on_curve; /* current point's state */ + + x_first = SCALED( ras.coords[first].x ); + y_first = SCALED( ras.coords[first].y ); + + if ( flipped ) SWAP_( x_first,y_first ); + + x_last = SCALED( ras.coords[last].x ); + y_last = SCALED( ras.coords[last].y ); + + if ( flipped ) SWAP_( x_last,y_last ); + + ras.lastX = cx = x_first; + ras.lastY = cy = y_first; + + on_curve = (ras.flags[first] & 1); + index = first; + + /* check first point to determine origin */ + if ( !on_curve ) + { + /* first point is off the curve. Yes, this happens... */ + if ( ras.flags[last] & 1 ) + { + ras.lastX = x_last; /* start at last point if it */ + ras.lastY = y_last; /* is on the curve */ + } + else + { + /* if both first and last points are off the curve, */ + /* start at their middle and record its position */ + /* for closure */ + ras.lastX = (ras.lastX + x_last)/2; + ras.lastY = (ras.lastY + y_last)/2; + + x_last = ras.lastX; + y_last = ras.lastY; + } + } + + /* now process each contour point individually */ + while ( index < last ) + { + index++; + x = SCALED( ras.coords[index].x ); + y = SCALED( ras.coords[index].y ); + + if ( flipped ) SWAP_( x, y ); + + if ( on_curve ) + { + /* the previous point was on the curve */ + on_curve = ( ras.flags[index] & 1 ); + if ( on_curve ) + { + /* two successive on points => emit segment */ + if ( Line_To( RAS_VARS x, y ) ) return FAILURE; + } + else + { + /* else, keep current control point for next bezier */ + cx = x; + cy = y; + } + } + else + { + /* the previous point was off the curve */ + on_curve = ( ras.flags[index] & 1 ); + if ( on_curve ) + { + /* reaching an `on' point */ + if ( Bezier_To( RAS_VARS x, y, cx, cy ) ) return FAILURE; + } + else + { + /* two successive `off' points => create middle point */ + mx = ( cx + x ) / 2; + my = ( cy + y ) / 2; + + if ( Bezier_To( RAS_VARS mx, my, cx, cy ) ) return FAILURE; + + cx = x; + cy = y; + } + } + } + + /* end of contour, close curve cleanly */ + if ( ras.flags[first] & 1 ) + { + if ( on_curve ) + return Line_To( RAS_VARS x_first, y_first ); + else + return Bezier_To( RAS_VARS x_first, y_first, cx, cy ); + } + else + if ( !on_curve ) + return Bezier_To( RAS_VARS x_last, y_last, cx, cy ); + + return SUCCESS; + } + + +/****************************************************************************/ +/* */ +/* Function: Convert_Glyph */ +/* */ +/* Description: Converts a glyph into a series of segments and arcs */ +/* and makes a Profiles list with them. */ +/* */ +/* Input: _xCoord, _yCoord : coordinates tables. */ +/* */ +/* Uses the 'Flag' table too. */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + + static Bool Convert_Glyph( RAS_ARGS int flipped ) + { + Short i; + UShort start; + + PProfile lastProfile; + + + ras.fProfile = NULL; + ras.joint = FALSE; + ras.fresh = FALSE; + + ras.maxBuff = ras.sizeBuff - AlignProfileSize; + + ras.numTurns = 0; + + ras.cProfile = (PProfile)ras.top; + ras.cProfile->offset = ras.top; + ras.num_Profs = 0; + + start = 0; + + for ( i = 0; i < ras.nContours; i++ ) + { + ras.state = Unknown; + ras.gProfile = NULL; + + if ( Decompose_Curve( RAS_VARS start, ras.outs[i], flipped ) ) + return FAILURE; + + start = ras.outs[i] + 1; + + /* We must now see if the extreme arcs join or not */ + if ( ( FRAC( ras.lastY ) == 0 && + ras.lastY >= ras.minY && + ras.lastY <= ras.maxY ) ) + if ( ras.gProfile && ras.gProfile->flow == ras.cProfile->flow ) + ras.top--; + /* Note that ras.gProfile can be nil if the contour was too small */ + /* to be drawn. */ + + lastProfile = ras.cProfile; + if ( End_Profile( RAS_VAR ) ) return FAILURE; + + /* close the 'next profile in contour' linked list */ + if ( ras.gProfile ) + lastProfile->next = ras.gProfile; + } + + if (Finalize_Profile_Table( RAS_VAR )) + return FAILURE; + + return (ras.top < ras.maxBuff ? SUCCESS : FAILURE ); + } + + +/************************************************/ +/* */ +/* Init_Linked */ +/* */ +/* Inits an empty linked list. */ +/* */ +/************************************************/ + + static void Init_Linked( TProfileList* l ) + { + *l = NULL; + } + + +/************************************************/ +/* */ +/* InsNew : */ +/* */ +/* Inserts a new Profile in a linked list. */ +/* */ +/************************************************/ + + static void InsNew( PProfileList list, + PProfile profile ) + { + PProfile *old, current; + Long x; + + + old = list; + current = *old; + x = profile->X; + + while ( current ) + { + if ( x < current->X ) + break; + old = ¤t->link; + current = *old; + } + + profile->link = current; + *old = profile; + } + + +/*************************************************/ +/* */ +/* DelOld : */ +/* */ +/* Removes an old Profile from a linked list. */ +/* */ +/*************************************************/ + + static void DelOld( PProfileList list, + PProfile profile ) + { + PProfile *old, current; + + + old = list; + current = *old; + + while ( current ) + { + if ( current == profile ) + { + *old = current->link; + return; + } + + old = ¤t->link; + current = *old; + } + + /* we should never get there, unless the Profile was not part of */ + /* the list. */ + } + + +/************************************************/ +/* */ +/* Update : */ +/* */ +/* Update all X offsets of a drawing list */ +/* */ +/************************************************/ + + static void Update( PProfile first ) + { + PProfile current = first; + + + while ( current ) + { + current->X = *current->offset; + current->offset += current->flow; + current->height--; + current = current->link; + } + } + + +/************************************************/ +/* */ +/* Sort : */ +/* */ +/* Sorts a trace list. In 95%, the list */ +/* is already sorted. We need an algorithm */ +/* which is fast in this case. Bubble sort */ +/* is enough and simple. */ +/* */ +/************************************************/ + + static void Sort( PProfileList list ) + { + PProfile *old, current, next; + + + /* First, set the new X coordinate of each profile */ + Update( *list ); + + /* Then sort them */ + old = list; + current = *old; + + if ( !current ) + return; + + next = current->link; + + while ( next ) + { + if ( current->X <= next->X ) + { + old = ¤t->link; + current = *old; + + if ( !current ) + return; + } + else + { + *old = next; + current->link = next->link; + next->link = current; + + old = list; + current = *old; + } + + next = current->link; + } + } + + +/***********************************************************************/ +/* */ +/* Vertical Sweep Procedure Set : */ +/* */ +/* These three routines are used during the vertical black/white */ +/* sweep phase by the generic Draw_Sweep() function. */ +/* */ +/***********************************************************************/ + + static void Vertical_Sweep_Init( RAS_ARGS Short* min, Short* max ) + { + switch ( ras.target.flow ) + { + case TT_Flow_Up: + ras.traceOfs = *min * ras.target.cols; + ras.traceIncr = ras.target.cols; + break; + + default: + ras.traceOfs = ( ras.target.rows - 1 - *min ) * ras.target.cols; + ras.traceIncr = -ras.target.cols; + } + + ras.gray_min_x = 0; + ras.gray_max_x = 0; + } + + + static void Vertical_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + Short c1, c2; + Short f1, f2; + Byte* target; + + + /* Drop-out control */ + + e1 = TRUNC( CEILING( x1 ) ); + + if ( x2-x1-ras.precision <= ras.precision_jitter ) + e2 = e1; + else + e2 = TRUNC( FLOOR( x2 ) ); + + if ( e2 >= 0 && e1 < ras.bWidth ) + { + if ( e1 < 0 ) e1 = 0; + if ( e2 >= ras.bWidth ) e2 = ras.bWidth-1; + + c1 = (Short)(e1 >> 3); + c2 = (Short)(e2 >> 3); + + f1 = e1 & 7; + f2 = e2 & 7; + + if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1; + if ( ras.gray_max_x < c2 ) ras.gray_max_x = c2; + + target = ras.bTarget + ras.traceOfs + c1; + + if ( c1 != c2 ) + { + *target |= LMask[f1]; + + if ( c2 > c1 + 1 ) + MEM_Set( target + 1, 0xFF, c2 - c1 - 1 ); + + target[c2 - c1] |= RMask[f2]; + } + else + *target |= ( LMask[f1] & RMask[f2] ); + } + } + + + static void Vertical_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + Short c1, f1; + + + /* Drop-out control */ + + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 > e2 ) + { + if ( e1 == e2 + ras.precision ) + { + switch ( ras.dropOutControl ) + { + case 1: + e1 = e2; + break; + + case 4: + e1 = CEILING( (x1 + x2 + 1) / 2 ); + break; + + case 2: + case 5: + /* Drop-out Control Rule #4 */ + + /* The spec is not very clear regarding rule #4. It */ + /* presents a method that is way too costly to implement */ + /* while the general idea seems to get rid of 'stubs'. */ + /* */ + /* Here, we only get rid of stubs recognized when: */ + /* */ + /* upper stub: */ + /* */ + /* - P_Left and P_Right are in the same contour */ + /* - P_Right is the successor of P_Left in that contour */ + /* - y is the top of P_Left and P_Right */ + /* */ + /* lower stub: */ + /* */ + /* - P_Left and P_Right are in the same contour */ + /* - P_Left is the successor of P_Right in that contour */ + /* - y is the bottom of P_Left */ + /* */ + + /* FIXXXME : uncommenting this line solves the disappearing */ + /* bit problem in the '7' of verdana 10pts, but */ + /* makes a new one in the 'C' of arial 14pts */ + + /* if ( x2-x1 < ras.precision_half ) */ + { + /* upper stub test */ + + if ( left->next == right && left->height <= 0 ) return; + + /* lower stub test */ + + if ( right->next == left && left->start == y ) return; + } + + /* check that the rightmost pixel isn't set */ + + e1 = TRUNC( e1 ); + + c1 = (Short)(e1 >> 3); + f1 = e1 & 7; + + if ( e1 >= 0 && e1 < ras.bWidth && + ras.bTarget[ras.traceOfs + c1] & (0x80 >> f1) ) + return; + + if ( ras.dropOutControl == 2 ) + e1 = e2; + else + e1 = CEILING( (x1 + x2 + 1) / 2 ); + + break; + + default: + return; /* unsupported mode */ + } + } + else + return; + } + + e1 = TRUNC( e1 ); + + if ( e1 >= 0 && e1 < ras.bWidth ) + { + c1 = (Short)(e1 >> 3); + f1 = e1 & 7; + + if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1; + if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1; + + ras.bTarget[ras.traceOfs + c1] |= (Char)(0x80 >> f1); + } + } + + + static void Vertical_Sweep_Step( RAS_ARG ) + { + ras.traceOfs += ras.traceIncr; + } + + +/***********************************************************************/ +/* */ +/* Horizontal Sweep Procedure Set : */ +/* */ +/* These three routines are used during the horizontal black/white */ +/* sweep phase by the generic Draw_Sweep() function. */ +/* */ +/***********************************************************************/ + + static void Horizontal_Sweep_Init( RAS_ARGS Short* min, Short* max ) + { + /* nothing, really */ + } + + + static void Horizontal_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + PByte bits; + Byte f1; + + + if ( x2-x1 < ras.precision ) + { + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 == e2 ) + { + bits = ras.bTarget + (y >> 3); + f1 = (Byte)(0x80 >> (y & 7)); + + e1 = TRUNC( e1 ); + + if ( e1 >= 0 && e1 < ras.target.rows ) + { + if ( ras.target.flow == TT_Flow_Down ) + bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1; + else + bits[e1 * ras.target.cols] |= f1; + } + } + } +#if 0 + e2 = TRUNC( e2 ); + + if ( e2 >= 0 && e2 < ras.target.rows ) + if ( ras.target.flow == TT_Flow_Down ) + bits[(ras.target.rows-1-e2) * ras.target.cols] |= f1; + else + bits[e2 * ras.target.cols] |= f1; +#endif + } + + + static void Horizontal_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + PByte bits; + Byte f1; + + + /* During the horizontal sweep, we only take care of drop-outs */ + + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 > e2 ) + { + if ( e1 == e2 + ras.precision ) + { + switch ( ras.dropOutControl ) + { + case 1: + e1 = e2; + break; + + case 4: + e1 = CEILING( (x1 + x2 + 1) / 2 ); + break; + + case 2: + case 5: + + /* Drop-out Control Rule #4 */ + + /* The spec is not very clear regarding rule #4. It */ + /* presents a method that is way too costly to implement */ + /* while the general idea seems to get rid of 'stubs'. */ + /* */ + + /* rightmost stub test */ + + if ( left->next == right && left->height <= 0 ) return; + + /* leftmost stub test */ + + if ( right->next == left && left->start == y ) return; + + /* check that the rightmost pixel isn't set */ + + e1 = TRUNC( e1 ); + + bits = ras.bTarget + (y >> 3); + f1 = (Byte)(0x80 >> (y & 7)); + + if ( ras.target.flow == TT_Flow_Down ) + bits += (ras.target.rows-1-e1) * ras.target.cols; + else + bits += e1 * ras.target.cols; + + if ( e1 >= 0 && + e1 < ras.target.rows && + *bits & f1 ) + return; + + if ( ras.dropOutControl == 2 ) + e1 = e2; + else + e1 = CEILING( (x1 + x2 + 1) / 2 ); + + break; + + default: + return; /* unsupported mode */ + } + } + else + return; + } + + bits = ras.bTarget + (y >> 3); + f1 = (Byte)(0x80 >> (y & 7)); + + e1 = TRUNC( e1 ); + + if ( e1 >= 0 && e1 < ras.target.rows ) + { + if (ras.target.flow==TT_Flow_Down) + bits[(ras.target.rows-1-e1) * ras.target.cols] |= f1; + else + bits[e1 * ras.target.cols] |= f1; + } + } + + + static void Horizontal_Sweep_Step( RAS_ARG ) + { + /* Nothing, really */ + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/***********************************************************************/ +/* */ +/* Vertical Gray Sweep Procedure Set: */ +/* */ +/* These two routines are used during the vertical gray-levels */ +/* sweep phase by the generic Draw_Sweep() function. */ +/* */ +/* */ +/* NOTES: */ +/* */ +/* - The target pixmap's width *must* be a multiple of 4. */ +/* */ +/* - you have to use the function Vertical_Sweep_Span() for */ +/* the gray span call. */ +/* */ +/***********************************************************************/ + + static void Vertical_Gray_Sweep_Init( RAS_ARGS Short* min, Short* max ) + { + *min = *min & -2; + *max = ( *max + 3 ) & -2; + + ras.traceOfs = 0; + + switch ( ras.target.flow ) + { + case TT_Flow_Up: + ras.traceG = (*min / 2) * ras.target.cols; + ras.traceIncr = ras.target.cols; + break; + + default: + ras.traceG = (ras.target.rows-1 - *min/2) * ras.target.cols; + ras.traceIncr = -ras.target.cols; + } + + ras.gray_min_x = ras.target.cols; + ras.gray_max_x = -ras.target.cols; + } + + + static void Vertical_Gray_Sweep_Step( RAS_ARG ) + { + Int c1, c2; + PByte pix, bit, bit2; + Int* count = ras.count_table; + Byte* grays; + + + ras.traceOfs += ras.gray_width; + + if ( ras.traceOfs > ras.gray_width ) + { + pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4; + grays = ras.grays; + + if ( ras.gray_max_x >= 0 ) + { + if ( ras.gray_max_x >= ras.target.width ) + ras.gray_max_x = ras.target.width-1; + + if ( ras.gray_min_x < 0 ) + ras.gray_min_x = 0; + + bit = ras.bTarget + ras.gray_min_x; + bit2 = bit + ras.gray_width; + + c1 = ras.gray_max_x - ras.gray_min_x; + + while ( c1 >= 0 ) + { + c2 = count[*bit] + count[*bit2]; + + if ( c2 ) + { + pix[0] = grays[(c2 & 0xF000) >> 12]; + pix[1] = grays[(c2 & 0x0F00) >> 8]; + pix[2] = grays[(c2 & 0x00F0) >> 4]; + pix[3] = grays[(c2 & 0x000F) ]; + + *bit = 0; + *bit2 = 0; + } + + bit ++; + bit2++; + pix += 4; + c1 --; + } + } + + ras.traceOfs = 0; + ras.traceG += ras.traceIncr; + + ras.gray_min_x = ras.target.cols; + ras.gray_max_x = -ras.target.cols; + } + } + + + static void Horizontal_Gray_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + /* nothing, really */ + } + + static void Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + PByte pixel; + Byte color; + + + /* During the horizontal sweep, we only take care of drop-outs */ + e1 = CEILING( x1 ); + e2 = FLOOR ( x2 ); + + if ( e1 > e2 ) + { + if ( e1 == e2 + ras.precision ) + { + switch ( ras.dropOutControl ) + { + case 1: + e1 = e2; + break; + + case 4: + e1 = CEILING( (x1 + x2 + 1) / 2 ); + break; + + case 2: + case 5: + + /* Drop-out Control Rule #4 */ + + /* The spec is not very clear regarding rule #4. It */ + /* presents a method that is way too costly to implement */ + /* while the general idea seems to get rid of 'stubs'. */ + /* */ + + /* rightmost stub test */ + if ( left->next == right && left->height <= 0 ) return; + + /* leftmost stub test */ + if ( right->next == left && left->start == y ) return; + + if ( ras.dropOutControl == 2 ) + e1 = e2; + else + e1 = CEILING( (x1 + x2 + 1) / 2 ); + + break; + + default: + return; /* unsupported mode */ + } + } + else + return; + } + + if ( e1 >= 0 ) + { + if ( x2 - x1 >= ras.precision_half ) + color = ras.grays[2]; + else + color = ras.grays[1]; + + e1 = TRUNC( e1 ) / 2; + if ( e1 < ras.target.rows ) + { + if ( ras.target.flow == TT_Flow_Down ) + pixel = ras.gTarget + + (ras.target.rows - 1 - e1) * ras.target.cols + y / 2; + else + pixel = ras.gTarget + + e1 * ras.target.cols + y / 2; + + if (pixel[0] == ras.grays[0]) + pixel[0] = color; + } + } + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/********************************************************************/ +/* */ +/* Generic Sweep Drawing routine */ +/* */ +/********************************************************************/ + + static Bool Draw_Sweep( RAS_ARG ) + { + Short y, y_change, y_height; + + PProfile P, Q, P_Left, P_Right; + + Short min_Y, max_Y, top, bottom, dropouts; + + Long x1, x2, xs, e1, e2; + + TProfileList wait; + TProfileList draw_left, draw_right; + + + /* Init empty linked lists */ + + Init_Linked( &wait ); + + Init_Linked( &draw_left ); + Init_Linked( &draw_right ); + + /* first, compute min and max Y */ + + P = ras.fProfile; + max_Y = (short)TRUNC( ras.minY ); + min_Y = (short)TRUNC( ras.maxY ); + + while ( P ) + { + Q = P->link; + + bottom = P->start; + top = P->start + P->height-1; + + if ( min_Y > bottom ) min_Y = bottom; + if ( max_Y < top ) max_Y = top; + + P->X = 0; + InsNew( &wait, P ); + + P = Q; + } + + /* Check the Y-turns */ + if ( ras.numTurns == 0 ) + { + ras.error = Raster_Err_Invalid; + return FAILURE; + } + + /* Now inits the sweep */ + +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Init, RAS_VARS &min_Y, &max_Y ); +#else + ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); +#endif /* ifdef __GEOS__ */ + + /* Then compute the distance of each profile from min_Y */ + + P = wait; + + while ( P ) + { + P->countL = P->start - min_Y; + P = P->link; + } + + /* Let's go */ + + y = min_Y; + y_height = 0; + + if ( ras.numTurns > 0 && + ras.sizeBuff[-ras.numTurns] == min_Y ) + ras.numTurns--; + + while ( ras.numTurns > 0 ) + { + /* look in the wait list for new activations */ + + P = wait; + + while ( P ) + { + Q = P->link; + P->countL -= y_height; + if ( P->countL == 0 ) + { + DelOld( &wait, P ); + + switch ( P->flow ) + { + case TT_Flow_Up: InsNew( &draw_left, P ); break; + case TT_Flow_Down: InsNew( &draw_right, P ); break; + } + } + + P = Q; + } + + /* Sort the drawing lists */ + + Sort( &draw_left ); + Sort( &draw_right ); + + y_change = (Short)ras.sizeBuff[-ras.numTurns--]; + y_height = y_change - y; + + while ( y < y_change ) + { + + /* Let's trace */ + + dropouts = 0; + + P_Left = draw_left; + P_Right = draw_right; + + while ( P_Left ) + { + x1 = P_Left ->X; + x2 = P_Right->X; + + if ( x1 > x2 ) + { + xs = x1; + x1 = x2; + x2 = xs; + } + + if ( x2-x1 <= ras.precision ) + { + e1 = FLOOR( x1 ); + e2 = CEILING( x2 ); + + if ( ras.dropOutControl != 0 && + (e1 > e2 || e2 == e1 + ras.precision) ) + { + /* a drop out was detected */ + + P_Left ->X = x1; + P_Right->X = x2; + + /* mark profile for drop-out processing */ + P_Left->countL = 1; + dropouts++; + + goto Skip_To_Next; + } + } + +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Span, RAS_VARS y, x1, x2, P_Left, P_Right ); +#else + ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right ); +#endif /* __GEOS__ */ + + Skip_To_Next: + + P_Left = P_Left->link; + P_Right = P_Right->link; + } + + /* now perform the dropouts _after_ the span drawing */ + /* drop-outs processing has been moved out of the loop */ + /* for performance tuning */ + if (dropouts > 0) + goto Scan_DropOuts; + + Next_Line: + +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); +#else + ras.Proc_Sweep_Step( RAS_VAR ); +#endif /* ifdef __GEOS__ */ + + y++; + + if ( y < y_change ) + { + Sort( &draw_left ); + Sort( &draw_right ); + } + + } + + /* Now finalize the profiles that needs it */ + + { + PProfile Q, P; + P = draw_left; + while ( P ) + { + Q = P->link; + if ( P->height == 0 ) + DelOld( &draw_left, P ); + P = Q; + } + } + + { + PProfile Q, P = draw_right; + while ( P ) + { + Q = P->link; + if ( P->height == 0 ) + DelOld( &draw_right, P ); + P = Q; + } + } + } + + /* for gray-scaling, flushes the bitmap scanline cache */ + while ( y <= max_Y ) + { +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); +#else + ras.Proc_Sweep_Step( RAS_VAR ); +#endif /* __GEOS__ */ + y++; + } + + return SUCCESS; + +Scan_DropOuts : + + P_Left = draw_left; + P_Right = draw_right; + + while ( P_Left ) + { + if ( P_Left->countL ) + { + P_Left->countL = 0; + /* dropouts--; -- this is useful when debugging only */ +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Drop, RAS_VARS y, + P_Left->X, + P_Right->X, + P_Left, + P_Right ); +#else + ras.Proc_Sweep_Drop( RAS_VARS y, + P_Left->X, + P_Right->X, + P_Left, + P_Right ); +#endif /* ifdef __GEOS__ */ + } + + P_Left = P_Left->link; + P_Right = P_Right->link; + } + + goto Next_Line; + } + + +/****************************************************************************/ +/* */ +/* Function: Render_Single_Pass */ +/* */ +/* Description: Performs one sweep with sub-banding. */ +/* */ +/* Input: _XCoord, _YCoord : x and y coordinates arrays */ +/* */ +/* Returns: SUCCESS on success */ +/* FAILURE if any error was encountered during render. */ +/* */ +/****************************************************************************/ + + static TT_Error Render_Single_Pass( RAS_ARGS Bool flipped ) + { + Short i, j, k; + + + while ( ras.band_top >= 0 ) + { + ras.maxY = (Long)ras.band_stack[ras.band_top].y_max * ras.precision; + ras.minY = (Long)ras.band_stack[ras.band_top].y_min * ras.precision; + + ras.top = ras.buff; + + ras.error = Raster_Err_None; + + if ( Convert_Glyph( RAS_VARS flipped ) ) + { + if ( ras.error != Raster_Err_Overflow ) return FAILURE; + + ras.error = Raster_Err_None; + + /* sub-banding */ + +#ifdef DEBUG_RASTER + ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) ); +#endif + + i = ras.band_stack[ras.band_top].y_min; + j = ras.band_stack[ras.band_top].y_max; + + k = ( i + j ) / 2; + + if ( ras.band_top >= 7 || k < i ) + { + ras.band_top = 0; + ras.error = Raster_Err_Invalid; + return ras.error; + } + + ras.band_stack[ras.band_top+1].y_min = k; + ras.band_stack[ras.band_top+1].y_max = j; + + ras.band_stack[ras.band_top].y_max = k - 1; + + ras.band_top++; + } + else + { + if ( ras.fProfile ) + if ( Draw_Sweep( RAS_VAR ) ) return ras.error; + ras.band_top--; + } + } + + return TT_Err_Ok; + } + + +/****************************************************************************/ +/* */ +/* Function: Render_Glyph */ +/* */ +/* Description: Renders a glyph in a bitmap. Sub-banding if needed. */ +/* */ +/* Input: AGlyph Glyph record */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + + LOCAL_FUNC + TT_Error Render_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target_map ) + { + TT_Error error; + + + if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + return TT_Err_Ok; + + if ( !ras.buff ) + { + ras.error = Raster_Err_Not_Ini; + return ras.error; + } + + if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) + { + ras.error = TT_Err_Too_Many_Points; + return ras.error; + } + + if ( target_map ) + ras.target = *target_map; + + ras.outs = glyph->contours; + ras.flags = glyph->flags; + ras.nPoints = glyph->n_points; + ras.nContours = glyph->n_contours; + ras.coords = glyph->points; + + Set_High_Precision( RAS_VARS glyph->high_precision ); + ras.scale_shift = ras.precision_shift; + ras.dropOutControl = glyph->dropout_mode; + ras.second_pass = glyph->second_pass; + + + /* Vertical Sweep */ + ras.Proc_Sweep_Init = Vertical_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.rows - 1; + + ras.bWidth = ras.target.width; + ras.bTarget = (Byte*)ras.target.bitmap; + + if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) + return error; + + /* Horizontal Sweep */ + + if ( ras.second_pass && ras.dropOutControl != 0 ) + { + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.width - 1; + + if ( (error = Render_Single_Pass( RAS_VARS 1 )) != 0 ) + return error; + } + + return TT_Err_Ok; + } + + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + +/****************************************************************************/ +/* */ +/* Function: Render_Gray_Glyph */ +/* */ +/* Description: Renders a glyph with grayscaling. Sub-banding if needed. */ +/* */ +/* Input: AGlyph Glyph record */ +/* */ +/* Returns: SUCCESS on success */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + + LOCAL_FUNC + TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target_map, + Byte* palette ) + { + Int i; + TT_Error error; + + if ( !ras.buff ) + { + ras.error = Raster_Err_Not_Ini; + return ras.error; + } + + if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + return TT_Err_Ok; + + if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) + { + ras.error = TT_Err_Too_Many_Points; + return ras.error; + } + + if ( palette ) + { + for ( i = 0; i < 5; i++ ) + ras.grays[i] = palette[i]; + } + + if ( target_map ) + ras.target = *target_map; + + ras.outs = glyph->contours; + ras.flags = glyph->flags; + ras.nPoints = glyph->n_points; + ras.nContours = glyph->n_contours; + ras.coords = glyph->points; + + Set_High_Precision( RAS_VARS glyph->high_precision ); + ras.scale_shift = ras.precision_shift+1; + ras.dropOutControl = glyph->dropout_mode; + ras.second_pass = glyph->second_pass; + + + /* Vertical Sweep */ + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = 2 * ras.target.rows - 1; + + ras.bWidth = ras.gray_width; + if ( ras.bWidth > ras.target.cols/4 ) + ras.bWidth = ras.target.cols/4; + + ras.bWidth = ras.bWidth * 8; + ras.bTarget = (Byte*)ras.gray_lines; + ras.gTarget = (Byte*)ras.target.bitmap; + + ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; + + error = Render_Single_Pass( RAS_VARS 0 ); + if (error) + return error; + + /* Horizontal Sweep */ + + if ( ras.second_pass && ras.dropOutControl != 0 ) + { + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.width * 2 - 1; + + error = Render_Single_Pass( RAS_VARS 1 ); + if (error) + return error; + } + + return TT_Err_Ok; + } + +#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ + + +/************************************************/ +/* */ +/* InitRasterizer */ +/* */ +/* Raster Initialization. */ +/* Gets the bitmap description and render pool */ +/* addresses. */ +/* */ +/************************************************/ + +#undef ras + + LOCAL_FUNC + TT_Error TTRaster_Done( PEngine_Instance engine ) + { + TRaster_Instance* ras = (TRaster_Instance*)engine->raster_component; + + + if ( !ras ) + return TT_Err_Ok; + + FREE( ras->buff ); + FREE( ras->gray_lines ); + +#ifndef TT_CONFIG_OPTION_STATIC_RASTER + FREE( engine->raster_component ); +#endif + + return TT_Err_Ok; + } + + + LOCAL_FUNC + TT_Error TTRaster_Init( PEngine_Instance engine ) + { + TT_Error error; + + Int i, l, j, c; + + TRaster_Instance* ras; + + +#ifdef TT_CONFIG_OPTION_STATIC_RASTER + ras = engine->raster_component = &cur_ras; +#else + if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) + return error; + + ras = (TRaster_Instance*)engine->raster_component; +#endif + + if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) || + ALLOC( ras->gray_lines, RASTER_GRAY_LINES ) ) + return error; + + ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) ); + ras->gray_width = RASTER_GRAY_LINES/2; + + /* Initialization of Count_Table */ + + for ( i = 0; i < 256; i++ ) + { + l = 0; + j = i; + + for ( c = 0; c < 4; c++ ) + { + l <<= 4; + + if ( j & 0x80 ) l++; + if ( j & 0x40 ) l++; + + j = ( j << 2 ) & 0xFF; + } + + ras->count_table[i] = l; + } + + ras->dropOutControl = 2; + ras->error = Raster_Err_None; + + return TT_Err_Ok; + } + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttraster.h b/Driver/Font/TrueType/FreeType/ttraster.h new file mode 100644 index 000000000..6af372090 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/ttraster.h @@ -0,0 +1,127 @@ +/******************************************************************* + * + * ttraster.h v 1.4 + * + * The FreeType glyph rasterizer. + * + * 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. + * + * NOTES: + * + * This version supports the following: + * + * - direct grayscaling + * - sub-banding + * - drop-out modes 4 and 5 + * - second pass for complete drop-out control (bitmap only) + * - variable precision + * + * + * Changes between 1.4 and 1.3: + * + * Mainly performance tunings: + * + * - Line_Down() and Bezier_Down() now use the functions Line_Up() + * and Bezier_Up() to do their work. + * - optimized Split_Bezier() + * - optimized linked lists used during sweeps + * + * Changes between 1.2 and 1.3: + * + * - made the engine optionaly re-entrant. Saves a lot + * of code for a moderate performance hit. + * + ******************************************************************/ + +#ifndef TTRASTER_H +#define TTRASTER_H + +#include "ttconfig.h" +#include "freetype.h" /* for TT_Outline */ +#include "ttengine.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* We provide two different builds of the scan-line converter */ + /* The static build uses global variables and isn't */ + /* re-entrant. */ + /* The indirect build is re-entrant but accesses all variables */ + /* indirectly. */ + /* */ + /* As a consequence, the indirect build is about 10% slower */ + /* than the static one on a _Pentium_ (this could get worse */ + /* on older processors), but the code size is reduced by */ + /* more than 30% ! */ + /* */ + /* The indirect build is now the default, defined in */ + /* ttconfig.h. Be careful if you experiment with this. */ + + /* Note also that, though its code can be re-entrant, the */ + /* component is always used in thread-safe mode. This is */ + /* simply due to the fact that we want to use a single */ + /* render pool (of 64 Kb), and not to waste memory. */ + +#ifdef TT_STATIC_RASTER + +#define RAS_ARGS /* void */ +#define RAS_ARG /* void */ + +#define RAS_VARS /* void */ +#define RAS_VAR /* void */ + +#else + +#define RAS_ARGS TRaster_Instance* raster, +#define RAS_ARG TRaster_Instance* raster + +#define RAS_VARS raster, +#define RAS_VAR raster + +#endif + + + struct TRaster_Instance_; + typedef struct TRaster_Instance_ TRaster_Instance; + + /* Render one glyph in the target bitmap, using drop-out control */ + /* mode 'scan'. */ + LOCAL_DEF + TT_Error Render_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target ); + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + /* Render one gray-level glyph in the target pixmap. */ + /* Palette points to an array of 5 colors used for the rendering. */ + /* Use NULL to reuse the last palette. Default is VGA graylevels. */ + LOCAL_DEF + TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target, + Byte* palette ); +#endif + + /* Initialize rasterizer */ + LOCAL_DEF + TT_Error TTRaster_Init( PEngine_Instance engine ); + + /* Finalize it */ + LOCAL_DEF + TT_Error TTRaster_Done( PEngine_Instance engine ); + + +#ifdef __cplusplus +} +#endif + +#endif /* TTRASTER_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/tttables.h b/Driver/Font/TrueType/FreeType/tttables.h new file mode 100644 index 000000000..0ea5fffe8 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/tttables.h @@ -0,0 +1,215 @@ +/******************************************************************* + * + * tttables.h 1.1 + * + * TrueType Tables structures and handling (specification). + * + * 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 TTTABLES_H +#define TTTABLES_H + +#include "ttconfig.h" +#include "tttypes.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /***********************************************************************/ + /* */ + /* TrueType Table Types */ + /* */ + /***********************************************************************/ + + /* TrueType Collection Header */ + + struct TTTCHeader_ + { + ULong Tag; + TT_Fixed version; + ULong DirCount; + PULong TableDirectory; + }; + + typedef struct TTTCHeader_ TTTCHeader; + typedef TTTCHeader* PTTCHeader; + + + /* TrueType Table Directory type */ + + struct TTableDir_ + { + TT_Fixed version; /* should be 0x10000 */ + UShort numTables; /* number of tables */ + + UShort searchRange; /* These parameters are only used */ + UShort entrySelector; /* for a dichotomy search in the */ + UShort rangeShift; /* directory. We ignore them. */ + }; + + typedef struct TTableDir_ TTableDir; + typedef TTableDir* PTableDir; + + + /* The 'TableDir' is followed by 'numTables' TableDirEntries */ + + struct TTableDirEntry_ + { + ULong Tag; /* table type */ + ULong CheckSum; /* table checksum */ + ULong Offset; /* table file offset */ + ULong Length; /* table length */ + }; + + typedef struct TTableDirEntry_ TTableDirEntry; + typedef TTableDirEntry* PTableDirEntry; + + + /* 'cmap' tables */ + + struct TCMapDir_ + { + UShort tableVersionNumber; + UShort numCMaps; + }; + + typedef struct TCMapDir_ TCMapDir; + typedef TCMapDir* PCMapDir; + + struct TCMapDirEntry_ + { + UShort platformID; + UShort platformEncodingID; + Long offset; + }; + + typedef struct TCMapDirEntry_ TCMapDirEntry; + typedef TCMapDirEntry* PCMapDirEntries; + + + /* 'maxp' Maximum Profiles table */ + + struct TMaxProfile_ + { + TT_Fixed version; + UShort numGlyphs, + maxPoints, + maxContours, + maxCompositePoints, + maxCompositeContours, + maxZones, + maxTwilightPoints, + maxStorage, + maxFunctionDefs, + maxInstructionDefs, + maxStackElements, + maxSizeOfInstructions, + maxComponentElements, + maxComponentDepth; + }; + + typedef struct TMaxProfile_ TMaxProfile; + typedef TMaxProfile* PMaxProfile; + + + /* table "gasp" */ + +#define GASP_GRIDFIT 0x01 +#define GASP_DOGRAY 0x02 + + struct GaspRange_ + { + UShort maxPPEM; + UShort gaspFlag; + }; + + typedef struct GaspRange_ GaspRange; + + + struct TGasp_ + { + UShort version; + UShort numRanges; + GaspRange* gaspRanges; + }; + + typedef struct TGasp_ TGasp; + + + /* table "head" - now defined in freetype.h */ + /* table "hhea" - now defined in freetype.h */ + + + /* tables "HMTX" and "VMTX" */ + + struct TLongMetrics_ + { + UShort advance; + Short bearing; + }; + + typedef struct TLongMetrics_ TLongMetrics, *PLongMetrics; + + typedef Short TShortMetrics, *PShortMetrics; + + /* 'loca' location table type */ + + struct TLoca_ + { + UShort Size; + PStorage Table; + }; + + typedef struct TLoca_ TLoca; + + + /* table "name" */ + + struct TNameRec_ + { + UShort platformID; + UShort encodingID; + UShort languageID; + UShort nameID; + UShort stringLength; + UShort stringOffset; + + /* this last field is not defined in the spec */ + /* but used by the FreeType engine */ + + PByte string; + }; + + typedef struct TNameRec_ TNameRec; + + + struct TName_Table_ + { + UShort format; + UShort numNameRecords; + UShort storageOffset; + TNameRec* names; + PByte storage; + }; + + typedef struct TName_Table_ TName_Table; + + +#ifdef __cplusplus + } +#endif + +#endif /* TTTABLES_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/tttags.h b/Driver/Font/TrueType/FreeType/tttags.h new file mode 100644 index 000000000..474a3b80b --- /dev/null +++ b/Driver/Font/TrueType/FreeType/tttags.h @@ -0,0 +1,61 @@ +/******************************************************************* + * + * tttags.h + * + * tags for TrueType tables (specification only). + * + * 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 TTAGS_H +#define TTAGS_H + +#include "ttconfig.h" +#include "freetype.h" /* for MAKE_TT_TAG() */ + +#define TTAG_BASE MAKE_TT_TAG( 'B', 'A', 'S', 'E' ) +#define TTAG_bloc MAKE_TT_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bdat MAKE_TT_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_cmap MAKE_TT_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_cvt MAKE_TT_TAG( 'c', 'v', 't', ' ' ) +#define TTAG_EBDT MAKE_TT_TAG( 'E', 'B', 'D', 'T' ) +#define TTAG_EBLC MAKE_TT_TAG( 'E', 'B', 'L', 'C' ) +#define TTAG_EBSC MAKE_TT_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_fpgm MAKE_TT_TAG( 'f', 'p', 'g', 'm' ) +#define TTAG_gasp MAKE_TT_TAG( 'g', 'a', 's', 'p' ) +#define TTAG_glyf MAKE_TT_TAG( 'g', 'l', 'y', 'f' ) +#define TTAG_GDEF MAKE_TT_TAG( 'G', 'D', 'E', 'F' ) +#define TTAG_GPOS MAKE_TT_TAG( 'G', 'P', 'O', 'S' ) +#define TTAG_GSUB MAKE_TT_TAG( 'G', 'S', 'U', 'B' ) +#define TTAG_hdmx MAKE_TT_TAG( 'h', 'd', 'm', 'x' ) +#define TTAG_head MAKE_TT_TAG( 'h', 'e', 'a', 'd' ) +#define TTAG_hhea MAKE_TT_TAG( 'h', 'h', 'e', 'a' ) +#define TTAG_hmtx MAKE_TT_TAG( 'h', 'm', 't', 'x' ) +#define TTAG_JSTF MAKE_TT_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_kern MAKE_TT_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_loca MAKE_TT_TAG( 'l', 'o', 'c', 'a' ) +#define TTAG_LTSH MAKE_TT_TAG( 'L', 'T', 'S', 'H' ) +#define TTAG_maxp MAKE_TT_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_name MAKE_TT_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_OS2 MAKE_TT_TAG( 'O', 'S', '/', '2' ) +#define TTAG_PCLT MAKE_TT_TAG( 'P', 'C', 'L', 'T' ) +#define TTAG_post MAKE_TT_TAG( 'p', 'o', 's', 't' ) +#define TTAG_prep MAKE_TT_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_ttc MAKE_TT_TAG( 't', 't', 'c', ' ' ) +#define TTAG_ttcf MAKE_TT_TAG( 't', 't', 'c', 'f' ) +#define TTAG_VDMX MAKE_TT_TAG( 'V', 'D', 'M', 'X' ) +#define TTAG_vhea MAKE_TT_TAG( 'v', 'h', 'e', 'a' ) +#define TTAG_vmtx MAKE_TT_TAG( 'v', 'm', 't', 'x' ) + +#endif /* TTAGS_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/FreeType/tttypes.h b/Driver/Font/TrueType/FreeType/tttypes.h new file mode 100644 index 000000000..9ebf472f7 --- /dev/null +++ b/Driver/Font/TrueType/FreeType/tttypes.h @@ -0,0 +1,150 @@ +/******************************************************************* + * + * tttypes.h + * + * Freetype engine's common types specification + * (this spec has no associated body). + * + * 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. + * + * NOTE: + * + * All these declarations are library internals, and *not* part + * of the high-level interface. See also 'freetype.h'. + * + ******************************************************************/ + +#ifndef TTTYPES_H +#define TTTYPES_H + +#include "ttconfig.h" +#include "freetype.h" + +#ifdef __MACTYPES__ +#error " have been included, and this prevents the proper\ + compilation of this library. Please remove the precompiled headers." +#endif + + typedef char String; + typedef signed char Char; + typedef unsigned char Byte; + + typedef unsigned short UShort; + typedef signed short Short; + + typedef unsigned long ULong; + typedef signed long Long; + + typedef TT_Int32 Fixed; + + typedef int Int; + + /* Simple access types: pointers and tables */ + + typedef Byte* PByte; + typedef UShort* PUShort; + typedef Short* PShort; + typedef ULong* PULong; + typedef Long* PLong; + + typedef Fixed* PFixed; + + typedef Int* PInt; + + typedef void* Pointer; + + typedef TT_F26Dot6* PCoordinates; + typedef unsigned char* PTouchTable; + + +#ifndef Bool + typedef int Bool; /* No boolean type in C */ +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + + typedef Long Storage; + typedef Storage* PStorage; + + +/* Rounding mode constants */ + +#define TT_Round_Off 5 +#define TT_Round_To_Half_Grid 0 +#define TT_Round_To_Grid 1 +#define TT_Round_To_Double_Grid 2 +#define TT_Round_Up_To_Grid 4 +#define TT_Round_Down_To_Grid 3 +#define TT_Round_Super 6 +#define TT_Round_Super_45 7 + + +/* Touch flag masks */ + +#define TT_Flag_On_Curve 1 +#define TT_Flag_Touched_X 2 +#define TT_Flag_Touched_Y 4 +#define TT_Flag_Touched_Both 6 + + +/* Error management constants :) */ + +#define SUCCESS 0 +#define FAILURE -1 + + +/* The min and max functions missing in C. As usual, be careful not to */ +/* write things like MIN( a++, b++ ) to avoid side effects. */ + +#ifndef MIN +#define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) +#endif + +#ifndef MAX +#define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) +#endif + +#ifndef ABS +#define ABS( a ) ( (a) < 0 ? -(a) : (a) ) +#endif + +/* conversion macros for the handles defined in freetype.h */ + +#define HANDLE_Val( handle ) ((handle).z) + +#define HANDLE_Engine( handle ) ((PEngine_Instance)HANDLE_Val( handle )) + +#define HANDLE_Face( handle ) ((PFace)HANDLE_Val( handle )) + +#define HANDLE_Instance( handle ) ((PInstance)HANDLE_Val( handle )) + +/* HANDLE_Stream( handle ) must be defined in ttfile.c */ + +#define HANDLE_Glyph( handle ) ((PGlyph)HANDLE_Val( handle )) + +#define HANDLE_CharMap( handle ) ((PCMapTable)HANDLE_Val( handle )) + +#define HANDLE_Set( handle, val ) ((handle).z = (void*)(val)) + + +#endif /* TTTYPES_H */ + + +/* END */ diff --git a/Driver/Font/TrueType/truetype.asm b/Driver/Font/TrueType/Main/mainManager.asm similarity index 94% rename from Driver/Font/TrueType/truetype.asm rename to Driver/Font/TrueType/Main/mainManager.asm index 5101133c2..87294f055 100644 --- a/Driver/Font/TrueType/truetype.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -87,7 +87,7 @@ WidthMod segment resource include truetypeWidths.asm ;include nimbusUtils.asm ;include nimbusSetTrans.asm -include fontcomUtils.asm +include ../FontCom/fontcomUtils.asm WidthMod ends CharMod segment resource @@ -113,7 +113,7 @@ MetricsMod ends InitMod segment resource include truetypeInit.asm include truetypeEscape.asm -include fontcomEscape.asm +include ../FontCom/fontcomEscape.asm InitMod ends include truetypeEC.asm diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm similarity index 100% rename from Driver/Font/TrueType/truetypeChars.asm rename to Driver/Font/TrueType/Main/truetypeChars.asm diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/Main/truetypeConstant.def similarity index 100% rename from Driver/Font/TrueType/truetypeConstant.def rename to Driver/Font/TrueType/Main/truetypeConstant.def diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/Main/truetypeEC.asm similarity index 100% rename from Driver/Font/TrueType/truetypeEC.asm rename to Driver/Font/TrueType/Main/truetypeEC.asm diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/Main/truetypeEscape.asm similarity index 100% rename from Driver/Font/TrueType/truetypeEscape.asm rename to Driver/Font/TrueType/Main/truetypeEscape.asm diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm similarity index 100% rename from Driver/Font/TrueType/truetypeInit.asm rename to Driver/Font/TrueType/Main/truetypeInit.asm diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/Main/truetypeMacros.def similarity index 100% rename from Driver/Font/TrueType/truetypeMacros.def rename to Driver/Font/TrueType/Main/truetypeMacros.def diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm similarity index 100% rename from Driver/Font/TrueType/truetypeMetrics.asm rename to Driver/Font/TrueType/Main/truetypeMetrics.asm diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/Main/truetypePath.asm similarity index 100% rename from Driver/Font/TrueType/truetypePath.asm rename to Driver/Font/TrueType/Main/truetypePath.asm diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def similarity index 100% rename from Driver/Font/TrueType/truetypeVariable.def rename to Driver/Font/TrueType/Main/truetypeVariable.def diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm similarity index 100% rename from Driver/Font/TrueType/truetypeWidths.asm rename to Driver/Font/TrueType/Main/truetypeWidths.asm diff --git a/Driver/Font/TrueType/truetype.gp b/Driver/Font/TrueType/truetype.gp index 7b23e0938..8b3bee350 100644 --- a/Driver/Font/TrueType/truetype.gp +++ b/Driver/Font/TrueType/truetype.gp @@ -26,6 +26,7 @@ type driver, single # Import kernel routine definitions # library geos +library ansic # # Desktop-related things # diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 44877a5af..4ad4c65a1 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -1,30 +1,43 @@ -# -# THIS FILE HAS BEEN GENERATED AUTOMATICALLY. -# -# If you edit it, you will lose your changes, should it be regenerated. -# -GEODE = truetype -ASM_TO_OBJS = truetype.asm -UI_TO_RDFS = -SRCS = truetype.asm truetypeChars.asm truetypeEC.asm\ - truetypeEscape.asm truetypeInit.asm truetypeMetrics.asm\ - truetypePath.asm truetypeWidths.asm fontcomUtils.asm\ - fontcomEscape.asm truetypeConstant.def truetypeMacros.def\ - truetypeVariable.def -OBJS = truetype.obj -LOBJS = - -SYSMAKEFILE = geode.mk - -#include -#include - -#if exists(local.mk) -#include "local.mk" -#else -#include <$(SYSMAKEFILE)> -#endif - -#if exists($(DEPFILE)) -#include "$(DEPFILE)" -#endif +# +# THIS FILE HAS BEEN GENERATED AUTOMATICALLY. +# +# If you edit it, you will lose your changes, should it be regenerated. +# +GEODE = truetype +MAIN = truetypeEscape.asm mainManager.asm truetypeWidths.asm\ + truetypeMetrics.asm truetypeInit.asm truetypeEC.asm\ + truetypeChars.asm truetypePath.asm truetypeMacros.def\ + truetypeVariable.def truetypeConstant.def +FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ + ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ + ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ + header.h ttinterp.h ttload.h tttables.h ttobjs.h\ + fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ + ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ + ttmemory.h tttags.h +UI_TO_RDFS = +OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ + ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ + ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ + ttmemory.obj +COMMON = +MODULES = Main +CMODULES = FreeType +SRCS = $(MAIN) $(FREETYPE) $(COMMON) +LOBJS = + +SYSMAKEFILE = geode.mk + +#include +#include + +#if exists(local.mk) +#include "local.mk" +#else +#include <$(SYSMAKEFILE)> +#endif + +#if exists($(DEPFILE)) +#include "$(DEPFILE)" +#endif diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index 52a9a0fe3..ed44ef930 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -1,15 +1,131 @@ -truetype.obj \ -truetype.eobj: geos.def heap.def geode.def resource.def ec.def driver.def \ - lmem.def graphics.def fontID.def font.def color.def \ - gstring.def text.def char.def sem.def file.def \ - localize.def sllang.def system.def fileEnum.def \ - Internal/fontDr.def Internal/tmatrix.def \ - Internal/grWinInt.def Internal/gstate.def \ - Internal/window.def win.def Internal/threadIn.def \ - truetypeConstant.def truetypeVariable.def \ - truetypeMacros.def truetypeWidths.asm fontcomUtils.asm \ - truetypeChars.asm truetypeMetrics.asm truetypePath.asm \ - truetypeInit.asm truetypeEscape.asm fontcomEscape.asm \ - truetypeEC.asm - -truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file +Main.obj \ +Main.eobj: Main/mainManager.asm \ + geos.def heap.def geode.def resource.def ec.def driver.def \ + lmem.def graphics.def fontID.def font.def color.def \ + gstring.def text.def char.def sem.def file.def \ + localize.def sllang.def system.def fileEnum.def \ + Internal/fontDr.def Internal/tmatrix.def \ + Internal/grWinInt.def Internal/gstate.def \ + Internal/window.def win.def Internal/threadIn.def \ + truetypeConstant.def truetypeVariable.def \ + truetypeMacros.def truetypeWidths.asm fontcomUtils.asm \ + truetypeChars.asm truetypeMetrics.asm truetypePath.asm \ + truetypeInit.asm truetypeEscape.asm fontcomEscape.asm \ + truetypeEC.asm +ttcache.obj \ +ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ + FreeType/ft_conf.h geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttdebug.h +ttraster.obj \ +ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h +ttmutex.obj \ +ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h +ttgload.obj \ +ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ + FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h +ttextend.obj \ +ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h +ttcalc.obj \ +ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/tttypes.h \ + FreeType/tttables.h +ttapi.obj \ +ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ + FreeType/ttextend.h +ttdebug.obj \ +ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/ttcmap.h +ftxkern.obj \ +ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttextend.h \ + FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/ttobjs.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttcache.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttdebug.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttfile.h FreeType/ttload.h FreeType/tttags.h +ttinterp.obj \ +ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h +ttload.obj \ +ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ + FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/tttags.h FreeType/ttload.h +ttfile.obj \ +ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttmemory.h FreeType/ttfile.h +ttcmap.obj \ +ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ + FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttload.h +ttobjs.obj \ +ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h \ + FreeType/ttextend.h +ttmemory.obj \ +ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttengine.h FreeType/ttmutex.h + +truetypeEC.geo truetype.geo : geos.ldf ansic.ldf \ No newline at end of file From eacc001e8a954c870af4ba123421168f403fd803 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Thu, 17 Feb 2022 21:02:15 +0100 Subject: [PATCH 022/246] Add ansic dependency to makefile for truetype driver. #129 --- Installed/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installed/Makefile b/Installed/Makefile index d29547b3d..7c9af38bb 100644 --- a/Installed/Makefile +++ b/Installed/Makefile @@ -561,7 +561,7 @@ nimbus : Installed/Driver/Font/Nimbus Installed/Driver/Font/Nimbus: kernel MAKEDRV truetype : Installed/Driver/Font/TrueType -Installed/Driver/Font/TrueType: kernel MAKEDRV +Installed/Driver/Font/TrueType: kernel ansic MAKEDRV ms4 : Installed/Driver/IFS/DOS/MS4 Installed/Driver/IFS/DOS/MS4: kernel MAKEDRV From 38cd785f47a38cce7610df847a5077d4aab4ff8f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 23 Mar 2022 20:36:32 +0100 Subject: [PATCH 023/246] add extensions for geos regions and paths --- Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c | 0 Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c create mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c new file mode 100644 index 000000000..e69de29bb diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h new file mode 100644 index 000000000..e69de29bb From d43a43ead6ae9a552eb3a4343be71e5c3a3e8c0e Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sun, 10 Apr 2022 14:16:24 +0200 Subject: [PATCH 024/246] prototype for region rastering --- .../testapps/ttf2/FreeType/freetype.h | 27 ++++++++++++++++++- .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 4 +-- Appl/Breadbox/testapps/ttf2/backlog.md | 11 ++++---- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 91ee8e5f3..4320f639d 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -341,6 +341,18 @@ typedef struct TT_Raster_Map_ TT_Raster_Map; +#ifdef __GEOS__ + struct TT_Raster_Region_ + { + int rows; + int cols; + void* region; + long size; + }; + + typedef struct TT_Raster_Region_ TT_Raster_Region; +#endif + /* ------ The font header TrueType table structure ------ */ @@ -952,7 +964,20 @@ TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ); - +#ifdef __GEOS__ + /* Render the glyph into a region, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + EXPORT_DEF + TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, + TT_Raster_Region* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); +#endif /* ifdef __GEOS__ */ /* ----------------------- outline support ------------------------ */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index 447d3ce20..637eccd18 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -8,7 +8,7 @@ #ifndef FT_CONF_H #define FT_CONF_H -/* Under FreeGEOS we need this for the file operations. */ +/* Under FreeGEOS we need this for the file operations. */ #include #include #include @@ -111,7 +111,7 @@ /* emerged recently on the FreeType lists. We still do not have Apple's */ /* opinion on the subject and will change this as soon as we have. */ -#undef TT_CONFIG_OPTION_NO_INTERPRETER +#undef TT_CONFIG_OPTION_NO_INTERPRETER /*************************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 63e9cf8d7..62bee48f5 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -1,5 +1,5 @@ ## TODO -- ft_conf.h aus /FreeType/arch/geos nutzen und unter /FreeType löschen +- ~~ft_conf.h aus /FreeType/arch/geos nutzen und unter /FreeType löschen~~ - ~~Speicherbedarf begrenzen (ttraster.c RASTER_RENDER_POOL)~~ ## Meilensteine @@ -18,12 +18,13 @@ - ~~Zeichensatz im Testprogramm anzeigen, übersetzbar und lauffähig~~ - Memorymanagement auf Geos Spezifika (hugemem.c könnte genügen) umstellen, übersetzbar und lauffähig - ~~Extension für Kerning aktivieren~~ -- Bytecodeinterpreter aktivieren -- angepasstes FreeType in Treibersourcen verschieben -- Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH +- ~~Bytecodeinterpreter aktivieren~~ +- ~~angepasstes FreeType in Treibersourcen verschieben~~ +- Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH anlegen +- Implementierungen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH - FreeType in Treiber integrieren - Registrierung eines Fonts anpassen (FontID, TTC???) -- Darstellung kleiner PUnktgrößen weiter verbessern (bspw. high precision & scond pass) +- ~~Darstellung kleiner PUnktgrößen weiter verbessern (bspw. high precision & scond pass)~~ ## Fehler - ~~freigeben von resiervierten Resoucen führt zum einfrieren~~ From c2e3da0b8de0b0ad652f798a4e19f24d8a6d85e9 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sun, 10 Apr 2022 19:57:25 +0200 Subject: [PATCH 025/246] first step of region rasterizer --- .../testapps/ttf2/FreeType/freetype.h | 17 ++- .../Breadbox/testapps/ttf2/FreeType/ftxgeos.c | 0 .../Breadbox/testapps/ttf2/FreeType/ftxgeos.h | 0 Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 106 ++++++++++++++ .../testapps/ttf2/FreeType/ttraster.c | 29 ++++ .../testapps/ttf2/FreeType/ttraster.h | 8 ++ Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 4 +- .../Appl/Breadbox/testapps/ttf2/Makefile | 24 ++-- .../Breadbox/testapps/ttf2/dependencies.mk | 130 +++++++++--------- 9 files changed, 234 insertions(+), 84 deletions(-) delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 4320f639d..1062ca508 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -342,7 +342,7 @@ typedef struct TT_Raster_Map_ TT_Raster_Map; #ifdef __GEOS__ - struct TT_Raster_Region_ + struct TT_Region_Map_ { int rows; int cols; @@ -350,7 +350,7 @@ long size; }; - typedef struct TT_Raster_Region_ TT_Raster_Region; + typedef struct TT_Region_Map_ TT_Region_Map; #endif @@ -964,7 +964,7 @@ TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ); -#ifdef __GEOS__ + /* Render the glyph into a region, with given position offsets. */ /* */ /* Note: Only use integer pixel offsets to preserve the fine */ @@ -974,10 +974,10 @@ /* of 64! */ EXPORT_DEF TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, - TT_Raster_Region* map, + TT_Region_Map* map, TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ); -#endif /* ifdef __GEOS__ */ + /* ----------------------- outline support ------------------------ */ @@ -1018,6 +1018,13 @@ TT_Outline* outline, TT_Raster_Map* map ); + /* Render an outline into a region. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Region( TT_Engine engine, + TT_Outline* outline, + TT_Region_Map* map ); + /* Return an outline's bounding box -- this function is slow as it */ /* performs a complete scan-line process, without drawing, to get */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftxgeos.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index b9ddf1c2a..b622641d2 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -58,6 +58,9 @@ #define RENDER_Gray_Glyph( glyph, target, palette ) \ Render_Gray_Glyph( RAS_OPS glyph, target, palette ) +#define RENDER_Region_Glyph( glyph, target ) \ + Render_Region_Glyph( RAS_OPS glyph, target ) + /******************************************************************* @@ -1439,6 +1442,69 @@ #endif /* TT_CONFIG_OPTION_GRAY_SCALING */ +#ifdef __GEOS__ + +/******************************************************************* + * + * Function : TT_Get_Glyph_Region + * + * Description : Produces a region from a glyph outline. + * + * Input : glyph the glyph container's handle + * region target region description block + * xOffset x offset in fractional pixels (26.6 format) + * yOffset y offset in fractional pixels (26.6 format) + * + * Output : Error code. + * + * Note : Only use integer pixel offsets to preserve the fine + * hinting of the glyph and the 'correct' anti-aliasing + * (where vertical and horizontal stems aren't grayed). + * This means that xOffset and yOffset must be multiples + * of 64! + * + * You can experiment with offsets of +32 to get 'blurred' + * versions of the glyphs (a nice effect at large sizes that + * some graphic designers may appreciate :) + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, + TT_Region_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + /* XXX : For now, use only dropout mode 2 */ + /* outline.dropout_mode = _glyph->scan_type; */ + outline.dropout_mode = 2; + + TT_Translate_Outline( &outline, xOffset, yOffset ); + error = TT_Get_Outline_Region( engine, &outline, map ); + TT_Translate_Outline( &outline, -xOffset, -yOffset ); + + return error; + } + +#endif /* __GEOS__ */ + static const TT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0, 0, 0, 0 }; @@ -1607,6 +1673,46 @@ #endif /* TT_CONFIG_OPTION_GRAY_SCALING */ +#ifdef __GEOS__ + +/******************************************************************* + * + * Function : TT_Get_Outline_Region + * + * Description : Render a TrueType outline into a region. + * Note that the region must be created by the caller. + * + * Input : outline the outline to render + * map the target region + * + * Output : Error code + * + * MT-Safe : YES! + * + ******************************************************************/ +EXPORT_FUNC +TT_Error TT_Get_Outline_Region( TT_Engine engine, + TT_Outline* outline, + TT_Region_Map* map ) +{ + PEngine_Instance _engine = HANDLE_Engine( engine ); + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + if ( !outline || !map ) + return TT_Err_Invalid_Argument; + + MUTEX_Lock( _engine->raster_lock ); + error = RENDER_Region_Glyph( outline, map ); + MUTEX_Release( _engine->raster_lock ); + return error; +} + +#endif /* __GEOS__ */ + /******************************************************************* * diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index ad744b6da..f851b5c6b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -2663,6 +2663,35 @@ Scan_DropOuts : #endif /* TT_CONFIG_OPTION_GRAY_SCALING */ +#ifdef __GEOS__ + +/****************************************************************************/ +/* */ +/* Function: Render_Region_Glyph */ +/* */ +/* Description: Renders a glyph in a region. Sub-banding if needed. */ +/* */ +/* Input: AGlyph Glyph record */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + +LOCAL_FUNC +TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Region_Map* target_map ) +{ + TT_Error error; + + // TBD + + return error; +} + +#endif /* __GEOS__ */ + + /************************************************/ /* */ /* InitRasterizer */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h index 6af372090..e08882d8c 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h @@ -108,6 +108,14 @@ extern "C" { Byte* palette ); #endif +#ifdef __GEOS__ + /* Render one glyph in the target region, using drop-out control */ + /* mode 'scan'. */ + LOCAL_DEF + TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Region_Map* target ); +#endif + /* Initialize rasterizer */ LOCAL_DEF TT_Error TTRaster_Init( PEngine_Instance engine ); diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 291eceec5..264f64f9a 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -147,7 +147,7 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } - error = TT_Open_Face(engine, "Mont.ttf", &face); + error = TT_Open_Face(engine, "PTSerif.ttf", &face); if(error) { _log("Fehler beim laden des Fonts\r"); goto Fail; @@ -172,7 +172,7 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 11*64); + error = TT_Set_Instance_CharSize(instance, 9*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; diff --git a/Installed/Appl/Breadbox/testapps/ttf2/Makefile b/Installed/Appl/Breadbox/testapps/ttf2/Makefile index 5da7cc050..2602f551d 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/Makefile +++ b/Installed/Appl/Breadbox/testapps/ttf2/Makefile @@ -4,20 +4,20 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = ttf2 -FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ - ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ - header.h ttinterp.h ttload.h tttables.h ttobjs.h\ - fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ - ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ - ttmemory.h tttags.h +FREETYPE = ftxkern.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ + ttextend.c ttfile.c ttgload.c ttinterp.c ttload.c\ + ttmemory.c ttmutex.c ttobjs.c ttraster.c ttapi.c\ + freetype.h ft_conf.h fterrid.h ftnameid.h ftxkern.h\ + header.h ttcache.h ttcalc.h ttcmap.h ttconfig.h ttdebug.h\ + ttengine.h ttextend.h ttfile.h ttgload.h ttinterp.h\ + ttload.h ttmemory.h ttmutex.h ttobjs.h ttraster.h\ + tttables.h tttags.h tttypes.h UI = ttf2.goc UI_TO_RDFS = -OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ - ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ - ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ - ttmemory.obj ttf2.obj +OBJS = ftxkern.obj ttcache.obj ttcalc.obj ttcmap.obj ttdebug.obj\ + ttextend.obj ttfile.obj ttgload.obj ttinterp.obj\ + ttload.obj ttmemory.obj ttmutex.obj ttobjs.obj\ + ttraster.obj ttapi.obj ttf2.obj COMMON = MODULES = CMODULES = FreeType Ui diff --git a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk index efe7539d7..067542f7b 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk +++ b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk @@ -28,6 +28,15 @@ ttf2.eobj: geos.h heap.h geode.h resource.h ec.h object.h lmem.h \ parallDr.h hugearr.h fileEnum.h Ansi/stdlib.h \ Ansi/string.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h +ftxkern.obj \ +ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttextend.h \ + FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/ttobjs.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttcache.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttdebug.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttfile.h FreeType/ttload.h FreeType/tttags.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ft_conf.h geos.h file.h resource.h Ansi/stdlib.h \ @@ -36,48 +45,21 @@ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ FreeType/ttdebug.h -ttraster.obj \ -ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h -ttmutex.obj \ -ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h -ttgload.obj \ -ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ - FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/tttags.h FreeType/ttload.h -ttextend.obj \ -ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ - FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h ttcalc.obj \ ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h Ansi/stdlib.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttdebug.h FreeType/tttypes.h \ FreeType/tttables.h -ttapi.obj \ -ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ - FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ - FreeType/ttextend.h +ttcmap.obj \ +ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ + FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttload.h ttdebug.obj \ ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ @@ -85,15 +67,29 @@ ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/ttcmap.h -ftxkern.obj \ -ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttextend.h \ - FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/ttobjs.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/ttcache.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttdebug.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttfile.h FreeType/ttload.h FreeType/tttags.h +ttextend.obj \ +ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h +ttfile.obj \ +ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttmemory.h FreeType/ttfile.h +ttgload.obj \ +ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ + FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h ttinterp.obj \ ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ @@ -111,22 +107,15 @@ ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ FreeType/tttags.h FreeType/ttload.h -ttfile.obj \ -ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ - FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/ttmemory.h FreeType/ttfile.h -ttcmap.obj \ -ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ +ttmemory.obj \ +ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ - FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttload.h + FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttengine.h FreeType/ttmutex.h +ttmutex.obj \ +ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h ttobjs.obj \ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h Ansi/stdlib.h \ @@ -137,11 +126,22 @@ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h \ FreeType/ttextend.h -ttmemory.obj \ -ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ +ttraster.obj \ +ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h Ansi/stdlib.h \ FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttengine.h FreeType/ttmutex.h + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h +ttapi.obj \ +ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ + FreeType/ttextend.h ttf2EC.geo ttf2.geo : geos.ldf ui.ldf ansic.ldf \ No newline at end of file From f70d4b43ebe3a6386e103378bb362e4947c936e7 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Mon, 11 Apr 2022 21:56:09 +0200 Subject: [PATCH 026/246] a small step forward --- .../testapps/ttf2/FreeType/ttraster.c | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index f851b5c6b..e2d6eb015 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -270,6 +270,9 @@ TStates state; /* rendering state */ TT_Raster_Map target; /* description of target bit/pixmap */ +#ifdef __GEOS__ + TT_Region_Map region; /* description of target region */ +#endif /* __GEOS__ */ Long traceOfs; /* current offset in target bitmap */ Long traceG; /* current offset in target pixmap */ @@ -2680,13 +2683,57 @@ Scan_DropOuts : LOCAL_FUNC TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, - TT_Region_Map* target_map ) + TT_Region_Map* map ) { TT_Error error; - // TBD + if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + return TT_Err_Ok; + + if ( !ras.buff ) + { + ras.error = Raster_Err_Not_Ini; + return ras.error; + } + + if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) + { + ras.error = TT_Err_Too_Many_Points; + return ras.error; + } + + if ( map ) + ras.region = *map; + + ras.outs = glyph->contours; + ras.flags = glyph->flags; + ras.nPoints = glyph->n_points; + ras.nContours = glyph->n_contours; + ras.coords = glyph->points; + + Set_High_Precision( RAS_VARS glyph->high_precision ); + ras.scale_shift = ras.precision_shift; + ras.dropOutControl = glyph->dropout_mode; + ras.second_pass = glyph->second_pass; + + /* Vertical Sweep */ + ras.Proc_Sweep_Init = Vertical_Sweep_Init; // TODO: Funktionen für das Rendern in eine Region schreiben und hier registrieren + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Sweep_Step; + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.rows - 1; + + ras.bWidth = ras.target.width; + ras.bTarget = (Byte*)ras.target.bitmap; // TODO: Wir benötigen noch eine rTarget in TRaster_Instance für Regions + + + if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) + return error; - return error; + return TT_Err_Ok; } #endif /* __GEOS__ */ From 453ed70340a6c5430e115fcd03790282c02ab0d2 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Mon, 25 Apr 2022 20:02:31 +0200 Subject: [PATCH 027/246] adding function stubs for rendering in regions --- .../testapps/ttf2/FreeType/freetype.h | 2 +- .../testapps/ttf2/FreeType/ttraster.c | 95 ++++++++--- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 150 +++++++++++------- 3 files changed, 162 insertions(+), 85 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 1062ca508..da23024e9 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -346,7 +346,7 @@ { int rows; int cols; - void* region; + void* data; long size; }; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index e2d6eb015..361f98960 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -250,37 +250,40 @@ TPoint* arc; /* current Bezier arc pointer */ - UShort bWidth; /* target bitmap width */ + UShort bWidth; /* target buffer width */ PByte bTarget; /* target bitmap buffer */ PByte gTarget; /* target pixmap buffer */ +#ifdef __GEOS__ + PShort rTarget; /* target region buffer */ +#endif /* __GEOS__ */ Long lastX, lastY, minY, maxY; - UShort num_Profs; /* current number of profiles */ + UShort num_Profs; /* current number of profiles */ - Bool fresh; /* signals a fresh new profile which */ - /* 'start' field must be completed */ - Bool joint; /* signals that the last arc ended */ - /* exactly on a scanline. Allows */ - /* removal of doublets */ - PProfile cProfile; /* current profile */ - PProfile fProfile; /* head of linked list of profiles */ - PProfile gProfile; /* contour's first profile in case */ - /* of impact */ - TStates state; /* rendering state */ + Bool fresh; /* signals a fresh new profile which */ + /* 'start' field must be completed */ + Bool joint; /* signals that the last arc ended */ + /* exactly on a scanline. Allows */ + /* removal of doublets */ + PProfile cProfile; /* current profile */ + PProfile fProfile; /* head of linked list of profiles */ + PProfile gProfile; /* contour's first profile in case */ + /* of impact */ + TStates state; /* rendering state */ - TT_Raster_Map target; /* description of target bit/pixmap */ + TT_Raster_Map target; /* description of target bit/pixmap */ #ifdef __GEOS__ - TT_Region_Map region; /* description of target region */ + TT_Region_Map region; /* description of target region */ #endif /* __GEOS__ */ - Long traceOfs; /* current offset in target bitmap */ - Long traceG; /* current offset in target pixmap */ + Long traceOfs; /* current offset in target bitmap or region */ + Long traceG; /* current offset in target pixmap */ - Short traceIncr; /* sweep's increment in target bitmap */ + Short traceIncr; /* sweep's increment in target bitmap */ - Short gray_min_x; /* current min x during gray rendering */ - Short gray_max_x; /* current max x during gray rendering */ + Short gray_min_x; /* current min x during gray rendering */ + Short gray_max_x; /* current max x during gray rendering */ /* dispatch variables */ @@ -1778,6 +1781,49 @@ ras.traceOfs += ras.traceIncr; } +#ifdef __GEOS__ + +/***********************************************************************/ +/* */ +/* Vertical Sweep Procedure Set for regions : */ +/* */ +/* These three routines are used during the vertical black/white */ +/* sweep phase for regions by the generic Draw_Sweep() function. */ +/* */ +/***********************************************************************/ + + static void Vertical_Region_Sweep_Init( RAS_ARGS + Short* min, + Short* max ) + { + //TBD + } + + static void Vertical_Region_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + //TBD + } + + static void Vertical_Region_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + //TBD + } + + static void Vertical_Region_Sweep_Step( RAS_ARG ) + { + //TBD + } + +#endif /* __GEOS__ */ + /***********************************************************************/ /* */ @@ -2717,18 +2763,17 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras.second_pass = glyph->second_pass; /* Vertical Sweep */ - ras.Proc_Sweep_Init = Vertical_Sweep_Init; // TODO: Funktionen für das Rendern in eine Region schreiben und hier registrieren - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Sweep_Step; + ras.Proc_Sweep_Init = Vertical_Region_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Region_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Region_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Region_Sweep_Step; ras.band_top = 0; ras.band_stack[0].y_min = 0; ras.band_stack[0].y_max = ras.target.rows - 1; ras.bWidth = ras.target.width; - ras.bTarget = (Byte*)ras.target.bitmap; // TODO: Wir benötigen noch eine rTarget in TRaster_Instance für Regions - + ras.rTarget = (Short*)ras.region.data; if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) return error; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 264f64f9a..d53eb6304 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -71,60 +71,8 @@ typedef struct { /******************************************************************** * Zeichensatz rendern ********************************************************************/ -void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { - word characterId; - TT_Glyph_Metrics metrics; - TT_Raster_Map bitmap; - TT_Outline outline; - int offsetY = 0; - Bmp bmp; - - // Zeichensatz durchlaufen in einer 16 x 16 Matrix - for(characterId = 1; characterId <= 200; characterId++ ) { - TT_Error error; - int posX = ( characterId % 16 ) * FONT_SIZE + FONT_SIZE/2; - int posY = ( characterId / 16 ) * FONT_SIZE + FONT_SIZE; - - memset(&bmp, 0, sizeof(Bmp)); - bmp.b.B_compact = BMC_UNCOMPACTED; - bmp.b.B_type = BMF_MONO; - bmp.b.B_width = 24; - bmp.b.B_height = 24; - - bitmap.flow = TT_Flow_Down; - bitmap.rows = 24; - bitmap.cols = 3; - bitmap.width = 24; - bitmap.size = 3*24; - bitmap.bitmap = &bmp.data; - - error = TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ); - if(error) - continue; - - /*error = TT_Get_Glyph_Outline(glyph, &outline); - if(error) - continue; - - outline.second_pass = TRUE; - outline.high_precision = TRUE;*/ - - error = TT_Get_Glyph_Metrics(glyph, &metrics); - if(error) - continue; - offsetY = metrics.bbox.yMin; - - error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, -offsetY); - if(error) - continue; - - GrDrawImage(gstate, posX, posY - (offsetY>>6), IBS_1, (Bitmap *) &bmp); - } -} - -@method TtfProcessClass, MSG_META_EXPOSED { - GStateHandle gstate = GrCreateState( win ); +void testRendering(GStateHandle gstate) { char tmpStr[40]; TT_Face_Properties props; TT_Instance instance; @@ -172,7 +120,7 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 9*64); + error = TT_Set_Instance_CharSize(instance, 96*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; @@ -184,15 +132,99 @@ void TtfDraw( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { goto Fail; } +// DrawBitmap( gstate, instance, glyph); + DrawRegion( gstate, instance, glyph); + +Fail: + TT_Done_FreeType(engine); + return; +} + +void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { + word characterId; + TT_Glyph_Metrics metrics; + TT_Raster_Map bitmap; + TT_Outline outline; + int offsetY = 0; + Bmp bmp; + + // Zeichensatz durchlaufen in einer 16 x 16 Matrix + for(characterId = 1; characterId <= 200; characterId++ ) { + TT_Error error; + int posX = ( characterId % 16 ) * FONT_SIZE + FONT_SIZE/2; + int posY = ( characterId / 16 ) * FONT_SIZE + FONT_SIZE; + + memset(&bmp, 0, sizeof(Bmp)); + bmp.b.B_compact = BMC_UNCOMPACTED; + bmp.b.B_type = BMF_MONO; + bmp.b.B_width = 24; + bmp.b.B_height = 24; + + bitmap.flow = TT_Flow_Down; + bitmap.rows = 24; + bitmap.cols = 3; + bitmap.width = 24; + bitmap.size = 3*24; + bitmap.bitmap = &bmp.data; + + error = TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ); + if(error) + continue; + + error = TT_Get_Glyph_Metrics(glyph, &metrics); + if(error) + continue; + + offsetY = metrics.bbox.yMin; + + error = TT_Get_Glyph_Bitmap(glyph, &bitmap, 0, -offsetY); + if(error) + continue; + + GrDrawImage(gstate, posX, posY - (offsetY>>6), IBS_1, (Bitmap *) &bmp); + } +} + +void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { + /*Region region[] = { + 0, 0, 15, 10, + 1, EOREGREC, + 3, 8, 13, EOREGREC, + 8, 2, 13, EOREGREC, + 9, 2, 8, 10, 13, EOREGREC, + EOREGREC + };*/ + + word characterId = 40; + TT_Region_Map regionmap; + Region region[200]; + + region[0] = 0; + region[1] = 0; + region[2] = 96; + region[3] = 96; + + regionmap.rows = 96; + regionmap.cols = 96; + regionmap.data = ®ion[4]; + + if( TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ) ) + return; + + if( TT_Get_Glyph_Region(glyph, ®ionmap, 0, 0) ) + return; + + GrDrawRegion(gstate, 200, 200, region, 0, 0); +} + +@method TtfProcessClass, MSG_META_EXPOSED { + GStateHandle gstate = GrCreateState( win ); + GrBeginUpdate( gstate ); - TtfDraw( gstate, instance, glyph); + testRendering( gstate ); GrEndUpdate( gstate ); GrDestroyState( gstate ); - - Fail: - TT_Done_FreeType(engine); - return; } void _log(char * message) { From efd8fdcbba74c195f49efe11b5daaed358b84942 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Tue, 26 Apr 2022 21:54:11 +0200 Subject: [PATCH 028/246] Implementation of Vertical_Region_Sweep_Span --- .../testapps/ttf2/FreeType/ttraster.c | 36 ++++++++++++++++--- Appl/Breadbox/testapps/ttf2/backlog.md | 7 +++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 361f98960..f78cf8412 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -1796,7 +1796,11 @@ Short* min, Short* max ) { - //TBD + ras.traceOfs = 0; + ras.traceIncr = 0; + + ras.gray_min_x = 0; + ras.gray_max_x = 0; } static void Vertical_Region_Sweep_Span( RAS_ARGS Short y, @@ -1805,7 +1809,31 @@ PProfile left, PProfile right ) { - //TBD + Long e1, e2; + Short* target; + + + /* Drop-out control */ + + e1 = TRUNC( CEILING( x1 ) ); + + if ( x2-x1-ras.precision <= ras.precision_jitter ) + e2 = e1; + else + e2 = TRUNC( FLOOR( x2 ) ); + + // TODO write current lineindex if new line begins + + if ( e2 >= 0 && e1 < ras.bWidth ) + { + if ( e1 < 0 ) e1 = 0; + if ( e2 >= ras.bWidth ) e2 = ras.bWidth-1; + + target = ras.rTarget + ras.traceOfs; + + target[ras.traceIncr++] = ( Short ) e1; + target[ras.traceIncr++] = ( Short ) e2; + } } static void Vertical_Region_Sweep_Drop( RAS_ARGS Short y, @@ -2770,9 +2798,9 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras.band_top = 0; ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = ras.target.rows - 1; + ras.band_stack[0].y_max = ras.region.rows - 1; - ras.bWidth = ras.target.width; + ras.bWidth = ras.region.cols; ras.rTarget = (Short*)ras.region.data; if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 62bee48f5..54e55ca54 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -31,4 +31,9 @@ - ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ ## Bemerkungen -- die Darstellung keiner Punktgröße ist jetzt wesentlich besser aber stark vom Font abhänging; das ist bei der Font-Selektion zu beachten \ No newline at end of file +- die Darstellung keiner Punktgröße ist jetzt wesentlich besser aber stark vom Font abhänging; das ist bei der Font-Selektion zu beachten + +## Optimierungen +- diverse Offsets von long auf int ändern +- diverse sizes von long auf int ändern +- Elemente der TRaster_Instace_ Struktur die nur für Pixmaps benötig werden entfernen \ No newline at end of file From fd534655c640e9a52b4c411928aaf03051f4e107 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 29 Apr 2022 22:09:17 +0200 Subject: [PATCH 029/246] =?UTF-8?q?Generic=20function=20Sweep=5FFinish()?= =?UTF-8?q?=20added.=20This=20is=20needed=20f=C3=BCr=20rendering=20regions?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 3 +- .../testapps/ttf2/FreeType/ttraster.c | 80 ++++++++++++++----- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index 637eccd18..de3c0d233 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -8,10 +8,11 @@ #ifndef FT_CONF_H #define FT_CONF_H -/* Under FreeGEOS we need this for the file operations. */ +/* Under FreeGEOS we need this for the file operations and render regions. */ #include #include #include +#include /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index f78cf8412..880aa92d0 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -191,7 +191,9 @@ PProfile left, PProfile right ); - typedef void Function_Sweep_Step( RAS_ARG ); + typedef void Function_Sweep_Step( RAS_ARGS Short y ); + + typedef void Function_Sweep_Finish( RAS_ARG ); /* NOTE: These operations are only valid on 2's complement processors */ @@ -287,10 +289,11 @@ /* dispatch variables */ - Function_Sweep_Init* Proc_Sweep_Init; - Function_Sweep_Span* Proc_Sweep_Span; - Function_Sweep_Span* Proc_Sweep_Drop; - Function_Sweep_Step* Proc_Sweep_Step; + Function_Sweep_Init* Proc_Sweep_Init; + Function_Sweep_Span* Proc_Sweep_Span; + Function_Sweep_Span* Proc_Sweep_Drop; + Function_Sweep_Step* Proc_Sweep_Step; + Function_Sweep_Finish* Proc_Sweep_Finish; TT_Vector* coords; @@ -1776,11 +1779,20 @@ } - static void Vertical_Sweep_Step( RAS_ARG ) + static void Vertical_Sweep_Step( RAS_ARGS Short y ) { ras.traceOfs += ras.traceIncr; } +#ifdef __GEOS__ + + static void Vertical_Sweep_Finish( RAS_ARG ) + { + /* nothing to do */ + } + +#endif /* __GEOS__ */ + #ifdef __GEOS__ /***********************************************************************/ @@ -1822,15 +1834,16 @@ else e2 = TRUNC( FLOOR( x2 ) ); - // TODO write current lineindex if new line begins + target = ras.rTarget + ras.traceOfs; + + if ( ras.traceIncr == 0 ) + target[ras.traceIncr++] = y; if ( e2 >= 0 && e1 < ras.bWidth ) { if ( e1 < 0 ) e1 = 0; if ( e2 >= ras.bWidth ) e2 = ras.bWidth-1; - target = ras.rTarget + ras.traceOfs; - target[ras.traceIncr++] = ( Short ) e1; target[ras.traceIncr++] = ( Short ) e2; } @@ -1842,12 +1855,37 @@ PProfile left, PProfile right ) { - //TBD + /* nothing to do */ } - static void Vertical_Region_Sweep_Step( RAS_ARG ) + static void Vertical_Region_Sweep_Step( RAS_ARGS Short y ) { - //TBD + if ( ras.traceIncr == 0 ) + { + // schreibe akt. Zeile + // schreibe EOREGREC + // ras.traceIncr += 2 + } + else + { + // schreibe EOREGREC + // ras.traceIncr++ + } + + ras.traceOfs += ras.traceIncr; + ras.traceIncr = 0; + } + + static void Vertical_Region_Sweep_Finish( RAS_ARG ) + { + Short* target; + + + /* complete a region */ + + target = ras.rTarget + ras.traceOfs; + + target[ras.traceIncr] = EOREGREC; } #endif /* __GEOS__ */ @@ -2007,11 +2045,16 @@ } - static void Horizontal_Sweep_Step( RAS_ARG ) + static void Horizontal_Sweep_Step( RAS_ARGS Short y ) { /* Nothing, really */ } + static void Horizontal_Sweep_Finish( RAS_ARG ) + { + /* nothing to do */ + } + #ifdef TT_CONFIG_OPTION_GRAY_SCALING @@ -2056,7 +2099,7 @@ } - static void Vertical_Gray_Sweep_Step( RAS_ARG ) + static void Vertical_Gray_Sweep_Step( RAS_ARG Short y ) { Int c1, c2; PByte pix, bit, bit2; @@ -2389,9 +2432,9 @@ Next_Line: #ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); #else - ras.Proc_Sweep_Step( RAS_VAR ); + ras.Proc_Sweep_Step( RAS_VARS y ); #endif /* ifdef __GEOS__ */ y++; @@ -2434,13 +2477,14 @@ while ( y <= max_Y ) { #ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); #else - ras.Proc_Sweep_Step( RAS_VAR ); + ras.Proc_Sweep_Step( RAS_VARS y ); #endif /* __GEOS__ */ y++; } + // TODO finish redered glyph return SUCCESS; Scan_DropOuts : From 7027ff040425a4c3d9b208c9c68d47238151ed3e Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sun, 1 May 2022 20:39:18 +0200 Subject: [PATCH 030/246] rendering in regions completed --- .../testapps/ttf2/FreeType/ttraster.c | 81 +++++++++++-------- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 24 +++--- Appl/Breadbox/testapps/ttf2/backlog.md | 2 + 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 880aa92d0..76dbc5e01 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -1784,14 +1784,12 @@ ras.traceOfs += ras.traceIncr; } -#ifdef __GEOS__ static void Vertical_Sweep_Finish( RAS_ARG ) { /* nothing to do */ } -#endif /* __GEOS__ */ #ifdef __GEOS__ @@ -1860,17 +1858,19 @@ static void Vertical_Region_Sweep_Step( RAS_ARGS Short y ) { + Short* target; + + + target = ras.rTarget + ras.traceOfs; + + /* special case: the current line was empty */ + if ( ras.traceIncr == 0 ) - { - // schreibe akt. Zeile - // schreibe EOREGREC - // ras.traceIncr += 2 - } - else - { - // schreibe EOREGREC - // ras.traceIncr++ - } + target[ras.traceIncr++] = y; + + /* finish current line and move to the next one */ + + target[ras.traceIncr++] = EOREGREC; ras.traceOfs += ras.traceIncr; ras.traceIncr = 0; @@ -1885,7 +1885,8 @@ target = ras.rTarget + ras.traceOfs; - target[ras.traceIncr] = EOREGREC; + target[ras.traceIncr++] = EOREGREC; + ras.region.size = ras.traceOfs + ras.traceIncr; } #endif /* __GEOS__ */ @@ -2484,7 +2485,11 @@ y++; } - // TODO finish redered glyph +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Finish, RAS_VAR ); +#else + ras.Proc_Sweep_Finish( RAS_VAR ); +#endif return SUCCESS; Scan_DropOuts : @@ -2642,10 +2647,11 @@ Scan_DropOuts : /* Vertical Sweep */ - ras.Proc_Sweep_Init = Vertical_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Sweep_Step; + ras.Proc_Sweep_Init = Vertical_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Sweep_Step; + ras.Proc_Sweep_Finish = Vertical_Sweep_Finish; ras.band_top = 0; ras.band_stack[0].y_min = 0; @@ -2661,10 +2667,11 @@ Scan_DropOuts : if ( ras.second_pass && ras.dropOutControl != 0 ) { - ras.Proc_Sweep_Init = Horizontal_Sweep_Init; - ras.Proc_Sweep_Span = Horizontal_Sweep_Span; - ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; - ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Finish = Horizontal_Sweep_Finish; ras.band_top = 0; ras.band_stack[0].y_min = 0; @@ -2751,10 +2758,11 @@ Scan_DropOuts : ras.bTarget = (Byte*)ras.gray_lines; ras.gTarget = (Byte*)ras.target.bitmap; - ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; + ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; + ras.Proc_Sweep_Finish = Vertical_Sweep_Finish; error = Render_Single_Pass( RAS_VARS 0 ); if (error) @@ -2764,10 +2772,12 @@ Scan_DropOuts : if ( ras.second_pass && ras.dropOutControl != 0 ) { - ras.Proc_Sweep_Init = Horizontal_Sweep_Init; - ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; - ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; - ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Finish = Horizontal_Sweep_Finish; + ras.band_top = 0; ras.band_stack[0].y_min = 0; @@ -2835,10 +2845,13 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras.second_pass = glyph->second_pass; /* Vertical Sweep */ - ras.Proc_Sweep_Init = Vertical_Region_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Region_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Region_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Region_Sweep_Step; + + ras.Proc_Sweep_Init = Vertical_Region_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Region_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Region_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Region_Sweep_Step; + ras.Proc_Sweep_Finish = Vertical_Region_Sweep_Finish; + ras.band_top = 0; ras.band_stack[0].y_min = 0; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index d53eb6304..c588f8a71 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -120,7 +120,7 @@ void testRendering(GStateHandle gstate) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 96*64); + error = TT_Set_Instance_CharSize(instance, 40*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; @@ -186,26 +186,18 @@ void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { } void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { - /*Region region[] = { - 0, 0, 15, 10, - 1, EOREGREC, - 3, 8, 13, EOREGREC, - 8, 2, 13, EOREGREC, - 9, 2, 8, 10, 13, EOREGREC, - EOREGREC - };*/ - word characterId = 40; + char tmpStr[40]; TT_Region_Map regionmap; - Region region[200]; + Region region[250]; region[0] = 0; region[1] = 0; - region[2] = 96; - region[3] = 96; + region[2] = 48; + region[3] = 48; - regionmap.rows = 96; - regionmap.cols = 96; + regionmap.rows = 48; + regionmap.cols = 48; regionmap.data = ®ion[4]; if( TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ) ) @@ -214,6 +206,8 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if( TT_Get_Glyph_Region(glyph, ®ionmap, 0, 0) ) return; + sprintf(tmpStr, "region size:\t%d\r", ((int)regionmap.size)); _log(tmpStr); + GrDrawRegion(gstate, 200, 200, region, 0, 0); } diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 54e55ca54..eb88728d2 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -29,6 +29,8 @@ ## Fehler - ~~freigeben von resiervierten Resoucen führt zum einfrieren~~ - ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ +- die Size einer Region ist fehlerhaft +- (Testprogramm) TT_Init_Kerning_Extension() darf nur einmalig aufgerufen werden ## Bemerkungen - die Darstellung keiner Punktgröße ist jetzt wesentlich besser aber stark vom Font abhänging; das ist bei der Font-Selektion zu beachten From e285ac8f148bb9aec7d33eb03e7a7585449a569c Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 13 May 2022 23:09:04 +0200 Subject: [PATCH 031/246] use TT_Raster_Map instead of TT_Region_Map for rendering regions --- .../testapps/ttf2/FreeType/freetype.h | 29 ++++++----- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 6 +-- .../testapps/ttf2/FreeType/ttmemory.h | 4 ++ .../testapps/ttf2/FreeType/ttraster.c | 50 +++++++++++++------ .../testapps/ttf2/FreeType/ttraster.h | 4 +- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 10 ++-- Appl/Breadbox/testapps/ttf2/backlog.md | 7 ++- 7 files changed, 70 insertions(+), 40 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index da23024e9..72a5a5dce 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -327,6 +327,13 @@ /* cols = (W+3) & ~3 */ /* width = cols */ /* flow = your_choice */ + /* */ + /* - for a WxH region: */ + /* */ + /* rows = H */ + /* cols = W */ + /* width = cols */ + /* flow = your_choise */ struct TT_Raster_Map_ { @@ -335,24 +342,16 @@ int width; /* number of pixels per line */ int flow; /* bitmap orientation */ - void* bitmap; /* bit/pixmap buffer */ + void* bitmap; /* bit/pixmap/region buffer */ +#ifndef __GEOS__ long size; /* bit/pixmap size in bytes */ +#else + int size; /* bit/pixmap/region size in bytes */ +#endif /* __GEOS__ */ }; typedef struct TT_Raster_Map_ TT_Raster_Map; -#ifdef __GEOS__ - struct TT_Region_Map_ - { - int rows; - int cols; - void* data; - long size; - }; - - typedef struct TT_Region_Map_ TT_Region_Map; -#endif - /* ------ The font header TrueType table structure ------ */ @@ -974,7 +973,7 @@ /* of 64! */ EXPORT_DEF TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, - TT_Region_Map* map, + TT_Raster_Map* map, TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ); @@ -1023,7 +1022,7 @@ EXPORT_DEF TT_Error TT_Get_Outline_Region( TT_Engine engine, TT_Outline* outline, - TT_Region_Map* map ); + TT_Raster_Map* map ); /* Return an outline's bounding box -- this function is slow as it */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index b622641d2..d47e82f53 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1451,7 +1451,7 @@ * Description : Produces a region from a glyph outline. * * Input : glyph the glyph container's handle - * region target region description block + * map target region description block * xOffset x offset in fractional pixels (26.6 format) * yOffset y offset in fractional pixels (26.6 format) * @@ -1473,7 +1473,7 @@ EXPORT_FUNC TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, - TT_Region_Map* map, + TT_Raster_Map* map, TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ) { @@ -1693,7 +1693,7 @@ EXPORT_FUNC TT_Error TT_Get_Outline_Region( TT_Engine engine, TT_Outline* outline, - TT_Region_Map* map ) + TT_Raster_Map* map ) { PEngine_Instance _engine = HANDLE_Engine( engine ); TT_Error error; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h index 54394ecc2..42fe0d997 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -40,6 +40,10 @@ #define MEM_Set( dest, byte, count ) memset( dest, byte, count ) +#ifdef __GEOS__ +#define MEM_Cmp( left, right, count ) memcmp( left, right, count ) +#endif /* __GEOS__ */ + #ifdef HAVE_MEMCPY #define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) #else diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 76dbc5e01..d99014625 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -275,11 +275,9 @@ TStates state; /* rendering state */ TT_Raster_Map target; /* description of target bit/pixmap */ -#ifdef __GEOS__ - TT_Region_Map region; /* description of target region */ -#endif /* __GEOS__ */ Long traceOfs; /* current offset in target bitmap or region */ + Long traceOfsLastLine; /* offset in traget region before line step */ Long traceG; /* current offset in target pixmap */ Short traceIncr; /* sweep's increment in target bitmap */ @@ -1806,8 +1804,9 @@ Short* min, Short* max ) { - ras.traceOfs = 0; - ras.traceIncr = 0; + ras.traceOfs = 0; + ras.traceIncr = 0; + ras.traceOfsLastLine = -1; ras.gray_min_x = 0; ras.gray_max_x = 0; @@ -1859,21 +1858,40 @@ static void Vertical_Region_Sweep_Step( RAS_ARGS Short y ) { Short* target; + Short* targetLastLine; - target = ras.rTarget + ras.traceOfs; + target = ras.rTarget + ras.traceOfs; + targetLastLine = ras.rTarget + ras.traceOfsLastLine; + /* special case: the current line was empty */ if ( ras.traceIncr == 0 ) target[ras.traceIncr++] = y; + - /* finish current line and move to the next one */ + /* finish current line */ target[ras.traceIncr++] = EOREGREC; - ras.traceOfs += ras.traceIncr; - ras.traceIncr = 0; + + /* special case: no differences between last and current line */ + + if ( ( ras.traceOfsLastLine > -1 ) && + ( ras.traceOfs - ras.traceOfsLastLine == ras.traceIncr ) && + ( MEM_Cmp( targetLastLine + 1, target + 1, ( ras.traceIncr - 1 ) * sizeof( Short ) ) == 0 ) ) + { + ras.traceIncr = 0; + return; + } + + + /* move to the next line */ + + ras.traceOfsLastLine = ras.traceOfs; + ras.traceOfs += ras.traceIncr; + ras.traceIncr = 0; } static void Vertical_Region_Sweep_Finish( RAS_ARG ) @@ -1886,7 +1904,7 @@ target = ras.rTarget + ras.traceOfs; target[ras.traceIncr++] = EOREGREC; - ras.region.size = ras.traceOfs + ras.traceIncr; + ras.target.size = ( ras.traceOfs + ras.traceIncr ) * sizeof( Short ); } #endif /* __GEOS__ */ @@ -2811,7 +2829,7 @@ Scan_DropOuts : LOCAL_FUNC TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, - TT_Region_Map* map ) + TT_Raster_Map* map ) { TT_Error error; @@ -2831,7 +2849,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, } if ( map ) - ras.region = *map; + ras.target = *map; ras.outs = glyph->contours; ras.flags = glyph->flags; @@ -2855,14 +2873,16 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras.band_top = 0; ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = ras.region.rows - 1; + ras.band_stack[0].y_max = ras.target.rows - 1; - ras.bWidth = ras.region.cols; - ras.rTarget = (Short*)ras.region.data; + ras.bWidth = ras.target.cols; + ras.rTarget = (Short*)ras.target.bitmap; if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) return error; + map->size = ras.target.size; + return TT_Err_Ok; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h index e08882d8c..4730cc4fd 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h @@ -113,7 +113,9 @@ extern "C" { /* mode 'scan'. */ LOCAL_DEF TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, - TT_Region_Map* target ); + TT_Raster_Map* target ); + + #define SIZE_EMPTY_LINE 2 #endif /* Initialize rasterizer */ diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index c588f8a71..cb9f888ea 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -186,9 +186,9 @@ void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { } void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { - word characterId = 40; + word characterId = 41; char tmpStr[40]; - TT_Region_Map regionmap; + TT_Raster_Map regionmap; Region region[250]; region[0] = 0; @@ -198,7 +198,9 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { regionmap.rows = 48; regionmap.cols = 48; - regionmap.data = ®ion[4]; + regionmap.width = 48; + regionmap.flow = TT_Flow_Up; + regionmap.bitmap = ®ion[4]; if( TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ) ) return; @@ -206,7 +208,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if( TT_Get_Glyph_Region(glyph, ®ionmap, 0, 0) ) return; - sprintf(tmpStr, "region size:\t%d\r", ((int)regionmap.size)); _log(tmpStr); + sprintf(tmpStr, "region size:\t%d\r", (regionmap.size)); _log(tmpStr); GrDrawRegion(gstate, 200, 200, region, 0, 0); } diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index eb88728d2..2f47ff713 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -29,8 +29,10 @@ ## Fehler - ~~freigeben von resiervierten Resoucen führt zum einfrieren~~ - ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ -- die Size einer Region ist fehlerhaft +- ~~die Size einer Region ist fehlerhaft~~ - (Testprogramm) TT_Init_Kerning_Extension() darf nur einmalig aufgerufen werden +- das kompakte Ablegen von Region ist fehlerhaft +- Glyphs werden auf den Kopf stehen in Regions gerendert ## Bemerkungen - die Darstellung keiner Punktgröße ist jetzt wesentlich besser aber stark vom Font abhänging; das ist bei der Font-Selektion zu beachten @@ -38,4 +40,5 @@ ## Optimierungen - diverse Offsets von long auf int ändern - diverse sizes von long auf int ändern -- Elemente der TRaster_Instace_ Struktur die nur für Pixmaps benötig werden entfernen \ No newline at end of file +- Elemente der TRaster_Instace_ Struktur die nur für Pixmaps benötig werden entfernen +- engine->raster_palette abschaffen \ No newline at end of file From a4fa20c8ac10325e80c1338ec07ee17423408e9e Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 20 May 2022 17:18:32 +0200 Subject: [PATCH 032/246] glyph are stored more compactly in regions --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 7 ++-- .../testapps/ttf2/FreeType/ttraster.c | 2 +- .../testapps/ttf2/FreeType/ttraster.h | 3 +- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 33 +++++++++++-------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index d47e82f53..b589d996b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1481,6 +1481,7 @@ TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); + TT_Matrix flipmatrix = { 65536, 0, 0, -65536}; TT_Outline outline; @@ -1496,9 +1497,11 @@ /* outline.dropout_mode = _glyph->scan_type; */ outline.dropout_mode = 2; - TT_Translate_Outline( &outline, xOffset, yOffset ); + TT_Transform_Outline( &outline, &flipmatrix ); + TT_Translate_Outline( &outline, xOffset, yOffset + map->rows * 64 ); error = TT_Get_Outline_Region( engine, &outline, map ); - TT_Translate_Outline( &outline, -xOffset, -yOffset ); + TT_Translate_Outline( &outline, -xOffset, -yOffset - map->rows * 64 ); + TT_Transform_Outline( &outline, &flipmatrix ); return error; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index d99014625..0beabd017 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -1879,9 +1879,9 @@ /* special case: no differences between last and current line */ if ( ( ras.traceOfsLastLine > -1 ) && - ( ras.traceOfs - ras.traceOfsLastLine == ras.traceIncr ) && ( MEM_Cmp( targetLastLine + 1, target + 1, ( ras.traceIncr - 1 ) * sizeof( Short ) ) == 0 ) ) { + MEM_Copy( targetLastLine, target, ras.traceIncr * sizeof( Short ) ); ras.traceIncr = 0; return; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h index 4730cc4fd..b78b6d583 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h @@ -114,8 +114,7 @@ extern "C" { LOCAL_DEF TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, TT_Raster_Map* target ); - - #define SIZE_EMPTY_LINE 2 + #endif /* Initialize rasterizer */ diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index cb9f888ea..7f20c29fd 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -120,7 +120,7 @@ void testRendering(GStateHandle gstate) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 40*64); + error = TT_Set_Instance_CharSize(instance, 72*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; @@ -189,28 +189,35 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { word characterId = 41; char tmpStr[40]; TT_Raster_Map regionmap; - Region region[250]; - - region[0] = 0; - region[1] = 0; - region[2] = 48; - region[3] = 48; + TT_Glyph_Metrics metrics; + Region* region = calloc(sizeof(Region), 1000); - regionmap.rows = 48; - regionmap.cols = 48; - regionmap.width = 48; - regionmap.flow = TT_Flow_Up; + regionmap.flow = TT_Flow_Down; regionmap.bitmap = ®ion[4]; if( TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ) ) return; - if( TT_Get_Glyph_Region(glyph, ®ionmap, 0, 0) ) + if( TT_Get_Glyph_Metrics( glyph, &metrics ) ) + return; + + regionmap.rows = ( metrics.bbox.yMax - metrics.bbox.yMin ) >> 6; + regionmap.cols = ( metrics.bbox.xMax - metrics.bbox.yMin ) >> 6; + regionmap.width = regionmap.cols; + + region[0] = 0; + region[1] = 0; + region[2] = regionmap.rows; + region[3] = regionmap.cols; + + if( TT_Get_Glyph_Region( glyph, ®ionmap, 0, 0 ) ) return; sprintf(tmpStr, "region size:\t%d\r", (regionmap.size)); _log(tmpStr); - GrDrawRegion(gstate, 200, 200, region, 0, 0); + GrDrawRegion(gstate, 60, 60, region, 0, 0); + + free(region); } @method TtfProcessClass, MSG_META_EXPOSED { From 026cd0ac637c7782be863cbbf85546e7a12663bd Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 20 May 2022 21:52:11 +0200 Subject: [PATCH 033/246] move flipmatrix into a macro --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 4 +++- Appl/Breadbox/testapps/ttf2/backlog.md | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index b589d996b..a642ed3bb 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1444,6 +1444,8 @@ #ifdef __GEOS__ +#define HORIZONTAL_FLIP_MATRIX { 1 * 1 << 16, 0, 0, -1 * 1 << 16 } + /******************************************************************* * * Function : TT_Get_Glyph_Region @@ -1481,7 +1483,7 @@ TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); - TT_Matrix flipmatrix = { 65536, 0, 0, -65536}; + TT_Matrix flipmatrix = HORIZONTAL_FLIP_MATRIX; TT_Outline outline; diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index 2f47ff713..e9e6fecd5 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -31,11 +31,12 @@ - ~~Teile eines Zeichens die unter der Basislinie liegen werden nicht angezeigt~~ - ~~die Size einer Region ist fehlerhaft~~ - (Testprogramm) TT_Init_Kerning_Extension() darf nur einmalig aufgerufen werden -- das kompakte Ablegen von Region ist fehlerhaft -- Glyphs werden auf den Kopf stehen in Regions gerendert +- ~~das kompakte Ablegen von Region ist fehlerhaft~~ +- ~~Glyphs werden auf den Kopf stehen in Regions gerendert~~ ## Bemerkungen - die Darstellung keiner Punktgröße ist jetzt wesentlich besser aber stark vom Font abhänging; das ist bei der Font-Selektion zu beachten +- ~~flipMatix in TT_Get_Glyph_Region in ttapi.c in ein Makro verschieben~~ ## Optimierungen - diverse Offsets von long auf int ändern From 3c9a3dfe7f35cbba2fb8eb0846dc29b0bf741bcb Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 20 May 2022 21:59:02 +0200 Subject: [PATCH 034/246] small correction of the last commit --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index a642ed3bb..38830ab13 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1444,7 +1444,7 @@ #ifdef __GEOS__ -#define HORIZONTAL_FLIP_MATRIX { 1 * 1 << 16, 0, 0, -1 * 1 << 16 } +#define HORIZONTAL_FLIP_MATRIX { ( 1L << 16 ), 0, 0, -1 * ( 1L << 16 ) } /******************************************************************* * From 92b4823d45a0bd8e03a13c74bab71a93108f5feb Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Mon, 23 May 2022 19:31:03 +0200 Subject: [PATCH 035/246] optimazation when rendering a glyph into a region --- Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c | 4 ++-- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 0beabd017..ce6d244b2 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -1881,8 +1881,8 @@ if ( ( ras.traceOfsLastLine > -1 ) && ( MEM_Cmp( targetLastLine + 1, target + 1, ( ras.traceIncr - 1 ) * sizeof( Short ) ) == 0 ) ) { - MEM_Copy( targetLastLine, target, ras.traceIncr * sizeof( Short ) ); - ras.traceIncr = 0; + *targetLastLine = *target; + ras.traceIncr = 0; return; } diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 7f20c29fd..3b497a54f 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -186,7 +186,7 @@ void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { } void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { - word characterId = 41; + word characterId = 50; char tmpStr[40]; TT_Raster_Map regionmap; TT_Glyph_Metrics metrics; From f29f0b295f9f5f621f004047e6bb84854ba47cc8 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 3 Jun 2022 21:08:47 +0200 Subject: [PATCH 036/246] add c prototypes for GenInRegion and GenPath functions --- .../testapps/ttf2/FreeType/freetype.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 72a5a5dce..6a4d79a70 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -33,6 +33,10 @@ #include "fterrid.h" #include "ftnameid.h" +#ifdef __GEOS__ +#include +#endif /* __GEOS__ */ + /* To make freetype.h independent from configuration files we check */ /* whether EXPORT_DEF has been defined already. */ @@ -637,6 +641,15 @@ typedef long TT_Error; + #ifdef __GEOS__ + + /* Flags for control path generation for FreeGEOS. */ + + #define GEOS_TTF_POSTSCRIPT 0x0002 + #define GEOS_TTF_SAVE_STATE 0x0001 + + #endif /* __GEOS__ */ + /*******************************************************************/ /* */ @@ -971,6 +984,7 @@ /* (where vertical and horizontal stems aren't grayed). This */ /* means that `xOffset' and `yOffset' must be multiples */ /* of 64! */ + EXPORT_DEF TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, TT_Raster_Map* map, @@ -978,6 +992,20 @@ TT_F26Dot6 yOffset ); + /* Render the glyph into the passed GEOS regionpath. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, + Handle regionPath, + GStateHandle gstate ); + + + EXPORT_DEF + TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, + GStateHandle gstate, + TT_UShort controlFlags ); + + /* ----------------------- outline support ------------------------ */ /* Allocate a new outline. Reserve space for `numPoints' and */ From 2e8e9533f25837097f040e44fbcec10120ee3d60 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sat, 4 Jun 2022 21:41:24 +0200 Subject: [PATCH 037/246] First Steps to support GenInRegion function. --- .../testapps/ttf2/FreeType/freetype.h | 8 +-- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 69 +++++++++++++++++++ Appl/Breadbox/testapps/ttf2/backlog.md | 2 +- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 6a4d79a70..74d07198f 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -996,14 +996,14 @@ EXPORT_DEF TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, - Handle regionPath, - GStateHandle gstate ); - + Handle regionPath ); + /* Render the glyphs outline into the passsed GStateHandle */ + EXPORT_DEF TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, GStateHandle gstate, - TT_UShort controlFlags ); + TT_UShort controlFlags ); /* ----------------------- outline support ------------------------ */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 38830ab13..9dd399a7e 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1508,6 +1508,75 @@ return error; } + /******************************************************************* + * + * Function : TT_Get_Glyph_In_Region + * + * Description : Renders a glyph into the given region path. + * + * Input : glyph the glyph container's handle + * regionPath handle into the outline is to be written + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, + Handle regionPath ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + + //TBD Does the outline need to be translated or flipped? + + //TBD Iterate over the outline's contours and write its components to the regionpath. + + return TT_Err_Ok; + } + + + /******************************************************************* + * + * Function : TT_Get_Glyph_Path + * + * Description : Renders glyphs outline into the given GStateHandle. + * + * Input : glyph the glyph container's handle + * gstate handle to the graphic state + * controlFlags controls how the outline should be rendered + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, + GStateHandle gstate, + TT_UShort controlFlags ) + { + + //TBD + + return TT_Err_Ok; + } + #endif /* __GEOS__ */ diff --git a/Appl/Breadbox/testapps/ttf2/backlog.md b/Appl/Breadbox/testapps/ttf2/backlog.md index e9e6fecd5..673fecab2 100644 --- a/Appl/Breadbox/testapps/ttf2/backlog.md +++ b/Appl/Breadbox/testapps/ttf2/backlog.md @@ -20,7 +20,7 @@ - ~~Extension für Kerning aktivieren~~ - ~~Bytecodeinterpreter aktivieren~~ - ~~angepasstes FreeType in Treibersourcen verschieben~~ -- Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH anlegen +- ~~Funktionen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH anlegen~~ - Implementierungen für DR_FONT_GEN_IN_REGION, DR_FONT_GEN_PATH - FreeType in Treiber integrieren - Registrierung eines Fonts anpassen (FontID, TTC???) From dc7186f565c18ed8e937412a914aa8f36a2b4562 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Wed, 8 Jun 2022 21:38:48 +0200 Subject: [PATCH 038/246] first draft for Get_Glyph_Path --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 39 +++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 9dd399a7e..bcfa2d210 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1571,8 +1571,45 @@ GStateHandle gstate, TT_UShort controlFlags ) { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + + // if SAVE_STATE set save gstate + + // set Comment with glyphs boundig box + + // translate by current x,y position + + // if POSTSCRIPT set flip outline + + // transform by font matrix + + // iterate over contours + + // iterate over parts of current contour + + // switch over current part + + // MOVE_TO + // LINE_TO + // CURVE_TO + // REL... + + // restore glyphs outline - //TBD + // if SAVE_STATE set restore gstate return TT_Err_Ok; } From e06fb3292be83c3f9151ac04bd0ad1d75bf192e4 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 10 Jun 2022 21:40:56 +0200 Subject: [PATCH 039/246] draft for GenInRegion --- .../testapps/ttf2/FreeType/freetype.h | 1 + Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 31 +++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 74d07198f..e210b88ef 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -996,6 +996,7 @@ EXPORT_DEF TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, + MemHandle bitmapBlock, Handle regionPath ); /* Render the glyphs outline into the passsed GStateHandle */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index bcfa2d210..9a1bea030 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1515,6 +1515,7 @@ * Description : Renders a glyph into the given region path. * * Input : glyph the glyph container's handle + * bitmapBlock handle * regionPath handle into the outline is to be written * * Output : Error code. @@ -1525,6 +1526,7 @@ EXPORT_FUNC TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, + MemHandle bitmapBlock, Handle regionPath ) { PEngine_Instance _engine; @@ -1542,9 +1544,21 @@ outline = _glyph->outline; - //TBD Does the outline need to be translated or flipped? + // calc region size - //TBD Iterate over the outline's contours and write its components to the regionpath. + // alloc bitmapBlock and init regionPath --> GrRegionPathInit + + // translate by current x,y position + + // iterate over contours + + // iterate over segments of current contour + + // switch over current segment + + // LINE_SEGMENT --> GrRegionAddLineAtCP + // CURVE_SEGMENT --> GrRegionAddBezierAtCP + // ... return TT_Err_Ok; } @@ -1592,20 +1606,19 @@ // translate by current x,y position - // if POSTSCRIPT set flip outline + // if POSTSCRIPT set -> transform by hight and flip outline // transform by font matrix // iterate over contours - // iterate over parts of current contour + // iterate over segments of current contour - // switch over current part + // switch over current segment - // MOVE_TO - // LINE_TO - // CURVE_TO - // REL... + // LINE_SEGMENT --> GrDrawHLine(), GrDrawVLine() or GrDrawLine() + // CURVE_SEGMENT --> GrDrawCurve() + // ... // restore glyphs outline From 2f58541227aac322fbde0d9ad8c790a2377e6d05 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sat, 11 Jun 2022 20:23:41 +0200 Subject: [PATCH 040/246] Prototypes for driver functions GenInRegion and GenPath added. --- Driver/Font/TrueType/FreeType/freetype.h | 64 ++++- Driver/Font/TrueType/FreeType/ft_conf.h | 3 +- Driver/Font/TrueType/FreeType/ttapi.c | 232 +++++++++++++++++ Driver/Font/TrueType/FreeType/ttmemory.h | 4 + Driver/Font/TrueType/FreeType/ttraster.c | 318 +++++++++++++++++++---- Driver/Font/TrueType/FreeType/ttraster.h | 9 + 6 files changed, 582 insertions(+), 48 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index b9fc1f27c..e210b88ef 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -33,6 +33,10 @@ #include "fterrid.h" #include "ftnameid.h" +#ifdef __GEOS__ +#include +#endif /* __GEOS__ */ + /* To make freetype.h independent from configuration files we check */ /* whether EXPORT_DEF has been defined already. */ @@ -327,6 +331,13 @@ /* cols = (W+3) & ~3 */ /* width = cols */ /* flow = your_choice */ + /* */ + /* - for a WxH region: */ + /* */ + /* rows = H */ + /* cols = W */ + /* width = cols */ + /* flow = your_choise */ struct TT_Raster_Map_ { @@ -335,8 +346,12 @@ int width; /* number of pixels per line */ int flow; /* bitmap orientation */ - void* bitmap; /* bit/pixmap buffer */ + void* bitmap; /* bit/pixmap/region buffer */ +#ifndef __GEOS__ long size; /* bit/pixmap size in bytes */ +#else + int size; /* bit/pixmap/region size in bytes */ +#endif /* __GEOS__ */ }; typedef struct TT_Raster_Map_ TT_Raster_Map; @@ -626,6 +641,15 @@ typedef long TT_Error; + #ifdef __GEOS__ + + /* Flags for control path generation for FreeGEOS. */ + + #define GEOS_TTF_POSTSCRIPT 0x0002 + #define GEOS_TTF_SAVE_STATE 0x0001 + + #endif /* __GEOS__ */ + /*******************************************************************/ /* */ @@ -952,6 +976,37 @@ TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ); + + /* Render the glyph into a region, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Render the glyph into the passed GEOS regionpath. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, + MemHandle bitmapBlock, + Handle regionPath ); + + /* Render the glyphs outline into the passsed GStateHandle */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, + GStateHandle gstate, + TT_UShort controlFlags ); + + /* ----------------------- outline support ------------------------ */ /* Allocate a new outline. Reserve space for `numPoints' and */ @@ -991,6 +1046,13 @@ TT_Outline* outline, TT_Raster_Map* map ); + /* Render an outline into a region. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Region( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + /* Return an outline's bounding box -- this function is slow as it */ /* performs a complete scan-line process, without drawing, to get */ diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index 637eccd18..de3c0d233 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -8,10 +8,11 @@ #ifndef FT_CONF_H #define FT_CONF_H -/* Under FreeGEOS we need this for the file operations. */ +/* Under FreeGEOS we need this for the file operations and render regions. */ #include #include #include +#include /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 968fab911..9a1bea030 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -37,6 +37,7 @@ #include "ttraster.h" #include "ttextend.h" + /* required by the tracing mode */ #undef TT_COMPONENT #define TT_COMPONENT trace_api @@ -57,6 +58,9 @@ #define RENDER_Gray_Glyph( glyph, target, palette ) \ Render_Gray_Glyph( RAS_OPS glyph, target, palette ) +#define RENDER_Region_Glyph( glyph, target ) \ + Render_Region_Glyph( RAS_OPS glyph, target ) + /******************************************************************* @@ -1438,6 +1442,194 @@ #endif /* TT_CONFIG_OPTION_GRAY_SCALING */ +#ifdef __GEOS__ + +#define HORIZONTAL_FLIP_MATRIX { ( 1L << 16 ), 0, 0, -1 * ( 1L << 16 ) } + +/******************************************************************* + * + * Function : TT_Get_Glyph_Region + * + * Description : Produces a region from a glyph outline. + * + * Input : glyph the glyph container's handle + * map target region description block + * xOffset x offset in fractional pixels (26.6 format) + * yOffset y offset in fractional pixels (26.6 format) + * + * Output : Error code. + * + * Note : Only use integer pixel offsets to preserve the fine + * hinting of the glyph and the 'correct' anti-aliasing + * (where vertical and horizontal stems aren't grayed). + * This means that xOffset and yOffset must be multiples + * of 64! + * + * You can experiment with offsets of +32 to get 'blurred' + * versions of the glyphs (a nice effect at large sizes that + * some graphic designers may appreciate :) + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + TT_Matrix flipmatrix = HORIZONTAL_FLIP_MATRIX; + + TT_Outline outline; + + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + /* XXX : For now, use only dropout mode 2 */ + /* outline.dropout_mode = _glyph->scan_type; */ + outline.dropout_mode = 2; + + TT_Transform_Outline( &outline, &flipmatrix ); + TT_Translate_Outline( &outline, xOffset, yOffset + map->rows * 64 ); + error = TT_Get_Outline_Region( engine, &outline, map ); + TT_Translate_Outline( &outline, -xOffset, -yOffset - map->rows * 64 ); + TT_Transform_Outline( &outline, &flipmatrix ); + + return error; + } + + /******************************************************************* + * + * Function : TT_Get_Glyph_In_Region + * + * Description : Renders a glyph into the given region path. + * + * Input : glyph the glyph container's handle + * bitmapBlock handle + * regionPath handle into the outline is to be written + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, + MemHandle bitmapBlock, + Handle regionPath ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + + // calc region size + + // alloc bitmapBlock and init regionPath --> GrRegionPathInit + + // translate by current x,y position + + // iterate over contours + + // iterate over segments of current contour + + // switch over current segment + + // LINE_SEGMENT --> GrRegionAddLineAtCP + // CURVE_SEGMENT --> GrRegionAddBezierAtCP + // ... + + return TT_Err_Ok; + } + + + /******************************************************************* + * + * Function : TT_Get_Glyph_Path + * + * Description : Renders glyphs outline into the given GStateHandle. + * + * Input : glyph the glyph container's handle + * gstate handle to the graphic state + * controlFlags controls how the outline should be rendered + * + * Output : Error code. + * + * MT-Safe : NO! Glyph containers can't be shared. + * + ******************************************************************/ + + EXPORT_FUNC + TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, + GStateHandle gstate, + TT_UShort controlFlags ) + { + PEngine_Instance _engine; + TT_Engine engine; + TT_Error error; + PGlyph _glyph = HANDLE_Glyph( glyph ); + + TT_Outline outline; + + if ( !_glyph ) + return TT_Err_Invalid_Glyph_Handle; + + _engine = _glyph->face->engine; + HANDLE_Set(engine,_engine); + + outline = _glyph->outline; + + // if SAVE_STATE set save gstate + + // set Comment with glyphs boundig box + + // translate by current x,y position + + // if POSTSCRIPT set -> transform by hight and flip outline + + // transform by font matrix + + // iterate over contours + + // iterate over segments of current contour + + // switch over current segment + + // LINE_SEGMENT --> GrDrawHLine(), GrDrawVLine() or GrDrawLine() + // CURVE_SEGMENT --> GrDrawCurve() + // ... + + // restore glyphs outline + + // if SAVE_STATE set restore gstate + + return TT_Err_Ok; + } + +#endif /* __GEOS__ */ + + static const TT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0, 0, 0, 0 }; @@ -1605,6 +1797,46 @@ #endif /* TT_CONFIG_OPTION_GRAY_SCALING */ +#ifdef __GEOS__ + +/******************************************************************* + * + * Function : TT_Get_Outline_Region + * + * Description : Render a TrueType outline into a region. + * Note that the region must be created by the caller. + * + * Input : outline the outline to render + * map the target region + * + * Output : Error code + * + * MT-Safe : YES! + * + ******************************************************************/ +EXPORT_FUNC +TT_Error TT_Get_Outline_Region( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ) +{ + PEngine_Instance _engine = HANDLE_Engine( engine ); + TT_Error error; + + + if ( !_engine ) + return TT_Err_Invalid_Engine; + + if ( !outline || !map ) + return TT_Err_Invalid_Argument; + + MUTEX_Lock( _engine->raster_lock ); + error = RENDER_Region_Glyph( outline, map ); + MUTEX_Release( _engine->raster_lock ); + return error; +} + +#endif /* __GEOS__ */ + /******************************************************************* * diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h index 54394ecc2..42fe0d997 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.h +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -40,6 +40,10 @@ #define MEM_Set( dest, byte, count ) memset( dest, byte, count ) +#ifdef __GEOS__ +#define MEM_Cmp( left, right, count ) memcmp( left, right, count ) +#endif /* __GEOS__ */ + #ifdef HAVE_MEMCPY #define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) #else diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index ad744b6da..ce6d244b2 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -191,7 +191,9 @@ PProfile left, PProfile right ); - typedef void Function_Sweep_Step( RAS_ARG ); + typedef void Function_Sweep_Step( RAS_ARGS Short y ); + + typedef void Function_Sweep_Finish( RAS_ARG ); /* NOTE: These operations are only valid on 2's complement processors */ @@ -250,41 +252,46 @@ TPoint* arc; /* current Bezier arc pointer */ - UShort bWidth; /* target bitmap width */ + UShort bWidth; /* target buffer width */ PByte bTarget; /* target bitmap buffer */ PByte gTarget; /* target pixmap buffer */ +#ifdef __GEOS__ + PShort rTarget; /* target region buffer */ +#endif /* __GEOS__ */ Long lastX, lastY, minY, maxY; - UShort num_Profs; /* current number of profiles */ + UShort num_Profs; /* current number of profiles */ - Bool fresh; /* signals a fresh new profile which */ - /* 'start' field must be completed */ - Bool joint; /* signals that the last arc ended */ - /* exactly on a scanline. Allows */ - /* removal of doublets */ - PProfile cProfile; /* current profile */ - PProfile fProfile; /* head of linked list of profiles */ - PProfile gProfile; /* contour's first profile in case */ - /* of impact */ - TStates state; /* rendering state */ + Bool fresh; /* signals a fresh new profile which */ + /* 'start' field must be completed */ + Bool joint; /* signals that the last arc ended */ + /* exactly on a scanline. Allows */ + /* removal of doublets */ + PProfile cProfile; /* current profile */ + PProfile fProfile; /* head of linked list of profiles */ + PProfile gProfile; /* contour's first profile in case */ + /* of impact */ + TStates state; /* rendering state */ - TT_Raster_Map target; /* description of target bit/pixmap */ + TT_Raster_Map target; /* description of target bit/pixmap */ - Long traceOfs; /* current offset in target bitmap */ - Long traceG; /* current offset in target pixmap */ + Long traceOfs; /* current offset in target bitmap or region */ + Long traceOfsLastLine; /* offset in traget region before line step */ + Long traceG; /* current offset in target pixmap */ - Short traceIncr; /* sweep's increment in target bitmap */ + Short traceIncr; /* sweep's increment in target bitmap */ - Short gray_min_x; /* current min x during gray rendering */ - Short gray_max_x; /* current max x during gray rendering */ + Short gray_min_x; /* current min x during gray rendering */ + Short gray_max_x; /* current max x during gray rendering */ /* dispatch variables */ - Function_Sweep_Init* Proc_Sweep_Init; - Function_Sweep_Span* Proc_Sweep_Span; - Function_Sweep_Span* Proc_Sweep_Drop; - Function_Sweep_Step* Proc_Sweep_Step; + Function_Sweep_Init* Proc_Sweep_Init; + Function_Sweep_Span* Proc_Sweep_Span; + Function_Sweep_Span* Proc_Sweep_Drop; + Function_Sweep_Step* Proc_Sweep_Step; + Function_Sweep_Finish* Proc_Sweep_Finish; TT_Vector* coords; @@ -1770,12 +1777,139 @@ } - static void Vertical_Sweep_Step( RAS_ARG ) + static void Vertical_Sweep_Step( RAS_ARGS Short y ) { ras.traceOfs += ras.traceIncr; } + static void Vertical_Sweep_Finish( RAS_ARG ) + { + /* nothing to do */ + } + + +#ifdef __GEOS__ + +/***********************************************************************/ +/* */ +/* Vertical Sweep Procedure Set for regions : */ +/* */ +/* These three routines are used during the vertical black/white */ +/* sweep phase for regions by the generic Draw_Sweep() function. */ +/* */ +/***********************************************************************/ + + static void Vertical_Region_Sweep_Init( RAS_ARGS + Short* min, + Short* max ) + { + ras.traceOfs = 0; + ras.traceIncr = 0; + ras.traceOfsLastLine = -1; + + ras.gray_min_x = 0; + ras.gray_max_x = 0; + } + + static void Vertical_Region_Sweep_Span( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + Long e1, e2; + Short* target; + + + /* Drop-out control */ + + e1 = TRUNC( CEILING( x1 ) ); + + if ( x2-x1-ras.precision <= ras.precision_jitter ) + e2 = e1; + else + e2 = TRUNC( FLOOR( x2 ) ); + + target = ras.rTarget + ras.traceOfs; + + if ( ras.traceIncr == 0 ) + target[ras.traceIncr++] = y; + + if ( e2 >= 0 && e1 < ras.bWidth ) + { + if ( e1 < 0 ) e1 = 0; + if ( e2 >= ras.bWidth ) e2 = ras.bWidth-1; + + target[ras.traceIncr++] = ( Short ) e1; + target[ras.traceIncr++] = ( Short ) e2; + } + } + + static void Vertical_Region_Sweep_Drop( RAS_ARGS Short y, + TT_F26Dot6 x1, + TT_F26Dot6 x2, + PProfile left, + PProfile right ) + { + /* nothing to do */ + } + + static void Vertical_Region_Sweep_Step( RAS_ARGS Short y ) + { + Short* target; + Short* targetLastLine; + + + target = ras.rTarget + ras.traceOfs; + targetLastLine = ras.rTarget + ras.traceOfsLastLine; + + + /* special case: the current line was empty */ + + if ( ras.traceIncr == 0 ) + target[ras.traceIncr++] = y; + + + /* finish current line */ + + target[ras.traceIncr++] = EOREGREC; + + + /* special case: no differences between last and current line */ + + if ( ( ras.traceOfsLastLine > -1 ) && + ( MEM_Cmp( targetLastLine + 1, target + 1, ( ras.traceIncr - 1 ) * sizeof( Short ) ) == 0 ) ) + { + *targetLastLine = *target; + ras.traceIncr = 0; + return; + } + + + /* move to the next line */ + + ras.traceOfsLastLine = ras.traceOfs; + ras.traceOfs += ras.traceIncr; + ras.traceIncr = 0; + } + + static void Vertical_Region_Sweep_Finish( RAS_ARG ) + { + Short* target; + + + /* complete a region */ + + target = ras.rTarget + ras.traceOfs; + + target[ras.traceIncr++] = EOREGREC; + ras.target.size = ( ras.traceOfs + ras.traceIncr ) * sizeof( Short ); + } + +#endif /* __GEOS__ */ + + /***********************************************************************/ /* */ /* Horizontal Sweep Procedure Set : */ @@ -1930,11 +2064,16 @@ } - static void Horizontal_Sweep_Step( RAS_ARG ) + static void Horizontal_Sweep_Step( RAS_ARGS Short y ) { /* Nothing, really */ } + static void Horizontal_Sweep_Finish( RAS_ARG ) + { + /* nothing to do */ + } + #ifdef TT_CONFIG_OPTION_GRAY_SCALING @@ -1979,7 +2118,7 @@ } - static void Vertical_Gray_Sweep_Step( RAS_ARG ) + static void Vertical_Gray_Sweep_Step( RAS_ARG Short y ) { Int c1, c2; PByte pix, bit, bit2; @@ -2312,9 +2451,9 @@ Next_Line: #ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); #else - ras.Proc_Sweep_Step( RAS_VAR ); + ras.Proc_Sweep_Step( RAS_VARS y ); #endif /* ifdef __GEOS__ */ y++; @@ -2357,13 +2496,18 @@ while ( y <= max_Y ) { #ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VAR ); + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); #else - ras.Proc_Sweep_Step( RAS_VAR ); + ras.Proc_Sweep_Step( RAS_VARS y ); #endif /* __GEOS__ */ y++; } +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Finish, RAS_VAR ); +#else + ras.Proc_Sweep_Finish( RAS_VAR ); +#endif return SUCCESS; Scan_DropOuts : @@ -2521,10 +2665,11 @@ Scan_DropOuts : /* Vertical Sweep */ - ras.Proc_Sweep_Init = Vertical_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Sweep_Step; + ras.Proc_Sweep_Init = Vertical_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Sweep_Step; + ras.Proc_Sweep_Finish = Vertical_Sweep_Finish; ras.band_top = 0; ras.band_stack[0].y_min = 0; @@ -2540,10 +2685,11 @@ Scan_DropOuts : if ( ras.second_pass && ras.dropOutControl != 0 ) { - ras.Proc_Sweep_Init = Horizontal_Sweep_Init; - ras.Proc_Sweep_Span = Horizontal_Sweep_Span; - ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; - ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Finish = Horizontal_Sweep_Finish; ras.band_top = 0; ras.band_stack[0].y_min = 0; @@ -2630,10 +2776,11 @@ Scan_DropOuts : ras.bTarget = (Byte*)ras.gray_lines; ras.gTarget = (Byte*)ras.target.bitmap; - ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; + ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; + ras.Proc_Sweep_Finish = Vertical_Sweep_Finish; error = Render_Single_Pass( RAS_VARS 0 ); if (error) @@ -2643,10 +2790,12 @@ Scan_DropOuts : if ( ras.second_pass && ras.dropOutControl != 0 ) { - ras.Proc_Sweep_Init = Horizontal_Sweep_Init; - ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; - ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; - ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Init = Horizontal_Sweep_Init; + ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; + ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; + ras.Proc_Sweep_Step = Horizontal_Sweep_Step; + ras.Proc_Sweep_Finish = Horizontal_Sweep_Finish; + ras.band_top = 0; ras.band_stack[0].y_min = 0; @@ -2663,6 +2812,83 @@ Scan_DropOuts : #endif /* TT_CONFIG_OPTION_GRAY_SCALING */ +#ifdef __GEOS__ + +/****************************************************************************/ +/* */ +/* Function: Render_Region_Glyph */ +/* */ +/* Description: Renders a glyph in a region. Sub-banding if needed. */ +/* */ +/* Input: AGlyph Glyph record */ +/* */ +/* Returns: SUCCESS on success. */ +/* FAILURE if any error was encountered during rendering. */ +/* */ +/****************************************************************************/ + +LOCAL_FUNC +TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* map ) +{ + TT_Error error; + + if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + return TT_Err_Ok; + + if ( !ras.buff ) + { + ras.error = Raster_Err_Not_Ini; + return ras.error; + } + + if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) + { + ras.error = TT_Err_Too_Many_Points; + return ras.error; + } + + if ( map ) + ras.target = *map; + + ras.outs = glyph->contours; + ras.flags = glyph->flags; + ras.nPoints = glyph->n_points; + ras.nContours = glyph->n_contours; + ras.coords = glyph->points; + + Set_High_Precision( RAS_VARS glyph->high_precision ); + ras.scale_shift = ras.precision_shift; + ras.dropOutControl = glyph->dropout_mode; + ras.second_pass = glyph->second_pass; + + /* Vertical Sweep */ + + ras.Proc_Sweep_Init = Vertical_Region_Sweep_Init; + ras.Proc_Sweep_Span = Vertical_Region_Sweep_Span; + ras.Proc_Sweep_Drop = Vertical_Region_Sweep_Drop; + ras.Proc_Sweep_Step = Vertical_Region_Sweep_Step; + ras.Proc_Sweep_Finish = Vertical_Region_Sweep_Finish; + + + ras.band_top = 0; + ras.band_stack[0].y_min = 0; + ras.band_stack[0].y_max = ras.target.rows - 1; + + ras.bWidth = ras.target.cols; + ras.rTarget = (Short*)ras.target.bitmap; + + if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 ) + return error; + + map->size = ras.target.size; + + return TT_Err_Ok; +} + +#endif /* __GEOS__ */ + + /************************************************/ /* */ /* InitRasterizer */ diff --git a/Driver/Font/TrueType/FreeType/ttraster.h b/Driver/Font/TrueType/FreeType/ttraster.h index 6af372090..b78b6d583 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.h +++ b/Driver/Font/TrueType/FreeType/ttraster.h @@ -108,6 +108,15 @@ extern "C" { Byte* palette ); #endif +#ifdef __GEOS__ + /* Render one glyph in the target region, using drop-out control */ + /* mode 'scan'. */ + LOCAL_DEF + TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target ); + +#endif + /* Initialize rasterizer */ LOCAL_DEF TT_Error TTRaster_Init( PEngine_Instance engine ); From 98cb0b3aaa832ab0009b0c5ae0b5655b53f0373a Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sat, 11 Jun 2022 22:26:11 +0200 Subject: [PATCH 041/246] Duplicate files removed. --- Driver/Font/TrueType/truetypeChars.asm | 62 -- Driver/Font/TrueType/truetypeConstant.def | 104 --- Driver/Font/TrueType/truetypeEC.asm | 99 --- Driver/Font/TrueType/truetypeEscape.asm | 60 -- Driver/Font/TrueType/truetypeInit.asm | 959 ---------------------- Driver/Font/TrueType/truetypeMacros.def | 70 -- Driver/Font/TrueType/truetypeMetrics.asm | 63 -- Driver/Font/TrueType/truetypePath.asm | 107 --- Driver/Font/TrueType/truetypeVariable.def | 100 --- Driver/Font/TrueType/truetypeWidths.asm | 69 -- Installed/Driver/Font/TrueType/Makefile | 34 +- 11 files changed, 17 insertions(+), 1710 deletions(-) delete mode 100644 Driver/Font/TrueType/truetypeChars.asm delete mode 100644 Driver/Font/TrueType/truetypeConstant.def delete mode 100644 Driver/Font/TrueType/truetypeEC.asm delete mode 100644 Driver/Font/TrueType/truetypeEscape.asm delete mode 100644 Driver/Font/TrueType/truetypeInit.asm delete mode 100644 Driver/Font/TrueType/truetypeMacros.def delete mode 100644 Driver/Font/TrueType/truetypeMetrics.asm delete mode 100644 Driver/Font/TrueType/truetypePath.asm delete mode 100644 Driver/Font/TrueType/truetypeVariable.def delete mode 100644 Driver/Font/TrueType/truetypeWidths.asm diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/truetypeChars.asm deleted file mode 100644 index 4f5ecbdda..000000000 --- a/Driver/Font/TrueType/truetypeChars.asm +++ /dev/null @@ -1,62 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: RasterMod -FILE: truetypeChars.asm - -AUTHOR: Falk Rehwagen - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/1/21 Initial revision - -DESCRIPTION: - This file contains routines for generating individual characters. - - $Id: truetypeChars.asm,v 1.1 97/04/18 11:45:31 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenChar -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate one character for a font. -CALLED BY: VidBuildChar (via TrueTypeStrategy) - -PASS: dx - character to build (Chars) - es - seg addr of font (locked) - bp - seg addr of gstate (locked) - GS_fontHandle - handle of font - GS_fontAttr - font attributes - ds - seg addr of font info block - -RETURN: es - seg addr of font (locked) (may have changed) - carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/ 1/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenChar proc far - uses ax, bx, cx, dx, ds, si, di, bp - .enter - - - .leave - stc ;indicate no error - ret -TrueTypeGenChar endp - - diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/truetypeConstant.def deleted file mode 100644 index 942764157..000000000 --- a/Driver/Font/TrueType/truetypeConstant.def +++ /dev/null @@ -1,104 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: Font Driver -FILE: truetypeConstant.def - -AUTHOR: Falk Rehwagen - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 26/1/21 Initial revision - -DESCRIPTION: - Definitions, constants, etc needed for the PC/GEOS TrueType font driver - - $Id: truetypeConstant.def,v 1.1 21/01/26 11:45:25 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -;---------------------------------------------------------------------------- -; Font Style Factors -;---------------------------------------------------------------------------- - -SCRIPT_FACTOR_INT = 0 -SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 - -SUBSCRIPT_OFFSET_INT = 0 -SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below - -SUPERSCRIPT_OFFSET_INT = 0 -SUPERSCRIPT_OFFSET_FRAC = 0x6000 ;offset above - -BOLD_FACTOR_INT = 0x0001 -BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 - -ITALIC_FACTOR_INT = 0 -ITALIC_FACTOR_FRAC = 0x366A ;italic = tan(12) -NEG_ITALIC_FACTOR_INT = 0xffff -NEG_ITALIC_FACTOR_FRAC = 0xC996 ;italic = -tan(12) - -; -; Styles that affect the width of the character: -; -WIDTH_STYLES = mask TS_SUPERSCRIPT or \ - mask TS_SUBSCRIPT or \ - mask TS_BOLD -; -; Styles that affect the transformation matrix used: -; -TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ - mask TS_SUBSCRIPT or \ - mask TS_ITALIC or \ - mask TS_BOLD - -;---------------------------------------------------------------------------- -; Miscellaneous constants -;---------------------------------------------------------------------------- - -DEFAULT_CHAR = '.' - -; -; These sizes are in pixels, not points, since that's what -; really matters for these cutoff points. -; -; Continuity checking is not done above: -; -MAX_CONTINUITY_SIZE = 30 -; -; Characters are stored as regions instead of bitmaps above: -; -MAX_BITMAP_SIZE = 125 -SCRIPT_SAFETY_SIZE = 10 - -TRUETYPE_BLOCK_SIZE equ 1024 ;initial block size - -;---------------------------------------------------------------------------- -; Region constants -;---------------------------------------------------------------------------- - -UNUSED_PER_LINE = 4 ;# of unused points / line - -;---------------------------------------------------------------------------- -; Font Errors -;---------------------------------------------------------------------------- - -if ERROR_CHECK - -FONT_BAD_CHAR_FLAG enum FatalErrors - -RECURSIVE_CALL_TO_FONT_DRIVER enum FatalErrors -; The TrueType driver is non-reentrant, so only one thread can be in the -; driver at a time. This may indicate a bug in the Font Manager. - -FONT_BAD_ROUTINE enum FatalErrors -; A bad function passed to the TrueType driver. The function passed in -; di must be in the FontFunction enumerated type. - -TRUETYPE_INTERNAL_ERROR enum FatalErrors - -endif - diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/truetypeEC.asm deleted file mode 100644 index a87edeb5b..000000000 --- a/Driver/Font/TrueType/truetypeEC.asm +++ /dev/null @@ -1,99 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) blueway.Softworks 2021 -- All Rights Reserved - -PROJECT: PC/GEOS -MODULE: truetypeEC.asm -FILE: truetypeEC.asm - -AUTHOR: Falk Rehwagen, Jan 1, 2021 - -ROUTINES: - Name Description - ---- ----------- - ECNukeVariableBlock nuke variables so we don't inadvertently - re-use them - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial revision - -DESCRIPTION: - Error checking code for TrueType driver - - $Id: truetypeEC.asm,v 1.1 21/01/24 11:45:31 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -if ERROR_CHECK - -CharMod segment resource - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ECNukeVariableBlock -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Nuke the TrueType variable block -CALLED BY: NimbusStrategy() - -PASS: none -RETURN: none -DESTROYED: none (flags preserved) - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/29/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -ECNukeVariableBlock proc far - uses ax, bx, cx, di, es - .enter - - pushf - - ; - ; Lock the variable block - ; - mov ax, segment udata - mov es, ax ;es <- seg addr of idata - mov bx, es:variableHandle ;bx <- handle of vars - tst bx ;block freed? - jz done ;branch if freed - call MemLock - jc done ;branch if discarded - mov es, ax ;es <- seg addr of vars - ; - ; Zero the block - ; - clr al ;al <- byte to store - mov cx, (size TrueTypeVars) ;cx <- # of bytes - clr di ;es:di <- ptr to vars - rep stosb - ; - ; Nuke things we know are segments specially - ; - mov es:fontSegment, 0xa000 - mov es:gstateSegment, 0xa000 - mov es:infoSegment, 0xa000 - ; - ; All done... - ; - call MemUnlock -done: - - popf - - .leave - ret -ECNukeVariableBlock endp - - -CharMod ends - -endif - diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/truetypeEscape.asm deleted file mode 100644 index 3f3f33d6f..000000000 --- a/Driver/Font/TrueType/truetypeEscape.asm +++ /dev/null @@ -1,60 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) blueway.Softworks 2021 -- All Rights Reserved - -PROJECT: PC/GEOS -MODULE: truetypeEscape.asm -FILE: truetypeEscape.asm - -AUTHOR: Falk Rehwagen, Jan 24, 2021 - -ROUTINES: - Name Description - ---- ----------- - TrueTypeFontEscape handle any escape functions - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial revision - -DESCRIPTION: - Code for handling driver escape functions - - $Id: truetypeEscape.asm,v 1.1 21/01/24 11:45:26 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeFontEscape -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Hand -CALLED BY: TrueTypeStrategy() - -PASS: di - escape function -RETURN: di - 0 if escape function not supported -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeFontEscape proc far - call FontCallEscape ;call general handling routine - ret -TrueTypeFontEscape endp - -;---------------------------------------------------------------------------- -; Escape Function Table -;---------------------------------------------------------------------------- - -DefEscapeTable 1 - -DefEscape FontQueryEscape, DRV_ESC_QUERY_ESC diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm deleted file mode 100644 index e61f76018..000000000 --- a/Driver/Font/TrueType/truetypeInit.asm +++ /dev/null @@ -1,959 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) blueway.Softworks 2021 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: Init -FILE: truetypeInit.asm - -AUTHOR: Falk Rehwagen, Jan 24, 2021 - -ROUTINES: - Name Description - ---- ----------- - TrueTypeInit initialize the TrueType font driver - TrueTypeExit clean up after TrueType font driver - TrueTypeInitFonts initialize any non-PC/GEOS fonts - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 01/24/21 Initial revision - -DESCRIPTION: - Initialization & exit routines for TrueType font driver - - $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeInit -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Initialize the TrueType font driver. -CALLED BY: DR_INIT - TrueTypeStrategy - -PASS: none -RETURN: bitmapHandle - handle of block to use for bitmaps - bitmapSize - size of above block (0 at start) - variableHandle - handle of block containing variables - carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 01/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - public TrueTypeInit -TrueTypeInit proc far - uses ax, bx, cx, si, di, ds, es - .enter - - mov ax, segment udata - mov ds, ax ;ds <- seg addr of vars - ; - ; First, we need a block of memory to use as a bitmap - ; for generating characters. We don't need to actually - ; allocate memory for it yet. - ; - mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block - mov bx, handle 0 ;bx <- make TrueType owner - mov cx, mask HF_DISCARDABLE \ - or mask HF_SWAPABLE \ - or mask HF_SHARABLE \ - or mask HF_DISCARDED \ - or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags - call MemAllocSetOwner - mov ds:bitmapHandle, bx ;save handle of block - mov ds:bitmapSize, 0 ;no bytes yet - ; - ; We also need a block to use for variables. We don't - ; need it yet, either. - ; - mov ax, size TrueTypeVars ;ax <- size of block - mov bx, handle 0 ;bx <- make TrueType owner - mov cx, mask HF_DISCARDABLE \ - or mask HF_SWAPABLE \ - or mask HF_SHARABLE \ - or mask HF_DISCARDED \ - or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags - call MemAllocSetOwner - mov ds:variableHandle, bx ;save handle of block - clc ;indicate no error - - .leave - ret -TrueTypeInit endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeExit -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Free up blocks used and exit the TrueType driver. -CALLED BY: DR_EXIT - TrueTypeStrategy - -PASS: bitmapHandle - handle of bitmap block - variableHandle - handle of variable block -RETURN: carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeExit proc far - uses ax, bx, ds - .enter - - mov ax, segment udata - mov ds, ax ;ds <- seg addr of vars - mov bx, ds:bitmapHandle -EC < clr ds:bitmapHandle ;> - call MemFree ;done with bitmap block - mov bx, ds:variableHandle -EC < clr ds:variableHandle ;> - call MemFree ;done with variable block - clc ;indicate no error - - .leave - ret -TrueTypeExit endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeInitFonts -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Initialize any non-GEOS fonts for the font driver. -CALLED BY: DR_FONT_INIT_FONTS - TrueTypeStrategy - -PASS: ds - seg addr of font info block -RETURN: carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -initFontReturnAttr FileExtAttrDesc \ - , - - -TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp - - .enter - - ; - ; Enumerate files in SP_FONT - ; - call FilePushDir - mov ax, SP_FONT - call FileSetStandardPath - push ds - segmov ds, dgroup, ax - mov dx, offset truetypeDir - clr bx ; relative to CWD - call FileSetCurrentPath - pop ds - - ; - ; Lookup all .ttf files - sub sp, size FileEnumParams - mov bp, sp - ; GEOS datafiles - mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS - ; return longname - mov ss:[bp].FEP_returnAttrs.segment, cs - mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr - mov ss:[bp].FEP_returnSize, size FileLongName - mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED - ; callback sees all files - mov ss:[bp].FEP_matchAttrs.segment, 0 - - mov ss:[bp].FEP_skipCount, 0 - call FileEnum ; cx = # found, bx = handle - jc done ; error - jcxz done ; no files found - mov dx, ds ; ax = segment of font block - call MemLock ; ds:0 = first entry - mov ds, ax - mov si, 0 -fontLoop: - call ProcessFont - add si, size FileLongName - loop fontLoop - call MemFree ; free file block -done: - call FilePopDir - clc - .leave - ret - -TrueTypeInitFonts endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ProcessFont -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: initialize each font found - -CALLED BY: TrueTypeInitFonts - -PASS: ds:si - font file name (TTF) - dx - font block segment - -RETURN: dx - updated font block segment (may move) - -DESTROYED: none - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 2/17/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -ProcessFont proc far - - uses ax, bx, cx, di, si, es, ds - -fontNameSeg local sptr push ds -fontNameOff local word push si -fontBlockSeg local sptr push dx -subTableHeader local TrueTypeSubTable -tableDirectory local TrueTypeTableDirectory -fontId local FontID -fontInfoChunk local word -tableCount local word -fontFile local hptr -fontName local FONT_NAME_LEN dup (char) -fontStyle local TextStyle -fontWeight local FontWeight - - .enter - ; - ; generate font id from file names first character for now - ; - mov fontWeight, FW_NORMAL - - clr ah - mov al, ds:[si] - add ax, FM_TRUETYPE - mov fontId, ax - - ; - ; open truetype file - ; - mov dx, si ; ds:dx = name - mov al, FILE_ACCESS_R or FILE_DENY_W - call FileOpen - jc done - - mov bx, ax ; file handle to bx - mov fontFile, bx - - segmov ds, ss - lea dx, subTableHeader - - mov al, 0 - - mov cx, size subTableHeader ; size to read - - call FileRead - jc doneClose - - ; - ; scan all TTF file tables - ; keep structures and meta data needed to serve the font - ; - mov ah, subTableHeader.TTST_numTables.low - mov al, subTableHeader.TTST_numTables.high - mov tableCount, ax -nextEntry: - mov bx, fontFile - segmov ds, ss - lea dx, tableDirectory - mov al, 0 - - mov cx, size tableDirectory ; size to read - - call FileRead - jc doneClose - - ; remember file position - mov cx, 0 - mov dx, 0 - mov bx, fontFile ; pass file handle in BX - mov al, FILE_POS_RELATIVE ; jump from start - call FilePos ; get current pos to dx:ax - jc doneClose - mov cx, dx - mov dx, ax - - mov ax, 'na' - cmp ax, tableDirectory.TTTD_tag.low - jne tryOS_2 - mov ax, 'me' - cmp ax, tableDirectory.TTTD_tag.high - jne tryOS_2 - - lea si, tableDirectory - call LoadTable - - cmp bx, 0 ; failed to load? - je doneClose - - ; restore file position, cxdx hold position - push bx - mov bx, fontFile ; pass file handle in BX - mov al, FILE_POS_START ; jump from start - call FilePos - pop bx - jnc parseName - - ; free the block we don't keep it, bx handle of block - call MemFree - jmp doneClose - -parseName: - ; get relevant data from name table - - ; first load sub family (and reuse the buffer fontName) and map - ; the value to TextStyle bits to describe the resulting - ; font entry - lea si, fontName ; ss:si point to buffer - mov cx, FONT_NAME_LEN ; buffer size - mov ax, 2 ; sub family name of the font - call GetNameFromTable - jc doneClose ; jump if no name found - - lea si, fontName ; ss:si point to buffer - call MapFontStyle - jc doneClose ; fail if style mapping fails - - mov fontStyle, al ; save fontStyle - ; (type TextStyle) - ; ds is pointing to the name table here - lea si, fontName ; ss:si point to buffer - mov cx, FONT_NAME_LEN ; buffer size - mov ax, 1 ; family name of the font - call GetNameFromTable - jc doneClose ; jump if no name found - - ; free the block we don't keep it, bx handle of block - call MemFree -tryOS_2: - mov ax, 'OS' - cmp ax, tableDirectory.TTTD_tag.low - jne cont - mov ax, '/2' - cmp ax, tableDirectory.TTTD_tag.high - jne cont -loadOS_2: - lea si, tableDirectory - call LoadTable - - cmp bx, 0 ; failed to load? - je doneClose - - ; restore file position, cxdx hold position - push bx - mov bx, fontFile ; pass file handle in BX - mov al, FILE_POS_START ; jump from start - call FilePos - pop bx - jnc getWeight - - ; free the block we don't keep it, bx handle of block -freeAndClose: - call MemFree - jmp doneClose - -getWeight: - mov ah, ds:4 - mov al, ds:5 - mov dx, 0 - mov si, 100 - div si - cmp dx, 0 - jne freeAndClose - cmp ax, 10 - jnc freeAndClose - - mov si, ax - mov al, cs:weightAdjustTable[si] - mov fontWeight, al - -cont: - dec tableCount - jnz nextEntry - - ; we have one font and collected required meta data - ; let compute/determ the fontid to be used for the font - mov ax, 0 - lea si, fontName ; ss:si point to buffer - mov cx, 0 -calcFontId: - - xor al, ss:0[si] - - xor ah, ss:1[si] - - inc cx - cmp cx, FONT_NAME_LEN - je doneFontId - inc si - cmp ss:0[si], 0 - jnz calcFontId - - and ah, 00000001b - or ax, FM_TRUETYPE - or ah, 00001110b - mov fontId, ax -doneFontId: - - ; lookup if there is a FontsAvailEntry for the font already - mov cx, fontId - mov ds, fontBlockSeg - mov di, ds:[FONTS_AVAIL_HANDLE] ;di <- ptr to chunk - ChunkSizePtr ds, di, ax ;ax <- chunk size - add ax, di ;ax -> end of chunk -IFA_loop: - cmp di, ax ;are we thru the list? - jae noMatch ;yes, exit carry clear - cmp ds:[di].FAE_fontID, cx ;see if ID matches - je match ;we have a match, branch - add di, size FontsAvailEntry ;else move to next entry - jmp IFA_loop ;and loop - -match: - ; font already registered, check if there is already equal outline - ; outline is equal if style and weight is equal - mov di, ds:[di].FAE_infoHandle ; ds:si = FontInfo chunk handle - mov si, ds:[di] ; ds:si = FontInfo ptr - - mov cx, ds:[si].FI_outlineEnd - push si - mov si, ds:[si].FI_outlineTab - -checkOutline: - mov al, ds:[si].ODE_style - cmp al, fontStyle - jne nextOutline - - mov al, ds:[si].ODE_weight - cmp al, fontStyle - jne nextOutline - - ; matching outline found - pop ax - jmp doneClose ; skip this font - -nextOutline: - add si, size OutlineDataEntry - cmp si, cx - jne checkOutline - -appendOutline: - ; not found, append new outline - pop si - - mov bx, cx ; append at end - - push cx - add cx, size OutlineDataEntry - mov ds:[si].FI_outlineEnd, cx - - mov ax, di ; *ds:ax = chunk - mov cx, size OutlineDataEntry ; cx = sizeof outline entry - call LMemInsertAt ; ds updated - mov fontBlockSeg, ds ; store it - - pop si - jmp initEntry - -noMatch: - ; - ; create a new FontsAvailEntry - ; - mov ds, fontBlockSeg - mov ax, FONTS_AVAIL_HANDLE ; *ds:ax = chunk - clr bx ; insert at front - mov cx, size FontsAvailEntry ; cx = sizeof table entry - call LMemInsertAt ; ds updated - mov fontBlockSeg, ds ; store it - ; - ; fill in FontID - ; - mov si, ax - push si - mov si, ds:[si] ; ds:si = new FAE - mov ax, fontId - mov ds:[si].FAE_fontID, ax - ; - ; clear the name field because there is a font file for each font - ; rather than for each typeface (which this field is for) - ; - mov ds:[si].FAE_fileName, 0 - - ; - ; allocate a chunk for the FontInfo block - ; - mov cx, 1 ; font count - mov ax, size OutlineDataEntry - mul cx ; dx:ax = size -EC < tst dx > -EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > - mov cx, ax - add cx, size FontInfo - mov dx, cx ; save size for later - clr ax - call LMemAlloc ; ds updated, ax = chunk - mov fontBlockSeg, ds ; store it - mov fontInfoChunk, ax - - ; - ; finish filling the FontsAvailEntry - ; dx = end of OutlineDataEntrys - ; - pop si ; *ds:si = FontsAvailEntry - mov si, ds:[si] ; ds:si = FontsAvailEntry - mov ds:[si].FAE_infoHandle, ax ; save FontInfo chunk handle - - ; - ; now fill in the FontInfo struct - ; dx = end of OutlineDataEntrys - ; - mov di, ax ; *ds:di = FontInfo - mov si, ds:[di] ; ds:si = FontInfo - mov ds:[si].FI_fileHandle, 0 ; not used - mov ax, fontId - mov ds:[si].FI_fontID, ax - mov ds:[si].FI_maker, FM_TRUETYPE - mov al, FF_NON_PORTABLE - mov ds:[si].FI_family, al ; this is called family but it - ; actually is FontAttrs - mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? (for now) - mov ds:[si].FI_pointSizeEnd, 0 - mov ds:[si].FI_outlineTab, size FontInfo - mov ds:[si].FI_outlineEnd, dx - ; - ; copy in the font face name - ; ds:si = FontInfo - ; es = FFLH - ; - push es, ds, si ; save FFLH, FontInfo - segxchg es, ds ; es:di = FI_faceName - segmov ds, ss - mov di, si - add di, FI_faceName - lea si,fontName ; ds:si = fontName - mov cx, length FI_faceName ; dest. size - LocalCopyNString - LocalPrevChar esdi - mov ax, 0 - LocalPutChar esdi, ax ; ensure null term - pop es, ds, si ; restore FFLH, FontInfo - - add si, size FontInfo ; ds:si = first OutlineDataEntry -initEntry: - call initOutlineEntry - -doneClose: - mov bx, fontFile - mov al, FILE_NO_ERRORS - call FileClose -done: - mov dx, fontBlockSeg - - .leave - ret - -weightAdjustTable byte \ - 80, ;FWE_ULTRA_LIGHT - 85, ;FWE_EXTRA_LIGHT - 90, ;FWE_LIGHT - 95, ;FWE_BOOK - 100, ;FWE_NORMAL - 105, ;FWE_DEMI - 110, ;FWE_BOLD - 115, ;FWE_EXTRA_BOLD - 120, ;FWE_ULTRA_BOLD - 125 ;FWE_BLACK - -initOutlineEntry label near - ; - ; style and weight - ; ds:si = OutlineDataEntry - ; - mov al, fontStyle ; font style - mov ds:[si].ODE_style, al - mov al, fontWeight ; font weight - mov ds:[si].ODE_weight, al - ; - ; now allocate and fill in a TrueTypeOutlineEntry - ; ds:si = OutlineDataEntry - ; fontNameSeg:fontNameOff = font file name - ; - mov bx, si - mov si, fontInfoChunk - mov si, ds:[si] - sub bx, si ; bx = offset to ODE - mov cx, size TrueTypeOutlineEntry ; fixed size - clr ax - call LMemAlloc ; ax = BOE chunk, ds updated - mov fontBlockSeg, ds ; store it - mov si, fontInfoChunk - mov si, ds:[si] ; ds:si = FontInfo - add si, bx ; ds:si = OutlineDataEntry -if DBCS_PCGEOS - mov ds:[si].ODE_extraData, ax -else - ; store chunk at OutlineEntrys - mov ds:[si][(size ODE_style + size ODE_weight)], ax -endif - mov si, ax - mov di, ds:[si] - mov bx, di ; es:bx = TrueTypeOutlineEntry - segmov es, ds ; es:di = TrueTypeOutlineEntry -.assert (offset TTOE_fontFileName) eq 0 - mov ds, fontNameSeg ; ds:si = font filename - mov si, fontNameOff - mov cx, size TTOE_fontFileName ; dest. size - rep movsb - - retn - -ProcessFont endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - LoadTable -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Load ttf table into memory block - -CALLED BY: ProcessFont - -PASS: ss:si - table directory entry - bx - file handle - -RETURN: ds - segment of locked table (on success) - bx - handle of table block (0 if FAILURE) - -DESTROYED: Current file position in the given file. - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 8/30/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -LoadTable proc near - uses ax, cx, dx, di - -newBlock local hptr - .enter - - mov newBlock, handle 0 - - tst ss:[si].TTTD_length.low ; actually the high word - jnz err ; -> error if above 64K - mov al, ss:[si].TTTD_length.high.high - mov ah, ss:[si].TTTD_length.high.low - mov di, ax - - mov dx, bx ; keep file handle - mov bx, handle 0 ; bx <- make TrueType owner - mov cx, ALLOC_DYNAMIC_LOCK - call MemAllocSetOwner ; allocate blk for table - jc err - - mov newBlock, bx - segmov ds, ax - - mov bx, dx ; pass file handle in BX - mov al, FILE_POS_START ; jump from start - mov dl, ss:[si].TTTD_offset.high.high - mov dh, ss:[si].TTTD_offset.high.low - mov cl, ss:[si].TTTD_offset.low.high - mov ch, ss:[si].TTTD_offset.low.low - - call FilePos - jc err - - mov dx, 0 ; buffer offset in segment - mov cx, di ; size - clr al - call FileRead - jc err - - mov bx, newBlock -done: - .leave - ret - -err: - mov bx, 0 - mov ax, newBlock - jz done - call MemFree - jmp done - -LoadTable endp - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - GetNameFromTable -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Load ttf table into memory block - -CALLED BY: ProcessFont - -PASS: ss:si - buffer to hold the result - cx - buffer size (to include \0 terminiation) - ds - name table segment - -RETURN: carry set on not found - Otherwise buffer filled, \0 terminated, if cx is not 0. - if cx is 0 then the buffer is filled but without \n termination. - -DESTROYED: ax, si - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 8/30/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -GetNameFromTable proc near - uses bx, di, dx - -dataOffset local word -encoding local byte - .enter - - mov bx, ax - mov di, si - - ; check version - mov ax, ds:0 - cmp ax, 0 - jne err - - ; scan the name record table - mov ah, ds:4 - mov al, ds:5 - mov dataOffset, ax - - mov dx, ds:2 - mov si, 6 -recordLoop: - mov ax, ds:0[si] - cmp ax, 0100h - je macEncoding - cmp ax, 0 ; unicode - jne next - mov ah, ds:2[si] - mov al, ds:3[si] - cmp ax, 3 ; Unicode 2.0 BPM - jne next - mov ax, ds:4[si] - cmp ax, 0 ; language should be 0 for - ; unicode - jne next - mov encoding, 0 - jmp enterLoop - -macEncoding: - mov ah, ds:2[si] - mov al, ds:3[si] - cmp ax, 0 ; Roman? - jne next - mov ax, ds:4[si] - cmp ax, 0 ; English? - jne next - - mov encoding, 1 ; 1 = non-unicode - -enterLoop: - ; match the name id - mov ah, ds:6[si] - mov al, ds:7[si] - cmp ax, bx - jne next - - mov dh, ds:8[si] - mov dl, ds:9[si] - - mov ah, ds:10[si] - mov al, ds:11[si] - add ax, dataOffset - mov si, ax -copyLoop: - cmp encoding, 0 - jne nextByte - mov ah, ds:0[si] - inc si - dec dx - jz endOfBuffer -nextByte: - mov al, ds:0[si] - inc si - - mov ss:0[di], al - inc di - dec cx - jz endOfBuffer - dec dx - jnz copyLoop -endOfBuffer: - cmp cx, 0 - jz success - mov ss:0[di], 0 - jmp success -next: - mov ax, si - add ax, 12 ; size of name record - mov si, ax - - dec dx - jnz recordLoop - jz err - -success: - clc -done: - .leave - ret - -err: - stc - jc done - -GetNameFromTable endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - MapFontStyle -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: MapFontStyle - -CALLED BY: ProcessFont - -PASS: ss:si - buffer to sub family name - -RETURN: carry set if mapping failed - al - on success, mapped TextStyle - -DESTROYED: ah - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 9/9/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -LocalDefNLString StyleRegular, <"Regular", 0> -LocalDefNLString StyleBold, <"Bold", 0> -LocalDefNLString StyleItalic, <"Italic", 0> -LocalDefNLString StyleBoldItalic, <"Bold Italic", 0> -LocalDefNLString StyleOblique, <"Oblique", 0> -LocalDefNLString StyleBoldOblique, <"Bold Oblique", 0> - -styleNames nptr \ - StyleRegular, - StyleBold, - StyleItalic, - StyleBoldItalic, - StyleOblique, - StyleBoldOblique - -styleFlags TextStyle \ - 0, - mask TS_BOLD, - mask TS_ITALIC, - mask TS_BOLD or mask TS_ITALIC, - mask TS_ITALIC, - mask TS_BOLD or mask TS_ITALIC - -MapFontStyle proc near - uses es, ds, di, si, cx, bx - - .enter -; -; Find the style -; - segmov es, ss - mov di, si ;es:di <- string to look for -; -; Find the sub family name in the table -; - mov cx, length styleNames ;cx <- # of entries - clr bx ;bx <- table index - segmov ds, cs -styleLoop: - push cx - mov si, cs:styleNames[bx] ;ds:si <- extension - clr cx ;cx <- NULL-terminated - call LocalCmpStringsNoCase - pop cx - je foundStyle ;branch if match - add bx, (size nptr) ;bx <- next entry - loop styleLoop ;loop for more - jmp notFound - -; -; Found the style -- return the flags -; -foundStyle: - sar bx, 1 - mov al, cs:styleFlags[bx] ;ds:si <- library name - clc ;carry <- no error -done: - .leave - ret - -notFound: - stc ;carry <- error - jmp done - -MapFontStyle endp diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/truetypeMacros.def deleted file mode 100644 index 02930d0ae..000000000 --- a/Driver/Font/TrueType/truetypeMacros.def +++ /dev/null @@ -1,70 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1990 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: TrueType -FILE: truetypeMacros.def - -AUTHOR: Falk Rehwagen, Jan 26, 2021 - -MACROS: - Name Description - ---- ----------- - Abs Absolute value of word - - TRUNC Truncate number - CEIL Get ceiling of number - ROUND Round number to integer - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/26/21 Initial revision - -DESCRIPTION: - Macros for the PC/GEOS TrueType font driver. - - $Id: truetypeMacros.def,v 1.1 21/01/26 11:45:27 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -; -; absolute value of integer -; -Abs macro int -local A_10 - tst int - jns A_10 - neg int -A_10: -endm - -; -;PASS: number in 16ths -;RETURN: floor(number), no fraction -; -TRUNC macro num - sar num, 1 - sar num, 1 - sar num, 1 - sar num, 1 -endm - -; -;PASS: number in 16ths -;RETURN: ceiling(number), no fraction -; -CEIL macro num - add num, FRACTION - TRUNC num -endm - -; -;PASS: number in 16ths -;RETURN: round(number), no fraction -; -ROUND macro num - add num, ONE_HALF - TRUNC num -endm diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/truetypeMetrics.asm deleted file mode 100644 index 647b96c0d..000000000 --- a/Driver/Font/TrueType/truetypeMetrics.asm +++ /dev/null @@ -1,63 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1990 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: MetricsMod -FILE: truetypeMetrics.asm - -AUTHOR: Falk Rehwagen, Jan 29, 2021 - -ROUTINES: - Name Description - ---- ----------- -EXT TrueTypeCharMetrics Return character metric information. - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/ 1/21 Initial revision - -DESCRIPTION: - Routines for generating character metrics. - - $Id: truetypeMetrics.asm,v 1.1 97/04/18 11:45:29 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeCharMetrics -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Return character metrics information in document coords. -CALLED BY: DR_FONT_CHAR_METRICS - TrueTypeStrategy - -PASS: ds - seg addr of font info block - es - seg addr of GState - es:GS_fontAttr - font attributes - dx - character to get metrics of - cx - info to return (GCM_info) -RETURN: if GCMI_ROUNDED set: - dx - information (rounded) - else: - dx.ah - information (WBFixed) - carry - set if error (eg. data / font not available) -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/ 1/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeCharMetrics proc far - uses bx, cx, si, di, ds - .enter - - .leave - ret -TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/truetypePath.asm deleted file mode 100644 index 1b9950368..000000000 --- a/Driver/Font/TrueType/truetypePath.asm +++ /dev/null @@ -1,107 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1991 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: GeoCalc -FILE: truetypePath.asm - -AUTHOR: Falk Rehwagen, Jan 29, 2021 - -ROUTINES: - Name Description - ---- ----------- -EXT TrueTypeGenPath Generate path for character - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/29/21 Initial revision - -DESCRIPTION: - Routines for generating graphics string of a character. - - $Id: truetypePath.asm,v 1.1 97/04/18 11:45:26 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenPath -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate a path for the outline of a character -CALLED BY: DR_FONT_GEN_PATH (via TrueTypeStrategy) - -PASS: ds - seg addr of font info block - di - handle of GState (passed in bx, locked) - dx - character to generate (Chars) - cl - FontGenPathFlags - FGPF_POSTSCRIPT - transform for use as Postscript - Type 1 or Type 3 font. - FGPF_SAVE_STATE - do save/restore for GState -RETURN: none -DESTROYED: ax, bx, di (on the way here) - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/29/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenPath proc far - uses cx, dx, si, ds, es - .enter - - .leave - ret -TrueTypeGenPath endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenInRegion -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate a character in the passed RegionPath -CALLED BY: DR_FONT_GEN_IN_REGION (via TrueTypeStrategy) - -PASS: ds - seg addr of font info block - di - handle of GState (passed in BX) - dx - character to generate (Chars) - cx - RegionPath handle (locked) -RETURN: nothing -DESTROYED: ax, bx, di - -PSEUDO CODE/STRATEGY: - We want override some of the default functionality for - build a font's character. Essentially: - * Always build a character in a region - * Build this character in the passed region - - We accomplish this by: - 1) Find the character data - 2) Calculate/store the correct transformation - 3) Stuff in some new CharGenRouts - 4) Stuf in the pen position (in device coords) - 5) Go generate the character (via MakeBigCharInRegion) - -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/ 29/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenInRegion proc far - uses cx, dx, si, ds, es - .enter - - .leave - ret -TrueTypeGenInRegion endp - - diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def deleted file mode 100644 index d5126e846..000000000 --- a/Driver/Font/TrueType/truetypeVariable.def +++ /dev/null @@ -1,100 +0,0 @@ - -COMMENT @---------------------------------------------------------------------- - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: Font Driver -FILE: truetypeVariable.def - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - Falk 11/6/89 Initial version - -DESCRIPTION: - initialized and unitialized variables for TrueType font driver - - $Id: nimbusVariable.def,v 1.1 97/04/18 11:45:28 newdeal Exp $ - ------------------------------------------------------------------------------@ - - - -;------------------------------------------------------------------------------ -; Definition of variable block -;------------------------------------------------------------------------------ - -TrueTypeVars struct - -stackBot label byte -; -; The "stack" overlaps everything above this point -; - -x_offset sword ;x offset to create character -y_offset sword ;y offset to create character - -penPos Point <0, 0> ;pen position used for drawing - ;characters into a passed RegionPath - ;for NimbusGenInRegion(). -; -; Used to save passed variables: -; -genOffset word 0 ;offset of CharGenData -fontSegment word 0 ;seg addr of font -fontHandle hptr 0 ;handle of font -infoSegment word 0 ;seg addr of info block -gstateSegment word 0 ;seg addr of GState - -TrueTypeVars ends - -TrueTypeSubTable struct - TTST_scalerType dword - TTST_numTables word - TTST_searchRange word - TTST_entrySelector word - TTST_rangeShift word -TrueTypeSubTable ends - -TrueTypeTableDirectory struct - TTTD_tag dword - TTTD_checkSum dword - TTTD_offset dword - TTTD_length dword -TrueTypeTableDirectory ends - -TrueTypeOutlineEntry struc - TTOE_fontFileName DosDotFileName -TrueTypeOutlineEntry ends - -;------------------------------------------------------------------------------ - -;------------------------------------------------------------------------------ -; Initialized variables -;------------------------------------------------------------------------------ - -idata segment - -if DBCS_PCGEOS -truetypeDir wchar 'TTF',0 -else -truetypeDir char 'TTF',0 -endif - -idata ends - -;------------------------------------------------------------------------------ -; Uninitialized varaibles -;------------------------------------------------------------------------------ - -udata segment - -bitmapHandle hptr ;handle of our bitmap block -bitmapSize word ;size of our bitmap block (in bytes) - -variableHandle hptr ;handle of our variable block - -udata ends - - diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/truetypeWidths.asm deleted file mode 100644 index df274e67b..000000000 --- a/Driver/Font/TrueType/truetypeWidths.asm +++ /dev/null @@ -1,69 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1990 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: TrueType Font Driver -FILE: truetypeWidths.asm - -AUTHOR: Falk Rehwagen, Jan 29, 2021 - -ROUTINES: - Name Description - ---- ----------- -EXT TrueTypeGenWidths Generate font header and widths for a font. - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/1/21 Initial revision - -DESCRIPTION: - Implements a font driver for: - The TrueType outline fonts - - $Id: truetypeWidths.asm,v 1.1 97/04/18 11:45:30 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenWidths -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate the character width table for a font. -CALLED BY: EXTERNAL: GrFindFont - -PASS: di - 0 for new font; handle to rebuild old font (P'd) - es - seg addr of gstate (locked) - GS_fontAttr - font attributes - bp:cx - transformation matrix (TMatrix) - ds - seg addr of font info block -RETURN: bx - handle of font (locked) - ax - seg addr of font (locked) - carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - di is the bx passed to TrueTypeStrategy. - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/1/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenWidths proc far - uses cx, dx, si, di, ds, es, bp - - mov bx, bp - .enter - - clc ;indicate no error - - .leave - ret -TrueTypeGenWidths endp diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 4ad4c65a1..f1568bd9c 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,27 +4,27 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -MAIN = truetypeEscape.asm mainManager.asm truetypeWidths.asm\ - truetypeMetrics.asm truetypeInit.asm truetypeEC.asm\ - truetypeChars.asm truetypePath.asm truetypeMacros.def\ - truetypeVariable.def truetypeConstant.def -FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ - ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ - header.h ttinterp.h ttload.h tttables.h ttobjs.h\ - fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ - ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ - ttmemory.h tttags.h +FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ + ttextend.c ttfile.c ttgload.c ttinterp.c ttload.c\ + ttmemory.c ttmutex.c ttobjs.c ttraster.c freetype.h\ + ft_conf.h fterrid.h ftnameid.h ftxkern.h header.h\ + ttcache.h ttcalc.h ttcmap.h ttconfig.h ttdebug.h\ + ttengine.h ttextend.h ttfile.h ttgload.h ttinterp.h\ + ttload.h ttmemory.h ttmutex.h ttobjs.h ttraster.h\ + tttables.h tttags.h tttypes.h +MAIN = mainManager.asm truetypeChars.asm truetypeEC.asm\ + truetypeEscape.asm truetypeInit.asm truetypeMetrics.asm\ + truetypePath.asm truetypeWidths.asm truetypeConstant.def\ + truetypeMacros.def truetypeVariable.def UI_TO_RDFS = -OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ - ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ - ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ - ttmemory.obj +OBJS = ftxkern.obj ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj\ + ttdebug.obj ttextend.obj ttfile.obj ttgload.obj\ + ttinterp.obj ttload.obj ttmemory.obj ttmutex.obj\ + ttobjs.obj ttraster.obj COMMON = MODULES = Main CMODULES = FreeType -SRCS = $(MAIN) $(FREETYPE) $(COMMON) +SRCS = $(FREETYPE) $(MAIN) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk From c41e6d02cff719393bdb187d1d8014d8f14c0205 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 19 Jun 2022 17:55:38 +0200 Subject: [PATCH 042/246] Revert "Duplicate files removed." This reverts commit 98cb0b3aaa832ab0009b0c5ae0b5655b53f0373a. --- Driver/Font/TrueType/truetypeChars.asm | 62 ++ Driver/Font/TrueType/truetypeConstant.def | 104 +++ Driver/Font/TrueType/truetypeEC.asm | 99 +++ Driver/Font/TrueType/truetypeEscape.asm | 60 ++ Driver/Font/TrueType/truetypeInit.asm | 959 ++++++++++++++++++++++ Driver/Font/TrueType/truetypeMacros.def | 70 ++ Driver/Font/TrueType/truetypeMetrics.asm | 63 ++ Driver/Font/TrueType/truetypePath.asm | 107 +++ Driver/Font/TrueType/truetypeVariable.def | 100 +++ Driver/Font/TrueType/truetypeWidths.asm | 69 ++ Installed/Driver/Font/TrueType/Makefile | 34 +- 11 files changed, 1710 insertions(+), 17 deletions(-) create mode 100644 Driver/Font/TrueType/truetypeChars.asm create mode 100644 Driver/Font/TrueType/truetypeConstant.def create mode 100644 Driver/Font/TrueType/truetypeEC.asm create mode 100644 Driver/Font/TrueType/truetypeEscape.asm create mode 100644 Driver/Font/TrueType/truetypeInit.asm create mode 100644 Driver/Font/TrueType/truetypeMacros.def create mode 100644 Driver/Font/TrueType/truetypeMetrics.asm create mode 100644 Driver/Font/TrueType/truetypePath.asm create mode 100644 Driver/Font/TrueType/truetypeVariable.def create mode 100644 Driver/Font/TrueType/truetypeWidths.asm diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/truetypeChars.asm new file mode 100644 index 000000000..4f5ecbdda --- /dev/null +++ b/Driver/Font/TrueType/truetypeChars.asm @@ -0,0 +1,62 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: RasterMod +FILE: truetypeChars.asm + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + This file contains routines for generating individual characters. + + $Id: truetypeChars.asm,v 1.1 97/04/18 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenChar +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate one character for a font. +CALLED BY: VidBuildChar (via TrueTypeStrategy) + +PASS: dx - character to build (Chars) + es - seg addr of font (locked) + bp - seg addr of gstate (locked) + GS_fontHandle - handle of font + GS_fontAttr - font attributes + ds - seg addr of font info block + +RETURN: es - seg addr of font (locked) (may have changed) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenChar proc far + uses ax, bx, cx, dx, ds, si, di, bp + .enter + + + .leave + stc ;indicate no error + ret +TrueTypeGenChar endp + + diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/truetypeConstant.def new file mode 100644 index 000000000..942764157 --- /dev/null +++ b/Driver/Font/TrueType/truetypeConstant.def @@ -0,0 +1,104 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeConstant.def + +AUTHOR: Falk Rehwagen + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 26/1/21 Initial revision + +DESCRIPTION: + Definitions, constants, etc needed for the PC/GEOS TrueType font driver + + $Id: truetypeConstant.def,v 1.1 21/01/26 11:45:25 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +;---------------------------------------------------------------------------- +; Font Style Factors +;---------------------------------------------------------------------------- + +SCRIPT_FACTOR_INT = 0 +SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 + +SUBSCRIPT_OFFSET_INT = 0 +SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below + +SUPERSCRIPT_OFFSET_INT = 0 +SUPERSCRIPT_OFFSET_FRAC = 0x6000 ;offset above + +BOLD_FACTOR_INT = 0x0001 +BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 + +ITALIC_FACTOR_INT = 0 +ITALIC_FACTOR_FRAC = 0x366A ;italic = tan(12) +NEG_ITALIC_FACTOR_INT = 0xffff +NEG_ITALIC_FACTOR_FRAC = 0xC996 ;italic = -tan(12) + +; +; Styles that affect the width of the character: +; +WIDTH_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_BOLD +; +; Styles that affect the transformation matrix used: +; +TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ + mask TS_SUBSCRIPT or \ + mask TS_ITALIC or \ + mask TS_BOLD + +;---------------------------------------------------------------------------- +; Miscellaneous constants +;---------------------------------------------------------------------------- + +DEFAULT_CHAR = '.' + +; +; These sizes are in pixels, not points, since that's what +; really matters for these cutoff points. +; +; Continuity checking is not done above: +; +MAX_CONTINUITY_SIZE = 30 +; +; Characters are stored as regions instead of bitmaps above: +; +MAX_BITMAP_SIZE = 125 +SCRIPT_SAFETY_SIZE = 10 + +TRUETYPE_BLOCK_SIZE equ 1024 ;initial block size + +;---------------------------------------------------------------------------- +; Region constants +;---------------------------------------------------------------------------- + +UNUSED_PER_LINE = 4 ;# of unused points / line + +;---------------------------------------------------------------------------- +; Font Errors +;---------------------------------------------------------------------------- + +if ERROR_CHECK + +FONT_BAD_CHAR_FLAG enum FatalErrors + +RECURSIVE_CALL_TO_FONT_DRIVER enum FatalErrors +; The TrueType driver is non-reentrant, so only one thread can be in the +; driver at a time. This may indicate a bug in the Font Manager. + +FONT_BAD_ROUTINE enum FatalErrors +; A bad function passed to the TrueType driver. The function passed in +; di must be in the FontFunction enumerated type. + +TRUETYPE_INTERNAL_ERROR enum FatalErrors + +endif + diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/truetypeEC.asm new file mode 100644 index 000000000..a87edeb5b --- /dev/null +++ b/Driver/Font/TrueType/truetypeEC.asm @@ -0,0 +1,99 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEC.asm +FILE: truetypeEC.asm + +AUTHOR: Falk Rehwagen, Jan 1, 2021 + +ROUTINES: + Name Description + ---- ----------- + ECNukeVariableBlock nuke variables so we don't inadvertently + re-use them + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Error checking code for TrueType driver + + $Id: truetypeEC.asm,v 1.1 21/01/24 11:45:31 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +if ERROR_CHECK + +CharMod segment resource + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ECNukeVariableBlock +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Nuke the TrueType variable block +CALLED BY: NimbusStrategy() + +PASS: none +RETURN: none +DESTROYED: none (flags preserved) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +ECNukeVariableBlock proc far + uses ax, bx, cx, di, es + .enter + + pushf + + ; + ; Lock the variable block + ; + mov ax, segment udata + mov es, ax ;es <- seg addr of idata + mov bx, es:variableHandle ;bx <- handle of vars + tst bx ;block freed? + jz done ;branch if freed + call MemLock + jc done ;branch if discarded + mov es, ax ;es <- seg addr of vars + ; + ; Zero the block + ; + clr al ;al <- byte to store + mov cx, (size TrueTypeVars) ;cx <- # of bytes + clr di ;es:di <- ptr to vars + rep stosb + ; + ; Nuke things we know are segments specially + ; + mov es:fontSegment, 0xa000 + mov es:gstateSegment, 0xa000 + mov es:infoSegment, 0xa000 + ; + ; All done... + ; + call MemUnlock +done: + + popf + + .leave + ret +ECNukeVariableBlock endp + + +CharMod ends + +endif + diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/truetypeEscape.asm new file mode 100644 index 000000000..3f3f33d6f --- /dev/null +++ b/Driver/Font/TrueType/truetypeEscape.asm @@ -0,0 +1,60 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: truetypeEscape.asm +FILE: truetypeEscape.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeFontEscape handle any escape functions + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial revision + +DESCRIPTION: + Code for handling driver escape functions + + $Id: truetypeEscape.asm,v 1.1 21/01/24 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeFontEscape +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Hand +CALLED BY: TrueTypeStrategy() + +PASS: di - escape function +RETURN: di - 0 if escape function not supported +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeFontEscape proc far + call FontCallEscape ;call general handling routine + ret +TrueTypeFontEscape endp + +;---------------------------------------------------------------------------- +; Escape Function Table +;---------------------------------------------------------------------------- + +DefEscapeTable 1 + +DefEscape FontQueryEscape, DRV_ESC_QUERY_ESC diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm new file mode 100644 index 000000000..e61f76018 --- /dev/null +++ b/Driver/Font/TrueType/truetypeInit.asm @@ -0,0 +1,959 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) blueway.Softworks 2021 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Init +FILE: truetypeInit.asm + +AUTHOR: Falk Rehwagen, Jan 24, 2021 + +ROUTINES: + Name Description + ---- ----------- + TrueTypeInit initialize the TrueType font driver + TrueTypeExit clean up after TrueType font driver + TrueTypeInitFonts initialize any non-PC/GEOS fonts + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial revision + +DESCRIPTION: + Initialization & exit routines for TrueType font driver + + $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize the TrueType font driver. +CALLED BY: DR_INIT - TrueTypeStrategy + +PASS: none +RETURN: bitmapHandle - handle of block to use for bitmaps + bitmapSize - size of above block (0 at start) + variableHandle - handle of block containing variables + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 01/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + public TrueTypeInit +TrueTypeInit proc far + uses ax, bx, cx, si, di, ds, es + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + ; + ; First, we need a block of memory to use as a bitmap + ; for generating characters. We don't need to actually + ; allocate memory for it yet. + ; + mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:bitmapHandle, bx ;save handle of block + mov ds:bitmapSize, 0 ;no bytes yet + ; + ; We also need a block to use for variables. We don't + ; need it yet, either. + ; + mov ax, size TrueTypeVars ;ax <- size of block + mov bx, handle 0 ;bx <- make TrueType owner + mov cx, mask HF_DISCARDABLE \ + or mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDED \ + or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags + call MemAllocSetOwner + mov ds:variableHandle, bx ;save handle of block + clc ;indicate no error + + .leave + ret +TrueTypeInit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeExit +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Free up blocks used and exit the TrueType driver. +CALLED BY: DR_EXIT - TrueTypeStrategy + +PASS: bitmapHandle - handle of bitmap block + variableHandle - handle of variable block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeExit proc far + uses ax, bx, ds + .enter + + mov ax, segment udata + mov ds, ax ;ds <- seg addr of vars + mov bx, ds:bitmapHandle +EC < clr ds:bitmapHandle ;> + call MemFree ;done with bitmap block + mov bx, ds:variableHandle +EC < clr ds:variableHandle ;> + call MemFree ;done with variable block + clc ;indicate no error + + .leave + ret +TrueTypeExit endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeInitFonts +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Initialize any non-GEOS fonts for the font driver. +CALLED BY: DR_FONT_INIT_FONTS - TrueTypeStrategy + +PASS: ds - seg addr of font info block +RETURN: carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/24/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +initFontReturnAttr FileExtAttrDesc \ + , + + +TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp + + .enter + + ; + ; Enumerate files in SP_FONT + ; + call FilePushDir + mov ax, SP_FONT + call FileSetStandardPath + push ds + segmov ds, dgroup, ax + mov dx, offset truetypeDir + clr bx ; relative to CWD + call FileSetCurrentPath + pop ds + + ; + ; Lookup all .ttf files + sub sp, size FileEnumParams + mov bp, sp + ; GEOS datafiles + mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS + ; return longname + mov ss:[bp].FEP_returnAttrs.segment, cs + mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr + mov ss:[bp].FEP_returnSize, size FileLongName + mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED + ; callback sees all files + mov ss:[bp].FEP_matchAttrs.segment, 0 + + mov ss:[bp].FEP_skipCount, 0 + call FileEnum ; cx = # found, bx = handle + jc done ; error + jcxz done ; no files found + mov dx, ds ; ax = segment of font block + call MemLock ; ds:0 = first entry + mov ds, ax + mov si, 0 +fontLoop: + call ProcessFont + add si, size FileLongName + loop fontLoop + call MemFree ; free file block +done: + call FilePopDir + clc + .leave + ret + +TrueTypeInitFonts endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ProcessFont +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: initialize each font found + +CALLED BY: TrueTypeInitFonts + +PASS: ds:si - font file name (TTF) + dx - font block segment + +RETURN: dx - updated font block segment (may move) + +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 2/17/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +ProcessFont proc far + + uses ax, bx, cx, di, si, es, ds + +fontNameSeg local sptr push ds +fontNameOff local word push si +fontBlockSeg local sptr push dx +subTableHeader local TrueTypeSubTable +tableDirectory local TrueTypeTableDirectory +fontId local FontID +fontInfoChunk local word +tableCount local word +fontFile local hptr +fontName local FONT_NAME_LEN dup (char) +fontStyle local TextStyle +fontWeight local FontWeight + + .enter + ; + ; generate font id from file names first character for now + ; + mov fontWeight, FW_NORMAL + + clr ah + mov al, ds:[si] + add ax, FM_TRUETYPE + mov fontId, ax + + ; + ; open truetype file + ; + mov dx, si ; ds:dx = name + mov al, FILE_ACCESS_R or FILE_DENY_W + call FileOpen + jc done + + mov bx, ax ; file handle to bx + mov fontFile, bx + + segmov ds, ss + lea dx, subTableHeader + + mov al, 0 + + mov cx, size subTableHeader ; size to read + + call FileRead + jc doneClose + + ; + ; scan all TTF file tables + ; keep structures and meta data needed to serve the font + ; + mov ah, subTableHeader.TTST_numTables.low + mov al, subTableHeader.TTST_numTables.high + mov tableCount, ax +nextEntry: + mov bx, fontFile + segmov ds, ss + lea dx, tableDirectory + mov al, 0 + + mov cx, size tableDirectory ; size to read + + call FileRead + jc doneClose + + ; remember file position + mov cx, 0 + mov dx, 0 + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_RELATIVE ; jump from start + call FilePos ; get current pos to dx:ax + jc doneClose + mov cx, dx + mov dx, ax + + mov ax, 'na' + cmp ax, tableDirectory.TTTD_tag.low + jne tryOS_2 + mov ax, 'me' + cmp ax, tableDirectory.TTTD_tag.high + jne tryOS_2 + + lea si, tableDirectory + call LoadTable + + cmp bx, 0 ; failed to load? + je doneClose + + ; restore file position, cxdx hold position + push bx + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + call FilePos + pop bx + jnc parseName + + ; free the block we don't keep it, bx handle of block + call MemFree + jmp doneClose + +parseName: + ; get relevant data from name table + + ; first load sub family (and reuse the buffer fontName) and map + ; the value to TextStyle bits to describe the resulting + ; font entry + lea si, fontName ; ss:si point to buffer + mov cx, FONT_NAME_LEN ; buffer size + mov ax, 2 ; sub family name of the font + call GetNameFromTable + jc doneClose ; jump if no name found + + lea si, fontName ; ss:si point to buffer + call MapFontStyle + jc doneClose ; fail if style mapping fails + + mov fontStyle, al ; save fontStyle + ; (type TextStyle) + ; ds is pointing to the name table here + lea si, fontName ; ss:si point to buffer + mov cx, FONT_NAME_LEN ; buffer size + mov ax, 1 ; family name of the font + call GetNameFromTable + jc doneClose ; jump if no name found + + ; free the block we don't keep it, bx handle of block + call MemFree +tryOS_2: + mov ax, 'OS' + cmp ax, tableDirectory.TTTD_tag.low + jne cont + mov ax, '/2' + cmp ax, tableDirectory.TTTD_tag.high + jne cont +loadOS_2: + lea si, tableDirectory + call LoadTable + + cmp bx, 0 ; failed to load? + je doneClose + + ; restore file position, cxdx hold position + push bx + mov bx, fontFile ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + call FilePos + pop bx + jnc getWeight + + ; free the block we don't keep it, bx handle of block +freeAndClose: + call MemFree + jmp doneClose + +getWeight: + mov ah, ds:4 + mov al, ds:5 + mov dx, 0 + mov si, 100 + div si + cmp dx, 0 + jne freeAndClose + cmp ax, 10 + jnc freeAndClose + + mov si, ax + mov al, cs:weightAdjustTable[si] + mov fontWeight, al + +cont: + dec tableCount + jnz nextEntry + + ; we have one font and collected required meta data + ; let compute/determ the fontid to be used for the font + mov ax, 0 + lea si, fontName ; ss:si point to buffer + mov cx, 0 +calcFontId: + + xor al, ss:0[si] + + xor ah, ss:1[si] + + inc cx + cmp cx, FONT_NAME_LEN + je doneFontId + inc si + cmp ss:0[si], 0 + jnz calcFontId + + and ah, 00000001b + or ax, FM_TRUETYPE + or ah, 00001110b + mov fontId, ax +doneFontId: + + ; lookup if there is a FontsAvailEntry for the font already + mov cx, fontId + mov ds, fontBlockSeg + mov di, ds:[FONTS_AVAIL_HANDLE] ;di <- ptr to chunk + ChunkSizePtr ds, di, ax ;ax <- chunk size + add ax, di ;ax -> end of chunk +IFA_loop: + cmp di, ax ;are we thru the list? + jae noMatch ;yes, exit carry clear + cmp ds:[di].FAE_fontID, cx ;see if ID matches + je match ;we have a match, branch + add di, size FontsAvailEntry ;else move to next entry + jmp IFA_loop ;and loop + +match: + ; font already registered, check if there is already equal outline + ; outline is equal if style and weight is equal + mov di, ds:[di].FAE_infoHandle ; ds:si = FontInfo chunk handle + mov si, ds:[di] ; ds:si = FontInfo ptr + + mov cx, ds:[si].FI_outlineEnd + push si + mov si, ds:[si].FI_outlineTab + +checkOutline: + mov al, ds:[si].ODE_style + cmp al, fontStyle + jne nextOutline + + mov al, ds:[si].ODE_weight + cmp al, fontStyle + jne nextOutline + + ; matching outline found + pop ax + jmp doneClose ; skip this font + +nextOutline: + add si, size OutlineDataEntry + cmp si, cx + jne checkOutline + +appendOutline: + ; not found, append new outline + pop si + + mov bx, cx ; append at end + + push cx + add cx, size OutlineDataEntry + mov ds:[si].FI_outlineEnd, cx + + mov ax, di ; *ds:ax = chunk + mov cx, size OutlineDataEntry ; cx = sizeof outline entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + + pop si + jmp initEntry + +noMatch: + ; + ; create a new FontsAvailEntry + ; + mov ds, fontBlockSeg + mov ax, FONTS_AVAIL_HANDLE ; *ds:ax = chunk + clr bx ; insert at front + mov cx, size FontsAvailEntry ; cx = sizeof table entry + call LMemInsertAt ; ds updated + mov fontBlockSeg, ds ; store it + ; + ; fill in FontID + ; + mov si, ax + push si + mov si, ds:[si] ; ds:si = new FAE + mov ax, fontId + mov ds:[si].FAE_fontID, ax + ; + ; clear the name field because there is a font file for each font + ; rather than for each typeface (which this field is for) + ; + mov ds:[si].FAE_fileName, 0 + + ; + ; allocate a chunk for the FontInfo block + ; + mov cx, 1 ; font count + mov ax, size OutlineDataEntry + mul cx ; dx:ax = size +EC < tst dx > +EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > + mov cx, ax + add cx, size FontInfo + mov dx, cx ; save size for later + clr ax + call LMemAlloc ; ds updated, ax = chunk + mov fontBlockSeg, ds ; store it + mov fontInfoChunk, ax + + ; + ; finish filling the FontsAvailEntry + ; dx = end of OutlineDataEntrys + ; + pop si ; *ds:si = FontsAvailEntry + mov si, ds:[si] ; ds:si = FontsAvailEntry + mov ds:[si].FAE_infoHandle, ax ; save FontInfo chunk handle + + ; + ; now fill in the FontInfo struct + ; dx = end of OutlineDataEntrys + ; + mov di, ax ; *ds:di = FontInfo + mov si, ds:[di] ; ds:si = FontInfo + mov ds:[si].FI_fileHandle, 0 ; not used + mov ax, fontId + mov ds:[si].FI_fontID, ax + mov ds:[si].FI_maker, FM_TRUETYPE + mov al, FF_NON_PORTABLE + mov ds:[si].FI_family, al ; this is called family but it + ; actually is FontAttrs + mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? (for now) + mov ds:[si].FI_pointSizeEnd, 0 + mov ds:[si].FI_outlineTab, size FontInfo + mov ds:[si].FI_outlineEnd, dx + ; + ; copy in the font face name + ; ds:si = FontInfo + ; es = FFLH + ; + push es, ds, si ; save FFLH, FontInfo + segxchg es, ds ; es:di = FI_faceName + segmov ds, ss + mov di, si + add di, FI_faceName + lea si,fontName ; ds:si = fontName + mov cx, length FI_faceName ; dest. size + LocalCopyNString + LocalPrevChar esdi + mov ax, 0 + LocalPutChar esdi, ax ; ensure null term + pop es, ds, si ; restore FFLH, FontInfo + + add si, size FontInfo ; ds:si = first OutlineDataEntry +initEntry: + call initOutlineEntry + +doneClose: + mov bx, fontFile + mov al, FILE_NO_ERRORS + call FileClose +done: + mov dx, fontBlockSeg + + .leave + ret + +weightAdjustTable byte \ + 80, ;FWE_ULTRA_LIGHT + 85, ;FWE_EXTRA_LIGHT + 90, ;FWE_LIGHT + 95, ;FWE_BOOK + 100, ;FWE_NORMAL + 105, ;FWE_DEMI + 110, ;FWE_BOLD + 115, ;FWE_EXTRA_BOLD + 120, ;FWE_ULTRA_BOLD + 125 ;FWE_BLACK + +initOutlineEntry label near + ; + ; style and weight + ; ds:si = OutlineDataEntry + ; + mov al, fontStyle ; font style + mov ds:[si].ODE_style, al + mov al, fontWeight ; font weight + mov ds:[si].ODE_weight, al + ; + ; now allocate and fill in a TrueTypeOutlineEntry + ; ds:si = OutlineDataEntry + ; fontNameSeg:fontNameOff = font file name + ; + mov bx, si + mov si, fontInfoChunk + mov si, ds:[si] + sub bx, si ; bx = offset to ODE + mov cx, size TrueTypeOutlineEntry ; fixed size + clr ax + call LMemAlloc ; ax = BOE chunk, ds updated + mov fontBlockSeg, ds ; store it + mov si, fontInfoChunk + mov si, ds:[si] ; ds:si = FontInfo + add si, bx ; ds:si = OutlineDataEntry +if DBCS_PCGEOS + mov ds:[si].ODE_extraData, ax +else + ; store chunk at OutlineEntrys + mov ds:[si][(size ODE_style + size ODE_weight)], ax +endif + mov si, ax + mov di, ds:[si] + mov bx, di ; es:bx = TrueTypeOutlineEntry + segmov es, ds ; es:di = TrueTypeOutlineEntry +.assert (offset TTOE_fontFileName) eq 0 + mov ds, fontNameSeg ; ds:si = font filename + mov si, fontNameOff + mov cx, size TTOE_fontFileName ; dest. size + rep movsb + + retn + +ProcessFont endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + LoadTable +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Load ttf table into memory block + +CALLED BY: ProcessFont + +PASS: ss:si - table directory entry + bx - file handle + +RETURN: ds - segment of locked table (on success) + bx - handle of table block (0 if FAILURE) + +DESTROYED: Current file position in the given file. + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 8/30/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +LoadTable proc near + uses ax, cx, dx, di + +newBlock local hptr + .enter + + mov newBlock, handle 0 + + tst ss:[si].TTTD_length.low ; actually the high word + jnz err ; -> error if above 64K + mov al, ss:[si].TTTD_length.high.high + mov ah, ss:[si].TTTD_length.high.low + mov di, ax + + mov dx, bx ; keep file handle + mov bx, handle 0 ; bx <- make TrueType owner + mov cx, ALLOC_DYNAMIC_LOCK + call MemAllocSetOwner ; allocate blk for table + jc err + + mov newBlock, bx + segmov ds, ax + + mov bx, dx ; pass file handle in BX + mov al, FILE_POS_START ; jump from start + mov dl, ss:[si].TTTD_offset.high.high + mov dh, ss:[si].TTTD_offset.high.low + mov cl, ss:[si].TTTD_offset.low.high + mov ch, ss:[si].TTTD_offset.low.low + + call FilePos + jc err + + mov dx, 0 ; buffer offset in segment + mov cx, di ; size + clr al + call FileRead + jc err + + mov bx, newBlock +done: + .leave + ret + +err: + mov bx, 0 + mov ax, newBlock + jz done + call MemFree + jmp done + +LoadTable endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + GetNameFromTable +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Load ttf table into memory block + +CALLED BY: ProcessFont + +PASS: ss:si - buffer to hold the result + cx - buffer size (to include \0 terminiation) + ds - name table segment + +RETURN: carry set on not found + Otherwise buffer filled, \0 terminated, if cx is not 0. + if cx is 0 then the buffer is filled but without \n termination. + +DESTROYED: ax, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 8/30/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +GetNameFromTable proc near + uses bx, di, dx + +dataOffset local word +encoding local byte + .enter + + mov bx, ax + mov di, si + + ; check version + mov ax, ds:0 + cmp ax, 0 + jne err + + ; scan the name record table + mov ah, ds:4 + mov al, ds:5 + mov dataOffset, ax + + mov dx, ds:2 + mov si, 6 +recordLoop: + mov ax, ds:0[si] + cmp ax, 0100h + je macEncoding + cmp ax, 0 ; unicode + jne next + mov ah, ds:2[si] + mov al, ds:3[si] + cmp ax, 3 ; Unicode 2.0 BPM + jne next + mov ax, ds:4[si] + cmp ax, 0 ; language should be 0 for + ; unicode + jne next + mov encoding, 0 + jmp enterLoop + +macEncoding: + mov ah, ds:2[si] + mov al, ds:3[si] + cmp ax, 0 ; Roman? + jne next + mov ax, ds:4[si] + cmp ax, 0 ; English? + jne next + + mov encoding, 1 ; 1 = non-unicode + +enterLoop: + ; match the name id + mov ah, ds:6[si] + mov al, ds:7[si] + cmp ax, bx + jne next + + mov dh, ds:8[si] + mov dl, ds:9[si] + + mov ah, ds:10[si] + mov al, ds:11[si] + add ax, dataOffset + mov si, ax +copyLoop: + cmp encoding, 0 + jne nextByte + mov ah, ds:0[si] + inc si + dec dx + jz endOfBuffer +nextByte: + mov al, ds:0[si] + inc si + + mov ss:0[di], al + inc di + dec cx + jz endOfBuffer + dec dx + jnz copyLoop +endOfBuffer: + cmp cx, 0 + jz success + mov ss:0[di], 0 + jmp success +next: + mov ax, si + add ax, 12 ; size of name record + mov si, ax + + dec dx + jnz recordLoop + jz err + +success: + clc +done: + .leave + ret + +err: + stc + jc done + +GetNameFromTable endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + MapFontStyle +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: MapFontStyle + +CALLED BY: ProcessFont + +PASS: ss:si - buffer to sub family name + +RETURN: carry set if mapping failed + al - on success, mapped TextStyle + +DESTROYED: ah + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + none + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 9/9/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +LocalDefNLString StyleRegular, <"Regular", 0> +LocalDefNLString StyleBold, <"Bold", 0> +LocalDefNLString StyleItalic, <"Italic", 0> +LocalDefNLString StyleBoldItalic, <"Bold Italic", 0> +LocalDefNLString StyleOblique, <"Oblique", 0> +LocalDefNLString StyleBoldOblique, <"Bold Oblique", 0> + +styleNames nptr \ + StyleRegular, + StyleBold, + StyleItalic, + StyleBoldItalic, + StyleOblique, + StyleBoldOblique + +styleFlags TextStyle \ + 0, + mask TS_BOLD, + mask TS_ITALIC, + mask TS_BOLD or mask TS_ITALIC, + mask TS_ITALIC, + mask TS_BOLD or mask TS_ITALIC + +MapFontStyle proc near + uses es, ds, di, si, cx, bx + + .enter +; +; Find the style +; + segmov es, ss + mov di, si ;es:di <- string to look for +; +; Find the sub family name in the table +; + mov cx, length styleNames ;cx <- # of entries + clr bx ;bx <- table index + segmov ds, cs +styleLoop: + push cx + mov si, cs:styleNames[bx] ;ds:si <- extension + clr cx ;cx <- NULL-terminated + call LocalCmpStringsNoCase + pop cx + je foundStyle ;branch if match + add bx, (size nptr) ;bx <- next entry + loop styleLoop ;loop for more + jmp notFound + +; +; Found the style -- return the flags +; +foundStyle: + sar bx, 1 + mov al, cs:styleFlags[bx] ;ds:si <- library name + clc ;carry <- no error +done: + .leave + ret + +notFound: + stc ;carry <- error + jmp done + +MapFontStyle endp diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/truetypeMacros.def new file mode 100644 index 000000000..02930d0ae --- /dev/null +++ b/Driver/Font/TrueType/truetypeMacros.def @@ -0,0 +1,70 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType +FILE: truetypeMacros.def + +AUTHOR: Falk Rehwagen, Jan 26, 2021 + +MACROS: + Name Description + ---- ----------- + Abs Absolute value of word + + TRUNC Truncate number + CEIL Get ceiling of number + ROUND Round number to integer + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/26/21 Initial revision + +DESCRIPTION: + Macros for the PC/GEOS TrueType font driver. + + $Id: truetypeMacros.def,v 1.1 21/01/26 11:45:27 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +; +; absolute value of integer +; +Abs macro int +local A_10 + tst int + jns A_10 + neg int +A_10: +endm + +; +;PASS: number in 16ths +;RETURN: floor(number), no fraction +; +TRUNC macro num + sar num, 1 + sar num, 1 + sar num, 1 + sar num, 1 +endm + +; +;PASS: number in 16ths +;RETURN: ceiling(number), no fraction +; +CEIL macro num + add num, FRACTION + TRUNC num +endm + +; +;PASS: number in 16ths +;RETURN: round(number), no fraction +; +ROUND macro num + add num, ONE_HALF + TRUNC num +endm diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/truetypeMetrics.asm new file mode 100644 index 000000000..647b96c0d --- /dev/null +++ b/Driver/Font/TrueType/truetypeMetrics.asm @@ -0,0 +1,63 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: MetricsMod +FILE: truetypeMetrics.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeCharMetrics Return character metric information. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial revision + +DESCRIPTION: + Routines for generating character metrics. + + $Id: truetypeMetrics.asm,v 1.1 97/04/18 11:45:29 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeCharMetrics +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Return character metrics information in document coords. +CALLED BY: DR_FONT_CHAR_METRICS - TrueTypeStrategy + +PASS: ds - seg addr of font info block + es - seg addr of GState + es:GS_fontAttr - font attributes + dx - character to get metrics of + cx - info to return (GCM_info) +RETURN: if GCMI_ROUNDED set: + dx - information (rounded) + else: + dx.ah - information (WBFixed) + carry - set if error (eg. data / font not available) +DESTROYED: none + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/ 1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeCharMetrics proc far + uses bx, cx, si, di, ds + .enter + + .leave + ret +TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/truetypePath.asm new file mode 100644 index 000000000..1b9950368 --- /dev/null +++ b/Driver/Font/TrueType/truetypePath.asm @@ -0,0 +1,107 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1991 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: GeoCalc +FILE: truetypePath.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenPath Generate path for character + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial revision + +DESCRIPTION: + Routines for generating graphics string of a character. + + $Id: truetypePath.asm,v 1.1 97/04/18 11:45:26 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenPath +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a path for the outline of a character +CALLED BY: DR_FONT_GEN_PATH (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in bx, locked) + dx - character to generate (Chars) + cl - FontGenPathFlags + FGPF_POSTSCRIPT - transform for use as Postscript + Type 1 or Type 3 font. + FGPF_SAVE_STATE - do save/restore for GState +RETURN: none +DESTROYED: ax, bx, di (on the way here) + +PSEUDO CODE/STRATEGY: +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenPath proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenPath endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenInRegion +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate a character in the passed RegionPath +CALLED BY: DR_FONT_GEN_IN_REGION (via TrueTypeStrategy) + +PASS: ds - seg addr of font info block + di - handle of GState (passed in BX) + dx - character to generate (Chars) + cx - RegionPath handle (locked) +RETURN: nothing +DESTROYED: ax, bx, di + +PSEUDO CODE/STRATEGY: + We want override some of the default functionality for + build a font's character. Essentially: + * Always build a character in a region + * Build this character in the passed region + + We accomplish this by: + 1) Find the character data + 2) Calculate/store the correct transformation + 3) Stuff in some new CharGenRouts + 4) Stuf in the pen position (in device coords) + 5) Go generate the character (via MakeBigCharInRegion) + +KNOWN BUGS/SIDE EFFECTS/IDEAS: +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 1/ 29/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenInRegion proc far + uses cx, dx, si, ds, es + .enter + + .leave + ret +TrueTypeGenInRegion endp + + diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def new file mode 100644 index 000000000..d5126e846 --- /dev/null +++ b/Driver/Font/TrueType/truetypeVariable.def @@ -0,0 +1,100 @@ + +COMMENT @---------------------------------------------------------------------- + + Copyright (c) GeoWorks 1989 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: Font Driver +FILE: truetypeVariable.def + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + Falk 11/6/89 Initial version + +DESCRIPTION: + initialized and unitialized variables for TrueType font driver + + $Id: nimbusVariable.def,v 1.1 97/04/18 11:45:28 newdeal Exp $ + +-----------------------------------------------------------------------------@ + + + +;------------------------------------------------------------------------------ +; Definition of variable block +;------------------------------------------------------------------------------ + +TrueTypeVars struct + +stackBot label byte +; +; The "stack" overlaps everything above this point +; + +x_offset sword ;x offset to create character +y_offset sword ;y offset to create character + +penPos Point <0, 0> ;pen position used for drawing + ;characters into a passed RegionPath + ;for NimbusGenInRegion(). +; +; Used to save passed variables: +; +genOffset word 0 ;offset of CharGenData +fontSegment word 0 ;seg addr of font +fontHandle hptr 0 ;handle of font +infoSegment word 0 ;seg addr of info block +gstateSegment word 0 ;seg addr of GState + +TrueTypeVars ends + +TrueTypeSubTable struct + TTST_scalerType dword + TTST_numTables word + TTST_searchRange word + TTST_entrySelector word + TTST_rangeShift word +TrueTypeSubTable ends + +TrueTypeTableDirectory struct + TTTD_tag dword + TTTD_checkSum dword + TTTD_offset dword + TTTD_length dword +TrueTypeTableDirectory ends + +TrueTypeOutlineEntry struc + TTOE_fontFileName DosDotFileName +TrueTypeOutlineEntry ends + +;------------------------------------------------------------------------------ + +;------------------------------------------------------------------------------ +; Initialized variables +;------------------------------------------------------------------------------ + +idata segment + +if DBCS_PCGEOS +truetypeDir wchar 'TTF',0 +else +truetypeDir char 'TTF',0 +endif + +idata ends + +;------------------------------------------------------------------------------ +; Uninitialized varaibles +;------------------------------------------------------------------------------ + +udata segment + +bitmapHandle hptr ;handle of our bitmap block +bitmapSize word ;size of our bitmap block (in bytes) + +variableHandle hptr ;handle of our variable block + +udata ends + + diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/truetypeWidths.asm new file mode 100644 index 000000000..df274e67b --- /dev/null +++ b/Driver/Font/TrueType/truetypeWidths.asm @@ -0,0 +1,69 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) GeoWorks 1990 -- All Rights Reserved + +PROJECT: PC GEOS +MODULE: TrueType Font Driver +FILE: truetypeWidths.asm + +AUTHOR: Falk Rehwagen, Jan 29, 2021 + +ROUTINES: + Name Description + ---- ----------- +EXT TrueTypeGenWidths Generate font header and widths for a font. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial revision + +DESCRIPTION: + Implements a font driver for: + The TrueType outline fonts + + $Id: truetypeWidths.asm,v 1.1 97/04/18 11:45:30 bluewaysw Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + TrueTypeGenWidths +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Generate the character width table for a font. +CALLED BY: EXTERNAL: GrFindFont + +PASS: di - 0 for new font; handle to rebuild old font (P'd) + es - seg addr of gstate (locked) + GS_fontAttr - font attributes + bp:cx - transformation matrix (TMatrix) + ds - seg addr of font info block +RETURN: bx - handle of font (locked) + ax - seg addr of font (locked) + carry - clear +DESTROYED: none + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + di is the bx passed to TrueTypeStrategy. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + FR 29/1/21 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +TrueTypeGenWidths proc far + uses cx, dx, si, di, ds, es, bp + + mov bx, bp + .enter + + clc ;indicate no error + + .leave + ret +TrueTypeGenWidths endp diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index f1568bd9c..4ad4c65a1 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,27 +4,27 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ - ttextend.c ttfile.c ttgload.c ttinterp.c ttload.c\ - ttmemory.c ttmutex.c ttobjs.c ttraster.c freetype.h\ - ft_conf.h fterrid.h ftnameid.h ftxkern.h header.h\ - ttcache.h ttcalc.h ttcmap.h ttconfig.h ttdebug.h\ - ttengine.h ttextend.h ttfile.h ttgload.h ttinterp.h\ - ttload.h ttmemory.h ttmutex.h ttobjs.h ttraster.h\ - tttables.h tttags.h tttypes.h -MAIN = mainManager.asm truetypeChars.asm truetypeEC.asm\ - truetypeEscape.asm truetypeInit.asm truetypeMetrics.asm\ - truetypePath.asm truetypeWidths.asm truetypeConstant.def\ - truetypeMacros.def truetypeVariable.def +MAIN = truetypeEscape.asm mainManager.asm truetypeWidths.asm\ + truetypeMetrics.asm truetypeInit.asm truetypeEC.asm\ + truetypeChars.asm truetypePath.asm truetypeMacros.def\ + truetypeVariable.def truetypeConstant.def +FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ + ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ + ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ + header.h ttinterp.h ttload.h tttables.h ttobjs.h\ + fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ + ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ + ttmemory.h tttags.h UI_TO_RDFS = -OBJS = ftxkern.obj ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj\ - ttdebug.obj ttextend.obj ttfile.obj ttgload.obj\ - ttinterp.obj ttload.obj ttmemory.obj ttmutex.obj\ - ttobjs.obj ttraster.obj +OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ + ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ + ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ + ttmemory.obj COMMON = MODULES = Main CMODULES = FreeType -SRCS = $(FREETYPE) $(MAIN) $(COMMON) +SRCS = $(MAIN) $(FREETYPE) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk From 4b5268edf5cc302cb79fd316369b9744fb303205 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 16 Jul 2022 21:30:09 +0200 Subject: [PATCH 043/246] Let's start with the integration of the FreeType engine into the TrueType driver. --- Driver/Font/TrueType/Adapter/ttadapter.c | 37 + Driver/Font/TrueType/Adapter/ttadapter.h | 36 + Driver/Font/TrueType/FreeType/ft_conf.h | 4 +- Driver/Font/TrueType/FreeType/header.h | 49 - Driver/Font/TrueType/FreeType/ttconfig.h | 2 +- Driver/Font/TrueType/Main/ansic_malloc.asm | 790 +++++++ Driver/Font/TrueType/Main/ansic_memory.asm | 421 ++++ Driver/Font/TrueType/Main/ansic_runtime.asm | 150 ++ Driver/Font/TrueType/Main/ansic_string.asm | 1936 +++++++++++++++++ Driver/Font/TrueType/Main/mainManager.asm | 16 + Driver/Font/TrueType/Main/truetypeInit.asm | 48 +- .../Font/TrueType/Main/truetypeVariable.def | 11 +- Driver/Font/TrueType/backlog.md | 76 + Driver/Font/TrueType/local.mk | 3 +- Driver/Font/TrueType/truetype.asm | 236 -- Driver/Font/TrueType/truetype.gp | 2 +- Driver/Font/TrueType/truetypeChars.asm | 62 - Driver/Font/TrueType/truetypeConstant.def | 104 - Driver/Font/TrueType/truetypeEC.asm | 99 - Driver/Font/TrueType/truetypeEscape.asm | 60 - Driver/Font/TrueType/truetypeInit.asm | 959 -------- Driver/Font/TrueType/truetypeMacros.def | 70 - Driver/Font/TrueType/truetypeMetrics.asm | 63 - Driver/Font/TrueType/truetypePath.asm | 107 - Driver/Font/TrueType/truetypeVariable.def | 100 - Driver/Font/TrueType/truetypeWidths.asm | 69 - Installed/Driver/Font/TrueType/Makefile | 31 +- .../Driver/Font/TrueType/dependencies.mk | 137 +- 28 files changed, 3619 insertions(+), 2059 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttadapter.c create mode 100644 Driver/Font/TrueType/Adapter/ttadapter.h delete mode 100644 Driver/Font/TrueType/FreeType/header.h create mode 100644 Driver/Font/TrueType/Main/ansic_malloc.asm create mode 100644 Driver/Font/TrueType/Main/ansic_memory.asm create mode 100644 Driver/Font/TrueType/Main/ansic_runtime.asm create mode 100644 Driver/Font/TrueType/Main/ansic_string.asm create mode 100644 Driver/Font/TrueType/backlog.md delete mode 100644 Driver/Font/TrueType/truetype.asm delete mode 100644 Driver/Font/TrueType/truetypeChars.asm delete mode 100644 Driver/Font/TrueType/truetypeConstant.def delete mode 100644 Driver/Font/TrueType/truetypeEC.asm delete mode 100644 Driver/Font/TrueType/truetypeEscape.asm delete mode 100644 Driver/Font/TrueType/truetypeInit.asm delete mode 100644 Driver/Font/TrueType/truetypeMacros.def delete mode 100644 Driver/Font/TrueType/truetypeMetrics.asm delete mode 100644 Driver/Font/TrueType/truetypePath.asm delete mode 100644 Driver/Font/TrueType/truetypeVariable.def delete mode 100644 Driver/Font/TrueType/truetypeWidths.asm diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c new file mode 100644 index 000000000..46cae88c2 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -0,0 +1,37 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttadapter.c + * + * AUTHOR: Jirka Kunze: July 5 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 7/5/22 JK Initial version + * + * DESCRIPTION: + * Functions to adapt the FreeGEOS font driver interface to the + * FreeType library interface. + * + ***********************************************************************/ + +#include "ttadapter.h" + + +TT_Error _pascal Init_FreeType() { + TT_Error error; + + error = TT_Init_FreeType(&tt_Engine); + + //TT_Init_Kerning + + return error; +} + +void _pascal Exit_FreeType() { + //TT_Done_FreeType +} \ No newline at end of file diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h new file mode 100644 index 000000000..692a3c7ec --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -0,0 +1,36 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttadapter.h + * + * AUTHOR: Jirka Kunze: July 5 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 05.07.22 JK Initial version + * + * DESCRIPTION: + * Declaration of global objects which are defined in assembler + * and are also needed in the c functions. + ***********************************************************************/ +#ifndef _TTADAPTER_H_ +#define _TTADAPTER_H_ + +#include +#include "../FreeType/freetype.h" + +/*********************************************************************** + * global dgoup objects + ***********************************************************************/ +extern TT_Engine tt_Engine; + + +/*********************************************************************** + * adapter functions + ***********************************************************************/ + +#endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index de3c0d233..0faffd4b9 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -8,11 +8,13 @@ #ifndef FT_CONF_H #define FT_CONF_H -/* Under FreeGEOS we need this for the file operations and render regions. */ +/* Under FreeGEOS we need this for the file operations, render regions and manage memory. */ #include #include #include #include +#include +#include /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Driver/Font/TrueType/FreeType/header.h b/Driver/Font/TrueType/FreeType/header.h deleted file mode 100644 index a7a493192..000000000 --- a/Driver/Font/TrueType/FreeType/header.h +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************* - * - * Function : - * - * Description : - * - * Input : - * - * Output : - * - * Notes : - * - ******************************************************************/ - -/******************************************************************* - * - * Function : - * - * Description : - * - * Input : None - * - * Output : Error code. - * - ******************************************************************/ - -/******************************************************************* - * - * Function : - * - * Description : - * - ******************************************************************/ - -/******************************************************************* - * - * Component Name (e.g. TTRaster.C) + eventually a version number. - * - * Component Short Description (e.g. Rasterizer). - * - * Copyright 1996 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. - * - ******************************************************************/ diff --git a/Driver/Font/TrueType/FreeType/ttconfig.h b/Driver/Font/TrueType/FreeType/ttconfig.h index 616a1a654..7cdbf28e5 100644 --- a/Driver/Font/TrueType/FreeType/ttconfig.h +++ b/Driver/Font/TrueType/FreeType/ttconfig.h @@ -164,7 +164,7 @@ /* The number of extensions available. Don't change this value */ /* except if you add new extensions to the engine. */ -#define TT_MAX_EXTENSIONS 8 +#define TT_MAX_EXTENSIONS 2 diff --git a/Driver/Font/TrueType/Main/ansic_malloc.asm b/Driver/Font/TrueType/Main/ansic_malloc.asm new file mode 100644 index 000000000..eb95d9c27 --- /dev/null +++ b/Driver/Font/TrueType/Main/ansic_malloc.asm @@ -0,0 +1,790 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: AnsiC library +FILE: malloc_asm.asm + +AUTHOR: Andrew Wilson, Sep 17, 1991 + +ROUTINES: + Name Description + ---- ----------- + _MALLOC allocs fixed memory + _REALLOC resizes fixed memory + _Free frees fixed memory + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/17/91 Initial revision + schoon 6/11/92 Revised for ANSI C standards + +DESCRIPTION: + This file contains the PC/GEOS implementations of the C routines + malloc(), calloc(), realloc(), cfree(), and free(). + +NOTES: + There are 2 allocation strategies used by this code. If the block size + is below MALLOC_LARGE_THRESHOLD, then it is allocated in one of the + fixed LMem heaps kept for this purpose. If the block size is above + the threshold, then the memory is allocated in a global memory block + by itself. Since the pointer to memory returned by the "large" strategy + is below any of the valid pointers returned by the "small" strategy + (due to the fact that the small blocks all lie beyond the + LMemBlockHeader at the start of the lmem blocks, while the large + blocks all lie at LARGE_BLOCK_OFFSET, which is less than the + LMemBlockHeader), we are able to tell which type of block it is just + by looking at the address. + + When we free these blocks, we have a different strategy for each. + When we free a large block, we just call MemFree on the block. If + it is a small block, we free the chunk, and then check to see if that + LMem block is now empty. If it isn't, we just exit. If it is, we scan + through the list of lmem blocks to see if it is the only lmem block. + if it isn't, we free it up (so we have at most one empty lmem block + hanging around per geode). + + In the GeodePrivData for each geode we keep 2 words - the first one + is the handle of a block containing a list of handles of lmem blocks + used for the small allocation scheme. The second one is the handle + of a block containing a list of handles of global memory blocks + containing blocks allocated via the large allocation scheme. + The format of these blocks is as follows: + + word numberOfEntriesInList ;This includes any empty slots + word entry1 + word entry2 + word entry3 + . + . + . + + $Id: malloc_asm.asm,v 1.1 97/04/04 17:42:12 newdeal Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +GEO_MALLOC_PASSED_SIZE_OF_ZERO enum FatalErrors +NULL_PTR_PASSED_TO_GEO_FREE enum FatalErrors +INVALID_PTR_PASSED_TO_GEO_REALLOC enum FatalErrors +COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT enum FatalErrors +LMEM_REALLOC_FAILED_WHEN_MAKING_CHUNK_SMALLER enum FatalErrors +MORE_THAN_ONE_FREE_MALLOC_BLOCK enum FatalErrors +FREE_CALLED_BEFORE_MALLOC enum FatalErrors +HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS enum FatalErrors + + +;RESIDENT segment word public 'CODE' +;MAINCODE segment word public 'CODE' +MAINCODE segment public 'CODE' + +.model medium, pascal + +GeodePrivReadOneWord proc near ;Returns value in CX + mov cx, 1 ;Read one word + push ax + segmov ds, ss + mov si, sp ;DS:SI <- ptr to word on stack + call GeodePrivRead + pop cx ; + ret +GeodePrivReadOneWord endp + +GeodePrivWriteOneWord proc near ;Pass value to write in CX + push cx + mov cx, 1 ;Write one word + segmov ds, ss + mov si, sp ;DS:SI <- ptr to word on stack + call GeodePrivWrite + pop cx ; + ret +GeodePrivWriteOneWord endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + AddHandleToMallocList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Adds a handle to the associated list of handles. + +CALLED BY: GLOBAL +PASS: ds:[LMBH_handle] - handle to add + bx - geode whose privData we should use + di - offset to pass to GeodePrivRead/GeodePrivWrite +RETURN: carry set if error +DESTROYED: bx, cx, dx, di, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +SLOT_INCREMENT equ 8 +AddHandleToMallocList proc near uses ds, es, bp, ax + .enter + +; Read in the handle of the block containing the list of blocks + + mov dx, ds:[LMBH_handle] + call GeodePrivReadOneWord + jcxz doMalloc ;If no block, allocate a new one + +; Scan through the block looking for an empty slot to store the new +; handle. + + mov bx, cx + call MemLock + mov es, ax +scanTop: + mov di, 2 + mov cx, es:[0] ;CX <- # items in block + clr ax + repne scasw ;Look for an empty spot + jne reAlloc ;Branch if no empty slots found + + mov es:[di][-2], dx ;Save handle in empty slot + clc ;Signify no errors +unlockExit: + call MemUnlock ;Unlock the block +exit: + .leave + ret +reAlloc: + +; No empty slots found, so reallocate the block bigger (create some). + + mov ax, es:[0] + inc ax ;AX <- # words in block currently + shl ax, 1 ;AX <- # bytes in block + add ax, SLOT_INCREMENT*2 ;Add room for 8 more slots + mov ch, mask HAF_ZERO_INIT + call MemReAlloc + jc unlockExit ;If error reallocing, branch + mov es, ax + add {word} es:[0], SLOT_INCREMENT ; + jmp scanTop +doMalloc: + +; ALLOCATE A NEW BLOCK TO HOLD DATA + + mov bp, bx ;BP <- geode handle + mov ax, SLOT_INCREMENT*2 ; + mov cx, ALLOC_DYNAMIC_LOCK or mask HF_SHARABLE or (mask HAF_ZERO_INIT shl 8) + call MemAllocSetOwnerOrDefault + jc exit ;If we could not allocate the block, + ; branch. + mov es, ax ; + mov {word} es:[0], SLOT_INCREMENT-1; + mov cx, bx ; + mov bx, bp ;BX <- GeodeHandle + call GeodePrivWriteOneWord ;Store the handle in the GeodePrivData + mov bx, cx ; area. + jnc scanTop ;If no error, branch + call MemFree ;Else, free up this block and exit. + stc + jmp exit +AddHandleToMallocList endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + RemoveHandleFromMallocList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Removes a handle from the associated list of handles. + +CALLED BY: GLOBAL +PASS: ds:[LMBH_handle] - handle to remove + bx - geode whose privData we should use + di - offset to pass to GeodePrivRead/GeodePrivWrite +RETURN: nothing +DESTROYED: ax, bx, cx, dx, di, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +RemoveHandleFromMallocList proc near uses es, ds + .enter + +; Read in the handle of the block containing the list of blocks + + mov dx, ds:[LMBH_handle] + call GeodePrivReadOneWord +EC < jcxz nullError ;If no block, allocate a new one > + +; Scan through the block looking for the passed handle. + + mov bx, cx + call MemLock + mov es, ax + mov di, 2 + mov cx, es:[0] ;CX <- # items in block + mov ax, dx + repne scasw ;Look for an empty spot +EC < ERROR_NZ HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS > + + mov {word} es:[di][-2], 0 ;Nuke handle + call MemUnlock + .leave + ret +EC +EC < ERROR FREE_CALLED_BEFORE_MALLOC > +RemoveHandleFromMallocList endp + + +if ERROR_CHECK +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ECCountFreeBlocksOnMallocList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Counts total number of malloc heaps with no items + +CALLED BY: _Free +PASS: bx - geode whose privData we should use + di - offset to pass to GeodePrivRead/GeodePrivWrite +RETURN: dx - # free blocks +DESTROYED: ax, bx, cx, di, si, ds, es + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +ECCountFreeBlocksOnMallocList proc near + .enter + +; Read in the handle of the block containing the list of blocks + + call GeodePrivReadOneWord + jcxz nullError ;If no block, fail + +; Traverse the block counting the # empty blocks + + mov bx, cx + call MemLock + push bx + mov ds, ax + mov si, 2 + mov cx, ds:[0] ;CX <- # items in block + clr dx +findNext: + lodsw + tst ax + jz next + xchg ax, bx + call MemDerefES + cmp es:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader + jne next ;If not empty, branch + inc dx ;Else, increment count of empty blocks +next: + loop findNext + pop bx + call MemUnlock ; + .leave + ret +nullError: + ERROR FREE_CALLED_BEFORE_MALLOC +ECCountFreeBlocksOnMallocList endp +endif + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + AllocInSmallList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Traverses the list of lmem blocks and tries to allocate + the passed # bytes in each one until it is successful + +CALLED BY: GLOBAL +PASS: bx - geode whose privData we should use + cx - # bytes to allocate +RETURN: ds:ax <- pointer to block allocated + carry set if unsuccessful +DESTROYED: ax, bx, cx, di, si, ds + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +AllocInSmallList proc near + .enter + +; Read in the handle of the block containing the list of blocks + + mov dx, cx ;DX <- size + push ds +NOFXIP< segmov ds, dgroup, di > +FXIP < push bx > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > +FXIP < pop bx > + mov di, ds:[mallocOffset] ; + pop ds + call GeodePrivReadOneWord + stc + jcxz exit ;If no blocks allocated, exit + +; Traverse the block and attempt to allocate in each one (ignoring +; empty slots). + + mov bx, cx + mov cx, dx ;CX <- # bytes to allocate + push bx + call MemLock + mov ds, ax + mov si, 2 + mov dx, ds:[0] ;CX <- # items in block +findNext: + lodsw + tst ax + jz next ;If handle is null, branch (empty slot) + mov di, ds ;. + xchg ax, bx ;BX <- handle of this lmem block + call MemDerefDS ;DS <- segment of this lmem block + call LMemAlloc ;Try to allocate here + jnc success ;Branch if no error allocating + mov ds, di ; +next: + dec dx ;Decrement # handles to try + jnz findNext ; + stc ;Unsuccessful, so unlock and exit w/carry set +success: + pop bx ;Unlock list of blocks + call MemUnlock ; +exit: + .leave + ret +AllocInSmallList endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + MemAllocFixed +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Just a front end to MemAlloc + +CALLED BY: GLOBAL +PASS: ax - size of block to alloc + bx - owner of block +RETURN: ds - segment of block + + rest of MemAlloc return values +DESTROYED: cx + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +MemAllocFixed proc near + mov cx, mask HF_FIXED or mask HF_SHARABLE + call MemAllocSetOwnerOrDefault + mov ds, ax + ret +MemAllocFixed endp + +MemAllocSetOwnerOrDefault proc near + tst bx ;If an owner is passed in, + jnz setOwner ; then set the owner. + call MemAlloc ;Else, use current process + jmp exit +setOwner: + call MemAllocSetOwner ;Try to allocate memory +exit: + ret +MemAllocSetOwnerOrDefault endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _MALLOC +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: This routine allocates fixed memory for C programs to use. + +C DECLARATION: + +extern void _far _pascal + *_MALLOC(size_t blockSize, GeodeHandle geodeHan, word zeroInit) + +NOTES: geodeHan can be 0, if you just want to use the current process' + malloc heap. + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/17/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +MALLOC_LARGE_THRESHOLD equ 511 +MALLOC_SMALL_BLOCK_SIZE equ 1024 +LARGE_BLOCK_OFFSET equ size hptr +global _MALLOC:far +_MALLOC proc far blockSize:word, geodeHan:hptr, zinit:word + uses ds, di, si + .enter + mov cx, blockSize +EC < tst cx > +EC < ERROR_Z GEO_MALLOC_PASSED_SIZE_OF_ZERO > + +; Mallocs of over MALLOC_LARGE_THRESHOLD should be put in their own +; fixed block. + + cmp cx, MALLOC_LARGE_THRESHOLD + ja largeAlloc + +; Scan through the list of fixed lmem blocks to allocate this +; small block. + + mov bx, geodeHan + call AllocInSmallList ;Try to allocate in various blocks + ; in small list (returns pointer in + ; DS:AX). + jnc zinitAndExit ;Branch if successful + +; Could not allocate in already existing lmem block, so allocate a new +; lmem block and allocate in it. + + mov ax, MALLOC_SMALL_BLOCK_SIZE + mov bx, geodeHan + call MemAllocFixed ;Try to allocate new lmem block. + jc errRet ;If unsuccessful, branch to exit. + mov ax, LMEM_TYPE_GENERAL + mov dx, size LMemBlockHeader + mov di, mask LMF_NO_HANDLES or mask LMF_NO_ENLARGE or mask LMF_RETURN_ERRORS + push bp + clr bp + call LMemInitHeap + pop bp + +; Allocate a new chunk on the just-allocated lmem heap. + + mov cx, blockSize + call LMemAlloc +EC < ERROR_C COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT > + clr di + jmp mallocCommon ;Branch to add block to list, and + ; to return pointer to block + +largeAlloc: + +; Allocate a fixed block on the heap with the handle of the block at the +; start, and the remainder of the block to be returned for use by the +; caller. + + + add cx, LARGE_BLOCK_OFFSET ;These blocks have the handle of the + xchg ax, cx ; block at the start. Put size in AX. + mov bx, geodeHan + call MemAllocFixed ; + jc errRet ;If we couldn't, branch + mov dx, bx ;DX <- handle of new block + mov ds:[0], bx ;Save handle of block + + + mov di, 2 ;DI <- offset to handle of block + ; containing list of large data blocks + ; (in the GeodePrivData area reserved + ; for the malloc routines). + mov ax, LARGE_BLOCK_OFFSET ;DS:AX <- pointer to data just alloc'd + +mallocCommon: + +; Get the offset to the GeodePriv area reserved for the malloc routines. + + push ds +NOFXIP< segmov ds, , bx > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + add di, ds:[mallocOffset] ; + pop ds + mov bx, geodeHan ; + call AddHandleToMallocList ;Add handle at DS:0 to malloc list + jc freeError ;If couldn't add to list, branch and + ; exit. +zinitAndExit: ; + mov dx, ds ;DX:AX <- pointer to data + tst zinit ;If no zero-init desired, just branch + jz exit + + push es, ax + mov es, dx ;ES:DI <- pointer to block + xchg di, ax + clr ax + mov cx, blockSize + shr cx, 1 + jnc 80$ + stosb +80$: + rep stosw + pop es, ax ;DX:AX <- pointer to block +exit: + .leave + ret + +freeError: + mov bx, dx ;Free up the block + call MemFree +errRet: + clr dx + clr ax + jmp exit +_MALLOC endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _Free +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Frees up a block previously returned from _Malloc. + +CALLED BY: GLOBAL +C DECLARATION: + extern void _far _pascal _Free(void *blockPtr, GeodeHandle geodeHan); + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global _FREE:far +_FREE proc far blockPtr:fptr, geodeHan:hptr + uses ds, di, si + .enter +EC < tst blockPtr.high > +EC < ERROR_Z NULL_PTR_PASSED_TO_GEO_FREE > + cmp blockPtr.low, LARGE_BLOCK_OFFSET + jne smallBlockFree + +; The free block was large (allocated as a single block on the global +; heap). Remove the block from the list, and free it up. + +NOFXIP< segmov ds, , di > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov di, ds:[mallocOffset] ;DI <- ptr to handle of large + add di, 2 ; block list in GeodePrivData +freeAndRemoveBlock: + mov bx, geodeHan ; + mov ds, blockPtr.segment + call RemoveHandleFromMallocList ; + mov bx, ds:[0] + call MemFree ;Free up the handle + jmp exit +smallBlockFree: + lds ax, blockPtr ;If small block, just free + call LMemFree ; up the chunk. We never + ; return this memory to the + ; global heap. + +; If the block is now empty, free it. + + cmp ds:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader + jne exit ; Branch if block is non-empty + + push ds +NOFXIP< segmov ds, , di > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov di, ds:[mallocOffset] ;DI <- ptr to handle of small + pop ds ; block list in GeodePrivData + +EC < mov bx, geodeHan ; > +EC < call ECCountFreeBlocksOnMallocList ; > +EC < cmp dx, 2 ; > +EC < ERROR_A MORE_THAN_ONE_FREE_MALLOC_BLOCK > + jmp freeAndRemoveBlock +exit: + .leave + ret +_FREE endp + + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _REALLOC +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: ReAllocates a previously _MALLOC'd block of memory. + +CALLED BY: GLOBAL + +C DECLARATION: extern void _far _pascal + *_REALLOC(void *blockPtr, size_t newSize, GeodeHandle geodeHan); + + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + * + * 1) If the space is resized larger, new space is *not* zero-initialized. + * + * 2) If realloc() is called to resize the memory *smaller*, it will + * always succeed. + * + * 3) If realloc() does not succeed, it will return NULL, and the original + * memory block will be unaffected. + * + * 4) If the passed blockPtr is NULL, realloc() acts like malloc(). + * + * 5) If the passed newSize is 0, the passed blockPtr is freed, and + * NULL is returned. + * + * 6) The block *may* move. + * +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global _REALLOC:far +_REALLOC proc far blockPtr:fptr, newSize:word, geodeHan:hptr + uses ds + .enter + +; Handle special goofy cases (null size or block ptr passed in) + + mov cx, newSize + tst blockPtr.high ;If null block ptr, pass off to malloc() + jz doMalloc ; + jcxz doFree ;If zero new size, pass off to free() + mov ds, blockPtr.high + cmp blockPtr.low, LARGE_BLOCK_OFFSET;If large block, use + je largeBlockReAlloc ; appropriate realloc method + +; If this is a "small" block, then try to LMemReAlloc it. If that fails, +; then try malloc-ing a new block, and copying the data over. + + mov ax, blockPtr.low ;DS:AX <- ptr to block + call LMemReAlloc ; + mov dx, ds ;DX:AX <- ptr to block +if 0 + jc 20$ ;Error + +; Copy data from blockptr to new chunk and delete blockptr. +; LMemRealloc does not always resize blockptr, instead it may +; allocate a new chunk. +; + cmp ax, blockPtr.low + je exit ;No new chunk, so done + push es, di, si + jmp 30$ ;Copy and delete. +else +; +; For LMF_NO_HANDLES, if LMemReAlloc has to allocate a new chunk, it will +; copy over the data itself and delete the old chunk, so we don't need to +; do this -- brianc 11/17/98 (yes, '98) +; + jnc exit +endif + +; Simple allocation failed. malloc() new block and copy the data over. +20$: + push es, di, si + push newSize + push geodeHan + clr ax + push ax + call _MALLOC + tst dx ;If malloc failed, branch + jz mallocFailed + +; Copy the data from the old block into the newly alloc'd block. +30$: + mov si, blockPtr.low ;DS:SI <- ptr to original block + ChunkSizePtr ds, si, cx ;CX <- size of original block (data to + ; copy over). +EC < cmp cx, newSize > +EC < ERROR_AE LMEM_REALLOC_FAILED_WHEN_MAKING_CHUNK_SMALLER > + mov es, dx + mov di, ax + shr cx, 1 + jnc 10$ + movsb +10$: + rep movsw + +; Free the old block up. + + push dx, ax + push blockPtr.high + push blockPtr.low + push geodeHan + call _FREE + pop dx, ax +mallocFailed: + pop es, di, si +exit: + .leave + ret +doFree: + push blockPtr.high + push blockPtr.low + push geodeHan + call _FREE + jmp clrRet +doMalloc: +EC < tst blockPtr.low > +EC < ERROR_NZ INVALID_PTR_PASSED_TO_GEO_REALLOC > + push cx ; newSize + push geodeHan + clr ax ;Do not zero init + push ax + call _MALLOC + jmp exit + +; For large blocks, the data lies in a global memory block by itself. +; Just call MemReAlloc routine. +largeBlockReAlloc: + mov ds, blockPtr.high + mov_tr ax, cx + add ax, LARGE_BLOCK_OFFSET + clr ch + mov bx, ds:[0] ;ReAllocate the block + call MemReAlloc + xchg dx, ax ;DX <- segment of fixed block + mov ax, LARGE_BLOCK_OFFSET ;DX:AX <- ptr to large block + jnc exit ;If no error in the realloc, branch +clrRet: + clr ax, dx + jmp exit +_REALLOC endp + +;RESIDENT ends +MAINCODE ends diff --git a/Driver/Font/TrueType/Main/ansic_memory.asm b/Driver/Font/TrueType/Main/ansic_memory.asm new file mode 100644 index 000000000..200194d14 --- /dev/null +++ b/Driver/Font/TrueType/Main/ansic_memory.asm @@ -0,0 +1,421 @@ +STRINGCODE segment word public 'CODE' +.model medium, pascal + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + memchr +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Search the given array of unsigned characters of the given + size for the first occurrence matching the given character. + +CALLED BY: External. + +PASS: const void *source = Array to search. + (For XIP system, *source can be pointing into the XIP + movable code resource.) + int value = Search for (unsigned char) val. + size_t count = Length of array in characters. + +RETURN: void * = NULL iff character not found. + Otherwise, pointer to the matching element. + +DESTROYED: Nada. + +SIDE EFFECTS: + Requires: ???? + + Asserts: ???? + +CHECKS: None. + +PSEUDO CODE/STRATEGY: + Check for silly case of zero length. + Search the given array for the given value. + If not found then + Set return pointer to NULL. + Otherwise, + Set return pointer to start of match. + +KNOWN DEFECTS/CAVEATS/IDEAS: + Note that this routine 'fails' if given a array length of zero (0). + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version. + JDM 93.03.23 Big update. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global MEMCHR:far +memchr equ MEMCHR +MEMCHR proc far source:fptr, value:word, count:word + uses di,es + .enter +if FULL_EXECUTE_IN_PLACE + ; + ; Make sure the fptr passed in is valid + ; +EC < pushdw bxsi > +EC < movdw bxsi, source > +EC < call ECAssertValidFarPointerXIP > +EC < popdw bxsi > +endif + + mov cx, count ; CX = Number of chars to search. + jcxz notFound ; Anything to search? No, quit. + + les di, source ; ES:DI = String to search. + mov ax, value ; AX = Character to search for. + repne scasb ; Search for it. + jne notFound ; Find it or bail. + dec di ; Found it. Fix up pointer. + mov dx, es ; DX:AX = Pointer to match. + mov ax, di +exit: + .leave + ret + +notFound: + clr ax, dx ; DX:AX = NULL. + jmp exit + +MEMCHR endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + memcmp +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Compare the two given arrays of unsigned characters. + +CALLED BY: External. + +PASS: const void *strOne = First character array. + const void *strTwo = Second character array. + (For XIP system, the string ptrs can be pointing into the XIP + movable code resource.) + size_t count = Length of arrays in characters. + +RETURN: int = 0 iff all elements equal. + > 0 iff the differing element from strOne is + greater than the element from strTwo. + < 0 iff the differing element from strOne is + less than the element from strTwo. + +DESTROYED: Nada. + +SIDE EFFECTS: + Requires: ???? + + Asserts: ???? + +CHECKS: None. + +PSEUDO CODE/STRATEGY: + Check for a passed array length of zero (0). + Compare the two given arrays until they don't match or length + characters have been looked at. + Subtract the last character looked at from strTwo from the last + character looked at in strOne to produce the return value. + +KNOWN DEFECTS/CAVEATS/IDEAS: ???? + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version. + JDM 93.03.23 Big update. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global MEMCMP:far +memcmp equ MEMCMP +MEMCMP proc far strOne:fptr, strTwo:fptr, count:word + uses di,si,ds,es + .enter +if FULL_EXECUTE_IN_PLACE + ; + ; Make sure the fptr passed in is valid. Anyway, it shouldn't crash + ; for any circumstances because we are now in fixed code resource. + ; +EC < pushdw bxsi > +EC < movdw bxsi, strOne > +EC < call ECAssertValidFarPointerXIP > +EC < movdw bxsi, strTwo > +EC < call ECAssertValidFarPointerXIP > +EC < popdw bxsi > +endif + + ; First, check for silly length. + clr ax ; Assume silly length. + mov cx, count ; CX = Number of chars to compare. + jcxz exit ; Exit iff CX == 0. + + ; Compare the strings. + les di, strOne ; ES:DI = strOne. + lds si, strTwo ; DS:SI = strTwo. + repe cmpsb + + ; Return difference of last two characters seen. + mov al, es:[di][-1] + sub al, ds:[si][-1] + cbw +exit: + .leave + ret +MEMCMP endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + memcpy +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Copy the first length characters from the second given + buffer into the first buffer as fast as possible. + +CALLED BY: External. + +PASS: void *dest = Buffer to copy to. + const void *source = Buffer to copy from. + (For XIP system, *source can be pointing into the XIP movable + code resource.) + size_t count = Number of characters to copy. + +RETURN: void * = 'dest' string. + +DESTROYED: Nada. + +SIDE EFFECTS: + Requires: ???? + + Asserts: ???? + +CHECKS: None. + +PSEUDO CODE/STRATEGY: ???? + Copy the given number of characters from the source character array + to the destination character array in the fastest possible manner. + +KNOWN DEFECTS/CAVEATS/IDEAS: + Note that as per the C language standard, this routine does *not* + handle overlap since that is slower than the version that does. If + you want to not have to worry about buffer overlap then use the + memmove function. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version. + JDM 93.03.23 Big rewrite. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global MEMCPY:far +memcpy equ MEMCPY +MEMCPY proc far dest:fptr, source:fptr, count:word + uses ds, si, es, di + .enter + + ; Check for any initial problems... + les di, dest ; ES:DI = destination string. + lds si, source ; DS:SI = source string. + mov cx, count ; CX = count. + jcxz exit ; Exit iff *no* number of chars... + shr cx ; Word-sized moves please. +if SUPPORT_32BIT_DATA_REGS + lahf ; Save carry flag for odd byte move + shr cx ; DWord-sized moves please. + rep movsd ; Move it! + jnc noWords ; Carry flag set from second shr. + movsw ; Copy the odd word +noWords: + sahf ; Restore carry flag from first shr. +else + rep movsw ; Move it! +endif + jnc exit ; Carry flag set from shr above. + movsb ; Move odd byte if necessary. +exit: + mov dx, es ; Return ptr to dest in DX:AX. + mov ax, dest.offset + .leave + ret +MEMCPY endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + memmove +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Copy the given 'count' char's from the 'source' string to + the given 'destination' string. + +CALLED BY: External. + +PASS: const void *destin = String to copy to. + void *source = String to copy from. + (For XIP system, *source can be pointing into the XIP + movable code resource.) + size_t count = Number of characters to copy. + +RETURN: void * = 'destin' string. + +DESTROYED: Nada. + +SIDE EFFECTS: + Requires: ???? + + Asserts: ???? + +CHECKS: None. + +PSEUDO CODE/STRATEGY: + Copy the given number of characters from the source character array + to the destination character array allowing for the overlap. + + If no overlap then copy the arrays in the 'forward' direction. + Otherwise, copy the arrays in the 'backwards' direction to ensure + that the value is read from the source array before it has been + overwritten in the destination array. + +KNOWN DEFECTS/CAVEATS/IDEAS: + Note that this assumes that the source and destination character + arrays overlap *only* if the segment registers are the same! + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + JDM 93.03.22 Initial version. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +global MEMMOVE:far +memmove equ MEMMOVE +MEMMOVE proc far destin:fptr, source:fptr, count:word + uses ds, si, es, di + .enter + + ; Check for any initial problems... + les di, destin ; ES:DI = destination string. + mov dx, es ; Return ptr to dest in DX:AX. + mov ax, di + lds si, source ; DS:SI = source string. + mov cx, count ; CX = count. + jcxz exit ; Exit iff *no* number of chars... + + ; Check for array overlap... (See note in header.) + mov bx, ds + cmp dx, bx ; Segments different? + jne forward ; Yep. Move it! + + ; Assert: + ; Source & destination segments are equal. + ; + ; If the destination offset comes before the source offset then no + ; need to worry about overlap since things will work already. + cmp di, si ; Destination < Source? + jb forward ; Yep. Move it! + + ; Assert: + ; Source & destination segments are equal. + ; Source offset <= Destination offset. + ; + ; If the end of the source array comes *after* the start of the + ; destination array then the arrays overlap and so we'll have to + ; copy the arrays from the ends to the beginning. + mov bx, si ; BX = Source offset. + add bx, cx ; BX += Character count. + cmp bx, di ; Overlap? + jbe forward ; Nope. Move it! + + ; Assert: Arrays overlap. + ; + ; Fix-up each array pointer to point to the end of the array. + mov si, bx ; BX from above. + dec si ; DS:SI = End of source array. + add di, cx ; DI += Character count. + dec di ; ES:DI = End of destinatation. + + std ; Move backwards through strings. + shr cx ; Move words. + jnc backward ; => no extra byte to move. + movsb ; Move final byte, since buffers... + ; ...tend to be word-aligned. +backward: + dec si ; Point to initial word to move... + dec di ; ...not final byte. + rep movsw ; Move it! + cld ; Clean up after ourselves. + jmp exit + +forward: + shr cx ; Word-sized moves please. + rep movsw ; Move it! + jnc exit ; Carry flag set from shr above. + movsb ; Move odd byte if necessary. +exit: + .leave + ret +MEMMOVE endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + memset +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Store the given character in each of the elements of the + given character array. + +CALLED BY: External. + +PASS: void *target = String to store into. + int value = Set each element to + (unsigned char) val. + size_t count = Number of replications. + +RETURN: void * = 'target' string. + +DESTROYED: Nada. + +SIDE EFFECTS: + Requires: ???? + + Asserts: The first 'length' number of characters of the + 'target' string has been set to the given 'value'. + +CHECKS: None. + +PSEUDO CODE/STRATEGY: + Check for silly zero (0) array length. + Write the value to the array by word-sized writes for efficiency + (write the odd byte at the end iff needed). + +KNOWN DEFECTS/CAVEATS/IDEAS: + Assumes that the string begins on a word-sized boundary. + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + JDM 93.03.23 Big update. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global MEMSET:far +memset equ MEMSET +MEMSET proc far target:fptr, value:word, count:word + uses di, es + .enter + + les di, target ; ES:DI = String to set. + mov dx, di ; ES:DX = String to set. + mov cx, count ; CX = Number of bytes to write. + jcxz exit ; Bail iff no bytes to write. + mov ax, value ; AL = (unsigned char) value; + mov ah, al ; Duplicate value for setting... + shr cx ; ...by word sized writes. + rep stosw ; Write it! + jnc exit ; Skip odd byte move if not needed. + stosb ; Store odd byte. +exit: + mov_trash ax, dx ; ES:AX = String to set. + mov dx, es ; DX:AX = String to set. + + .leave + ret +MEMSET endp + +STRINGCODE ends diff --git a/Driver/Font/TrueType/Main/ansic_runtime.asm b/Driver/Font/TrueType/Main/ansic_runtime.asm new file mode 100644 index 000000000..70704657a --- /dev/null +++ b/Driver/Font/TrueType/Main/ansic_runtime.asm @@ -0,0 +1,150 @@ +; Copyright 2020 Falk Rehwagen, Jirka Kunze +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + + +WCC_TEXT SEGMENT BYTE PUBLIC 'CODE' + ASSUME CS:WCC_TEXT + + public __U4M + public __U4D + public __I4M + public __I4D + +; __U4M +; __I4M +; +; Multiplies two 32bit integers (signed and unsigned). +; +; In: +; dx:ax int1 ( dx: high( int1 ); ax low( int1 ) ) +; cx:bx int2 ( cx: high( int2 ); bx low( int2 ) ) +; +; Out: +; dx:ax product of int1 and int2 +; +; Description: +; dx := low( high( int1 ) * low( int2 ) ) + --> part1 +; low( high( int2 ) * low( int1 ) ) + --> part2 +; high( low( int1 ) * low( int2 ) ) --> part3 +; ax := low( low( int1 ) * low( int2 ) ) --> part4 + + __U4M proc far + .fall_thru + __U4M endp + + __I4M proc far + + push bx ; save low( int2 ) + push ax ; save low( int1 ) + + xchg ax, dx ; ax := high( int1 ), dx := low( int1 ) + mul bx ; ax := low( high( int1 ) * low( int2 ) ) --> part1 + xchg ax, bx ; bx := part1, ax := low( int2 ) + + pop ax ; restore low( int1 ) + xchg ax, cx ; ax := high( int2 ), cx := low( int1 ) + mul cx ; ax := low( low( int1 ) * high( int2 ) ) --> part2 + add ax, bx ; ax := part1 + part2 + + xchg ax, cx ; cx := part1 + part2, ax := high( int2 ) + pop bx ; restore low( int2 ) + mul bx ; ax := low( high( int2 ) * low( int2 ) ) --> part4 + ; dx := high( high( int2 ) * low( int2 ) ) --> part3 + + add dx, cx ; dx := part 3 + part 1 + part 2 + + ret + + __I4M endp + +; __U4D +; +; Divide two 32 bit unsigned integers. +; +; In: +; dx:ax dividend +; cx:bx divisor +; +; Out: +; dx:ax qoutient +; cx:bx remainder +; +; Note: This is a temporary implementation. This function must be reimplemented in 8086 assembler instructions. + + .386 + __U4D proc far + + push dx ;push dividend in dx:ax to stack + push ax + push cx ;push divisor in cx:bx to stack + push bx + + pop ecx ;pop divisor from stack to ecx + pop eax ;pop low qword from stack to eax + mov edx, 0h ;set high qword of dividend to 0h + + div ecx ;unsigned divide + + push eax ;push quotient to stack + push edx ;push remainder to stack + + pop bx ;pop low word of remainder from stack to bx + pop cx ;pop high word of remainder from stack to cx + pop ax ;pop low word of qoutient from stack to ax + pop dx ;pop high word of qoutient from stack to dx + + ret + __U4D endp + +; __I4D +; +; Divide two 32 bit signed integers. +; +; In: +; dx:ax dividend +; cx:bx divisor +; +; Out: +; dx:ax qoutient +; cx:bx remainder +; +; Note: This is a temporary implementation. This function must be reimplemented in 8086 assembler instructions. + + .386 + __I4D proc far + + push dx ;push dividend in dx:ax to stack + push ax + push cx ;push divisor in cx:bx to stack + push bx + + pop ecx ;pop divisor from stack to ecx + pop eax ;pop low qword from stack to eax + + cdq ;extend dividend in eax to edx:eax + idiv ecx ;signed divide + + push eax ;push quotient to stack + push edx ;push remainder to stack + + pop bx ;pop low word of remainder from stack to bx + pop cx ;pop high word of remainder from stack to cx + pop ax ;pop low word of quotient from stack to ax + pop dx ;pop high word of quotient from stack to dx + + ret + __I4D endp + + +WCC_TEXT ENDS diff --git a/Driver/Font/TrueType/Main/ansic_string.asm b/Driver/Font/TrueType/Main/ansic_string.asm new file mode 100644 index 000000000..07dc97546 --- /dev/null +++ b/Driver/Font/TrueType/Main/ansic_string.asm @@ -0,0 +1,1936 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved + +PROJECT: AnsiC +FILE: string_asm.asm + +AUTHOR: Andrew Wilson, Aug 23, 1991 + +ROUTINES: + Name Description + ---- ----------- + strlen Get the length of the passed string + strchr Return ptr to first occurrence of char in + passed string + strrchr Return ptr to last occurrence of char in + passed string + strpos Return offset in TCHARS to first occurrence of char in + passed string + strrpos Return offset in TCHARS to last occurrence of char in + passed string + strcpy Copy second string onto first string + strncpy Copy up to N characters from second string onto + first string + (output not necessarily null terminated) + strcmp Compare equality of strings + strncmp Compare equality of strings up to N chars + strcat Copy second string after first string + strncat Copy up to N bytes from second string onto + first string + strspn Get # chars from start of first string that + exist in second string + strcspn Get # chars from start of first string that + do not exist in second string + strpbrk Return ptr (into first string) to the first + char from second string that is found + in first string + strrpbrk Return ptr (into first string) to the last + char from second string that is found + in first string + strstr Return ptr (into first string) to the first + occurrence of the second string + (excluding its final null) in + the first string + + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 8/23/91 Initial version + jenny 30/9/91 Added strstr + schoon 6/3/92 Updated to near ANSI C standards + +DESCRIPTION: + Assembly versions of ANSI C string routines. + + $Id: string_asm.asm,v 1.1 97/04/04 17:42:28 newdeal Exp $ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +STRINGCODE segment word public 'CODE' +.model medium, pascal +if ERROR_CHECK +ECCheckBoundsESDI proc near + segxchg es, ds + xchg si, di + call ECCheckBounds + xchg si, di + segxchg es, ds + ret +ECCheckBoundsESDI endp +ECCheckBoundsESDIMinusOne proc near + pushf + push di + dec di + call ECCheckBoundsESDI + pop di + popf + ret +ECCheckBoundsESDIMinusOne endp +ECCheckBoundsMinusOne proc near + pushf + push si + dec si + call ECCheckBounds + pop si + popf + ret +ECCheckBoundsMinusOne endp +endif + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strlen +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strlen + + +C DECLARATION word strlen(TCHAR far *str); + (For XIP system, *str can be pointing to the XIP movable + code resource.) + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global STRLEN:far +STRLEN proc far strPtr:fptr + uses es, di + .enter + les di, strPtr +EC < call ECCheckBoundsESDI > + mov cx, -1 +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > + not cx + dec cx ;Nuke count of null terminator + xchg ax, cx + .leave + ret +STRLEN endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strchr +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strchr + +C DECLARATION TCHAR far * strchr(TCHAR *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strchr:far +strchr proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 +EC < call ECCheckBoundsESDI > + mov cx, -1 +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > + not cx ;CX <- # chars including null + mov di, str1.offset + mov ax, theC +SBCS < repne scasb > ;Look for the character +DBCS < repne scasw > + jne notFound ;If not found, branch + dec di +DBCS < dec di > + mov dx, es ;DX:AX <- ptr to char found + xchg ax, di +exit: + .leave + ret +notFound: + clr dx ;If char not found, return NULL + clr ax + jmp exit +strchr endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strrchr +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strrchr + +C DECLARATION TCHAR far * strrchr(TCHAR *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strrchr:far +strrchr proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 + mov cx, -1 +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars including null + dec di ;DI <- ptr to null char +DBCS < dec di > + mov ax, theC + std +SBCS < repne scasb > ;Look for the character +DBCS < repne scasw > + cld + jne notFound ;If not found, branch + inc di +DBCS < inc di > + mov dx, es ;DX:AX <- ptr to char found + xchg ax, di +exit: + .leave + ret +notFound: + clr dx ;If char not found, return NULL + clr ax + jmp exit +strrchr endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strpos +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strpos + +C DECLARATION word strpos(TCHAR *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strpos:far +strpos proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 + mov cx, -1 +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars including null + mov di, str1.offset + mov ax, theC +SBCS < repne scasb > ;Look for the character +DBCS < repne scasw > + mov ax, -1 + jne exit ;If not found, branch + dec di +DBCS < dec di > + sub di, str1.offset + xchg ax, di ;AX <- offset to char in string +DBCS < shr ax > +exit: + .leave + ret +strpos endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strrpos +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strrpos + +C DECLARATION word strrpos(TCHAR *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strrpos:far +strrpos proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 + mov cx, -1 + clr ax +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars including null + dec di ;DI <- ptr to null char +DBCS < dec di > + mov ax, theC + std +SBCS < repne scasb > ;Look for the character +DBCS < repne scasw > + cld + mov ax, -1 + jne exit ;If not found, branch + inc di +DBCS < inc di > + sub di, str1.offset + xchg ax, di ;AX <- offset to char in string +DBCS < shr ax > +exit: + .leave + ret +strrpos endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcpy +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcpy + +C DECLARATION TCHAR far * strcpy(TCHAR far *dest, TCHAR far *source); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcpy:far +strcpy proc far destPtr:fptr, sourcePtr:fptr + uses ds, es, di, si + .enter + les di, sourcePtr ;ES:DI <- ptr to src string + mov ds, sourcePtr.segment + mov si, di ;DS:SI <- ptr to src string + + mov cx, -1 + clr ax +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars (+ null) in src string + + les di, destPtr ;ES:DI <- ptr to dest for string + mov dx, es ;DX:AX <- ptr to dest for string + mov ax, di + +SBCS < shr cx, 1 > +SBCS < jnc 10$ > +SBCS < movsb > +SBCS < 10$: > + rep movsw +EC < call ECCheckBoundsESDIMinusOne > + .leave + ret +strcpy endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + STRNCPY +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: STRNCPY + +C DECLARATION TCHAR far * strcpy(TCHAR far *dest, TCHAR far *source, word len); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global STRNCPY:far +STRNCPY proc far destPtr:fptr, sourcePtr:fptr, len:word + uses ds, es, di, si + .enter + + lds si, sourcePtr ;DS:SI <- ptr to src string + les di, destPtr ;ES:DI <- ptr to dest string + mov cx, len + jcxz exit +5$: +SBCS < lodsb > +DBCS < lodsw > +SBCS < tst al > +DBCS < tst ax > + jz 10$ +SBCS < stosb > +DBCS < stosw > + loop 5$ +exit: + .leave + ret +10$: +SBCS < rep stosb > ;Null pad the dest string +DBCS < rep stosw > +EC < call ECCheckBoundsMinusOne > +EC < call ECCheckBoundsESDIMinusOne > + jmp exit +STRNCPY endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcmp +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcmp + +C DECLARATION word strcmp(word far *str1, word far *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcmp:far +strcmp proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str1 ;ES:DI <- ptr to str1 + lds si, str2 ;DS:SI <- ptr to str 2 + mov cx, -1 + clr ax ; +SBCS < repne scasb > ; +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars in str 1 (w/null) + + mov di, str1.offset ;ES:DI <- ptr to str1 +SBCS < repe cmpsb > +DBCS < repe cmpsw > +EC < call ECCheckBoundsMinusOne > + jz exit ;If match, exit (with ax=0) +SBCS < mov al, es:[di][-1] > ;Else, return difference of chars> +DBCS < mov ax, es:[di][-2] > +SBCS < sub al, ds:[si][-1] > ; +DBCS < sub ax, ds:[si][-2] > +SBCS < cbw > ; +exit: + .leave + ret +strcmp endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strncmp +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strncmp + +C DECLARATION word strncmp(word far *str1, word far *str2, word len); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strncmp:far +strncmp proc far str1:fptr, str2:fptr, len:word + uses ds, es, di, si + .enter + clr ax ; + mov cx, len ; + jcxz exit ;If string is empty, return that they + ; are equal. + les di, str1 ;ES:DI <- ptr to str1 +SBCS < repne scasb > ;Get length of string +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + neg cx + add cx, len ;CX <- min (len, strlen(str1)+1); + lds si, str2 ;DS:SI <- ptr to str 2 + mov di, str1.offset ;ES:DI <- ptr to str1 +SBCS < repe cmpsb > +DBCS < repe cmpsw > +EC < call ECCheckBoundsMinusOne > +SBCS < mov al, es:[di][-1] > ;Return difference of chars +DBCS < mov ax, es:[di][-2] > +SBCS < sub al, ds:[si][-1] > ; +DBCS < sub ax, ds:[si][-2] > +SBCS < cbw > ; +exit: + .leave + ret +strncmp endp + + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcat +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcat + +C DECLARATION VOID * strcat(TCHAR far *str1, TCHAR far *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcat:far +strcat proc far str1:fptr, str2:fptr + uses es, ds, di, si + .enter + les di, str2 ; + lds si, str2 ; + +; GET LENGTH OF SECOND STRING + + clr ax + mov cx, -1 +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars in second string + null + +; SCAN TO END OF FIRST (DEST) STRING + + mov dx, cx ;DX <- size of second string + les di, str1 ;ES:DI <- ptr to str1 + mov cx, -1 ; +SBCS < repne scasb > ;ES:DI <- ptr past null +DBCS < repne scasw > + dec di ;ES:DI <- ptr to null byte of string +DBCS < dec di > +EC < call ECCheckBoundsESDI > + mov cx, dx ;CX <- size of second string + +; COPY SECOND STRING ONTO END OF FIRST STRING + +SBCS < shr cx, 1 > +SBCS < jnc 10$ > +SBCS < movsb > +SBCS <10$: > + rep movsw +EC < call ECCheckBoundsESDIMinusOne > +EC < call ECCheckBoundsMinusOne > + mov dx, es + mov ax, str1.offset + .leave + ret +strcat endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strncat +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strncat + +C DECLARATION VOID * strncat(TCHAR far *str1, TCHAR far *str2, word len); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + Name is in caps so routine can be published now that it's + fixed. + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strncat_old:far +; +; Exported as a place holder for the old, buggy strncat. +; +strncat_old proc far + REAL_FALL_THRU STRNCAT +endp + +global STRNCAT:far +STRNCAT proc far str1:fptr, str2:fptr, len:word + uses es, ds, di, si + .enter + les di, str1 ;ES:DI <- ptr to str1 + mov cx, -1 +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > + dec di ;ES:DI <- ptr to null-terminator for +DBCS < dec di > + ; str1 + mov cx, len ; + jcxz exit ;If string is empty, just exit + lds si, str2 +loopTop: +SBCS < lodsb > +DBCS < lodsw > +SBCS < tst al > +DBCS < tst ax > + jz 10$ +SBCS < stosb > +DBCS < stosw > + loop loopTop +SBCS < clr al> +DBCS < clr ax > +10$: +EC < call ECCheckBoundsMinusOne > +EC < call ECCheckBoundsESDI > +SBCS < stosb > +DBCS < stosw > +exit: + mov dx, es + mov ax, str1.offset + .leave + ret +STRNCAT endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcspn +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcspn + +C DECLARATION word strcspn(TCHAR *str1, TCHAR *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcspn:far +strcspn proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str2 ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov cx, -1 ;CX <- # chars in str2 not counting null +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx + dec cx + mov bx, cx + mov dx,-1 +loopTop: + inc dx ;DX <- # chars at start of str1 that aren't in + ; str2 +SBCS < lodsb > ;AL <- next char in str1 +DBCS < lodsw > +SBCS < tst al > +DBCS < tst ax > + jz exit + mov cx, bx ;CX <- # chars in string + mov di, str2.offset ;ES:DI <- ptr to str2 + jcxz loopTop +SBCS < repne scasb > +DBCS < repne scasw > + jnz loopTop ;If char not found, branch + + +exit: +EC < call ECCheckBoundsMinusOne > + xchg ax, dx ;AX <- # chars at start of str1 that do not lie + ; in str2 + .leave + ret +strcspn endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strspn +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strspn + +C DECLARATION word strspn(TCHAR *str1, TCHAR *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strspn:far +strspn proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str2 ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov cx, -1 ;CX <- # chars in str2 not counting null + clr ax +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx + dec cx + jcxz exit ;Exit if str2 is null + + mov bx, cx ;BX <- strlen(str2) + mov dx, -1 +loopTop: + inc dx ;DX <- # chars at start of str1 that are in + ; str2 +SBCS < lodsb > ;AL <- next char in str1 +DBCS < lodsw > +SBCS < tst al > ;Exit if at end of str1 +DBCS < tst ax > + jz 99$ ; + mov cx, bx ;CX <- # chars in string + mov di, str2.offset ;ES:DI <- ptr to str2 +SBCS < repne scasb > ; +DBCS < repne scasw > + jz loopTop ;If char found, branch + +99$: +EC < call ECCheckBoundsMinusOne > + xchg ax, dx ;AX <- # chars at start of str1 that lie + ; in str2 +exit: + .leave + ret +strspn endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strpbrk +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strpbrk + +C DECLARATION TCHAR *strpbrk(TCHAR *str1, TCHAR *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strpbrk:far +strpbrk proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str2 ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov cx, -1 ;CX <- # chars in str2 not counting null + clr ax +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx + dec cx + jcxz notFound ;Exit if str2 is null + + mov bx, cx ;BX <- strlen(str2) +loopTop: +SBCS < lodsb > ;AL <- next char in str1 +DBCS < lodsw > +SBCS < tst al > ;Exit if at end of str1 +DBCS < tst ax > + jz checkNotFound ; + mov cx, bx ;CX <- # chars in str2 + mov di, str2.offset ;ES:DI <- ptr to str2 +SBCS < repne scasb > ; +DBCS < repne scasw > + jnz loopTop ;If char not found, branch + dec si +DBCS < dec si > +EC < call ECCheckBounds > + movdw dxax, dssi ;DX:AX <- ptr to char in string1 +exit: + .leave + ret +checkNotFound: +EC < call ECCheckBoundsMinusOne > +notFound: + clrdw dxax + jmp exit +strpbrk endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strrpbrk +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strrpbrk + +C DECLARATION TCHAR *strrpbrk(TCHAR *str1, TCHAR *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strrpbrk:far +strrpbrk proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str1 + mov cx, -1 + clr ax +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx + dec cx + jcxz notFound ;if str1 is null, exit + mov dx, cx ;DX <- strlen(str1) + + mov ds, str1.segment + mov si, di +SBCS < sub si, 2 > ;DS:SI <- ptr to last char in str1 +DBCS < sub si, 4 > + + les di, str2 ;ES:DI <- ptr to str2 + mov cx, -1 ;CX <- strlen(str2) + clr ax ; +SBCS < repne scasb > ; +DBCS < repne scasw > + not cx ; +EC < call ECCheckBoundsESDIMinusOne > + dec cx ; + + jcxz notFound ;Exit if str2 is null + + mov bx, cx ;BX <- strlen(str2) +loopTop: +; +; DS:SI <- ptr to next char in str1 +; BX <- # chars in str2 +; DX <- # chars left to check in str1 +; + std +SBCS < lodsb > ;AL <- next char in str1 +DBCS < lodsw > + cld + mov cx, bx ;CX <- # chars in str2 + mov di, str2.offset ;ES:DI <- ptr to str2 +SBCS < repne scasb > ; +DBCS < repne scasw > + jz found ;If char found, branch + + dec dx ;Dec # chars to check in str1 + jnz loopTop + +notFound: + clr dx ;Return NULL + mov ax, dx + jmp exit +found: + inc si +DBCS < inc si > + movdw dxax, dssi ;DX:AX <- ptr to char in string1 +exit: + .leave + ret +strrpbrk endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strstr +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strstr + +C DECLARATION TCHAR far * strstr(TCHAR *str1, TCHAR *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + jenny 30/9/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strstr:far +strstr proc far str1:fptr, str2:fptr + uses ds, es, di, si + + .enter + les di, str1 ;ES:DI <- ptr to str1 + mov cx, -1 +SBCS < clr al> +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx + mov bx, cx ;BX <- # chars in str1 (w/ null) + + les di, str2 ;ES:DI <- ptr to str2 + mov cx, -1 +SBCS < clr al > +DBCS < clr ax > +SBCS < repne scasb > +DBCS < repne scasw > +EC < call ECCheckBoundsESDIMinusOne > + not cx ;CX <- # chars in str2 (w/ null) + sub bx, cx ;BX <- length diff. betw. str1 & str2 + jl notFound ;If str1 is shorter than str2, branch + dec cx + mov ax, cx ;AX <- # chars in str2 (without null) + + mov dx, str2.offset ;DX <- str2.offset + mov di, dx ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov bp, si ;BP <- str1.offset +cmpStrings: +SBCS < repe cmpsb > +DBCS < repe cmpsw > + jne notSameChar ;If not same char, branch + mov dx, ds ;DX:AX <- ptr to string found + mov ax, bp ; + jmp exit +notSameChar: + inc bp ;Increment offset into str1 +DBCS < inc bp > + mov si, bp ;DS:SI <- next str1 char to start with + mov di, dx ;ES:DI <- ptr to str2 + mov cx, ax ;CX <- # of chars in str2 + dec bx ;Decrement length diff. betw. str2 + ; and what remains of str1 + jge cmpStrings ;If str2 is not longer, branch +notFound: + clrdw dxax ;If string not found, return NULL +exit: + .leave + ret +strstr endp + +STRINGCODE ends + + +; +; For DBCS, SBCS versions +; +ifdef DO_DBCS + +STRINGCODESBCS segment byte public 'CODE' +.model medium, pascal + +if ERROR_CHECK +ECCheckBoundsESDISBCS proc near + segxchg es, ds + xchg si, di + call ECCheckBounds + xchg si, di + segxchg es, ds + ret +ECCheckBoundsESDISBCS endp +ECCheckBoundsESDIMinusOneSBCS proc near + pushf + push di + dec di + call ECCheckBoundsESDISBCS + pop di + popf + ret +ECCheckBoundsESDIMinusOneSBCS endp +ECCheckBoundsMinusOneSBCS proc near + pushf + push si + dec si + call ECCheckBounds + pop si + popf + ret +ECCheckBoundsMinusOneSBCS endp +endif + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strlensbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strlensbcs + + +C DECLARATION word strlensbcs(char far *str); + (For XIP system, *str can be pointing to the XIP movable + code resource.) + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global STRLENSBCS:far +STRLENSBCS proc far strPtr:fptr + uses es, di + .enter + les di, strPtr +EC < call ECCheckBoundsESDISBCS > + mov cx, -1 + clr al + repne scasb + not cx + dec cx ;Nuke count of null terminator + xchg ax, cx + .leave + ret +STRLENSBCS endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strchrsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strchrsbcs + +C DECLARATION char far * strchrsbcs(char *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strchrsbcs:far +strchrsbcs proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 +EC < call ECCheckBoundsESDISBCS > + mov cx, -1 + clr al + repne scasb + not cx ;CX <- # chars including null + mov di, str1.offset + mov ax, theC + repne scasb ;Look for the character + jne notFound ;If not found, branch + dec di + mov dx, es ;DX:AX <- ptr to char found + xchg ax, di +exit: + .leave + ret +notFound: + clr dx ;If char not found, return NULL + clr ax + jmp exit +strchrsbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strrchrsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strrchrsbcs + +C DECLARATION char far * strrchrsbcs(char *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strrchrsbcs:far +strrchrsbcs proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 + mov cx, -1 + clr al + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars including null + dec di ;DI <- ptr to null char + mov ax, theC + std + repne scasb ;Look for the character + cld + jne notFound ;If not found, branch + inc di + mov dx, es ;DX:AX <- ptr to char found + xchg ax, di +exit: + .leave + ret +notFound: + clr dx ;If char not found, return NULL + clr ax + jmp exit +strrchrsbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strpos +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strpos + +C DECLARATION word strpos(char *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strpossbcs:far +strpossbcs proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 + mov cx, -1 + clr al + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars including null + mov di, str1.offset + mov ax, theC + repne scasb ;Look for the character + mov ax, -1 + jne exit ;If not found, branch + dec di + sub di, str1.offset + xchg ax, di ;AX <- offset to char in string +exit: + .leave + ret +strpossbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strrpossbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strrpossbcs + +C DECLARATION word strrpossbcs(char *str1, word c); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strrpossbcs:far +strrpossbcs proc far str1:fptr, theC:word + uses es, di + .enter + les di, str1 + mov cx, -1 + clr ax + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars including null + dec di ;DI <- ptr to null char + mov ax, theC + std + repne scasb ;Look for the character + cld + mov ax, -1 + jne exit ;If not found, branch + inc di + sub di, str1.offset + xchg ax, di ;AX <- offset to char in string +exit: + .leave + ret +strrpossbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcpysbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcpysbcs + +C DECLARATION char far * strcpysbcs(char far *dest, char far *source); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcpysbcs:far +strcpysbcs proc far destPtr:fptr, sourcePtr:fptr + uses ds, es, di, si + .enter + les di, sourcePtr ;ES:DI <- ptr to src string + mov ds, sourcePtr.segment + mov si, di ;DS:SI <- ptr to src string + + mov cx, -1 + clr ax + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars (+ null) in src string + + les di, destPtr ;ES:DI <- ptr to dest for string + mov dx, es ;DX:AX <- ptr to dest for string + mov ax, di + + shr cx, 1 + jnc 10$ + movsb +10$: + rep movsw +EC < call ECCheckBoundsESDIMinusOneSBCS > + .leave + ret +strcpysbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strncpysbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strncpysbcs + +C DECLARATION char far * strcpysbcs(char far *dest, char far *source, word len); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strncpysbcs:far +strncpysbcs proc far destPtr:fptr, sourcePtr:fptr, len:word + uses ds, es, di, si + .enter + + lds si, sourcePtr ;DS:SI <- ptr to src string + les di, destPtr ;ES:DI <- ptr to dest string + mov cx, len + jcxz exit +5$: + lodsb + tst al + jz 10$ + stosb + loop 5$ +exit: + .leave + ret +10$: + rep stosb ;Null pad the dest string +EC < call ECCheckBoundsMinusOneSBCS > +EC < call ECCheckBoundsESDIMinusOneSBCS > + jmp exit +strncpysbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcmpsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcmpsbcs + +C DECLARATION word strcmpsbcs(word far *str1, word far *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcmpsbcs:far +strcmpsbcs proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str1 ;ES:DI <- ptr to str1 + lds si, str2 ;DS:SI <- ptr to str 2 + mov cx, -1 + clr ax ; + repne scasb ; +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars in str 1 (w/null) + + mov di, str1.offset ;ES:DI <- ptr to str1 + repe cmpsb +EC < call ECCheckBoundsMinusOneSBCS > + jz exit ;If match, exit (with ax=0) + mov al, es:[di][-1] ;Else, return difference of chars> + sub al, ds:[si][-1] ; + cbw ; +exit: + .leave + ret +strcmpsbcs endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strncmpsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strncmpsbcs + +C DECLARATION word strncmpsbcs(word far *str1, word far *str2, word len); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strncmpsbcs:far +strncmpsbcs proc far str1:fptr, str2:fptr, len:word + uses ds, es, di, si + .enter + clr ax ; + mov cx, len ; + jcxz exit ;If string is empty, return that they + ; are equal. + les di, str1 ;ES:DI <- ptr to str1 + repne scasb ;Get length of string +EC < call ECCheckBoundsESDIMinusOneSBCS > + neg cx + add cx, len ;CX <- min (len, strlen(str1)+1); + lds si, str2 ;DS:SI <- ptr to str 2 + mov di, str1.offset ;ES:DI <- ptr to str1 + repe cmpsb +EC < call ECCheckBoundsMinusOneSBCS > + mov al, es:[di][-1] ;Return difference of chars + sub al, ds:[si][-1] ; + cbw ; +exit: + .leave + ret +strncmpsbcs endp + + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcatsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcatsbcs + +C DECLARATION VOID * strcatsbcs(char far *str1, char far *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcatsbcs:far +strcatsbcs proc far str1:fptr, str2:fptr + uses es, ds, di, si + .enter + les di, str2 ; + lds si, str2 ; + +; GET LENGTH OF SECOND STRING + + clr ax + mov cx, -1 + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars in second string + null + +; SCAN TO END OF FIRST (DEST) STRING + + mov dx, cx ;DX <- size of second string + les di, str1 ;ES:DI <- ptr to str1 + mov cx, -1 ; + repne scasb ;ES:DI <- ptr past null + dec di ;ES:DI <- ptr to null byte of string +EC < call ECCheckBoundsESDISBCS > + mov cx, dx ;CX <- size of second string + +; COPY SECOND STRING ONTO END OF FIRST STRING + + shr cx, 1 + jnc 10$ + movsb +10$: + rep movsw +EC < call ECCheckBoundsESDIMinusOneSBCS > +EC < call ECCheckBoundsMinusOneSBCS > + mov dx, es + mov ax, str1.offset + .leave + ret +strcatsbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strncatsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strncatsbcs + +C DECLARATION VOID * strncatsbcs(char far *str1, char far *str2, word len); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + Name is in caps so routine can be published now that it's + fixed. + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global STRNCATSBCS:far +STRNCATSBCS proc far str1:fptr, str2:fptr, len:word + uses es, ds, di, si + .enter + les di, str1 ;ES:DI <- ptr to str1 + mov cx, -1 + clr al + repne scasb + dec di ;ES:DI <- ptr to null-terminator for + ; str1 + mov cx, len ; + jcxz exit ;If string is empty, just exit + lds si, str2 +loopTop: + lodsb + tst al + jz 10$ + stosb + loop loopTop + clr al +10$: +EC < call ECCheckBoundsMinusOneSBCS > +EC < call ECCheckBoundsESDISBCS > + stosb +exit: + mov dx, es + mov ax, str1.offset + .leave + ret +STRNCATSBCS endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strcspnsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strcspnsbcs + +C DECLARATION word strcspnsbcs(char *str1, char *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strcspnsbcs:far +strcspnsbcs proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str2 ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov cx, -1 ;CX <- # chars in str2 not counting null + clr al + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx + dec cx + mov bx, cx + mov dx,-1 +loopTop: + inc dx ;DX <- # chars at start of str1 that aren't in + ; str2 + lodsb ;AL <- next char in str1 + tst al + jz exit + mov cx, bx ;CX <- # chars in string + mov di, str2.offset ;ES:DI <- ptr to str2 + jcxz loopTop + repne scasb + jnz loopTop ;If char not found, branch + + +exit: +EC < call ECCheckBoundsMinusOneSBCS > + xchg ax, dx ;AX <- # chars at start of str1 that do not lie + ; in str2 + .leave + ret +strcspnsbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strspnsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strspnsbcs + +C DECLARATION word strspn(char *str1, char *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strspnsbcs:far +strspnsbcs proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str2 ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov cx, -1 ;CX <- # chars in str2 not counting null + clr ax + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx + dec cx + jcxz exit ;Exit if str2 is null + + mov bx, cx ;BX <- strlen(str2) + mov dx, -1 +loopTop: + inc dx ;DX <- # chars at start of str1 that are in + ; str2 + lodsb ;AL <- next char in str1 + tst al ;Exit if at end of str1 + jz 99$ ; + mov cx, bx ;CX <- # chars in string + mov di, str2.offset ;ES:DI <- ptr to str2 + repne scasb ; + jz loopTop ;If char found, branch + +99$: +EC < call ECCheckBoundsMinusOneSBCS > + xchg ax, dx ;AX <- # chars at start of str1 that lie + ; in str2 +exit: + .leave + ret +strspnsbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strpbrksbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strpbrk + +C DECLARATION char *strpbrksbcs(char *str1, char *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strpbrksbcs:far +strpbrksbcs proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str2 ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov cx, -1 ;CX <- # chars in str2 not counting null + clr ax + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx + dec cx + jcxz notFound ;Exit if str2 is null + + mov bx, cx ;BX <- strlen(str2) +loopTop: + lodsb ;AL <- next char in str1 + tst al ;Exit if at end of str1 + jz checkNotFound ; + mov cx, bx ;CX <- # chars in str2 + mov di, str2.offset ;ES:DI <- ptr to str2 + repne scasb ; + jnz loopTop ;If char not found, branch + dec si +EC < call ECCheckBounds > + movdw dxax, dssi ;DX:AX <- ptr to char in string1 +exit: + .leave + ret +checkNotFound: +EC < call ECCheckBoundsMinusOneSBCS > +notFound: + clrdw dxax + jmp exit +strpbrksbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strrpbrksbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strrpbrksbcs + +C DECLARATION char *strrpbrksbcs(char *str1, char *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 3/ 8/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strrpbrksbcs:far +strrpbrksbcs proc far str1:fptr, str2:fptr + uses ds, es, di, si + .enter + les di, str1 + mov cx, -1 + clr ax + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx + dec cx + jcxz notFound ;if str1 is null, exit + mov dx, cx ;DX <- strlen(str1) + + mov ds, str1.segment + mov si, di + sub si, 2 ;DS:SI <- ptr to last char in str1 + + les di, str2 ;ES:DI <- ptr to str2 + mov cx, -1 ;CX <- strlen(str2) + clr ax ; + repne scasb ; + not cx ; +EC < call ECCheckBoundsESDIMinusOneSBCS > + dec cx ; + + jcxz notFound ;Exit if str2 is null + + mov bx, cx ;BX <- strlen(str2) +loopTop: +; +; DS:SI <- ptr to next char in str1 +; BX <- # chars in str2 +; DX <- # chars left to check in str1 +; + std + lodsb ;AL <- next char in str1 + cld + mov cx, bx ;CX <- # chars in str2 + mov di, str2.offset ;ES:DI <- ptr to str2 + repne scasb ; + jz found ;If char found, branch + + dec dx ;Dec # chars to check in str1 + jnz loopTop + +notFound: + clr dx ;Return NULL + mov ax, dx + jmp exit +found: + inc si + inc si + movdw dxax, dssi ;DX:AX <- ptr to char in string1 +exit: + .leave + ret +strrpbrksbcs endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + strstrsbcs +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +C FUNCTION: strstrsbcs + +C DECLARATION char far * strstrsbcs(char *str1, char *str2); + +DESTROYED: various important but undocumented things + +PSEUDO CODE/STRATEGY: + This page intentionally left blank + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + jenny 30/9/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global strstrsbcs:far +strstrsbcs proc far str1:fptr, str2:fptr + uses ds, es, di, si + + .enter + les di, str1 ;ES:DI <- ptr to str1 + mov cx, -1 + clr al + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx + mov bx, cx ;BX <- # chars in str1 (w/ null) + + les di, str2 ;ES:DI <- ptr to str2 + mov cx, -1 + clr al + repne scasb +EC < call ECCheckBoundsESDIMinusOneSBCS > + not cx ;CX <- # chars in str2 (w/ null) + sub bx, cx ;BX <- length diff. betw. str1 & str2 + jl notFound ;If str1 is shorter than str2, branch + dec cx + mov ax, cx ;AX <- # chars in str2 (without null) + + mov dx, str2.offset ;DX <- str2.offset + mov di, dx ;ES:DI <- ptr to str2 + lds si, str1 ;DS:SI <- ptr to str1 + mov bp, si ;BP <- str1.offset +cmpStrings: + repe cmpsb + jne notSameChar ;If not same char, branch + mov dx, ds ;DX:AX <- ptr to string found + mov ax, bp ; + jmp exit +notSameChar: + inc bp ;Increment offset into str1 + mov si, bp ;DS:SI <- next str1 char to start with + mov di, dx ;ES:DI <- ptr to str2 + mov cx, ax ;CX <- # of chars in str2 + dec bx ;Decrement length diff. betw. str2 + ; and what remains of str1 + jge cmpStrings ;If str2 is not longer, branch +notFound: + clrdw dxax ;If string not found, return NULL +exit: + .leave + ret +strstrsbcs endp + +STRINGCODESBCS ends + +endif diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index 87294f055..9995cb3f1 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -81,6 +81,12 @@ ForceRef DriverTable idata ends +;TODO: remove dependencys from ansic +udata segment + mallocOffset word (?) + public mallocOffset +udata ends + include truetypeMacros.def WidthMod segment resource @@ -105,6 +111,12 @@ NimbusStart label near AA_NIMBUS_SIZE equ $-NimbusStart CharMod ends +;routines form GEOS adapter +global INIT_FREETYPE:far +global EXIT_FREETYPE:far + +global tt_Engine:TT_Engine + MetricsMod segment resource include truetypeMetrics.asm include truetypePath.asm @@ -117,6 +129,10 @@ include ../FontCom/fontcomEscape.asm InitMod ends include truetypeEC.asm +include ansic_runtime.asm +include ansic_memory.asm +include ansic_malloc.asm +include ansic_string.asm Resident segment resource ;MODULE_FIXED diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index e61f76018..f98fc3a71 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -85,12 +85,33 @@ TrueTypeInit proc far or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags call MemAllocSetOwner mov ds:variableHandle, bx ;save handle of block - clc ;indicate no error + ; + ; Initialize FreeType engine. + ; + + call InitEngine +noerror: + clc ;indicate no error +done: .leave ret TrueTypeInit endp +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + InitEngine +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +InitEngine proc far + .enter + call INIT_FREETYPE + .leave + ret + +InitEngine endp + COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TrueTypeExit @@ -125,12 +146,35 @@ EC < clr ds:bitmapHandle ;> mov bx, ds:variableHandle EC < clr ds:variableHandle ;> call MemFree ;done with variable block - clc ;indicate no error + call EXIT_FREETYPE ;finish FreeType engine + ;ax <- FreeType errorcode + test ax, 0 ;check for errors + jz noerror + stc + jmp exit +noerror: + clc ;indicate no error +exit: .leave ret TrueTypeExit endp + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ExitEngine +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +ExitEngine proc far + .enter + call EXIT_FREETYPE + .leave + ret + +ExitEngine endp + COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TrueTypeInitFonts diff --git a/Driver/Font/TrueType/Main/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def index d5126e846..f6f48dabd 100644 --- a/Driver/Font/TrueType/Main/truetypeVariable.def +++ b/Driver/Font/TrueType/Main/truetypeVariable.def @@ -64,10 +64,17 @@ TrueTypeTableDirectory struct TTTD_length dword TrueTypeTableDirectory ends -TrueTypeOutlineEntry struc +TrueTypeOutlineEntry struct TTOE_fontFileName DosDotFileName TrueTypeOutlineEntry ends +; +; TT_Engine structure of the FreeType framework +; +TT_Engine struct + z fptr +TT_Engine ends + ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ @@ -95,6 +102,8 @@ bitmapSize word ;size of our bitmap block (in bytes) variableHandle hptr ;handle of our variable block +tt_Engine TT_Engine ;structure for all FreeType variables + udata ends diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md new file mode 100644 index 000000000..7da163208 --- /dev/null +++ b/Driver/Font/TrueType/backlog.md @@ -0,0 +1,76 @@ +## Integration des FreeType Frameworks in den FreeGEOS TrueType Font-Treiber + +Der Treiber wird in 3 Schichten realisiert: +- die Treiberschicht + + ist in Assembler geschrieben + + implementiert die Strategiefunktionen des Treibers + + delegiert an die Funktionen der Adapterschicht + + der Code liegt unter /Main +- die Adapterschicht + + ist in c geschrieben + + implementiert eine Funktion je Strategiefunktion + + eigene Logik und delegieren an die FreeType Engine + + der Code liegt unter /Adapter +- die FreeType Schicht + + die angepasste Implementierung der FreeType Engine + + der Code liegt unter /FreeType + +### Speicherverwaltung +- TT_Engine auf MemHandle umstellen +- Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles umstellen +- Speicherverwaltungsmakros auf MemHandles umstellen +- Nutzer der Speicherverwaltungsmakros auf MemHandles umstellen + +### DR_INIT +- Wrapper für DR_INIT schreiben +- Aufruf in truetypeInit.asm + +### DR_EXIT +- Wrapper für DR_EXIT schreiben +- Aufruf in truetypeInit.asm + +### DR_FONT_GEN_CHAR +- Wrapper für DR_FONT_GEN_CHAR schreiben +- Aufruf in truetypeChars.asm + +### DR_FONT_GEN_WIDTHS +- Wrapper für DR_FONT_GEN_WIDTHS schreiben +- Aufruf in truetypeWidts.asm + +### DR_FONT_CHAR_METRICS +- Wrapper für DR_FONT_CHAR_METRICS schreiben +- Aufruf in truetypeMetrics.asm + +### DR_FONT_INIT_FONTS (geringe Priorität) +Die bisherigen Implementierung in Assembler kann auf die FreeType Engine umgestellt werden, somit vermeiden wir Redundanzen. Die akt. Implementierung scheint nicht korrekt zu funktionieren, das wird gleich mit behoben. +- Wrapper für DR_FONT_INIT_FONTS schreiben +- Aufruf in truetypeInit.asm + +### DR_FONT_GEN_PATH +- Wrapper für DR_FONT_GEN_PATH schreiben +- Aufruf in truetypePath.asm +- hier ist die Behandlung der Transformationsmatrizen noch unklar + +### DR_FONT_GEN_IN_REGION +- Wrapper für DR_FONT_GEN_REGION schreiben +- Aufruf in truetypePath.asm +- hier ist die Behandlung der Transformationsmatrizen noch unklar + +### sonstiges +- laden eines Fonts auf FileHandle umstellen +- diverse Segmente sind noch sehr groß (ttraster und ttinterp) -> prüfen wie diese verkleinert werden können +- diverse Strukturen prüfen ob diese noch verkleinert werden können + +### Aufräumarbeiten +- Abhängigkeit von Ansic auflösen (**sehr wichtig da jetzt im Sourcetree Codefragmente aus ansic liegen**) +- nicht genutzte Funktionen ausklammern +- Initalisierung des Graustufenarrays in TT_Init_FreeType entfernen +- das Graustufenarray kann aus TT_Engine entfernt werden +- Warnungen entfernen + +### Funktionen die ausgeklammert werden können +- TT_Open_Collection() +- TT_Set_Face_Pointer() +- TT_Get_Face_Pointer() +- TT_Set_Instance_Pointer() +- TT_Get_Instance_Pointer() diff --git a/Driver/Font/TrueType/local.mk b/Driver/Font/TrueType/local.mk index d30315277..4691964f0 100644 --- a/Driver/Font/TrueType/local.mk +++ b/Driver/Font/TrueType/local.mk @@ -13,7 +13,8 @@ # $Id: local.mk,v 1.1 97/04/18 11:45:28 newdeal Exp $ # ############################################################################### -ASMFLAGS += -i +#ASMFLAGS += -i +ASMFLAGS += -i -DFULL_EXECUTE_IN_PLACE=1 -DSUPPORT_32BIT_DATA_REGS=0 _PROTO = 3.0 diff --git a/Driver/Font/TrueType/truetype.asm b/Driver/Font/TrueType/truetype.asm deleted file mode 100644 index 5101133c2..000000000 --- a/Driver/Font/TrueType/truetype.asm +++ /dev/null @@ -1,236 +0,0 @@ -COMMENT @---------------------------------------------------------------------- - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - - -PROJECT: PC GEOS -MODULE: Font Driver -FILE: truetype.asm - -AUTHOR: Gene Anderson - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - Gene 11/03/89 Initial revision - -DESCRIPTION: - This file implements a font driver using TrueType. - - $Id: truetype.asm,v 1.1 97/04/18 11:45:30 newdeal Exp $ - -------------------------------------------------------------------------------@ - - -;------------------------------------------------------------------------------ -; System Definition -;------------------------------------------------------------------------------ - -_Driver = 1 -_FontDriver = 1 - -;------------------------------------------------------------------------------ -; Include files -;------------------------------------------------------------------------------ - -include geos.def -include heap.def -include geode.def -include resource.def -include ec.def -include driver.def -include graphics.def -include gstring.def -include sem.def -include file.def -include lmem.def -include font.def -include localize.def -include char.def -include system.def - -include fileEnum.def - -DefDriver Internal/fontDr.def -include Internal/tmatrix.def -include Internal/grWinInt.def -include Internal/gstate.def -include Internal/window.def -include Internal/threadIn.def - - - - - -; Font Driver specific include files -; -include truetypeConstant.def ; constants used for font driver -include truetypeVariable.def ; Variables - - -idata segment - -; Driver information table -; -DriverTable FontDriverInfoStruct < - , DRIVER_TYPE_FONT>, - FM_TRUETYPE ; FDIS_maker -> - -ForceRef DriverTable - -idata ends - -include truetypeMacros.def - -WidthMod segment resource -include truetypeWidths.asm -;include nimbusUtils.asm -;include nimbusSetTrans.asm -include fontcomUtils.asm -WidthMod ends - -CharMod segment resource -include truetypeChars.asm -;include nimbusRegions.asm -;include nimbusLoadFont.asm -;include nimbusBig.asm -;include nimbusBitmap.asm -NimbusStart label near -;include nimbusMakechar.asm -;include nimbusSegments.asm -;include nimbusTrans.asm -;include nimbusMul.asm -;include nimbusContinuity.asm -AA_NIMBUS_SIZE equ $-NimbusStart -CharMod ends - -MetricsMod segment resource -include truetypeMetrics.asm -include truetypePath.asm -MetricsMod ends - -InitMod segment resource -include truetypeInit.asm -include truetypeEscape.asm -include fontcomEscape.asm -InitMod ends - -include truetypeEC.asm - -Resident segment resource ;MODULE_FIXED - - -COMMENT }---------------------------------------------------------------------- - -FUNCTION: TrueTypeStrategy - -DESCRIPTION: Entry point for driver. All access to devices performed - through this function - -CALLED BY: EXTERNAL - -PASS: - di - one of the following function codes: - Function # routine called Function - ---------- -------------- -------- - DR_INIT NimbusInit initialize - DR_EXIT NimbusExit exit - DR_FONT_GEN_CHAR NimbusGenChar generate one char - DR_FONT_GEN_WIDTHS NimbusGenWidths generate char widths - DR_FONT_CHAR_METRICS NimbusCharMetrics return character metrics - DR_FONT_INIT_FONTS NimbusInitFonts init non-GEOS fonts - DR_FONT_GEN_PATH NimbusGenPath generate outline path - DR_FONT_GEN_IN_REGION NimbusGenInRegion gen in passed region - -RETURN: - depends on function called - carry - set if error - -DESTROYED: - depends on function called - -REGISTER/STACK USAGE: - -PSEUDO CODE/STRATEGY: - Calls routine from jump table - -KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - Gene 5/89 modified for font driver - -------------------------------------------------------------------------------} - - -EC - -TrueTypeStrategy proc far - -EC < tst cs:[inDriverFlag] > -EC < ERROR_NZ RECURSIVE_CALL_TO_FONT_DRIVER > -EC < inc cs:[inDriverFlag] > - - tst di ;escape function (>=0x8000) ? - js escapeFunction ;branch if escape function - - push bx -EC < cmp di, (size offTable) ;> -EC < ERROR_AE FONT_BAD_ROUTINE ;> - mov ax, cs:offTable[di] ;ax <- addr of routine in module - mov bx, cs:hanTable[di] ;bx <- handle of module - pop di ;pass old bx in di - tst bx ; function supported? - jz ignoreCall ; => no (carry clear) - call ProcCallModuleRoutine -callComplete: -EC < mov cs:[inDriverFlag],0 > -done: -EC < call ECNukeVariableBlock ;> - ret - -ignoreCall: - mov bx, di - jmp callComplete - - ; - ; The function is an escape function, so we deal with it specially - ; -escapeFunction: - call TrueTypeFontEscape - jmp done - -;---------------------------- - -TrueTypeStrategy endp - -offTable nptr \ - offset TrueTypeInit, ;DR_INIT - offset TrueTypeExit, ;DR_EXIT - 0, ;DR_SUSPEND - 0, ;DR_UNSUSPEND - offset TrueTypeGenChar, ;DR_FONT_GEN_CHAR - offset TrueTypeGenWidths, ;DR_FONT_GEN_WIDTHS - offset TrueTypeCharMetrics, ;DR_FONT_CHAR_METRICS - offset TrueTypeInitFonts, ;DR_FONT_INIT_FONTS - offset TrueTypeGenPath, ;DR_FONT_GEN_PATH - offset TrueTypeGenInRegion ;DR_FONT_GEN_IN_REGION -hanTable hptr \ - handle InitMod, ;DR_INIT - handle InitMod, ;DR_EXIT - 0, ;DR_SUSPEND - 0, ;DR_UNSUSPEND - handle CharMod, ;DR_FONT_GEN_CHAR - handle WidthMod, ;DR_FONT_GEN_WIDTHS - handle MetricsMod, ;DR_FONT_CHAR_METRICS - handle InitMod, ;DR_FONT_INIT_FONTS - handle MetricsMod, ;DR_FONT_GEN_PATH - handle MetricsMod ;DR_FONT_GEN_IN_REGION - -CheckHack <(length offTable) eq (length hanTable)> - -Resident ends - - end diff --git a/Driver/Font/TrueType/truetype.gp b/Driver/Font/TrueType/truetype.gp index 8b3bee350..20b3ff5cb 100644 --- a/Driver/Font/TrueType/truetype.gp +++ b/Driver/Font/TrueType/truetype.gp @@ -26,7 +26,7 @@ type driver, single # Import kernel routine definitions # library geos -library ansic +#library ansic # # Desktop-related things # diff --git a/Driver/Font/TrueType/truetypeChars.asm b/Driver/Font/TrueType/truetypeChars.asm deleted file mode 100644 index 4f5ecbdda..000000000 --- a/Driver/Font/TrueType/truetypeChars.asm +++ /dev/null @@ -1,62 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: RasterMod -FILE: truetypeChars.asm - -AUTHOR: Falk Rehwagen - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/1/21 Initial revision - -DESCRIPTION: - This file contains routines for generating individual characters. - - $Id: truetypeChars.asm,v 1.1 97/04/18 11:45:31 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenChar -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate one character for a font. -CALLED BY: VidBuildChar (via TrueTypeStrategy) - -PASS: dx - character to build (Chars) - es - seg addr of font (locked) - bp - seg addr of gstate (locked) - GS_fontHandle - handle of font - GS_fontAttr - font attributes - ds - seg addr of font info block - -RETURN: es - seg addr of font (locked) (may have changed) - carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/ 1/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenChar proc far - uses ax, bx, cx, dx, ds, si, di, bp - .enter - - - .leave - stc ;indicate no error - ret -TrueTypeGenChar endp - - diff --git a/Driver/Font/TrueType/truetypeConstant.def b/Driver/Font/TrueType/truetypeConstant.def deleted file mode 100644 index 942764157..000000000 --- a/Driver/Font/TrueType/truetypeConstant.def +++ /dev/null @@ -1,104 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: Font Driver -FILE: truetypeConstant.def - -AUTHOR: Falk Rehwagen - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 26/1/21 Initial revision - -DESCRIPTION: - Definitions, constants, etc needed for the PC/GEOS TrueType font driver - - $Id: truetypeConstant.def,v 1.1 21/01/26 11:45:25 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -;---------------------------------------------------------------------------- -; Font Style Factors -;---------------------------------------------------------------------------- - -SCRIPT_FACTOR_INT = 0 -SCRIPT_FACTOR_FRAC = 0x8000 ;superscript,subscript = 1/2 - -SUBSCRIPT_OFFSET_INT = 0 -SUBSCRIPT_OFFSET_FRAC = 0x1a00 ;offset below - -SUPERSCRIPT_OFFSET_INT = 0 -SUPERSCRIPT_OFFSET_FRAC = 0x6000 ;offset above - -BOLD_FACTOR_INT = 0x0001 -BOLD_FACTOR_FRAC = 0x2000 ;bold = 1.10 - -ITALIC_FACTOR_INT = 0 -ITALIC_FACTOR_FRAC = 0x366A ;italic = tan(12) -NEG_ITALIC_FACTOR_INT = 0xffff -NEG_ITALIC_FACTOR_FRAC = 0xC996 ;italic = -tan(12) - -; -; Styles that affect the width of the character: -; -WIDTH_STYLES = mask TS_SUPERSCRIPT or \ - mask TS_SUBSCRIPT or \ - mask TS_BOLD -; -; Styles that affect the transformation matrix used: -; -TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ - mask TS_SUBSCRIPT or \ - mask TS_ITALIC or \ - mask TS_BOLD - -;---------------------------------------------------------------------------- -; Miscellaneous constants -;---------------------------------------------------------------------------- - -DEFAULT_CHAR = '.' - -; -; These sizes are in pixels, not points, since that's what -; really matters for these cutoff points. -; -; Continuity checking is not done above: -; -MAX_CONTINUITY_SIZE = 30 -; -; Characters are stored as regions instead of bitmaps above: -; -MAX_BITMAP_SIZE = 125 -SCRIPT_SAFETY_SIZE = 10 - -TRUETYPE_BLOCK_SIZE equ 1024 ;initial block size - -;---------------------------------------------------------------------------- -; Region constants -;---------------------------------------------------------------------------- - -UNUSED_PER_LINE = 4 ;# of unused points / line - -;---------------------------------------------------------------------------- -; Font Errors -;---------------------------------------------------------------------------- - -if ERROR_CHECK - -FONT_BAD_CHAR_FLAG enum FatalErrors - -RECURSIVE_CALL_TO_FONT_DRIVER enum FatalErrors -; The TrueType driver is non-reentrant, so only one thread can be in the -; driver at a time. This may indicate a bug in the Font Manager. - -FONT_BAD_ROUTINE enum FatalErrors -; A bad function passed to the TrueType driver. The function passed in -; di must be in the FontFunction enumerated type. - -TRUETYPE_INTERNAL_ERROR enum FatalErrors - -endif - diff --git a/Driver/Font/TrueType/truetypeEC.asm b/Driver/Font/TrueType/truetypeEC.asm deleted file mode 100644 index a87edeb5b..000000000 --- a/Driver/Font/TrueType/truetypeEC.asm +++ /dev/null @@ -1,99 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) blueway.Softworks 2021 -- All Rights Reserved - -PROJECT: PC/GEOS -MODULE: truetypeEC.asm -FILE: truetypeEC.asm - -AUTHOR: Falk Rehwagen, Jan 1, 2021 - -ROUTINES: - Name Description - ---- ----------- - ECNukeVariableBlock nuke variables so we don't inadvertently - re-use them - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial revision - -DESCRIPTION: - Error checking code for TrueType driver - - $Id: truetypeEC.asm,v 1.1 21/01/24 11:45:31 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -if ERROR_CHECK - -CharMod segment resource - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ECNukeVariableBlock -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Nuke the TrueType variable block -CALLED BY: NimbusStrategy() - -PASS: none -RETURN: none -DESTROYED: none (flags preserved) - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/29/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -ECNukeVariableBlock proc far - uses ax, bx, cx, di, es - .enter - - pushf - - ; - ; Lock the variable block - ; - mov ax, segment udata - mov es, ax ;es <- seg addr of idata - mov bx, es:variableHandle ;bx <- handle of vars - tst bx ;block freed? - jz done ;branch if freed - call MemLock - jc done ;branch if discarded - mov es, ax ;es <- seg addr of vars - ; - ; Zero the block - ; - clr al ;al <- byte to store - mov cx, (size TrueTypeVars) ;cx <- # of bytes - clr di ;es:di <- ptr to vars - rep stosb - ; - ; Nuke things we know are segments specially - ; - mov es:fontSegment, 0xa000 - mov es:gstateSegment, 0xa000 - mov es:infoSegment, 0xa000 - ; - ; All done... - ; - call MemUnlock -done: - - popf - - .leave - ret -ECNukeVariableBlock endp - - -CharMod ends - -endif - diff --git a/Driver/Font/TrueType/truetypeEscape.asm b/Driver/Font/TrueType/truetypeEscape.asm deleted file mode 100644 index 3f3f33d6f..000000000 --- a/Driver/Font/TrueType/truetypeEscape.asm +++ /dev/null @@ -1,60 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) blueway.Softworks 2021 -- All Rights Reserved - -PROJECT: PC/GEOS -MODULE: truetypeEscape.asm -FILE: truetypeEscape.asm - -AUTHOR: Falk Rehwagen, Jan 24, 2021 - -ROUTINES: - Name Description - ---- ----------- - TrueTypeFontEscape handle any escape functions - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial revision - -DESCRIPTION: - Code for handling driver escape functions - - $Id: truetypeEscape.asm,v 1.1 21/01/24 11:45:26 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeFontEscape -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Hand -CALLED BY: TrueTypeStrategy() - -PASS: di - escape function -RETURN: di - 0 if escape function not supported -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeFontEscape proc far - call FontCallEscape ;call general handling routine - ret -TrueTypeFontEscape endp - -;---------------------------------------------------------------------------- -; Escape Function Table -;---------------------------------------------------------------------------- - -DefEscapeTable 1 - -DefEscape FontQueryEscape, DRV_ESC_QUERY_ESC diff --git a/Driver/Font/TrueType/truetypeInit.asm b/Driver/Font/TrueType/truetypeInit.asm deleted file mode 100644 index e61f76018..000000000 --- a/Driver/Font/TrueType/truetypeInit.asm +++ /dev/null @@ -1,959 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) blueway.Softworks 2021 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: Init -FILE: truetypeInit.asm - -AUTHOR: Falk Rehwagen, Jan 24, 2021 - -ROUTINES: - Name Description - ---- ----------- - TrueTypeInit initialize the TrueType font driver - TrueTypeExit clean up after TrueType font driver - TrueTypeInitFonts initialize any non-PC/GEOS fonts - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 01/24/21 Initial revision - -DESCRIPTION: - Initialization & exit routines for TrueType font driver - - $Id: truetypeInit.asm,v 1.1 21/01/24 11:45:29 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeInit -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Initialize the TrueType font driver. -CALLED BY: DR_INIT - TrueTypeStrategy - -PASS: none -RETURN: bitmapHandle - handle of block to use for bitmaps - bitmapSize - size of above block (0 at start) - variableHandle - handle of block containing variables - carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 01/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - public TrueTypeInit -TrueTypeInit proc far - uses ax, bx, cx, si, di, ds, es - .enter - - mov ax, segment udata - mov ds, ax ;ds <- seg addr of vars - ; - ; First, we need a block of memory to use as a bitmap - ; for generating characters. We don't need to actually - ; allocate memory for it yet. - ; - mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block - mov bx, handle 0 ;bx <- make TrueType owner - mov cx, mask HF_DISCARDABLE \ - or mask HF_SWAPABLE \ - or mask HF_SHARABLE \ - or mask HF_DISCARDED \ - or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags - call MemAllocSetOwner - mov ds:bitmapHandle, bx ;save handle of block - mov ds:bitmapSize, 0 ;no bytes yet - ; - ; We also need a block to use for variables. We don't - ; need it yet, either. - ; - mov ax, size TrueTypeVars ;ax <- size of block - mov bx, handle 0 ;bx <- make TrueType owner - mov cx, mask HF_DISCARDABLE \ - or mask HF_SWAPABLE \ - or mask HF_SHARABLE \ - or mask HF_DISCARDED \ - or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags - call MemAllocSetOwner - mov ds:variableHandle, bx ;save handle of block - clc ;indicate no error - - .leave - ret -TrueTypeInit endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeExit -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Free up blocks used and exit the TrueType driver. -CALLED BY: DR_EXIT - TrueTypeStrategy - -PASS: bitmapHandle - handle of bitmap block - variableHandle - handle of variable block -RETURN: carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeExit proc far - uses ax, bx, ds - .enter - - mov ax, segment udata - mov ds, ax ;ds <- seg addr of vars - mov bx, ds:bitmapHandle -EC < clr ds:bitmapHandle ;> - call MemFree ;done with bitmap block - mov bx, ds:variableHandle -EC < clr ds:variableHandle ;> - call MemFree ;done with variable block - clc ;indicate no error - - .leave - ret -TrueTypeExit endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeInitFonts -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Initialize any non-GEOS fonts for the font driver. -CALLED BY: DR_FONT_INIT_FONTS - TrueTypeStrategy - -PASS: ds - seg addr of font info block -RETURN: carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/24/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -initFontReturnAttr FileExtAttrDesc \ - , - - -TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp - - .enter - - ; - ; Enumerate files in SP_FONT - ; - call FilePushDir - mov ax, SP_FONT - call FileSetStandardPath - push ds - segmov ds, dgroup, ax - mov dx, offset truetypeDir - clr bx ; relative to CWD - call FileSetCurrentPath - pop ds - - ; - ; Lookup all .ttf files - sub sp, size FileEnumParams - mov bp, sp - ; GEOS datafiles - mov ss:[bp].FEP_searchFlags, mask FESF_NON_GEOS - ; return longname - mov ss:[bp].FEP_returnAttrs.segment, cs - mov ss:[bp].FEP_returnAttrs.offset, offset initFontReturnAttr - mov ss:[bp].FEP_returnSize, size FileLongName - mov ss:[bp].FEP_bufSize, FE_BUFSIZE_UNLIMITED - ; callback sees all files - mov ss:[bp].FEP_matchAttrs.segment, 0 - - mov ss:[bp].FEP_skipCount, 0 - call FileEnum ; cx = # found, bx = handle - jc done ; error - jcxz done ; no files found - mov dx, ds ; ax = segment of font block - call MemLock ; ds:0 = first entry - mov ds, ax - mov si, 0 -fontLoop: - call ProcessFont - add si, size FileLongName - loop fontLoop - call MemFree ; free file block -done: - call FilePopDir - clc - .leave - ret - -TrueTypeInitFonts endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ProcessFont -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: initialize each font found - -CALLED BY: TrueTypeInitFonts - -PASS: ds:si - font file name (TTF) - dx - font block segment - -RETURN: dx - updated font block segment (may move) - -DESTROYED: none - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 2/17/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -ProcessFont proc far - - uses ax, bx, cx, di, si, es, ds - -fontNameSeg local sptr push ds -fontNameOff local word push si -fontBlockSeg local sptr push dx -subTableHeader local TrueTypeSubTable -tableDirectory local TrueTypeTableDirectory -fontId local FontID -fontInfoChunk local word -tableCount local word -fontFile local hptr -fontName local FONT_NAME_LEN dup (char) -fontStyle local TextStyle -fontWeight local FontWeight - - .enter - ; - ; generate font id from file names first character for now - ; - mov fontWeight, FW_NORMAL - - clr ah - mov al, ds:[si] - add ax, FM_TRUETYPE - mov fontId, ax - - ; - ; open truetype file - ; - mov dx, si ; ds:dx = name - mov al, FILE_ACCESS_R or FILE_DENY_W - call FileOpen - jc done - - mov bx, ax ; file handle to bx - mov fontFile, bx - - segmov ds, ss - lea dx, subTableHeader - - mov al, 0 - - mov cx, size subTableHeader ; size to read - - call FileRead - jc doneClose - - ; - ; scan all TTF file tables - ; keep structures and meta data needed to serve the font - ; - mov ah, subTableHeader.TTST_numTables.low - mov al, subTableHeader.TTST_numTables.high - mov tableCount, ax -nextEntry: - mov bx, fontFile - segmov ds, ss - lea dx, tableDirectory - mov al, 0 - - mov cx, size tableDirectory ; size to read - - call FileRead - jc doneClose - - ; remember file position - mov cx, 0 - mov dx, 0 - mov bx, fontFile ; pass file handle in BX - mov al, FILE_POS_RELATIVE ; jump from start - call FilePos ; get current pos to dx:ax - jc doneClose - mov cx, dx - mov dx, ax - - mov ax, 'na' - cmp ax, tableDirectory.TTTD_tag.low - jne tryOS_2 - mov ax, 'me' - cmp ax, tableDirectory.TTTD_tag.high - jne tryOS_2 - - lea si, tableDirectory - call LoadTable - - cmp bx, 0 ; failed to load? - je doneClose - - ; restore file position, cxdx hold position - push bx - mov bx, fontFile ; pass file handle in BX - mov al, FILE_POS_START ; jump from start - call FilePos - pop bx - jnc parseName - - ; free the block we don't keep it, bx handle of block - call MemFree - jmp doneClose - -parseName: - ; get relevant data from name table - - ; first load sub family (and reuse the buffer fontName) and map - ; the value to TextStyle bits to describe the resulting - ; font entry - lea si, fontName ; ss:si point to buffer - mov cx, FONT_NAME_LEN ; buffer size - mov ax, 2 ; sub family name of the font - call GetNameFromTable - jc doneClose ; jump if no name found - - lea si, fontName ; ss:si point to buffer - call MapFontStyle - jc doneClose ; fail if style mapping fails - - mov fontStyle, al ; save fontStyle - ; (type TextStyle) - ; ds is pointing to the name table here - lea si, fontName ; ss:si point to buffer - mov cx, FONT_NAME_LEN ; buffer size - mov ax, 1 ; family name of the font - call GetNameFromTable - jc doneClose ; jump if no name found - - ; free the block we don't keep it, bx handle of block - call MemFree -tryOS_2: - mov ax, 'OS' - cmp ax, tableDirectory.TTTD_tag.low - jne cont - mov ax, '/2' - cmp ax, tableDirectory.TTTD_tag.high - jne cont -loadOS_2: - lea si, tableDirectory - call LoadTable - - cmp bx, 0 ; failed to load? - je doneClose - - ; restore file position, cxdx hold position - push bx - mov bx, fontFile ; pass file handle in BX - mov al, FILE_POS_START ; jump from start - call FilePos - pop bx - jnc getWeight - - ; free the block we don't keep it, bx handle of block -freeAndClose: - call MemFree - jmp doneClose - -getWeight: - mov ah, ds:4 - mov al, ds:5 - mov dx, 0 - mov si, 100 - div si - cmp dx, 0 - jne freeAndClose - cmp ax, 10 - jnc freeAndClose - - mov si, ax - mov al, cs:weightAdjustTable[si] - mov fontWeight, al - -cont: - dec tableCount - jnz nextEntry - - ; we have one font and collected required meta data - ; let compute/determ the fontid to be used for the font - mov ax, 0 - lea si, fontName ; ss:si point to buffer - mov cx, 0 -calcFontId: - - xor al, ss:0[si] - - xor ah, ss:1[si] - - inc cx - cmp cx, FONT_NAME_LEN - je doneFontId - inc si - cmp ss:0[si], 0 - jnz calcFontId - - and ah, 00000001b - or ax, FM_TRUETYPE - or ah, 00001110b - mov fontId, ax -doneFontId: - - ; lookup if there is a FontsAvailEntry for the font already - mov cx, fontId - mov ds, fontBlockSeg - mov di, ds:[FONTS_AVAIL_HANDLE] ;di <- ptr to chunk - ChunkSizePtr ds, di, ax ;ax <- chunk size - add ax, di ;ax -> end of chunk -IFA_loop: - cmp di, ax ;are we thru the list? - jae noMatch ;yes, exit carry clear - cmp ds:[di].FAE_fontID, cx ;see if ID matches - je match ;we have a match, branch - add di, size FontsAvailEntry ;else move to next entry - jmp IFA_loop ;and loop - -match: - ; font already registered, check if there is already equal outline - ; outline is equal if style and weight is equal - mov di, ds:[di].FAE_infoHandle ; ds:si = FontInfo chunk handle - mov si, ds:[di] ; ds:si = FontInfo ptr - - mov cx, ds:[si].FI_outlineEnd - push si - mov si, ds:[si].FI_outlineTab - -checkOutline: - mov al, ds:[si].ODE_style - cmp al, fontStyle - jne nextOutline - - mov al, ds:[si].ODE_weight - cmp al, fontStyle - jne nextOutline - - ; matching outline found - pop ax - jmp doneClose ; skip this font - -nextOutline: - add si, size OutlineDataEntry - cmp si, cx - jne checkOutline - -appendOutline: - ; not found, append new outline - pop si - - mov bx, cx ; append at end - - push cx - add cx, size OutlineDataEntry - mov ds:[si].FI_outlineEnd, cx - - mov ax, di ; *ds:ax = chunk - mov cx, size OutlineDataEntry ; cx = sizeof outline entry - call LMemInsertAt ; ds updated - mov fontBlockSeg, ds ; store it - - pop si - jmp initEntry - -noMatch: - ; - ; create a new FontsAvailEntry - ; - mov ds, fontBlockSeg - mov ax, FONTS_AVAIL_HANDLE ; *ds:ax = chunk - clr bx ; insert at front - mov cx, size FontsAvailEntry ; cx = sizeof table entry - call LMemInsertAt ; ds updated - mov fontBlockSeg, ds ; store it - ; - ; fill in FontID - ; - mov si, ax - push si - mov si, ds:[si] ; ds:si = new FAE - mov ax, fontId - mov ds:[si].FAE_fontID, ax - ; - ; clear the name field because there is a font file for each font - ; rather than for each typeface (which this field is for) - ; - mov ds:[si].FAE_fileName, 0 - - ; - ; allocate a chunk for the FontInfo block - ; - mov cx, 1 ; font count - mov ax, size OutlineDataEntry - mul cx ; dx:ax = size -EC < tst dx > -EC < ERROR_NZ TRUETYPE_INTERNAL_ERROR > - mov cx, ax - add cx, size FontInfo - mov dx, cx ; save size for later - clr ax - call LMemAlloc ; ds updated, ax = chunk - mov fontBlockSeg, ds ; store it - mov fontInfoChunk, ax - - ; - ; finish filling the FontsAvailEntry - ; dx = end of OutlineDataEntrys - ; - pop si ; *ds:si = FontsAvailEntry - mov si, ds:[si] ; ds:si = FontsAvailEntry - mov ds:[si].FAE_infoHandle, ax ; save FontInfo chunk handle - - ; - ; now fill in the FontInfo struct - ; dx = end of OutlineDataEntrys - ; - mov di, ax ; *ds:di = FontInfo - mov si, ds:[di] ; ds:si = FontInfo - mov ds:[si].FI_fileHandle, 0 ; not used - mov ax, fontId - mov ds:[si].FI_fontID, ax - mov ds:[si].FI_maker, FM_TRUETYPE - mov al, FF_NON_PORTABLE - mov ds:[si].FI_family, al ; this is called family but it - ; actually is FontAttrs - mov ds:[si].FI_pointSizeTab, 0 ; no bitmaps ??? (for now) - mov ds:[si].FI_pointSizeEnd, 0 - mov ds:[si].FI_outlineTab, size FontInfo - mov ds:[si].FI_outlineEnd, dx - ; - ; copy in the font face name - ; ds:si = FontInfo - ; es = FFLH - ; - push es, ds, si ; save FFLH, FontInfo - segxchg es, ds ; es:di = FI_faceName - segmov ds, ss - mov di, si - add di, FI_faceName - lea si,fontName ; ds:si = fontName - mov cx, length FI_faceName ; dest. size - LocalCopyNString - LocalPrevChar esdi - mov ax, 0 - LocalPutChar esdi, ax ; ensure null term - pop es, ds, si ; restore FFLH, FontInfo - - add si, size FontInfo ; ds:si = first OutlineDataEntry -initEntry: - call initOutlineEntry - -doneClose: - mov bx, fontFile - mov al, FILE_NO_ERRORS - call FileClose -done: - mov dx, fontBlockSeg - - .leave - ret - -weightAdjustTable byte \ - 80, ;FWE_ULTRA_LIGHT - 85, ;FWE_EXTRA_LIGHT - 90, ;FWE_LIGHT - 95, ;FWE_BOOK - 100, ;FWE_NORMAL - 105, ;FWE_DEMI - 110, ;FWE_BOLD - 115, ;FWE_EXTRA_BOLD - 120, ;FWE_ULTRA_BOLD - 125 ;FWE_BLACK - -initOutlineEntry label near - ; - ; style and weight - ; ds:si = OutlineDataEntry - ; - mov al, fontStyle ; font style - mov ds:[si].ODE_style, al - mov al, fontWeight ; font weight - mov ds:[si].ODE_weight, al - ; - ; now allocate and fill in a TrueTypeOutlineEntry - ; ds:si = OutlineDataEntry - ; fontNameSeg:fontNameOff = font file name - ; - mov bx, si - mov si, fontInfoChunk - mov si, ds:[si] - sub bx, si ; bx = offset to ODE - mov cx, size TrueTypeOutlineEntry ; fixed size - clr ax - call LMemAlloc ; ax = BOE chunk, ds updated - mov fontBlockSeg, ds ; store it - mov si, fontInfoChunk - mov si, ds:[si] ; ds:si = FontInfo - add si, bx ; ds:si = OutlineDataEntry -if DBCS_PCGEOS - mov ds:[si].ODE_extraData, ax -else - ; store chunk at OutlineEntrys - mov ds:[si][(size ODE_style + size ODE_weight)], ax -endif - mov si, ax - mov di, ds:[si] - mov bx, di ; es:bx = TrueTypeOutlineEntry - segmov es, ds ; es:di = TrueTypeOutlineEntry -.assert (offset TTOE_fontFileName) eq 0 - mov ds, fontNameSeg ; ds:si = font filename - mov si, fontNameOff - mov cx, size TTOE_fontFileName ; dest. size - rep movsb - - retn - -ProcessFont endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - LoadTable -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Load ttf table into memory block - -CALLED BY: ProcessFont - -PASS: ss:si - table directory entry - bx - file handle - -RETURN: ds - segment of locked table (on success) - bx - handle of table block (0 if FAILURE) - -DESTROYED: Current file position in the given file. - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 8/30/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -LoadTable proc near - uses ax, cx, dx, di - -newBlock local hptr - .enter - - mov newBlock, handle 0 - - tst ss:[si].TTTD_length.low ; actually the high word - jnz err ; -> error if above 64K - mov al, ss:[si].TTTD_length.high.high - mov ah, ss:[si].TTTD_length.high.low - mov di, ax - - mov dx, bx ; keep file handle - mov bx, handle 0 ; bx <- make TrueType owner - mov cx, ALLOC_DYNAMIC_LOCK - call MemAllocSetOwner ; allocate blk for table - jc err - - mov newBlock, bx - segmov ds, ax - - mov bx, dx ; pass file handle in BX - mov al, FILE_POS_START ; jump from start - mov dl, ss:[si].TTTD_offset.high.high - mov dh, ss:[si].TTTD_offset.high.low - mov cl, ss:[si].TTTD_offset.low.high - mov ch, ss:[si].TTTD_offset.low.low - - call FilePos - jc err - - mov dx, 0 ; buffer offset in segment - mov cx, di ; size - clr al - call FileRead - jc err - - mov bx, newBlock -done: - .leave - ret - -err: - mov bx, 0 - mov ax, newBlock - jz done - call MemFree - jmp done - -LoadTable endp - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - GetNameFromTable -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Load ttf table into memory block - -CALLED BY: ProcessFont - -PASS: ss:si - buffer to hold the result - cx - buffer size (to include \0 terminiation) - ds - name table segment - -RETURN: carry set on not found - Otherwise buffer filled, \0 terminated, if cx is not 0. - if cx is 0 then the buffer is filled but without \n termination. - -DESTROYED: ax, si - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 8/30/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -GetNameFromTable proc near - uses bx, di, dx - -dataOffset local word -encoding local byte - .enter - - mov bx, ax - mov di, si - - ; check version - mov ax, ds:0 - cmp ax, 0 - jne err - - ; scan the name record table - mov ah, ds:4 - mov al, ds:5 - mov dataOffset, ax - - mov dx, ds:2 - mov si, 6 -recordLoop: - mov ax, ds:0[si] - cmp ax, 0100h - je macEncoding - cmp ax, 0 ; unicode - jne next - mov ah, ds:2[si] - mov al, ds:3[si] - cmp ax, 3 ; Unicode 2.0 BPM - jne next - mov ax, ds:4[si] - cmp ax, 0 ; language should be 0 for - ; unicode - jne next - mov encoding, 0 - jmp enterLoop - -macEncoding: - mov ah, ds:2[si] - mov al, ds:3[si] - cmp ax, 0 ; Roman? - jne next - mov ax, ds:4[si] - cmp ax, 0 ; English? - jne next - - mov encoding, 1 ; 1 = non-unicode - -enterLoop: - ; match the name id - mov ah, ds:6[si] - mov al, ds:7[si] - cmp ax, bx - jne next - - mov dh, ds:8[si] - mov dl, ds:9[si] - - mov ah, ds:10[si] - mov al, ds:11[si] - add ax, dataOffset - mov si, ax -copyLoop: - cmp encoding, 0 - jne nextByte - mov ah, ds:0[si] - inc si - dec dx - jz endOfBuffer -nextByte: - mov al, ds:0[si] - inc si - - mov ss:0[di], al - inc di - dec cx - jz endOfBuffer - dec dx - jnz copyLoop -endOfBuffer: - cmp cx, 0 - jz success - mov ss:0[di], 0 - jmp success -next: - mov ax, si - add ax, 12 ; size of name record - mov si, ax - - dec dx - jnz recordLoop - jz err - -success: - clc -done: - .leave - ret - -err: - stc - jc done - -GetNameFromTable endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - MapFontStyle -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: MapFontStyle - -CALLED BY: ProcessFont - -PASS: ss:si - buffer to sub family name - -RETURN: carry set if mapping failed - al - on success, mapped TextStyle - -DESTROYED: ah - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - none - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 9/9/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -LocalDefNLString StyleRegular, <"Regular", 0> -LocalDefNLString StyleBold, <"Bold", 0> -LocalDefNLString StyleItalic, <"Italic", 0> -LocalDefNLString StyleBoldItalic, <"Bold Italic", 0> -LocalDefNLString StyleOblique, <"Oblique", 0> -LocalDefNLString StyleBoldOblique, <"Bold Oblique", 0> - -styleNames nptr \ - StyleRegular, - StyleBold, - StyleItalic, - StyleBoldItalic, - StyleOblique, - StyleBoldOblique - -styleFlags TextStyle \ - 0, - mask TS_BOLD, - mask TS_ITALIC, - mask TS_BOLD or mask TS_ITALIC, - mask TS_ITALIC, - mask TS_BOLD or mask TS_ITALIC - -MapFontStyle proc near - uses es, ds, di, si, cx, bx - - .enter -; -; Find the style -; - segmov es, ss - mov di, si ;es:di <- string to look for -; -; Find the sub family name in the table -; - mov cx, length styleNames ;cx <- # of entries - clr bx ;bx <- table index - segmov ds, cs -styleLoop: - push cx - mov si, cs:styleNames[bx] ;ds:si <- extension - clr cx ;cx <- NULL-terminated - call LocalCmpStringsNoCase - pop cx - je foundStyle ;branch if match - add bx, (size nptr) ;bx <- next entry - loop styleLoop ;loop for more - jmp notFound - -; -; Found the style -- return the flags -; -foundStyle: - sar bx, 1 - mov al, cs:styleFlags[bx] ;ds:si <- library name - clc ;carry <- no error -done: - .leave - ret - -notFound: - stc ;carry <- error - jmp done - -MapFontStyle endp diff --git a/Driver/Font/TrueType/truetypeMacros.def b/Driver/Font/TrueType/truetypeMacros.def deleted file mode 100644 index 02930d0ae..000000000 --- a/Driver/Font/TrueType/truetypeMacros.def +++ /dev/null @@ -1,70 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1990 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: TrueType -FILE: truetypeMacros.def - -AUTHOR: Falk Rehwagen, Jan 26, 2021 - -MACROS: - Name Description - ---- ----------- - Abs Absolute value of word - - TRUNC Truncate number - CEIL Get ceiling of number - ROUND Round number to integer - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/26/21 Initial revision - -DESCRIPTION: - Macros for the PC/GEOS TrueType font driver. - - $Id: truetypeMacros.def,v 1.1 21/01/26 11:45:27 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -; -; absolute value of integer -; -Abs macro int -local A_10 - tst int - jns A_10 - neg int -A_10: -endm - -; -;PASS: number in 16ths -;RETURN: floor(number), no fraction -; -TRUNC macro num - sar num, 1 - sar num, 1 - sar num, 1 - sar num, 1 -endm - -; -;PASS: number in 16ths -;RETURN: ceiling(number), no fraction -; -CEIL macro num - add num, FRACTION - TRUNC num -endm - -; -;PASS: number in 16ths -;RETURN: round(number), no fraction -; -ROUND macro num - add num, ONE_HALF - TRUNC num -endm diff --git a/Driver/Font/TrueType/truetypeMetrics.asm b/Driver/Font/TrueType/truetypeMetrics.asm deleted file mode 100644 index 647b96c0d..000000000 --- a/Driver/Font/TrueType/truetypeMetrics.asm +++ /dev/null @@ -1,63 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1990 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: MetricsMod -FILE: truetypeMetrics.asm - -AUTHOR: Falk Rehwagen, Jan 29, 2021 - -ROUTINES: - Name Description - ---- ----------- -EXT TrueTypeCharMetrics Return character metric information. - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/ 1/21 Initial revision - -DESCRIPTION: - Routines for generating character metrics. - - $Id: truetypeMetrics.asm,v 1.1 97/04/18 11:45:29 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeCharMetrics -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Return character metrics information in document coords. -CALLED BY: DR_FONT_CHAR_METRICS - TrueTypeStrategy - -PASS: ds - seg addr of font info block - es - seg addr of GState - es:GS_fontAttr - font attributes - dx - character to get metrics of - cx - info to return (GCM_info) -RETURN: if GCMI_ROUNDED set: - dx - information (rounded) - else: - dx.ah - information (WBFixed) - carry - set if error (eg. data / font not available) -DESTROYED: none - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/ 1/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeCharMetrics proc far - uses bx, cx, si, di, ds - .enter - - .leave - ret -TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/truetypePath.asm b/Driver/Font/TrueType/truetypePath.asm deleted file mode 100644 index 1b9950368..000000000 --- a/Driver/Font/TrueType/truetypePath.asm +++ /dev/null @@ -1,107 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1991 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: GeoCalc -FILE: truetypePath.asm - -AUTHOR: Falk Rehwagen, Jan 29, 2021 - -ROUTINES: - Name Description - ---- ----------- -EXT TrueTypeGenPath Generate path for character - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/29/21 Initial revision - -DESCRIPTION: - Routines for generating graphics string of a character. - - $Id: truetypePath.asm,v 1.1 97/04/18 11:45:26 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenPath -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate a path for the outline of a character -CALLED BY: DR_FONT_GEN_PATH (via TrueTypeStrategy) - -PASS: ds - seg addr of font info block - di - handle of GState (passed in bx, locked) - dx - character to generate (Chars) - cl - FontGenPathFlags - FGPF_POSTSCRIPT - transform for use as Postscript - Type 1 or Type 3 font. - FGPF_SAVE_STATE - do save/restore for GState -RETURN: none -DESTROYED: ax, bx, di (on the way here) - -PSEUDO CODE/STRATEGY: -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/29/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenPath proc far - uses cx, dx, si, ds, es - .enter - - .leave - ret -TrueTypeGenPath endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenInRegion -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate a character in the passed RegionPath -CALLED BY: DR_FONT_GEN_IN_REGION (via TrueTypeStrategy) - -PASS: ds - seg addr of font info block - di - handle of GState (passed in BX) - dx - character to generate (Chars) - cx - RegionPath handle (locked) -RETURN: nothing -DESTROYED: ax, bx, di - -PSEUDO CODE/STRATEGY: - We want override some of the default functionality for - build a font's character. Essentially: - * Always build a character in a region - * Build this character in the passed region - - We accomplish this by: - 1) Find the character data - 2) Calculate/store the correct transformation - 3) Stuff in some new CharGenRouts - 4) Stuf in the pen position (in device coords) - 5) Go generate the character (via MakeBigCharInRegion) - -KNOWN BUGS/SIDE EFFECTS/IDEAS: -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 1/ 29/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenInRegion proc far - uses cx, dx, si, ds, es - .enter - - .leave - ret -TrueTypeGenInRegion endp - - diff --git a/Driver/Font/TrueType/truetypeVariable.def b/Driver/Font/TrueType/truetypeVariable.def deleted file mode 100644 index d5126e846..000000000 --- a/Driver/Font/TrueType/truetypeVariable.def +++ /dev/null @@ -1,100 +0,0 @@ - -COMMENT @---------------------------------------------------------------------- - - Copyright (c) GeoWorks 1989 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: Font Driver -FILE: truetypeVariable.def - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - Falk 11/6/89 Initial version - -DESCRIPTION: - initialized and unitialized variables for TrueType font driver - - $Id: nimbusVariable.def,v 1.1 97/04/18 11:45:28 newdeal Exp $ - ------------------------------------------------------------------------------@ - - - -;------------------------------------------------------------------------------ -; Definition of variable block -;------------------------------------------------------------------------------ - -TrueTypeVars struct - -stackBot label byte -; -; The "stack" overlaps everything above this point -; - -x_offset sword ;x offset to create character -y_offset sword ;y offset to create character - -penPos Point <0, 0> ;pen position used for drawing - ;characters into a passed RegionPath - ;for NimbusGenInRegion(). -; -; Used to save passed variables: -; -genOffset word 0 ;offset of CharGenData -fontSegment word 0 ;seg addr of font -fontHandle hptr 0 ;handle of font -infoSegment word 0 ;seg addr of info block -gstateSegment word 0 ;seg addr of GState - -TrueTypeVars ends - -TrueTypeSubTable struct - TTST_scalerType dword - TTST_numTables word - TTST_searchRange word - TTST_entrySelector word - TTST_rangeShift word -TrueTypeSubTable ends - -TrueTypeTableDirectory struct - TTTD_tag dword - TTTD_checkSum dword - TTTD_offset dword - TTTD_length dword -TrueTypeTableDirectory ends - -TrueTypeOutlineEntry struc - TTOE_fontFileName DosDotFileName -TrueTypeOutlineEntry ends - -;------------------------------------------------------------------------------ - -;------------------------------------------------------------------------------ -; Initialized variables -;------------------------------------------------------------------------------ - -idata segment - -if DBCS_PCGEOS -truetypeDir wchar 'TTF',0 -else -truetypeDir char 'TTF',0 -endif - -idata ends - -;------------------------------------------------------------------------------ -; Uninitialized varaibles -;------------------------------------------------------------------------------ - -udata segment - -bitmapHandle hptr ;handle of our bitmap block -bitmapSize word ;size of our bitmap block (in bytes) - -variableHandle hptr ;handle of our variable block - -udata ends - - diff --git a/Driver/Font/TrueType/truetypeWidths.asm b/Driver/Font/TrueType/truetypeWidths.asm deleted file mode 100644 index df274e67b..000000000 --- a/Driver/Font/TrueType/truetypeWidths.asm +++ /dev/null @@ -1,69 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) GeoWorks 1990 -- All Rights Reserved - -PROJECT: PC GEOS -MODULE: TrueType Font Driver -FILE: truetypeWidths.asm - -AUTHOR: Falk Rehwagen, Jan 29, 2021 - -ROUTINES: - Name Description - ---- ----------- -EXT TrueTypeGenWidths Generate font header and widths for a font. - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/1/21 Initial revision - -DESCRIPTION: - Implements a font driver for: - The TrueType outline fonts - - $Id: truetypeWidths.asm,v 1.1 97/04/18 11:45:30 bluewaysw Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - TrueTypeGenWidths -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Generate the character width table for a font. -CALLED BY: EXTERNAL: GrFindFont - -PASS: di - 0 for new font; handle to rebuild old font (P'd) - es - seg addr of gstate (locked) - GS_fontAttr - font attributes - bp:cx - transformation matrix (TMatrix) - ds - seg addr of font info block -RETURN: bx - handle of font (locked) - ax - seg addr of font (locked) - carry - clear -DESTROYED: none - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - di is the bx passed to TrueTypeStrategy. - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - FR 29/1/21 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -TrueTypeGenWidths proc far - uses cx, dx, si, di, ds, es, bp - - mov bx, bp - .enter - - clc ;indicate no error - - .leave - ret -TrueTypeGenWidths endp diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 4ad4c65a1..2d54dc051 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,27 +4,30 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -MAIN = truetypeEscape.asm mainManager.asm truetypeWidths.asm\ - truetypeMetrics.asm truetypeInit.asm truetypeEC.asm\ - truetypeChars.asm truetypePath.asm truetypeMacros.def\ - truetypeVariable.def truetypeConstant.def +MAIN = truetypeEscape.asm ansic_malloc.asm ansic_runtime.asm\ + mainManager.asm ansic_string.asm truetypeWidths.asm\ + ansic_memory.asm truetypeMetrics.asm truetypeInit.asm\ + truetypeEC.asm truetypeChars.asm truetypePath.asm\ + truetypeMacros.def truetypeVariable.def\ + truetypeConstant.def +ADAPTER = ttadapter.c ttadapter.h FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ - header.h ttinterp.h ttload.h tttables.h ttobjs.h\ - fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ - ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ - ttmemory.h tttags.h + ttinterp.h ttload.h tttables.h ttobjs.h fterrid.h\ + ttraster.h ttengine.h tttypes.h ttmutex.h ft_conf.h\ + ttextend.h ftnameid.h ttcalc.h ftxkern.h ttmemory.h\ + tttags.h UI_TO_RDFS = -OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ - ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ - ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ - ttmemory.obj +OBJS = ttadapter.obj ttcache.obj ttraster.obj ttmutex.obj\ + ttgload.obj ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj\ + ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ + ttobjs.obj ttmemory.obj COMMON = MODULES = Main -CMODULES = FreeType -SRCS = $(MAIN) $(FREETYPE) $(COMMON) +CMODULES = Adapter FreeType +SRCS = $(MAIN) $(ADAPTER) $(FREETYPE) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index ed44ef930..3dc0081a4 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -8,13 +8,20 @@ Main.eobj: Main/mainManager.asm \ Internal/grWinInt.def Internal/gstate.def \ Internal/window.def win.def Internal/threadIn.def \ truetypeConstant.def truetypeVariable.def \ - truetypeMacros.def truetypeWidths.asm fontcomUtils.asm \ - truetypeChars.asm truetypeMetrics.asm truetypePath.asm \ - truetypeInit.asm truetypeEscape.asm fontcomEscape.asm \ - truetypeEC.asm + truetypeMacros.def truetypeWidths.asm \ + ../FontCom/fontcomUtils.asm truetypeChars.asm \ + truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ + truetypeEscape.asm ../FontCom/fontcomEscape.asm \ + truetypeEC.asm ansic_runtime.asm ansic_memory.asm \ + ansic_malloc.asm ansic_string.asm +ttadapter.obj \ +ttadapter.eobj: Adapter/ttadapter.h geos.h Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ - FreeType/ft_conf.h geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ + fontID.h font.h color.h heap.h ec.h Ansi/stdlib.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h \ FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ @@ -22,100 +29,109 @@ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ttdebug.h ttraster.obj \ ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h ttmutex.obj \ ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h ttgload.obj \ ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ - FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/tttags.h FreeType/ttload.h + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttgload.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/tttags.h \ + FreeType/ttload.h ttextend.obj \ ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h ttcalc.obj \ ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/tttypes.h \ - FreeType/tttables.h + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/tttypes.h FreeType/tttables.h ttapi.obj \ ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ - FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ + resource.h graphics.h fontID.h font.h color.h heap.h ec.h \ + Ansi/stdlib.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ + FreeType/ttfile.h FreeType/ttdebug.h FreeType/ttobjs.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttload.h \ + FreeType/ttgload.h FreeType/ttraster.h \ FreeType/ttextend.h ttdebug.obj \ ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/ttcmap.h ftxkern.obj \ ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttextend.h \ - FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/ttobjs.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/ttcache.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttdebug.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttfile.h FreeType/ttload.h FreeType/tttags.h + FreeType/ftnameid.h geos.h FreeType/ttextend.h \ + FreeType/ttconfig.h FreeType/ft_conf.h file.h resource.h \ + graphics.h fontID.h font.h color.h heap.h ec.h \ + Ansi/stdlib.h FreeType/tttypes.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttfile.h \ + FreeType/ttload.h FreeType/tttags.h ttinterp.obj \ ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ - FreeType/ttcmap.h + geos.h FreeType/tttypes.h FreeType/ttconfig.h \ + FreeType/ft_conf.h file.h resource.h graphics.h fontID.h \ + font.h color.h heap.h ec.h Ansi/stdlib.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/ttinterp.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h ttload.obj \ ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ - FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/tttags.h FreeType/ttload.h + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h ttfile.obj \ ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + resource.h graphics.h fontID.h font.h color.h heap.h ec.h \ + Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ FreeType/ttengine.h FreeType/ttmutex.h \ FreeType/ttmemory.h FreeType/ttfile.h ttcmap.obj \ ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ FreeType/ttload.h ttobjs.obj \ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ @@ -123,9 +139,10 @@ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ FreeType/ttextend.h ttmemory.obj \ ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h ec.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ FreeType/ttengine.h FreeType/ttmutex.h -truetypeEC.geo truetype.geo : geos.ldf ansic.ldf \ No newline at end of file +truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file From 03284c453a93fbc6a611eb96aa8f30d22a7171ab Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 17 Jul 2022 19:54:55 +0200 Subject: [PATCH 044/246] Add adapterfunctions for DR_INIT and DR_EXIT --- Driver/Font/TrueType/Adapter/ttadapter.c | 64 +++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttadapter.h | 8 +-- Driver/Font/TrueType/FreeType/freetype.h | 20 ++++++- Driver/Font/TrueType/Main/truetypeInit.asm | 48 ++++------------ Driver/Font/TrueType/backlog.md | 47 ++++++++++++---- 5 files changed, 123 insertions(+), 64 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 46cae88c2..b6bd8b343 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -1,6 +1,6 @@ /*********************************************************************** * - * Copyright FreeGEOS-Project + * Copyright FreeGEOS-Project * * PROJECT: FreeGEOS * MODULE: TrueType font driver @@ -22,16 +22,64 @@ #include "ttadapter.h" -TT_Error _pascal Init_FreeType() { +/******************************************************************** + * Init_FreeType + ******************************************************************** + * SYNOPSIS: Initialises the FreeType Engine with the kerning + * extension. This is the adapter function for DR_INIT. + * + * PARAMETERS: void + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Initialises the FreeType engine by delegating to + * TT_Init_FreeType() and TT_Init_Kerning(). + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 7/15/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Init_FreeType() +{ TT_Error error; - error = TT_Init_FreeType(&tt_Engine); - //TT_Init_Kerning + error = TT_Init_FreeType( &tt_Engine ); + if ( error != TT_Err_Ok ) + return error; - return error; + //TT_Init_Kerning() + + return TT_Err_Ok; } -void _pascal Exit_FreeType() { - //TT_Done_FreeType -} \ No newline at end of file + +/******************************************************************** + * Exit_FreeType + ******************************************************************** + * SYNOPSIS: Deinitialises the FreeType Engine. This is the + * adapter function for DR_EXIT. + * + * PARAMETERS: void + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Deinitialises the FreeType engine by delegating to + * TT_Done_FreeType(). + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 7/15/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Exit_FreeType() +{ + return TT_Done_FreeType( tt_Engine ); +} diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 692a3c7ec..da318df17 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -15,7 +15,7 @@ * * DESCRIPTION: * Declaration of global objects which are defined in assembler - * and are also needed in the c functions. + * and are also needed in c functions. ***********************************************************************/ #ifndef _TTADAPTER_H_ #define _TTADAPTER_H_ @@ -26,11 +26,7 @@ /*********************************************************************** * global dgoup objects ***********************************************************************/ -extern TT_Engine tt_Engine; +extern GTT_Engine tt_Engine; -/*********************************************************************** - * adapter functions - ***********************************************************************/ - #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index e210b88ef..d9fae9736 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -622,6 +622,14 @@ /* NOTE: Some macros are defined in tttypes.h to perform */ /* automatic type conversions for library hackers... */ + //TODO: soll TT_*_ ersetzen + struct GTT_Engine_ { MemHandle z; }; + struct GTT_Stream_ { MemHandle z; }; + struct GTT_Face_ { MemHandle z; }; + struct GTT_Instance_ { MemHandle z; }; + struct GTT_Glyph_ { MemHandle z; }; + struct GTT_CharMap_ { MemHandle z; }; + struct TT_Engine_ { void* z; }; struct TT_Stream_ { void* z; }; struct TT_Face_ { void* z; }; @@ -629,6 +637,14 @@ struct TT_Glyph_ { void* z; }; struct TT_CharMap_ { void* z; }; + //TODO: soll TT_* ersetzen + typedef struct GTT_Engine_ GTT_Engine; + typedef struct GTT_Stream_ GTT_Stream; + typedef struct GTT_Face_ GTT_Face; + typedef struct GTT_Instance_ GTT_Instance; + typedef struct GTT_Glyph_ GTT_Glyph; + typedef struct GTT_CharMap_ GTT_CharMap; + typedef struct TT_Engine_ TT_Engine; /* engine instance */ typedef struct TT_Stream_ TT_Stream; /* stream handle type */ typedef struct TT_Face_ TT_Face; /* face handle type */ @@ -671,13 +687,13 @@ /* Initialize the engine. */ EXPORT_DEF - TT_Error TT_Init_FreeType( TT_Engine* engine ); + TT_Error TT_Init_FreeType( GTT_Engine* engine ); /* Finalize the engine, and release all allocated objects. */ EXPORT_DEF - TT_Error TT_Done_FreeType( TT_Engine engine ); + TT_Error TT_Done_FreeType( GTT_Engine engine ); /* Set the gray level palette. This is an array of 5 bytes used */ diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index f98fc3a71..bc43da978 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -85,12 +85,14 @@ TrueTypeInit proc far or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags call MemAllocSetOwner mov ds:variableHandle, bx ;save handle of block - ; ; Initialize FreeType engine. ; - - call InitEngine + call INIT_FREETYPE + test ax, 0 + jz noerror + stc ;indicate error + jmp done noerror: clc ;indicate no error done: @@ -98,20 +100,6 @@ done: ret TrueTypeInit endp -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - InitEngine -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -InitEngine proc far - .enter - call INIT_FREETYPE - .leave - ret - -InitEngine endp - COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TrueTypeExit @@ -146,35 +134,21 @@ EC < clr ds:bitmapHandle ;> mov bx, ds:variableHandle EC < clr ds:variableHandle ;> call MemFree ;done with variable block - + ; + ; Deinitialize FreeType engine. + ; call EXIT_FREETYPE ;finish FreeType engine - ;ax <- FreeType errorcode test ax, 0 ;check for errors jz noerror - stc - jmp exit + stc ;indicate error + jmp done noerror: clc ;indicate no error -exit: +done: .leave ret TrueTypeExit endp - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ExitEngine -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -ExitEngine proc far - .enter - call EXIT_FREETYPE - .leave - ret - -ExitEngine endp - COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TrueTypeInitFonts diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index 7da163208..20940d4b7 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -16,45 +16,60 @@ Der Treiber wird in 3 Schichten realisiert: + der Code liegt unter /FreeType ### Speicherverwaltung -- TT_Engine auf MemHandle umstellen +- auf MemHandle umstellen + - TT_Engine + - TT_Stream + - TT_Face + - TT_Instance + - TT_Glyph + - TT_CharMap - Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles umstellen - Speicherverwaltungsmakros auf MemHandles umstellen - Nutzer der Speicherverwaltungsmakros auf MemHandles umstellen ### DR_INIT -- Wrapper für DR_INIT schreiben -- Aufruf in truetypeInit.asm +~~- Adapterfunktion für DR_INIT schreiben~~ +~~- Aufruf in truetypeInit.asm~~ +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_EXIT -- Wrapper für DR_EXIT schreiben -- Aufruf in truetypeInit.asm +~~- Adapter für DR_EXIT schreiben~~ +~~- Aufruf in truetypeInit.asm~~ +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_GEN_CHAR -- Wrapper für DR_FONT_GEN_CHAR schreiben +- Adapterfunktion für DR_FONT_GEN_CHAR schreiben +- Kerning implementieren - Aufruf in truetypeChars.asm +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_GEN_WIDTHS -- Wrapper für DR_FONT_GEN_WIDTHS schreiben +- Adapterfunktion für DR_FONT_GEN_WIDTHS schreiben - Aufruf in truetypeWidts.asm +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_CHAR_METRICS -- Wrapper für DR_FONT_CHAR_METRICS schreiben +- Adapterfunktion für DR_FONT_CHAR_METRICS schreiben - Aufruf in truetypeMetrics.asm +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_INIT_FONTS (geringe Priorität) Die bisherigen Implementierung in Assembler kann auf die FreeType Engine umgestellt werden, somit vermeiden wir Redundanzen. Die akt. Implementierung scheint nicht korrekt zu funktionieren, das wird gleich mit behoben. -- Wrapper für DR_FONT_INIT_FONTS schreiben +- Adapterfunktion für DR_FONT_INIT_FONTS schreiben - Aufruf in truetypeInit.asm +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_GEN_PATH -- Wrapper für DR_FONT_GEN_PATH schreiben +- Adapterfunktion für DR_FONT_GEN_PATH schreiben - Aufruf in truetypePath.asm - hier ist die Behandlung der Transformationsmatrizen noch unklar +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_GEN_IN_REGION -- Wrapper für DR_FONT_GEN_REGION schreiben +- Adapterfunktion für DR_FONT_GEN_REGION schreiben - Aufruf in truetypePath.asm - hier ist die Behandlung der Transformationsmatrizen noch unklar +- prüfen ob die Adapterfunktion sauber durchlaufen wird ### sonstiges - laden eines Fonts auf FileHandle umstellen @@ -67,6 +82,16 @@ Die bisherigen Implementierung in Assembler kann auf die FreeType Engine umgeste - Initalisierung des Graustufenarrays in TT_Init_FreeType entfernen - das Graustufenarray kann aus TT_Engine entfernt werden - Warnungen entfernen +- Makros vereinen: + - HANDLE_Engine und GHANDLE_Engine + - UNHANDLE_Engine und -/- +- Strukturen vereinen: + - GTT_Engine und TT_Engine + - GTT_Stream und TT_Stream + - GTT_Face und TT_Face + - GTT_Instance und TT_Instance + - GTT_Glyph und TT_Glyph + - GTT_CharMap und TT_CharMap ### Funktionen die ausgeklammert werden können - TT_Open_Collection() From bd638c7efc245265447079cd8330a7a43c98abcc Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 17 Jul 2022 19:57:18 +0200 Subject: [PATCH 045/246] freetype.h forgotten --- Driver/Font/TrueType/FreeType/freetype.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index d9fae9736..c1e90d5f9 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -687,13 +687,13 @@ /* Initialize the engine. */ EXPORT_DEF - TT_Error TT_Init_FreeType( GTT_Engine* engine ); + TT_Error TT_Init_FreeType( TT_Engine* engine ); /* Finalize the engine, and release all allocated objects. */ EXPORT_DEF - TT_Error TT_Done_FreeType( GTT_Engine engine ); + TT_Error TT_Done_FreeType( TT_Engine engine ); /* Set the gray level palette. This is an array of 5 bytes used */ From bf5da3fdb9e6b3a21d70626b10c5755ce191420f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 18 Jul 2022 22:05:09 +0200 Subject: [PATCH 046/246] Backlog concretised. --- Driver/Font/TrueType/Adapter/ttadapter.h | 2 +- Driver/Font/TrueType/backlog.md | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index da318df17..990092df8 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -26,7 +26,7 @@ /*********************************************************************** * global dgoup objects ***********************************************************************/ -extern GTT_Engine tt_Engine; +extern TT_Engine tt_Engine; #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index 20940d4b7..3b68d8d25 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -16,16 +16,32 @@ Der Treiber wird in 3 Schichten realisiert: + der Code liegt unter /FreeType ### Speicherverwaltung -- auf MemHandle umstellen +- auf MemHandle/ChunkHandle umstellen - TT_Engine - TT_Stream - TT_Face - TT_Instance - TT_Glyph - TT_CharMap -- Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles umstellen -- Speicherverwaltungsmakros auf MemHandles umstellen -- Nutzer der Speicherverwaltungsmakros auf MemHandles umstellen +- Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles/ChunkHandles umstellen +- Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen +- Nutzer der Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen + +**Wie soll die Speicherverwaltung aussehen?** + +**Variante a)** +- alle Pointer werden zu MemHandles +- vor/nach dem Zugriff muss gelock/geunlockt werden + +**Variante b)** +- die Pointer werden zu ChunkHandles +- unklar ob ein LMemBlock genügt oder eine Aufteillung notwendig/sinnvoll ist +-> währen der gesamten Lebenszeit des Treibers ist nur TT_Engine im Speicher notwendig +-> die anderen FreeType Objekte (TT_Face, TT_Glyph ...) können durch die Adapterfunktionen angelegt und abgeräumt werden (das ist ev. eine sinnvolle Trennung) + +**Klären:** +- wieviel Speicher und wieviele Blocks werden beim Rendervorgang belegt? +- gibt es bei der Speicherbelegung große Unterschieden bei versch. Fonts? ### DR_INIT ~~- Adapterfunktion für DR_INIT schreiben~~ From a3b6b7e883e38a74365b5bb2afe8931d24a64c37 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 21 Jul 2022 17:01:35 +0200 Subject: [PATCH 047/246] function to measure memory consumption --- .../testapps/ttf2/FreeType/ttconfig.h | 6 +-- .../testapps/ttf2/FreeType/ttmemory.c | 39 +++++++++++++-- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 47 ++++++++++++++----- 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h index 616a1a654..87adcacb9 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h @@ -40,7 +40,7 @@ /* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ /* version of the library. */ -#define TT_CONFIG_OPTION_THREAD_SAFE +/* #define TT_CONFIG_OPTION_THREAD_SAFE */ @@ -110,7 +110,7 @@ /* Please note that probably not all OS-specific versions of ttmemory.c */ /* provide this functionality. */ -/* #define DEBUG_MEMORY */ +#define DEBUG_MEMORY /*************************************************************************/ @@ -164,7 +164,7 @@ /* The number of extensions available. Don't change this value */ /* except if you add new extensions to the engine. */ -#define TT_MAX_EXTENSIONS 8 +#define TT_MAX_EXTENSIONS 2 diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c index 3687b5ca0..a8acf92fc 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c @@ -56,6 +56,11 @@ static Int num_realloc; /* counts only `real' reallocations (i.e., an existing buffer will be resized to a value larger than zero */ + static unsigned int allocated; + static unsigned int max_allocated; + static unsigned int max_blocksize; + static unsigned int num_blocks; + static unsigned int max_num_blocks; static Int fail_alloc; static Int fail_realloc; @@ -114,6 +119,14 @@ #ifdef DEBUG_MEMORY num_alloc++; + num_blocks++; + allocated += Size; + if( num_blocks > max_num_blocks ) + max_num_blocks = num_alloc; + if( allocated > max_allocated ) + max_allocated = allocated; + if( Size > max_blocksize ) + max_blocksize = Size; i = 0; while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) @@ -207,6 +220,13 @@ fail_realloc++; else { + allocated += Size - pointers[i].size; + if( allocated > max_allocated ) + max_allocated = allocated; + if( Size > max_blocksize ) + max_blocksize = Size; + + #ifndef TT_CONFIG_OPTION_THREAD_SAFE TTMemory_Allocated += Size - pointers[i].size; if ( Size > pointers[i].size ) @@ -214,7 +234,7 @@ #endif pointers[i].base = Q; - pointers[i].size = size; + pointers[i].size = Size; } #endif /* DEBUG_MEMORY */ @@ -264,6 +284,10 @@ fail_free++; else { + allocated -= pointers[i].size; + num_blocks--; + + #ifndef TT_CONFIG_OPTION_THREAD_SAFE TTMemory_Allocated -= pointers[i].size; #endif @@ -308,6 +332,11 @@ num_realloc = 0; num_free = 0; + allocated = 0; + max_allocated = 0; + num_blocks = 0; + max_num_blocks = 0; + fail_alloc = 0; fail_realloc = 0; fail_free = 0; @@ -351,7 +380,7 @@ tot_leaked += pointers[i].size; } } - +/* fprintf( stderr, "%d memory allocations, of which %d failed\n", num_alloc, @@ -366,8 +395,8 @@ "%d memory frees, of which %d failed\n", num_free, fail_free ); - - if ( num_leaked > 0 ) +*/ +/* if ( num_leaked > 0 ) { fprintf( stderr, "There are %d leaked memory blocks, totalizing %d bytes\n", @@ -386,7 +415,7 @@ } } else - fprintf( stderr, "No memory leaks !\n" ); + fprintf( stderr, "No memory leaks !\n" ); */ #endif /* DEBUG_MEMORY */ diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 3b497a54f..c99eb819a 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -18,9 +18,14 @@ TT_Face face; typedef struct { Bitmap b; - char data[24 * 3]; + char data[20 * 3]; } Bmp; +extern int allocated; +extern unsigned int max_allocated; +extern unsigned int max_blocksize; +extern unsigned int num_blocks; +extern unsigned int max_num_blocks; @class TtfProcessClass, GenProcessClass; @endc; @@ -56,7 +61,7 @@ typedef struct { GVI_horizAttrs = @default | GVDA_SCROLLABLE | GVDA_NO_LARGER_THAN_CONTENT; GVI_vertAttrs = @default | GVDA_SCROLLABLE | GVDA_NO_LARGER_THAN_CONTENT; GVI_content = process; - GVI_docBounds = { 0, 0, 500, 450 }; + GVI_docBounds = { 0, 0, 400, 450 }; ATTR_GEN_VIEW_DOES_NOT_ACCEPT_TEXT_INPUT; } @@ -74,12 +79,13 @@ typedef struct { void testRendering(GStateHandle gstate) { char tmpStr[40]; + word charIndex; TT_Face_Properties props; TT_Instance instance; TT_Glyph glyph; TT_UShort charMapId; - TT_CharMap charMap; TT_Glyph_Metrics metrics; + TT_CharMap charMap; TT_Error error; @@ -88,52 +94,65 @@ void testRendering(GStateHandle gstate) { _log("Fehler bei Initialisierung\r"); goto Fail; } + sprintf(tmpStr, "1: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_Init_Kerning_Extension(&engine); if(error) { _log("Fehler bei der Initialisierung des Kernings\r"); goto Fail; } + sprintf(tmpStr, "2: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - error = TT_Open_Face(engine, "PTSerif.ttf", &face); + error = TT_Open_Face(engine, "DejaVu.ttf", &face); if(error) { _log("Fehler beim laden des Fonts\r"); goto Fail; } + sprintf(tmpStr, "3: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_Get_Face_Properties(face, &props); if(error) { _log("Fehler beim laden der Properties\r"); goto Fail; } - + sprintf(tmpStr, "4: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); +/* sprintf(tmpStr, "num glyphs:\t%d\r", props.num_Glyphs); _log(tmpStr); sprintf(tmpStr, "num faces:\t%d\r", props.num_Faces); _log(tmpStr); sprintf(tmpStr, "num names:\t%d\r", props.num_Names); _log(tmpStr); sprintf(tmpStr, "num charMaps:\t%d\r", props.num_CharMaps); _log(tmpStr); sprintf(tmpStr, "max points:\t%d\r", props.max_Points); _log(tmpStr); sprintf(tmpStr, "max contours:\t%d\r", props.max_Contours); _log(tmpStr); - +*/ error = TT_New_Instance(face, &instance); if(error) { _log("Fehler beim erzeugen einer Instance\r"); goto Fail; } + sprintf(tmpStr, "5: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - error = TT_Set_Instance_CharSize(instance, 72*64); + error = TT_Set_Instance_CharSize(instance, 42*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; } + sprintf(tmpStr, "6: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_New_Glyph(face, &glyph); if(error) { _log("Fehler beim anlegen eines Glyphs\r"); goto Fail; } + sprintf(tmpStr, "7: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); + + TT_Get_CharMap(face, 0, &charMap); + sprintf(tmpStr, "8: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); + + charIndex = TT_Char_Index(charMap, 64); + sprintf(tmpStr, "9: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); // DrawBitmap( gstate, instance, glyph); - DrawRegion( gstate, instance, glyph); + DrawRegion( gstate, instance, glyph, charIndex); Fail: TT_Done_FreeType(engine); @@ -185,11 +204,11 @@ void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { } } -void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { - word characterId = 50; +void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word characterId ) { char tmpStr[40]; TT_Raster_Map regionmap; TT_Glyph_Metrics metrics; + Region* region = calloc(sizeof(Region), 1000); regionmap.flow = TT_Flow_Down; @@ -197,6 +216,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if( TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ) ) return; + sprintf(tmpStr, "10: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); if( TT_Get_Glyph_Metrics( glyph, &metrics ) ) return; @@ -212,10 +232,11 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { if( TT_Get_Glyph_Region( glyph, ®ionmap, 0, 0 ) ) return; - + sprintf(tmpStr, "11: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); +/* sprintf(tmpStr, "region size:\t%d\r", (regionmap.size)); _log(tmpStr); - - GrDrawRegion(gstate, 60, 60, region, 0, 0); +*/ + //GrDrawRegion(gstate, 60, 60, region, 0, 0); free(region); } From 9bb16eef6d55a76c550f9db404f6738dda10d200 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 21 Jul 2022 22:35:31 +0200 Subject: [PATCH 048/246] backlog updated --- Driver/Font/TrueType/backlog.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index 3b68d8d25..a4b959266 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -29,9 +29,9 @@ Der Treiber wird in 3 Schichten realisiert: **Wie soll die Speicherverwaltung aussehen?** -**Variante a)** -- alle Pointer werden zu MemHandles -- vor/nach dem Zugriff muss gelock/geunlockt werden +~~**Variante a)**~~ +- ~~alle Pointer werden zu MemHandles~~ +- ~~vor/nach dem Zugriff muss gelock/geunlockt werden~~ **Variante b)** - die Pointer werden zu ChunkHandles @@ -39,9 +39,21 @@ Der Treiber wird in 3 Schichten realisiert: -> währen der gesamten Lebenszeit des Treibers ist nur TT_Engine im Speicher notwendig -> die anderen FreeType Objekte (TT_Face, TT_Glyph ...) können durch die Adapterfunktionen angelegt und abgeräumt werden (das ist ev. eine sinnvolle Trennung) -**Klären:** -- wieviel Speicher und wieviele Blocks werden beim Rendervorgang belegt? -- gibt es bei der Speicherbelegung große Unterschieden bei versch. Fonts? +***Entscheidung:*** +- es wird 2 LMem Blöcke geben (Variante b): + - ein Block für die Engine (benötigt nach Analyse ca. 10kb) + - bleibt die ganze Laufzeit des Treibers erhalten + - enthält genau 8 Chunks + - wird durch die Adapterfunktion aufgebaut/abgebaut + - ein zweiter Block ist für die TrueTypeVars (Face, Instance, Glyph usw.) + - kann, je nach Font, bis zu 54kb anwachsen + - enthält bis zu 100 Chunks + - wird nur für das Rendern eines Glyphs aufgebaut und danach abgebaut + - wird durch die Adapterfunktionen aufgebaut/abgebaut + +~~**Klären:**~~ + - ~~wieviel Speicher und wieviele Blocks werden beim Rendervorgang belegt?~~ + - ~~gibt es bei der Speicherbelegung große Unterschieden bei versch. Fonts?~~ ### DR_INIT ~~- Adapterfunktion für DR_INIT schreiben~~ From 55c3890524c06bc574b543675525dd7093826367 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 22 Jul 2022 22:06:05 +0200 Subject: [PATCH 049/246] Start of the changes to the memory handling --- Driver/Font/TrueType/FreeType/ft_conf.h | 1 + Driver/Font/TrueType/FreeType/ttmemory.c | 63 ++++++++++++++++++++++++ Driver/Font/TrueType/FreeType/ttmemory.h | 41 +++++++++++++++ Driver/Font/TrueType/backlog.md | 13 ++--- 4 files changed, 112 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index 0faffd4b9..d85915477 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -15,6 +15,7 @@ #include #include #include +#include /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c index 3687b5ca0..952d09ba7 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.c +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -137,6 +137,29 @@ return TT_Err_Ok; } + /* TODO: diese Funktion soll TT_Alloc ablösen */ + EXPORT_FUNC + TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ) + { + if ( !M || !C ) + return TT_Err_Invalid_Argument; + + if ( Size > (size_t)-1 ) + return TT_Err_Out_Of_Memory; + if ( Size > 0 ) + { + *C = LMemAlloc( M, Size ); + if ( !*C ) + return TT_Err_Out_Of_Memory; + + /* TODO: erstellten Chunkt mit 0 initialisieren */ + } + else + *C = NullChunk; + + return TT_Err_Ok; + } + #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE @@ -223,6 +246,31 @@ return TT_Err_Ok; } + /* TODO: diese Funktion soll TT_Realloc ablösen */ + EXPORT_FUNC + TT_Error GTT_Realloc( MemHandle M, ChunkHandle* C, unsigned int Size ) + { + if ( !M || !C ) + return TT_Err_Invalid_Argument; + + if ( !*C ) + return GTT_Alloc( M, C, Size ); + + if ( Size == 0 ) + return GTT_Free( M, C ); + + if ( Size > (size_t)-1 ) + { + GTT_Free( M, C ); + return TT_Err_Out_Of_Memory; + } + + *C = LMemReAllocHandles( M, *C, Size ); + if ( !*C ) + return TT_Err_Out_Of_Memory; + + return TT_Err_Ok; + } #endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ @@ -281,6 +329,21 @@ } + /* TODO: diese Funktion soll TT_Free ablösen */ + EXPORT_FUNC + TT_Error GTT_Free( MemHandle M, ChunkHandle* C ) + { + if ( !M || !C || !*C ) + return TT_Err_Ok; + + LMemFreeHandles( M, *C ); + + *C = NullHandle; + + return TT_Err_Ok; + } + + /******************************************************************* * * Function : TTMemory_Init diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h index 42fe0d997..3e33c37a3 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.h +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -80,6 +80,38 @@ #define FREE( _pointer_ ) \ TT_Free( (void**)&(_pointer_) ) +/* TODO: diese Makros sollen die o.g. ablösen */ +#define MEM_USE_ENGINE MemHandle _memBlock = engineHandle + +#define MEM_LOCK MemLock( _memBlock ) + +#define MEM_UNLOCK MemUnlock( _memBlock ) + +#define GMEM_Alloc( _handle_, _size_ ) \ + GTT_Alloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + +#define GMEM_Realloc( _handle_, _size_ ) \ + GTT_Realloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + +#define GALLOC( _handle_, _size_ ) \ + ( ( error = GMEM_Alloc( _handle_, _size_ ) ) != TT_Err_Ok ) + +#define GALLOC_ARRAY( _handle_, _count_, _type_ ) \ + ( ( error = GMEM_Alloc( _handle_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define GREALLOC( _handle_, _size_ ) \ + ( ( error = GMEM_Realloc( _handle_, _size_ ) ) != TT_Err_Ok ) + +#define GREALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( (error = GMEM_Realloc( _handle_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define GFREE( _handle_ ) \ + GTT_Free( (ChunkHandle*)&(_handle_) ) + +/* ENDE: diese Makros sollen die o.g. ablösen */ + /* Allocate a block of memory of 'Size' bytes from the heap, and */ /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ @@ -88,6 +120,9 @@ EXPORT_DEF TT_Error TT_Alloc( ULong Size, void** P ); + EXPORT_DEF + TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ); + #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE /* Reallocates a block of memory pointed to by '*P' to 'Size' */ @@ -98,6 +133,9 @@ EXPORT_DEF TT_Error TT_Realloc( ULong Size, void** P ); + EXPORT_DEF + TT_Error GTT_Realloc( MemHandle M, ChunkHandle* C, unsigned int Size ); + #endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ /* Releases a block that was previously allocated through Alloc. */ @@ -108,6 +146,9 @@ EXPORT_DEF TT_Error TT_Free( void** P ); + EXPORT_DEF + TT_Error GTT_Free( MemHandle M, ChunkHandle* C ); + /* For "legacy" applications, that should be re-coded. */ /* Note that this won't release the previously allocated font pool. */ diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index a4b959266..140f1e7ac 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -23,8 +23,8 @@ Der Treiber wird in 3 Schichten realisiert: - TT_Instance - TT_Glyph - TT_CharMap -- Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles/ChunkHandles umstellen -- Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen +- ~~Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles/ChunkHandles umstellen~~ +- ~~Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen~~ - Nutzer der Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen **Wie soll die Speicherverwaltung aussehen?** @@ -56,13 +56,13 @@ Der Treiber wird in 3 Schichten realisiert: - ~~gibt es bei der Speicherbelegung große Unterschieden bei versch. Fonts?~~ ### DR_INIT -~~- Adapterfunktion für DR_INIT schreiben~~ -~~- Aufruf in truetypeInit.asm~~ +- ~~Adapterfunktion für DR_INIT schreiben~~ +- ~~Aufruf in truetypeInit.asm~~ - prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_EXIT -~~- Adapter für DR_EXIT schreiben~~ -~~- Aufruf in truetypeInit.asm~~ +- ~~Adapter für DR_EXIT schreiben~~ +- ~~Aufruf in truetypeInit.asm~~ - prüfen ob die Adapterfunktion sauber durchlaufen wird ### DR_FONT_GEN_CHAR @@ -70,6 +70,7 @@ Der Treiber wird in 3 Schichten realisiert: - Kerning implementieren - Aufruf in truetypeChars.asm - prüfen ob die Adapterfunktion sauber durchlaufen wird +- das gerenderte Glyph wird in die GEOS Datenstrukturen einsortiert ### DR_FONT_GEN_WIDTHS - Adapterfunktion für DR_FONT_GEN_WIDTHS schreiben From 9ce0b4c9dacf5d289e989abf1f023306b30de907 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 30 Jul 2022 21:19:57 +0200 Subject: [PATCH 050/246] Reduce memory consumption by reconfiguring and removing unneeded attributes in various structures. --- Driver/Font/TrueType/FreeType/ft_conf.h | 2 +- Driver/Font/TrueType/FreeType/ttapi.c | 7 +--- Driver/Font/TrueType/FreeType/ttengine.h | 1 - Driver/Font/TrueType/FreeType/ttraster.c | 44 +----------------------- 4 files changed, 3 insertions(+), 51 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index d85915477..4911d9adc 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -154,7 +154,7 @@ /* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ /* version of the library. */ -#undef TT_CONFIG_OPTION_THREAD_SAFE +#define TT_CONFIG_OPTION_THREAD_SAFE /**********************************************************************/ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 9a1bea030..f3662bec1 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -115,8 +115,7 @@ PEngine_Instance _engine; TT_Error error; - int n; - + /* first of all, initialize memory sub-system */ error = TTMemory_Init(); @@ -142,10 +141,6 @@ #undef TT_FAIL - /* set the gray palette defaults: 0 to 4 */ - for ( n = 0; n < 5; n++ ) - _engine->raster_palette[n] = (Byte)n; /* Conversion ok, some warn */ - /* create the engine lock */ MUTEX_Create( _engine->lock ); diff --git a/Driver/Font/TrueType/FreeType/ttengine.h b/Driver/Font/TrueType/FreeType/ttengine.h index c4945839f..0c00b0485 100644 --- a/Driver/Font/TrueType/FreeType/ttengine.h +++ b/Driver/Font/TrueType/FreeType/ttengine.h @@ -66,7 +66,6 @@ TMutex raster_lock; /* mutex for this engine's render pool */ void* raster_component; /* ttraster implementation depedent */ - Byte raster_palette[5]; /* gray-levels palette for anti-aliasing */ void* extension_component; /* extensions dependent */ diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index ce6d244b2..964f5a14b 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -54,10 +54,6 @@ /* The default render pool size */ #define RASTER_RENDER_POOL 4096 -/* The size of the two-lines intermediate bitmap used */ -/* for anti-aliasing */ -#define RASTER_GRAY_LINES 2048 - #define Raster_Err_None TT_Err_Ok #define Raster_Err_Not_Ini TT_Err_Raster_Not_Initialized @@ -297,19 +293,6 @@ Byte dropOutControl; /* current drop_out control method */ - Byte grays[5]; /* Palette of gray levels used for render */ - - Byte* gray_lines; /* Intermediate table used to render the */ - /* graylevels pixmaps. */ - /* gray_lines is a buffer holding two */ - /* monochrome scanlines */ - Short gray_width; /* width in bytes of one monochrome */ - /* intermediate scanline of gray_lines. */ - /* Each gray pixel takes 2 bits long there */ - - /* The gray_lines must hold 2 lines, thus with size */ - /* in bytes of at least 'gray_width*2' */ - Bool second_pass; /* indicates wether a horizontal pass */ /* should be performed to control drop-out */ /* accurately when calling Render_Glyph. */ @@ -2911,7 +2894,6 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, return TT_Err_Ok; FREE( ras->buff ); - FREE( ras->gray_lines ); #ifndef TT_CONFIG_OPTION_STATIC_RASTER FREE( engine->raster_component ); @@ -2926,8 +2908,6 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, { TT_Error error; - Int i, l, j, c; - TRaster_Instance* ras; @@ -2940,32 +2920,10 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras = (TRaster_Instance*)engine->raster_component; #endif - if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) || - ALLOC( ras->gray_lines, RASTER_GRAY_LINES ) ) + if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) return error; ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) ); - ras->gray_width = RASTER_GRAY_LINES/2; - - /* Initialization of Count_Table */ - - for ( i = 0; i < 256; i++ ) - { - l = 0; - j = i; - - for ( c = 0; c < 4; c++ ) - { - l <<= 4; - - if ( j & 0x80 ) l++; - if ( j & 0x40 ) l++; - - j = ( j << 2 ) & 0xFF; - } - - ras->count_table[i] = l; - } ras->dropOutControl = 2; ras->error = Raster_Err_None; From 6a6649b1542807eeb26db3f5c01ecf3de12a9b83 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Fri, 5 Aug 2022 19:26:25 +0200 Subject: [PATCH 051/246] Improved error handling and fix some parsing logic bugs. --- Driver/Font/TrueType/Main/truetypeInit.asm | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index e61f76018..f321e2575 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -171,7 +171,8 @@ TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp clr bx ; relative to CWD call FileSetCurrentPath pop ds - + jc done ; branch if error + ; ; Lookup all .ttf files sub sp, size FileEnumParams @@ -250,6 +251,7 @@ fontFile local hptr fontName local FONT_NAME_LEN dup (char) fontStyle local TextStyle fontWeight local FontWeight +tablesProcessed local word .enter ; @@ -290,6 +292,7 @@ fontWeight local FontWeight mov ah, subTableHeader.TTST_numTables.low mov al, subTableHeader.TTST_numTables.high mov tableCount, ax + mov tablesProcessed, 0 nextEntry: mov bx, fontFile segmov ds, ss @@ -333,8 +336,7 @@ nextEntry: jnc parseName ; free the block we don't keep it, bx handle of block - call MemFree - jmp doneClose + jmp freeAndClose parseName: ; get relevant data from name table @@ -346,11 +348,11 @@ parseName: mov cx, FONT_NAME_LEN ; buffer size mov ax, 2 ; sub family name of the font call GetNameFromTable - jc doneClose ; jump if no name found + jc freeAndClose ; jump if no name found lea si, fontName ; ss:si point to buffer call MapFontStyle - jc doneClose ; fail if style mapping fails + jc freeAndClose ; fail if style mapping fails mov fontStyle, al ; save fontStyle ; (type TextStyle) @@ -359,10 +361,13 @@ parseName: mov cx, FONT_NAME_LEN ; buffer size mov ax, 1 ; family name of the font call GetNameFromTable - jc doneClose ; jump if no name found + jc freeAndClose ; jump if no name found ; free the block we don't keep it, bx handle of block + inc tablesProcessed call MemFree + jmp cont + tryOS_2: mov ax, 'OS' cmp ax, tableDirectory.TTTD_tag.low @@ -404,11 +409,17 @@ getWeight: mov si, ax mov al, cs:weightAdjustTable[si] mov fontWeight, al + inc tablesProcessed + call MemFree cont: dec tableCount jnz nextEntry + mov ax, tablesProcessed + cmp ax, 0 + je doneClose + ; we have one font and collected required meta data ; let compute/determ the fontid to be used for the font mov ax, 0 From 9a9e2de446b7645daed8cf0d45f728da1c85e834 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 5 Aug 2022 23:07:24 +0200 Subject: [PATCH 052/246] Zwischenstand --- Driver/Font/TrueType/Adapter/ttadapter.c | 4 +- Driver/Font/TrueType/Adapter/ttadapter.h | 3 +- Driver/Font/TrueType/FreeType/freetype.h | 15 +-- Driver/Font/TrueType/FreeType/ft_conf.h | 4 + Driver/Font/TrueType/FreeType/ttapi.c | 107 ++++-------------- Driver/Font/TrueType/FreeType/ttfile.c | 2 +- Driver/Font/TrueType/FreeType/ttmemory.h | 10 +- Driver/Font/TrueType/FreeType/ttraster.h | 4 +- Driver/Font/TrueType/Main/mainManager.asm | 3 +- .../Font/TrueType/Main/truetypeVariable.def | 10 +- 10 files changed, 46 insertions(+), 116 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index b6bd8b343..839d70312 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -48,7 +48,7 @@ TT_Error _pascal Init_FreeType() TT_Error error; - error = TT_Init_FreeType( &tt_Engine ); + error = TT_Init_FreeType( &engineHandle ); if ( error != TT_Err_Ok ) return error; @@ -81,5 +81,5 @@ TT_Error _pascal Init_FreeType() TT_Error _pascal Exit_FreeType() { - return TT_Done_FreeType( tt_Engine ); + return TT_Done_FreeType( engineHandle ); } diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 990092df8..5a0693722 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -26,7 +26,8 @@ /*********************************************************************** * global dgoup objects ***********************************************************************/ -extern TT_Engine tt_Engine; +extern MemHandle trueTypeHandle; +extern ChunkHandle engineHandle; #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index c1e90d5f9..f2a79f02c 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -623,14 +623,12 @@ /* automatic type conversions for library hackers... */ //TODO: soll TT_*_ ersetzen - struct GTT_Engine_ { MemHandle z; }; struct GTT_Stream_ { MemHandle z; }; struct GTT_Face_ { MemHandle z; }; struct GTT_Instance_ { MemHandle z; }; struct GTT_Glyph_ { MemHandle z; }; struct GTT_CharMap_ { MemHandle z; }; - struct TT_Engine_ { void* z; }; struct TT_Stream_ { void* z; }; struct TT_Face_ { void* z; }; struct TT_Instance_ { void* z; }; @@ -638,14 +636,13 @@ struct TT_CharMap_ { void* z; }; //TODO: soll TT_* ersetzen - typedef struct GTT_Engine_ GTT_Engine; typedef struct GTT_Stream_ GTT_Stream; typedef struct GTT_Face_ GTT_Face; typedef struct GTT_Instance_ GTT_Instance; typedef struct GTT_Glyph_ GTT_Glyph; typedef struct GTT_CharMap_ GTT_CharMap; - typedef struct TT_Engine_ TT_Engine; /* engine instance */ + typedef ChunkHandle TT_Engine; /* handle to engine instance */ typedef struct TT_Stream_ TT_Stream; /* stream handle type */ typedef struct TT_Face_ TT_Face; /* face handle type */ typedef struct TT_Instance_ TT_Instance; /* instance handle type */ @@ -729,16 +726,6 @@ TT_Face* face ); - /* Open a TrueType font file located inside a collection. */ - /* The font is assigned by its index in `fontIndex'. */ - - EXPORT_DEF - TT_Error TT_Open_Collection( TT_Engine engine, - const TT_Text* collectionPathName, - TT_ULong fontIndex, - TT_Face* face ); - - /* Return face properties in the `properties' structure. */ /* */ /* Note that since version 1.3, we support font files with no */ diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index 4911d9adc..87f3c02ab 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -17,6 +17,10 @@ #include #include +/* MemHandle to our global memory block under FreeGEOS. In this memory block */ +/* we hold all dynamically allocated FreeType structures we need. */ +extern MemHandle trueTypeHandle; + /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index f3662bec1..1ea57a91b 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -123,11 +123,11 @@ return error; /* Allocate engine instance */ - if ( ALLOC( _engine, sizeof ( TEngine_Instance ) ) ) + if ( GALLOC( *engine, sizeof ( TEngine_Instance ) ) ) return error; #undef TT_FAIL -#define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok +#define TT_FAIL( x ) ( error = x (*engine) ) != TT_Err_Ok /* Initalize components */ if ( TT_FAIL( TTFile_Init ) || @@ -142,14 +142,14 @@ #undef TT_FAIL /* create the engine lock */ + _engine = (PEngine_Instance)DEREF( engine ); MUTEX_Create( _engine->lock ); - HANDLE_Set( *engine, _engine ); return TT_Err_Ok; Fail: TT_Done_FreeType( *engine ); - HANDLE_Set( *engine, NULL ); + *engine = NullChunk; return error; } @@ -176,22 +176,23 @@ EXPORT_FUNC TT_Error TT_Done_FreeType( TT_Engine engine ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine; - if ( !_engine ) + if ( !engine ) return TT_Err_Ok; + _engine = (PEngine_Instance)DEREF( engine ); MUTEX_Destroy( _engine->lock ); - TTRaster_Done( _engine ); - TTObjs_Done ( _engine ); + TTRaster_Done( engine ); + TTObjs_Done ( engine ); #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - TTExtend_Done( _engine ); + TTExtend_Done( engine ); #endif - TTCache_Done ( _engine ); - TTFile_Done ( _engine ); - FREE( _engine ); + TTCache_Done ( engine ); + TTFile_Done ( engine ); + GFREE( engine ); TTMemory_Done(); @@ -259,7 +260,7 @@ const TT_Text* fontPathName, TT_Face* face ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine; TFont_Input input; TT_Error error; @@ -267,7 +268,7 @@ PFace _face; - if ( !_engine ) + if ( !engine ) return TT_Err_Invalid_Engine; /* open the file */ @@ -280,6 +281,7 @@ input.engine = _engine; /* Create and load the new face object - this is thread-safe */ + _engine = (PEngine_Instance)DEREF( engine ); error = CACHE_New( _engine->objs_face_cache, _face, &input ); @@ -298,71 +300,6 @@ } -/******************************************************************* - * - * Function : TT_Open_Collection - * - * Description : Creates a new face object from a given font file. - * - * Input : engine FreeType engine instance - * collectionPathName the font file's pathname - * fontIndex index of font in TrueType collection - * face adress of returned face handle - * - * Output : Error code. - * - * Note : The face handle is set to NULL in case of failure. - * - * MT-Note : YES! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Open_Collection( TT_Engine engine, - const TT_Text* collectionPathName, - TT_ULong fontIndex, - TT_Face* face ) - { - PEngine_Instance _engine = HANDLE_Engine( engine ); - - TFont_Input input; - TT_Error error; - TT_Stream stream; - PFace _face; - - - if ( !_engine ) - return TT_Err_Invalid_Engine; - - /* open the file */ - error = TT_Open_Stream( collectionPathName, &stream ); - if ( error ) - return error; - - input.stream = stream; - input.fontIndex = fontIndex; - input.engine = _engine; - - /* Create and load the new face object - this is thread-safe */ - error = CACHE_New( _engine->objs_face_cache, - _face, - &input ); - - /* Set the handle */ - HANDLE_Set( *face, _face ); - - if ( error ) - goto Fail; - - return TT_Err_Ok; - - Fail: - TT_Close_Stream( &stream ); - - return error; - } - - /******************************************************************* * * Function : TT_Get_Face_Properties @@ -1358,7 +1295,7 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - HANDLE_Set( engine, _engine ); + // HANDLE_Set( engine, _engine ); outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1487,7 +1424,7 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); + // HANDLE_Set(engine,_engine); outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1535,7 +1472,7 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); + // HANDLE_Set(engine,_engine); outline = _glyph->outline; @@ -1591,7 +1528,7 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); + // HANDLE_Set(engine,_engine); outline = _glyph->outline; @@ -1733,7 +1670,7 @@ TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine; // = HANDLE_Engine( engine ); TT_Error error; @@ -1814,7 +1751,7 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine; // = HANDLE_Engine( engine ); TT_Error error; diff --git a/Driver/Font/TrueType/FreeType/ttfile.c b/Driver/Font/TrueType/FreeType/ttfile.c index f748aea15..5ac0ae4c2 100644 --- a/Driver/Font/TrueType/FreeType/ttfile.c +++ b/Driver/Font/TrueType/FreeType/ttfile.c @@ -464,7 +464,7 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) + TT_Error TTFile_Init( TT_Engine engine ) { return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h index 3e33c37a3..0e9d94e8c 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.h +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -88,7 +88,7 @@ #define MEM_UNLOCK MemUnlock( _memBlock ) #define GMEM_Alloc( _handle_, _size_ ) \ - GTT_Alloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + GTT_Alloc( trueTypeHandle, (ChunkHandle*)&(_handle_), _size_ ) #define GMEM_Realloc( _handle_, _size_ ) \ GTT_Realloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) @@ -108,7 +108,13 @@ (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) #define GFREE( _handle_ ) \ - GTT_Free( (ChunkHandle*)&(_handle_) ) + GTT_Free( trueTypeHandle, (ChunkHandle*)&(_handle_) ) + +#define DEREF( _handle_ ) LMemDerefHandles( trueTypeHandle, _handle_ ) + +#define FIELD( _type_, _chunk_, _field_) (((_type_*)DEREF(_chunk_))->_field_) + +#define ARRAY( _type_, _chunk_, _field_, _array_) ((_array_*)FIELD( _type_, _chunk_, _field_)) /* ENDE: diese Makros sollen die o.g. ablösen */ diff --git a/Driver/Font/TrueType/FreeType/ttraster.h b/Driver/Font/TrueType/FreeType/ttraster.h index b78b6d583..90d4192bf 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.h +++ b/Driver/Font/TrueType/FreeType/ttraster.h @@ -119,11 +119,11 @@ extern "C" { /* Initialize rasterizer */ LOCAL_DEF - TT_Error TTRaster_Init( PEngine_Instance engine ); + TT_Error TTRaster_Init( TT_Engine engine ); /* Finalize it */ LOCAL_DEF - TT_Error TTRaster_Done( PEngine_Instance engine ); + TT_Error TTRaster_Done( TT_Engine engine ); #ifdef __cplusplus diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index 9995cb3f1..f98b55219 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -115,7 +115,8 @@ CharMod ends global INIT_FREETYPE:far global EXIT_FREETYPE:far -global tt_Engine:TT_Engine +global engineHandle:lptr; +global trueTypeHandle:hptr; MetricsMod segment resource include truetypeMetrics.asm diff --git a/Driver/Font/TrueType/Main/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def index f6f48dabd..2b08c8b9f 100644 --- a/Driver/Font/TrueType/Main/truetypeVariable.def +++ b/Driver/Font/TrueType/Main/truetypeVariable.def @@ -68,13 +68,6 @@ TrueTypeOutlineEntry struct TTOE_fontFileName DosDotFileName TrueTypeOutlineEntry ends -; -; TT_Engine structure of the FreeType framework -; -TT_Engine struct - z fptr -TT_Engine ends - ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ @@ -102,7 +95,8 @@ bitmapSize word ;size of our bitmap block (in bytes) variableHandle hptr ;handle of our variable block -tt_Engine TT_Engine ;structure for all FreeType variables +trueTypeHandle hptr ;MemHandle to hold all FreeType structures +engineHandle lptr ;ChunkHandle to TT_EngineInstance udata ends From d498a358513bf5b05b22afd30a012b28edac8b83 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 5 Aug 2022 23:59:48 +0200 Subject: [PATCH 053/246] Umstellung auf LMemBlock Start --- .../testapps/ttf2/FreeType/freetype.h | 25 ----- .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 2 +- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 106 ------------------ .../testapps/ttf2/FreeType/ttengine.h | 12 +- .../testapps/ttf2/FreeType/ttraster.c | 45 +------- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 23 +++- 6 files changed, 23 insertions(+), 190 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index e210b88ef..6d2387aef 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -680,21 +680,6 @@ TT_Error TT_Done_FreeType( TT_Engine engine ); - /* Set the gray level palette. This is an array of 5 bytes used */ - /* to produce the font smoothed pixmaps. By convention: */ - /* */ - /* palette[0] = background (white) */ - /* palette[1] = light */ - /* palette[2] = medium */ - /* palette[3] = dark */ - /* palette[4] = foreground (black) */ - /* */ - - EXPORT_DEF - TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, - TT_Byte* palette ); - - /* ----------------------- face management ----------------------- */ /* Open a new TrueType font file, and returns a handle for */ @@ -713,16 +698,6 @@ TT_Face* face ); - /* Open a TrueType font file located inside a collection. */ - /* The font is assigned by its index in `fontIndex'. */ - - EXPORT_DEF - TT_Error TT_Open_Collection( TT_Engine engine, - const TT_Text* collectionPathName, - TT_ULong fontIndex, - TT_Face* face ); - - /* Return face properties in the `properties' structure. */ /* */ /* Note that since version 1.3, we support font files with no */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index de3c0d233..4bbab823f 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -151,7 +151,7 @@ /* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ /* version of the library. */ -#undef TT_CONFIG_OPTION_THREAD_SAFE +#define TT_CONFIG_OPTION_THREAD_SAFE /**********************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 9a1bea030..6e32e0d9d 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -142,10 +142,6 @@ #undef TT_FAIL - /* set the gray palette defaults: 0 to 4 */ - for ( n = 0; n < 5; n++ ) - _engine->raster_palette[n] = (Byte)n; /* Conversion ok, some warn */ - /* create the engine lock */ MUTEX_Create( _engine->lock ); @@ -204,43 +200,6 @@ } -#ifdef TT_CONFIG_OPTION_GRAY_SCALING - -/******************************************************************* - * - * Function : TT_Set_Raster_Gray_Palette - * - * Description : Sets the gray-levels palette used for font - * smoothing. - * - * Input : engine FreeType engine instance - * palette address of palette (a 5 byte array) - * - * Output : Invalid argument if 'palette' is NULL. - * - * MT-Note: NO! Unprotected modification of an engine's palette. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, - Byte* palette ) - { - int i; - - - if ( !palette ) - return TT_Err_Invalid_Argument; - - for ( i = 0; i < 5; i++ ) - HANDLE_Engine( engine )->raster_palette[i] = (Byte)palette[i]; - - return TT_Err_Ok; - } - -#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ - - /******************************************************************* * * Function : TT_Open_Face @@ -303,71 +262,6 @@ } -/******************************************************************* - * - * Function : TT_Open_Collection - * - * Description : Creates a new face object from a given font file. - * - * Input : engine FreeType engine instance - * collectionPathName the font file's pathname - * fontIndex index of font in TrueType collection - * face adress of returned face handle - * - * Output : Error code. - * - * Note : The face handle is set to NULL in case of failure. - * - * MT-Note : YES! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Open_Collection( TT_Engine engine, - const TT_Text* collectionPathName, - TT_ULong fontIndex, - TT_Face* face ) - { - PEngine_Instance _engine = HANDLE_Engine( engine ); - - TFont_Input input; - TT_Error error; - TT_Stream stream; - PFace _face; - - - if ( !_engine ) - return TT_Err_Invalid_Engine; - - /* open the file */ - error = TT_Open_Stream( collectionPathName, &stream ); - if ( error ) - return error; - - input.stream = stream; - input.fontIndex = fontIndex; - input.engine = _engine; - - /* Create and load the new face object - this is thread-safe */ - error = CACHE_New( _engine->objs_face_cache, - _face, - &input ); - - /* Set the handle */ - HANDLE_Set( *face, _face ); - - if ( error ) - goto Fail; - - return TT_Err_Ok; - - Fail: - TT_Close_Stream( &stream ); - - return error; - } - - /******************************************************************* * * Function : TT_Get_Face_Properties diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h index c4945839f..ac8089466 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h @@ -62,17 +62,11 @@ void* objs_exec_cache; /* the current face and execution */ /* context objects */ - void* file_component; /* ttfile implementation dependent */ - - TMutex raster_lock; /* mutex for this engine's render pool */ - void* raster_component; /* ttraster implementation depedent */ - Byte raster_palette[5]; /* gray-levels palette for anti-aliasing */ + void* file_component; /* ttfile implementation dependent */ + TMutex raster_lock; /* mutex for this engine's render pool */ + void* raster_component; /* ttraster implementation depedent */ void* extension_component; /* extensions dependent */ - -#if 0 - TT_Glyph_Loader_Callback glCallback; /* glyph loader callback, if any */ -#endif }; /* NOTE : The raster's lock is only acquired by the Render_Glyph and */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index ce6d244b2..bf1d2a4ca 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -54,10 +54,6 @@ /* The default render pool size */ #define RASTER_RENDER_POOL 4096 -/* The size of the two-lines intermediate bitmap used */ -/* for anti-aliasing */ -#define RASTER_GRAY_LINES 2048 - #define Raster_Err_None TT_Err_Ok #define Raster_Err_Not_Ini TT_Err_Raster_Not_Initialized @@ -297,19 +293,6 @@ Byte dropOutControl; /* current drop_out control method */ - Byte grays[5]; /* Palette of gray levels used for render */ - - Byte* gray_lines; /* Intermediate table used to render the */ - /* graylevels pixmaps. */ - /* gray_lines is a buffer holding two */ - /* monochrome scanlines */ - Short gray_width; /* width in bytes of one monochrome */ - /* intermediate scanline of gray_lines. */ - /* Each gray pixel takes 2 bits long there */ - - /* The gray_lines must hold 2 lines, thus with size */ - /* in bytes of at least 'gray_width*2' */ - Bool second_pass; /* indicates wether a horizontal pass */ /* should be performed to control drop-out */ /* accurately when calling Render_Glyph. */ @@ -319,9 +302,6 @@ TBand band_stack[16]; /* band stack used for sub-banding */ Int band_top; /* band stack top */ - - Int count_table[256]; /* Look-up table used to quickly count */ - /* set bits in a gray 2x2 cell */ }; @@ -2911,7 +2891,6 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, return TT_Err_Ok; FREE( ras->buff ); - FREE( ras->gray_lines ); #ifndef TT_CONFIG_OPTION_STATIC_RASTER FREE( engine->raster_component ); @@ -2940,32 +2919,10 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras = (TRaster_Instance*)engine->raster_component; #endif - if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) || - ALLOC( ras->gray_lines, RASTER_GRAY_LINES ) ) + if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) return error; ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) ); - ras->gray_width = RASTER_GRAY_LINES/2; - - /* Initialization of Count_Table */ - - for ( i = 0; i < 256; i++ ) - { - l = 0; - j = i; - - for ( c = 0; c < 4; c++ ) - { - l <<= 4; - - if ( j & 0x80 ) l++; - if ( j & 0x40 ) l++; - - j = ( j << 2 ) & 0xFF; - } - - ras->count_table[i] = l; - } ras->dropOutControl = 2; ras->error = Raster_Err_None; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index c99eb819a..9427e0ef5 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -16,6 +16,10 @@ TT_Engine engine; TT_Face face; +/* Umstellung auf LMemBlock */ +MemHandle trueTypeHandle; +ChunkHandle engineChunk; + typedef struct { Bitmap b; char data[20 * 3]; @@ -233,9 +237,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word if( TT_Get_Glyph_Region( glyph, ®ionmap, 0, 0 ) ) return; sprintf(tmpStr, "11: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); -/* - sprintf(tmpStr, "region size:\t%d\r", (regionmap.size)); _log(tmpStr); -*/ + //GrDrawRegion(gstate, 60, 60, region, 0, 0); free(region); @@ -243,14 +245,25 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word @method TtfProcessClass, MSG_META_EXPOSED { GStateHandle gstate = GrCreateState( win ); - + Init(); GrBeginUpdate( gstate ); testRendering( gstate ); GrEndUpdate( gstate ); - + Free(); GrDestroyState( gstate ); } +void Init() { + trueTypeHandle = MemAlloc( 2048, HF_SWAPABLE, HAF_ZERO_INIT | HAF_LOCK ); + LMemInitHeap(trueTypeHandle, LMEM_TYPE_GENERAL, 0, + sizeof(LMemBlockHeader), STD_INIT_HANDLES, STD_INIT_HEAP); +} + +void Free() { + MemUnlock(trueTypeHandle); + MemFree(trueTypeHandle); +} + void _log(char * message) { @call LogText::MSG_VIS_TEXT_APPEND_PTR(message, 0); } From 184e2437faf561f23f214b54c47e00b1662118bf Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 6 Aug 2022 10:27:26 +0200 Subject: [PATCH 054/246] Umstellung Speichermanagement Teil 2 --- .../testapps/ttf2/FreeType/ttconfig.h | 7 - .../testapps/ttf2/FreeType/ttmemory.c | 67 +++++++ .../testapps/ttf2/FreeType/ttmemory.h | 36 ++++ .../testapps/ttf2/FreeType/ttraster.c | 175 +----------------- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 12 +- 5 files changed, 110 insertions(+), 187 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h index 87adcacb9..8893acb99 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h @@ -36,13 +36,6 @@ #include "ft_conf.h" -/**************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -/* #define TT_CONFIG_OPTION_THREAD_SAFE */ - - /* ------------ general debugging -------------------------------------- */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c index a8acf92fc..b937c5c69 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c @@ -151,6 +151,31 @@ } + /* TODO: diese Funktion soll TT_Alloc ablösen */ + EXPORT_FUNC + TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ) + { + if ( !M || !C ) + return TT_Err_Invalid_Argument; + + if ( Size > (size_t)-1 ) + return TT_Err_Out_Of_Memory; + if ( Size > 0 ) + { + *C = LMemAlloc( M, Size ); + if ( !*C ) + return TT_Err_Out_Of_Memory; + + MEM_Set( DEREF( C ), 0, Size ); + } + else + *C = NullChunk; + + return TT_Err_Ok; + } + + + #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE @@ -244,6 +269,33 @@ } + /* TODO: diese Funktion soll TT_Realloc ablösen */ + EXPORT_FUNC + TT_Error GTT_Realloc( MemHandle M, ChunkHandle* C, unsigned int Size ) + { + if ( !M || !C ) + return TT_Err_Invalid_Argument; + + if ( !*C ) + return GTT_Alloc( M, C, Size ); + + if ( Size == 0 ) + return GTT_Free( M, C ); + + if ( Size > (size_t)-1 ) + { + GTT_Free( M, C ); + return TT_Err_Out_Of_Memory; + } + + *C = LMemReAllocHandles( M, *C, Size ); + if ( !*C ) + return TT_Err_Out_Of_Memory; + + return TT_Err_Ok; + } + + #endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ @@ -305,6 +357,21 @@ } + /* TODO: diese Funktion soll TT_Free ablösen */ + EXPORT_FUNC + TT_Error GTT_Free( MemHandle M, ChunkHandle* C ) + { + if ( !M || !C || !*C ) + return TT_Err_Ok; + + LMemFreeHandles( M, *C ); + + *C = NullHandle; + + return TT_Err_Ok; + } + + /******************************************************************* * * Function : TTMemory_Init diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h index 42fe0d997..2fcc2c790 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -81,6 +81,33 @@ TT_Free( (void**)&(_pointer_) ) + /* Macros needed to port FreeType for FreeGEOS */ + +#define GMEM_Alloc( _handle_, _size_ ) \ + GTT_Alloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + +#define GMEM_Realloc( _handle_, _size_ ) \ + GTT_Realloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + +#define GALLOC( _handle_, _size_ ) \ + ( ( error = GMEM_Alloc( _handle_, _size_ ) ) != TT_Err_Ok ) + +#define GALLOC_ARRAY( _handle_, _count_, _type_ ) \ + ( ( error = GMEM_Alloc( _handle_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define GREALLOC( _handle_, _size_ ) \ + ( ( error = GMEM_Realloc( _handle_, _size_ ) ) != TT_Err_Ok ) + +#define GREALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( (error = GMEM_Realloc( _handle_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define GFREE( _handle_ ) \ + GTT_Free( (ChunkHandle*)&(_handle_) ) + + + /* Allocate a block of memory of 'Size' bytes from the heap, and */ /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ /* case of error, the pointer is always set to NULL. */ @@ -88,6 +115,9 @@ EXPORT_DEF TT_Error TT_Alloc( ULong Size, void** P ); + EXPORT_DEF + TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ); + #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE /* Reallocates a block of memory pointed to by '*P' to 'Size' */ @@ -98,6 +128,9 @@ EXPORT_DEF TT_Error TT_Realloc( ULong Size, void** P ); + EXPORT_DEF + TT_Error GTT_Realloc( MemHandle M, ChunkHandle* C, unsigned int Size ); + #endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ /* Releases a block that was previously allocated through Alloc. */ @@ -108,6 +141,9 @@ EXPORT_DEF TT_Error TT_Free( void** P ); + EXPORT_DEF + TT_Error GTT_Free( MemHandle M, ChunkHandle* C ); + /* For "legacy" applications, that should be re-coded. */ /* Note that this won't release the previously allocated font pool. */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index bf1d2a4ca..8cf9c46ed 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -317,68 +317,6 @@ #endif /* TT_STATIC_RASTER */ -#ifdef DEBUG_RASTER - - /************************************************/ - /* */ - /* Pset: */ - /* */ - /* Used for debugging only. Plots a point */ - /* in VRAM during rendering (not afterwards). */ - /* */ - /* NOTE: This procedure relies on the value */ - /* of cProfile->start, which may not */ - /* be set when Pset is called sometimes. */ - /* This will usually result in a dot */ - /* plotted on the first screen scanline */ - /* (far away its original position). */ - /* */ - /* This "bug" reflects nothing wrong */ - /* in the current implementation, and */ - /* the bitmap is rendered correctly, */ - /* so don't panic if you see 'flying' */ - /* dots in debugging mode. */ - /* */ - /* - David */ - /* */ - /************************************************/ - - static void Pset( RAS_ARG ) - { - Long o; - Long x; - - - x = ras.top[-1]; - - switch ( ras.cProfile->flow ) - { - case TT_Flow_Up: - o = Vio_ScanLineWidth * - ( ras.top-ras.cProfile->offset + ras.cProfile->start ) + - ( x / (ras.precision*8) ); - break; - - case TT_Flow_Down: - o = Vio_ScanLineWidth * - ( ras.cProfile->start-ras.top + ras.cProfile->offset ) + - ( x / (ras.precision*8) ); - break; - } - - if ( o > 0 ) - Vio[o] |= (unsigned)0x80 >> ( (x/ras.precision) & 7 ); - } - - - static void Clear_Band( RAS_ARGS Int y1, Int y2 ) - { - MEM_Set( Vio + y1*Vio_ScanLineWidth, (y2-y1+1)*Vio_ScanLineWidth, 0 ); - } - -#endif /* DEBUG_RASTER */ - - /************************************************************************/ /* */ /* Function: Set_High_Precision */ @@ -2683,115 +2621,6 @@ Scan_DropOuts : } -#ifdef TT_CONFIG_OPTION_GRAY_SCALING - -/****************************************************************************/ -/* */ -/* Function: Render_Gray_Glyph */ -/* */ -/* Description: Renders a glyph with grayscaling. Sub-banding if needed. */ -/* */ -/* Input: AGlyph Glyph record */ -/* */ -/* Returns: SUCCESS on success */ -/* FAILURE if any error was encountered during rendering. */ -/* */ -/****************************************************************************/ - - LOCAL_FUNC - TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, - TT_Raster_Map* target_map, - Byte* palette ) - { - Int i; - TT_Error error; - - if ( !ras.buff ) - { - ras.error = Raster_Err_Not_Ini; - return ras.error; - } - - if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) - return TT_Err_Ok; - - if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) - { - ras.error = TT_Err_Too_Many_Points; - return ras.error; - } - - if ( palette ) - { - for ( i = 0; i < 5; i++ ) - ras.grays[i] = palette[i]; - } - - if ( target_map ) - ras.target = *target_map; - - ras.outs = glyph->contours; - ras.flags = glyph->flags; - ras.nPoints = glyph->n_points; - ras.nContours = glyph->n_contours; - ras.coords = glyph->points; - - Set_High_Precision( RAS_VARS glyph->high_precision ); - ras.scale_shift = ras.precision_shift+1; - ras.dropOutControl = glyph->dropout_mode; - ras.second_pass = glyph->second_pass; - - - /* Vertical Sweep */ - - ras.band_top = 0; - ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = 2 * ras.target.rows - 1; - - ras.bWidth = ras.gray_width; - if ( ras.bWidth > ras.target.cols/4 ) - ras.bWidth = ras.target.cols/4; - - ras.bWidth = ras.bWidth * 8; - ras.bTarget = (Byte*)ras.gray_lines; - ras.gTarget = (Byte*)ras.target.bitmap; - - ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; - ras.Proc_Sweep_Finish = Vertical_Sweep_Finish; - - error = Render_Single_Pass( RAS_VARS 0 ); - if (error) - return error; - - /* Horizontal Sweep */ - - if ( ras.second_pass && ras.dropOutControl != 0 ) - { - ras.Proc_Sweep_Init = Horizontal_Sweep_Init; - ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; - ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; - ras.Proc_Sweep_Step = Horizontal_Sweep_Step; - ras.Proc_Sweep_Finish = Horizontal_Sweep_Finish; - - - ras.band_top = 0; - ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = ras.target.width * 2 - 1; - - error = Render_Single_Pass( RAS_VARS 1 ); - if (error) - return error; - } - - return TT_Err_Ok; - } - -#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ - - #ifdef __GEOS__ /****************************************************************************/ @@ -2905,8 +2734,6 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, { TT_Error error; - Int i, l, j, c; - TRaster_Instance* ras; @@ -2919,7 +2746,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras = (TRaster_Instance*)engine->raster_component; #endif - if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) + if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) return error; ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) ); diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 9427e0ef5..010a85bbe 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -100,11 +100,11 @@ void testRendering(GStateHandle gstate) { } sprintf(tmpStr, "1: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - error = TT_Init_Kerning_Extension(&engine); + /* error = TT_Init_Kerning_Extension(&engine); if(error) { _log("Fehler bei der Initialisierung des Kernings\r"); goto Fail; - } + }*/ sprintf(tmpStr, "2: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_Open_Face(engine, "DejaVu.ttf", &face); @@ -135,7 +135,7 @@ void testRendering(GStateHandle gstate) { } sprintf(tmpStr, "5: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - error = TT_Set_Instance_CharSize(instance, 42*64); + error = TT_Set_Instance_CharSize(instance, 36*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; @@ -152,7 +152,7 @@ void testRendering(GStateHandle gstate) { TT_Get_CharMap(face, 0, &charMap); sprintf(tmpStr, "8: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - charIndex = TT_Char_Index(charMap, 64); + charIndex = TT_Char_Index(charMap, 65); sprintf(tmpStr, "9: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); // DrawBitmap( gstate, instance, glyph); @@ -213,7 +213,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word TT_Raster_Map regionmap; TT_Glyph_Metrics metrics; - Region* region = calloc(sizeof(Region), 1000); + Region* region = calloc(sizeof(Region), 400); regionmap.flow = TT_Flow_Down; regionmap.bitmap = ®ion[4]; @@ -238,7 +238,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word return; sprintf(tmpStr, "11: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - //GrDrawRegion(gstate, 60, 60, region, 0, 0); + GrDrawRegion(gstate, 60, 60, region, 0, 0); free(region); } From aba91e148ef8b1191ed42aad31f887568bd5118f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 6 Aug 2022 23:48:19 +0200 Subject: [PATCH 055/246] hptr --- Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h | 6 ++++++ Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 1 - Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c | 4 ++++ Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h | 8 +++++--- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 4 ++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index 4bbab823f..a0ae24007 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -13,6 +13,12 @@ #include #include #include +#include +#include + +/* MemHandle to our global memory block under FreeGEOS. In this memory block */ +/* we hold all dynamically allocated FreeType structures we need. */ +extern MemHandle trueTypeHandle; /* Define to empty if the keyword does not work. */ /* #undef const */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 6e32e0d9d..9b0d6558e 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -115,7 +115,6 @@ PEngine_Instance _engine; TT_Error error; - int n; /* first of all, initialize memory sub-system */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index 719f74ac2..606bdd94d 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -286,7 +286,11 @@ reset = cache->clazz->reset; if ( reset ) { +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( reset, object, parent_object ); +#else error = reset( object, parent_object ); +#endif if ( error ) { LOCK(); diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h index 2fcc2c790..a77ce147b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -84,10 +84,10 @@ /* Macros needed to port FreeType for FreeGEOS */ #define GMEM_Alloc( _handle_, _size_ ) \ - GTT_Alloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + GTT_Alloc( trueTypeHandle, (ChunkHandle*)&(_handle_), _size_ ) #define GMEM_Realloc( _handle_, _size_ ) \ - GTT_Realloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) + GTT_Realloc( trueTypeHandle, (ChunkHandle*)&(_handle_), _size_ ) #define GALLOC( _handle_, _size_ ) \ ( ( error = GMEM_Alloc( _handle_, _size_ ) ) != TT_Err_Ok ) @@ -104,7 +104,9 @@ (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) #define GFREE( _handle_ ) \ - GTT_Free( (ChunkHandle*)&(_handle_) ) + GTT_Free( trueTypeHandle, (ChunkHandle*)&(_handle_) ) + +#define DEREF( _handle_ ) LMemDerefHandles( trueTypeHandle, _handle_ ) diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 010a85bbe..5d39bde91 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -100,11 +100,11 @@ void testRendering(GStateHandle gstate) { } sprintf(tmpStr, "1: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - /* error = TT_Init_Kerning_Extension(&engine); + error = TT_Init_Kerning_Extension(&engine); if(error) { _log("Fehler bei der Initialisierung des Kernings\r"); goto Fail; - }*/ + } sprintf(tmpStr, "2: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_Open_Face(engine, "DejaVu.ttf", &face); From c778c969f478fddc46f98e9951202df38485b9c3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 7 Aug 2022 12:01:03 +0200 Subject: [PATCH 056/246] Kerning disabled because it causes a crash. --- .../testapps/ttf2/FreeType/ttconfig.h | 2 +- .../testapps/ttf2/FreeType/ttengine.h | 18 +++++----- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 33 +++++-------------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h index 8893acb99..ac6e62eb0 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttconfig.h @@ -103,7 +103,7 @@ /* Please note that probably not all OS-specific versions of ttmemory.c */ /* provide this functionality. */ -#define DEBUG_MEMORY +/* #define DEBUG_MEMORY */ /*************************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h index ac8089466..eff09089f 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h @@ -81,21 +81,21 @@ #ifdef TT_CONFIG_OPTION_THREAD_SAFE /* for re-entrant builds */ -#define ENGINE_ARG TEngine_Instance* _engine -#define ENGINE_ARGS TEngine_Instance* _engine, +//#define ENGINE_ARG TEngine_Instance* _engine +//#define ENGINE_ARGS TEngine_Instance* _engine, -#define ENGINE_VAR _engine -#define ENGINE_VARS _engine, +//#define ENGINE_VAR _engine +//#define ENGINE_VARS _engine, -#define ENGINE _engine +//#define ENGINE _engine #else /* for thread-safe builds */ -#define ENGINE_ARG /* void */ -#define ENGINE_ARGS +//#define ENGINE_ARG /* void */ +//#define ENGINE_ARGS -#define ENGINE_VAR -#define ENGINE_VARS +//#define ENGINE_VAR +//#define ENGINE_VARS #endif /* TT_CONFIG_OPTION_THREAD_SAFE */ diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 5d39bde91..916a143d0 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -25,12 +25,6 @@ typedef struct { char data[20 * 3]; } Bmp; -extern int allocated; -extern unsigned int max_allocated; -extern unsigned int max_blocksize; -extern unsigned int num_blocks; -extern unsigned int max_num_blocks; - @class TtfProcessClass, GenProcessClass; @endc; @classdecl TtfProcessClass, neverSaved; @@ -98,29 +92,25 @@ void testRendering(GStateHandle gstate) { _log("Fehler bei Initialisierung\r"); goto Fail; } - sprintf(tmpStr, "1: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - - error = TT_Init_Kerning_Extension(&engine); + +/* error = TT_Init_Kerning_Extension(engine); if(error) { _log("Fehler bei der Initialisierung des Kernings\r"); goto Fail; - } - sprintf(tmpStr, "2: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); + }*/ error = TT_Open_Face(engine, "DejaVu.ttf", &face); if(error) { _log("Fehler beim laden des Fonts\r"); goto Fail; } - sprintf(tmpStr, "3: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_Get_Face_Properties(face, &props); if(error) { _log("Fehler beim laden der Properties\r"); goto Fail; } - sprintf(tmpStr, "4: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); -/* + /* sprintf(tmpStr, "num glyphs:\t%d\r", props.num_Glyphs); _log(tmpStr); sprintf(tmpStr, "num faces:\t%d\r", props.num_Faces); _log(tmpStr); sprintf(tmpStr, "num names:\t%d\r", props.num_Names); _log(tmpStr); @@ -133,28 +123,23 @@ void testRendering(GStateHandle gstate) { _log("Fehler beim erzeugen einer Instance\r"); goto Fail; } - sprintf(tmpStr, "5: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_Set_Instance_CharSize(instance, 36*64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; } - sprintf(tmpStr, "6: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); error = TT_New_Glyph(face, &glyph); if(error) { _log("Fehler beim anlegen eines Glyphs\r"); goto Fail; } - sprintf(tmpStr, "7: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - + TT_Get_CharMap(face, 0, &charMap); - sprintf(tmpStr, "8: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); charIndex = TT_Char_Index(charMap, 65); - sprintf(tmpStr, "9: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - + // DrawBitmap( gstate, instance, glyph); DrawRegion( gstate, instance, glyph, charIndex); @@ -220,8 +205,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word if( TT_Load_Glyph( instance, glyph, characterId, TTLOAD_DEFAULT | TTLOAD_PEDANTIC ) ) return; - sprintf(tmpStr, "10: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - + if( TT_Get_Glyph_Metrics( glyph, &metrics ) ) return; @@ -236,8 +220,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word if( TT_Get_Glyph_Region( glyph, ®ionmap, 0, 0 ) ) return; - sprintf(tmpStr, "11: \t%u\t%u\t%u\t%u\t%u\r", allocated, max_allocated, max_blocksize, num_blocks, max_num_blocks); _log(tmpStr); - + GrDrawRegion(gstate, 60, 60, region, 0, 0); free(region); From 4f4cd39c81517fbf057b24463ee3f89e4c9f35a9 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 12 Aug 2022 23:22:42 +0200 Subject: [PATCH 057/246] Checkin zur weiteren Untersuchung --- .../testapps/ttf2/FreeType/freetype.h | 5 +- .../Breadbox/testapps/ttf2/FreeType/ftxkern.c | 10 ++- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 75 ++++++++++++------- .../testapps/ttf2/FreeType/ttextend.c | 2 +- .../testapps/ttf2/FreeType/ttmemory.c | 6 +- .../testapps/ttf2/FreeType/ttmemory.h | 6 ++ Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 3 +- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 10 ++- Appl/Breadbox/testapps/ttf2/local.mk | 4 + 9 files changed, 81 insertions(+), 40 deletions(-) create mode 100644 Appl/Breadbox/testapps/ttf2/local.mk diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 6d2387aef..362e5ceab 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -622,14 +622,15 @@ /* NOTE: Some macros are defined in tttypes.h to perform */ /* automatic type conversions for library hackers... */ - struct TT_Engine_ { void* z; }; + //struct TT_Engine_ { void* z; }; struct TT_Stream_ { void* z; }; struct TT_Face_ { void* z; }; struct TT_Instance_ { void* z; }; struct TT_Glyph_ { void* z; }; struct TT_CharMap_ { void* z; }; - typedef struct TT_Engine_ TT_Engine; /* engine instance */ + //typedef struct TT_Engine_ TT_Engine; /* engine instance */ + typedef ChunkHandle TT_Engine; /* engine instance */ typedef struct TT_Stream_ TT_Stream; /* stream handle type */ typedef struct TT_Face_ TT_Face; /* face handle type */ typedef struct TT_Instance_ TT_Instance; /* instance handle type */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c index 6d6c9f9a0..d094ba4d9 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c @@ -544,12 +544,16 @@ EXPORT_FUNC TT_Error TT_Init_Kerning_Extension( TT_Engine engine ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine; + TT_Error error; - TT_Error error; + ECCheckLMemChunk( engine ); + + _engine = DEREF( engine ); + ECCheckBounds( _engine ); - if ( !_engine ) + if ( !engine || !_engine ) return TT_Err_Invalid_Engine; error = TT_Register_Extension( _engine, diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 9b0d6558e..dc9fcd8fb 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -113,23 +113,34 @@ TT_Error TT_Init_FreeType( TT_Engine* engine ) { PEngine_Instance _engine; + TT_Engine newEngine; + TT_Error error; + MemHandle t = trueTypeHandle; - TT_Error error; - - + ECCheckLMemHandle( trueTypeHandle ); + /* first of all, initialize memory sub-system */ error = TTMemory_Init(); if ( error ) return error; /* Allocate engine instance */ - if ( ALLOC( _engine, sizeof ( TEngine_Instance ) ) ) + if ( GALLOC( newEngine, sizeof ( TEngine_Instance ) ) ) return error; + ECCheckLMemChunk( newEngine ); + + if ( !newEngine ) + return TT_Err_Invalid_Engine; + + *engine = newEngine; + #undef TT_FAIL #define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok /* Initalize components */ + _engine = DEREF( *engine ); + ECCheckBounds( _engine ); if ( TT_FAIL( TTFile_Init ) || TT_FAIL( TTCache_Init ) || #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE @@ -143,13 +154,11 @@ /* create the engine lock */ MUTEX_Create( _engine->lock ); - - HANDLE_Set( *engine, _engine ); return TT_Err_Ok; Fail: TT_Done_FreeType( *engine ); - HANDLE_Set( *engine, NULL ); + *engine = NullChunk; return error; } @@ -176,10 +185,14 @@ EXPORT_FUNC TT_Error TT_Done_FreeType( TT_Engine engine ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); - + PEngine_Instance _engine; + + + ECCheckLMemChunk( &engine ); + _engine = DEREF( engine ); + ECCheckBounds( _engine ); - if ( !_engine ) + if ( !engine || !_engine ) return TT_Err_Ok; MUTEX_Destroy( _engine->lock ); @@ -191,7 +204,7 @@ #endif TTCache_Done ( _engine ); TTFile_Done ( _engine ); - FREE( _engine ); + GFREE( engine ); TTMemory_Done(); @@ -222,15 +235,18 @@ const TT_Text* fontPathName, TT_Face* face ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine; + TFont_Input input; + TT_Error error; + TT_Stream stream; + PFace _face; - TFont_Input input; - TT_Error error; - TT_Stream stream; - PFace _face; + ECCheckLMemChunk( &engine ); + _engine = DEREF( engine ); + ECCheckBounds( _engine ); - if ( !_engine ) + if ( !engine || !_engine ) return TT_Err_Invalid_Engine; /* open the file */ @@ -565,7 +581,7 @@ TT_Close_Stream( &_face->stream ); /* delete the face object -- this is thread-safe */ - return CACHE_Done( _face->engine->objs_face_cache, _face ); + return CACHE_Done( ENGINE_ELEMENT(_face->engine, objs_face_cache), _face ); } @@ -1244,7 +1260,7 @@ TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ) { - PEngine_Instance _engine; + //PEngine_Instance _engine; TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1255,8 +1271,9 @@ if ( !_glyph ) return TT_Err_Invalid_Glyph_Handle; - _engine = _glyph->face->engine; - HANDLE_Set( engine, _engine ); + // _engine = _glyph->face->engine; + // HANDLE_Set( engine, _engine ); + engine = _glyph->face->engine; outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1384,8 +1401,8 @@ if ( !_glyph ) return TT_Err_Invalid_Glyph_Handle; - _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); + engine = _glyph->face->engine; + //HANDLE_Set(engine,_engine); outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1432,8 +1449,8 @@ if ( !_glyph ) return TT_Err_Invalid_Glyph_Handle; - _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); + engine = _glyph->face->engine; + //HANDLE_Set(engine,_engine); outline = _glyph->outline; @@ -1488,8 +1505,8 @@ if ( !_glyph ) return TT_Err_Invalid_Glyph_Handle; - _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); + engine = _glyph->face->engine; + //HANDLE_Set(engine,_engine); outline = _glyph->outline; @@ -1631,7 +1648,7 @@ TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine = DEREF( engine ); TT_Error error; @@ -1712,7 +1729,7 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); + PEngine_Instance _engine = DEREF( engine ); TT_Error error; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index d0a1d384d..43ff8af45 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -124,7 +124,7 @@ if ( !face->extension ) return TT_Err_Extensions_Unsupported; - registry = (PExtension_Registry)face->engine->extension_component; + registry = (PExtension_Registry)ENGINE_ELEMENT(face->engine, extension_component); for ( n = 0; n < face->n_extensions; n++ ) { diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c index b937c5c69..d23aabae3 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c @@ -155,6 +155,8 @@ EXPORT_FUNC TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ) { + ECCheckLMemHandle( M ); + if ( !M || !C ) return TT_Err_Invalid_Argument; @@ -163,10 +165,12 @@ if ( Size > 0 ) { *C = LMemAlloc( M, Size ); + ECCheckLMemChunk( C ); + if ( !*C ) return TT_Err_Out_Of_Memory; - MEM_Set( DEREF( C ), 0, Size ); + MEM_Set( LMemDerefHandles( M, *C ), 0, Size ); } else *C = NullChunk; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h index a77ce147b..b72f78f8f 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -108,6 +108,12 @@ #define DEREF( _handle_ ) LMemDerefHandles( trueTypeHandle, _handle_ ) +#define ELEMENT( _typ_, _handle_, _element_ ) \ + ( ((_typ_)DEREF(_handle_))->_element_ ) + +#define ENGINE_ELEMENT( _handle_, _element_ ) \ + ELEMENT( PEngine_Instance, _handle_, _element_ ) + /* Allocate a block of memory of 'Size' bytes from the heap, and */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index 2414c9fcf..dfb818e58 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -478,7 +478,8 @@ struct TFace_ { /* parent engine instance for the face object */ - PEngine_Instance engine; + //PEngine_Instance engine; + TT_Engine engine; /* i/o stream */ TT_Stream stream; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 916a143d0..78f729205 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -85,8 +85,11 @@ void testRendering(GStateHandle gstate) { TT_Glyph_Metrics metrics; TT_CharMap charMap; TT_Error error; + MemHandle t = trueTypeHandle; //nur zum Test + ECCheckLMemHandle( trueTypeHandle ); + error = TT_Init_FreeType(&engine); if(error) { _log("Fehler bei Initialisierung\r"); @@ -110,14 +113,14 @@ void testRendering(GStateHandle gstate) { _log("Fehler beim laden der Properties\r"); goto Fail; } - /* + sprintf(tmpStr, "num glyphs:\t%d\r", props.num_Glyphs); _log(tmpStr); sprintf(tmpStr, "num faces:\t%d\r", props.num_Faces); _log(tmpStr); sprintf(tmpStr, "num names:\t%d\r", props.num_Names); _log(tmpStr); sprintf(tmpStr, "num charMaps:\t%d\r", props.num_CharMaps); _log(tmpStr); sprintf(tmpStr, "max points:\t%d\r", props.max_Points); _log(tmpStr); sprintf(tmpStr, "max contours:\t%d\r", props.max_Contours); _log(tmpStr); -*/ + error = TT_New_Instance(face, &instance); if(error) { _log("Fehler beim erzeugen einer Instance\r"); @@ -239,7 +242,8 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word void Init() { trueTypeHandle = MemAlloc( 2048, HF_SWAPABLE, HAF_ZERO_INIT | HAF_LOCK ); LMemInitHeap(trueTypeHandle, LMEM_TYPE_GENERAL, 0, - sizeof(LMemBlockHeader), STD_INIT_HANDLES, STD_INIT_HEAP); + sizeof(LMemBlockHeader), STD_INIT_HANDLES, STD_INIT_HEAP); + ECCheckLMemHandle( trueTypeHandle ); } void Free() { diff --git a/Appl/Breadbox/testapps/ttf2/local.mk b/Appl/Breadbox/testapps/ttf2/local.mk new file mode 100644 index 000000000..9954c88e5 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/local.mk @@ -0,0 +1,4 @@ +#include <$(SYSMAKEFILE)> + +XCCOMFLAGS = -zu + From e8f0c4d89dd9785983723b3c43d2da450afb727f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 14 Aug 2022 12:27:28 +0200 Subject: [PATCH 058/246] TEngine_Instance moved from heap to lmem. --- .../Breadbox/testapps/ttf2/FreeType/ft_conf.h | 9 +- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 15 +- .../testapps/ttf2/FreeType/ttmemory.c | 4 +- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 4 +- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 25 +-- Appl/Breadbox/testapps/ttf2/local.mk | 4 - .../Appl/Breadbox/testapps/ttf2/Makefile | 24 +-- .../Breadbox/testapps/ttf2/dependencies.mk | 183 ++++++++++-------- 8 files changed, 141 insertions(+), 127 deletions(-) delete mode 100644 Appl/Breadbox/testapps/ttf2/local.mk diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h index a0ae24007..4888f1f6d 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ft_conf.h @@ -8,17 +8,22 @@ #ifndef FT_CONF_H #define FT_CONF_H -/* Under FreeGEOS we need this for the file operations and render regions. */ +/* Under FreeGEOS we need some special includes. */ #include #include #include #include #include #include +#include + +/* FreeGEOS specific constants and definitions. */ +#define MAX_LMEM_CHUNKSIZE 32000 /* MemHandle to our global memory block under FreeGEOS. In this memory block */ /* we hold all dynamically allocated FreeType structures we need. */ extern MemHandle trueTypeHandle; +extern void* enginePtr; //nur temprär bis die Umstellung abgeschlossen ist /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -98,7 +103,7 @@ extern MemHandle trueTypeHandle; /* by the engine and need no extensions, undefine this configuration */ /* macro to save a few more bytes. */ -#define TT_CONFIG_OPTION_EXTEND_ENGINE +//#define TT_CONFIG_OPTION_EXTEND_ENGINE /*************************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index dc9fcd8fb..80b16aa92 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -115,7 +115,6 @@ PEngine_Instance _engine; TT_Engine newEngine; TT_Error error; - MemHandle t = trueTypeHandle; ECCheckLMemHandle( trueTypeHandle ); @@ -128,7 +127,7 @@ if ( GALLOC( newEngine, sizeof ( TEngine_Instance ) ) ) return error; - ECCheckLMemChunk( newEngine ); + ECCheckLMemChunk( DEREF( newEngine ) ); if ( !newEngine ) return TT_Err_Invalid_Engine; @@ -188,9 +187,8 @@ PEngine_Instance _engine; - ECCheckLMemChunk( &engine ); + ECCheckLMemChunk( DEREF( engine ) ); _engine = DEREF( engine ); - ECCheckBounds( _engine ); if ( !engine || !_engine ) return TT_Err_Ok; @@ -242,9 +240,8 @@ PFace _face; - ECCheckLMemChunk( &engine ); + ECCheckLMemChunk( DEREF( engine ) ); _engine = DEREF( engine ); - ECCheckBounds( _engine ); if ( !engine || !_engine ) return TT_Err_Invalid_Engine; @@ -1401,8 +1398,9 @@ if ( !_glyph ) return TT_Err_Invalid_Glyph_Handle; - engine = _glyph->face->engine; + //engine = _glyph->face->engine; //HANDLE_Set(engine,_engine); + _engine = _glyph->face->engine; outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1729,7 +1727,8 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine = DEREF( engine ); + //PEngine_Instance _engine = DEREF( engine ); + PEngine_Instance _engine = enginePtr; // nur temporär TT_Error error; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c index d23aabae3..22f37864f 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.c @@ -160,12 +160,12 @@ if ( !M || !C ) return TT_Err_Invalid_Argument; - if ( Size > (size_t)-1 ) + if ( Size > MAX_LMEM_CHUNKSIZE ) return TT_Err_Out_Of_Memory; if ( Size > 0 ) { *C = LMemAlloc( M, Size ); - ECCheckLMemChunk( C ); + ECCheckLMemChunk( LMemDerefHandles( M, *C ) ); if ( !*C ) return TT_Err_Out_Of_Memory; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index dfb818e58..7f38e71b9 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -478,8 +478,8 @@ struct TFace_ { /* parent engine instance for the face object */ - //PEngine_Instance engine; - TT_Engine engine; + PEngine_Instance engine; + //TT_Engine engine; /* i/o stream */ TT_Stream stream; diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 78f729205..a439247b7 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -14,11 +14,11 @@ #define FONT_SIZE 30 TT_Engine engine; -TT_Face face; /* Umstellung auf LMemBlock */ MemHandle trueTypeHandle; ChunkHandle engineChunk; +void* enginePtr; //nur temprär bis die Umstellung abgeschlossen ist typedef struct { Bitmap b; @@ -76,16 +76,16 @@ typedef struct { ********************************************************************/ void testRendering(GStateHandle gstate) { - char tmpStr[40]; - word charIndex; - TT_Face_Properties props; - TT_Instance instance; - TT_Glyph glyph; - TT_UShort charMapId; - TT_Glyph_Metrics metrics; - TT_CharMap charMap; - TT_Error error; - MemHandle t = trueTypeHandle; //nur zum Test + char tmpStr[40]; + word charIndex; + TT_Face_Properties props; + TT_Instance instance; + TT_Glyph glyph; + TT_UShort charMapId; + TT_Glyph_Metrics metrics; + TT_CharMap charMap; + TT_Face face; + TT_Error error; ECCheckLMemHandle( trueTypeHandle ); @@ -95,6 +95,9 @@ void testRendering(GStateHandle gstate) { _log("Fehler bei Initialisierung\r"); goto Fail; } + + //temporär bis die Umstellung abgeschlossen ist + enginePtr = LMemDerefHandles( trueTypeHandle, engine ); /* error = TT_Init_Kerning_Extension(engine); if(error) { diff --git a/Appl/Breadbox/testapps/ttf2/local.mk b/Appl/Breadbox/testapps/ttf2/local.mk deleted file mode 100644 index 9954c88e5..000000000 --- a/Appl/Breadbox/testapps/ttf2/local.mk +++ /dev/null @@ -1,4 +0,0 @@ -#include <$(SYSMAKEFILE)> - -XCCOMFLAGS = -zu - diff --git a/Installed/Appl/Breadbox/testapps/ttf2/Makefile b/Installed/Appl/Breadbox/testapps/ttf2/Makefile index 2602f551d..5da7cc050 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/Makefile +++ b/Installed/Appl/Breadbox/testapps/ttf2/Makefile @@ -4,20 +4,20 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = ttf2 -FREETYPE = ftxkern.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ - ttextend.c ttfile.c ttgload.c ttinterp.c ttload.c\ - ttmemory.c ttmutex.c ttobjs.c ttraster.c ttapi.c\ - freetype.h ft_conf.h fterrid.h ftnameid.h ftxkern.h\ - header.h ttcache.h ttcalc.h ttcmap.h ttconfig.h ttdebug.h\ - ttengine.h ttextend.h ttfile.h ttgload.h ttinterp.h\ - ttload.h ttmemory.h ttmutex.h ttobjs.h ttraster.h\ - tttables.h tttags.h tttypes.h +FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ + ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ + ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ + header.h ttinterp.h ttload.h tttables.h ttobjs.h\ + fterrid.h ttraster.h ttengine.h tttypes.h ttmutex.h\ + ft_conf.h ttextend.h ftnameid.h ttcalc.h ftxkern.h\ + ttmemory.h tttags.h UI = ttf2.goc UI_TO_RDFS = -OBJS = ftxkern.obj ttcache.obj ttcalc.obj ttcmap.obj ttdebug.obj\ - ttextend.obj ttfile.obj ttgload.obj ttinterp.obj\ - ttload.obj ttmemory.obj ttmutex.obj ttobjs.obj\ - ttraster.obj ttapi.obj ttf2.obj +OBJS = ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ + ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj ftxkern.obj\ + ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ + ttmemory.obj ttf2.obj COMMON = MODULES = CMODULES = FreeType Ui diff --git a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk index 067542f7b..a053ff5b1 100644 --- a/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk +++ b/Installed/Appl/Breadbox/testapps/ttf2/dependencies.mk @@ -28,120 +28,131 @@ ttf2.eobj: geos.h heap.h geode.h resource.h ec.h object.h lmem.h \ parallDr.h hugearr.h fileEnum.h Ansi/stdlib.h \ Ansi/string.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h -ftxkern.obj \ -ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttextend.h \ - FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/ttobjs.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/ttcache.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttdebug.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttfile.h FreeType/ttload.h FreeType/tttags.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ - FreeType/ft_conf.h geos.h file.h resource.h Ansi/stdlib.h \ + FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ + fontID.h font.h color.h heap.h lmem.h Ansi/stdlib.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h \ FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ FreeType/ttdebug.h +ttraster.obj \ +ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h +ttmutex.obj \ +ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h +ttgload.obj \ +ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttgload.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/tttags.h \ + FreeType/ttload.h +ttextend.obj \ +ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h ttcalc.obj \ ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/tttypes.h \ - FreeType/tttables.h -ttcmap.obj \ -ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ - FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttload.h + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/tttypes.h FreeType/tttables.h +ttapi.obj \ +ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h graphics.h fontID.h font.h color.h heap.h \ + lmem.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ + FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ + FreeType/ttextend.h ttdebug.obj \ ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/ttcmap.h -ttextend.obj \ -ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ - FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h +ftxkern.obj \ +ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h geos.h FreeType/ttextend.h \ + FreeType/ttconfig.h FreeType/ft_conf.h file.h resource.h \ + graphics.h fontID.h font.h color.h heap.h lmem.h \ + Ansi/stdlib.h FreeType/tttypes.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttfile.h \ + FreeType/ttload.h FreeType/tttags.h +ttinterp.obj \ +ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ + geos.h FreeType/tttypes.h FreeType/ttconfig.h \ + FreeType/ft_conf.h file.h resource.h graphics.h fontID.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/ttinterp.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h +ttload.obj \ +ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ + FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ + FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h ttfile.obj \ ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + resource.h graphics.h fontID.h font.h color.h heap.h \ + lmem.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ FreeType/ttengine.h FreeType/ttmutex.h \ FreeType/ttmemory.h FreeType/ttfile.h -ttgload.obj \ -ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ - FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/tttags.h FreeType/ttload.h -ttinterp.obj \ -ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ - FreeType/ttcmap.h -ttload.obj \ -ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttdebug.h FreeType/ttcalc.h \ - FreeType/ttfile.h FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/tttags.h FreeType/ttload.h -ttmemory.obj \ -ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttengine.h FreeType/ttmutex.h -ttmutex.obj \ -ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h +ttcmap.obj \ +ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ + FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttload.h ttobjs.obj \ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h \ FreeType/ttextend.h -ttraster.obj \ -ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h Ansi/stdlib.h \ +ttmemory.obj \ +ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h Ansi/stdlib.h FreeType/tttypes.h \ FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h -ttapi.obj \ -ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttcache.h FreeType/ttfile.h FreeType/ttdebug.h \ - FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttload.h FreeType/ttgload.h FreeType/ttraster.h \ - FreeType/ttextend.h + FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttengine.h FreeType/ttmutex.h ttf2EC.geo ttf2.geo : geos.ldf ui.ldf ansic.ldf \ No newline at end of file From dd5d9082b9ea56a6cbb09f51983907c1d11a9111 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 15 Aug 2022 23:20:48 +0200 Subject: [PATCH 059/246] Change use of PEngine_Instance to TT_Engine --- .../testapps/ttf2/FreeType/freetype.h | 2 -- .../Breadbox/testapps/ttf2/FreeType/ftxkern.c | 3 +-- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 7 ++++-- .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 22 +++++++++++-------- .../Breadbox/testapps/ttf2/FreeType/ttcache.h | 2 +- .../testapps/ttf2/FreeType/ttextend.c | 7 +++--- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c | 2 +- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h | 2 +- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 4 ++-- 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 362e5ceab..15414cc9d 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -622,14 +622,12 @@ /* NOTE: Some macros are defined in tttypes.h to perform */ /* automatic type conversions for library hackers... */ - //struct TT_Engine_ { void* z; }; struct TT_Stream_ { void* z; }; struct TT_Face_ { void* z; }; struct TT_Instance_ { void* z; }; struct TT_Glyph_ { void* z; }; struct TT_CharMap_ { void* z; }; - //typedef struct TT_Engine_ TT_Engine; /* engine instance */ typedef ChunkHandle TT_Engine; /* engine instance */ typedef struct TT_Stream_ TT_Stream; /* stream handle type */ typedef struct TT_Face_ TT_Face; /* face handle type */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c index d094ba4d9..70c908b7c 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c @@ -548,10 +548,9 @@ TT_Error error; - ECCheckLMemChunk( engine ); + ECCheckLMemChunk( DEREF( engine ) ); _engine = DEREF( engine ); - ECCheckBounds( _engine ); if ( !engine || !_engine ) return TT_Err_Invalid_Engine; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 80b16aa92..c8eaecab6 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -135,13 +135,15 @@ *engine = newEngine; #undef TT_FAIL +#undef GTT_FAIL #define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok +#define GTT_FAIL( x ) ( error = x (*engine) ) != TT_Err_Ok /* Initalize components */ _engine = DEREF( *engine ); ECCheckBounds( _engine ); - if ( TT_FAIL( TTFile_Init ) || - TT_FAIL( TTCache_Init ) || + if ( GTT_FAIL( TTFile_Init ) || + GTT_FAIL( TTCache_Init ) || #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE TT_FAIL( TTExtend_Init ) || #endif @@ -150,6 +152,7 @@ goto Fail; #undef TT_FAIL +#undef GTT_FAIL /* create the engine lock */ MUTEX_Create( _engine->lock ); diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index 606bdd94d..932608da5 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -34,16 +34,16 @@ /* The macro FREE_Elements aliases the current engine instance's */ /* free list_elements recycle list. */ -#define FREE_Elements ( engine->list_free_elements ) +#define FREE_Elements ( _engine->list_free_elements ) /* Redefinition of LOCK and UNLOCK macros for New_Element and Done_Element */ /* Note: The macros are redefined below for the cache functions */ #undef LOCK -#define LOCK() MUTEX_Lock ( engine->lock ) +#define LOCK() MUTEX_Lock ( _engine->lock ) #undef UNLOCK -#define UNLOCK() MUTEX_Release( engine->lock ) +#define UNLOCK() MUTEX_Release( _engine->lock ) /******************************************************************* * @@ -59,7 +59,7 @@ ******************************************************************/ static - PList_Element Element_New( PEngine_Instance engine ) + PList_Element Element_New( PEngine_Instance _engine ) { PList_Element element; @@ -101,7 +101,7 @@ ******************************************************************/ static - void Element_Done( PEngine_Instance engine, + void Element_Done( PEngine_Instance _engine, PList_Element element ) { LOCK(); @@ -146,12 +146,12 @@ ******************************************************************/ LOCAL_FUNC - TT_Error Cache_Create( PEngine_Instance engine, + TT_Error Cache_Create( PEngine_Instance _engine, PCache_Class clazz, TCache* cache, TMutex* lock ) { - cache->engine = engine; + cache->engine = _engine; cache->clazz = clazz; cache->lock = lock; cache->idle_count = 0; @@ -456,8 +456,12 @@ LOCAL_FUNC - TT_Error TTCache_Init( PEngine_Instance engine ) + TT_Error TTCache_Init( TT_Engine engine ) { + PEngine_Instance _engine = (PEngine_Instance)DEREF( engine ); + + ECCheckLMemChunk( _engine ); + /* Create list elements mutex */ FREE_Elements = NULL; return TT_Err_Ok; @@ -465,7 +469,7 @@ LOCAL_FUNC - TT_Error TTCache_Done( PEngine_Instance engine ) + TT_Error TTCache_Done( PEngine_Instance _engine ) { /* We don't protect this function, as this is the end of the engine's */ /* execution.. */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h index 66d84bab0..4b8575f55 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h @@ -200,7 +200,7 @@ LOCAL_DEF - TT_Error TTCache_Init( PEngine_Instance engine ); + TT_Error TTCache_Init( TT_Engine engine ); LOCAL_DEF TT_Error TTCache_Done( PEngine_Instance engine ); diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index 43ff8af45..603b47c8e 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -52,6 +52,8 @@ if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) return error; + + ECCheckBounds( exts ); exts->num_extensions = 0; exts->cur_offset = 0; @@ -94,12 +96,11 @@ if ( p >= TT_MAX_EXTENSIONS ) return TT_Err_Too_Many_Extensions; + clazz = exts->classes + p; - clazz->id = id; clazz->size = size; clazz->build = create; clazz->destroy = destroy; - clazz->offset = exts->cur_offset; exts->num_extensions++; @@ -124,7 +125,7 @@ if ( !face->extension ) return TT_Err_Extensions_Unsupported; - registry = (PExtension_Registry)ENGINE_ELEMENT(face->engine, extension_component); + registry = face->engine->extension_component; for ( n = 0; n < face->n_extensions; n++ ) { diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c index f748aea15..5ac0ae4c2 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c @@ -464,7 +464,7 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) + TT_Error TTFile_Init( TT_Engine engine ) { return TT_Err_Ok; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h index 64fb233c1..0e92b3c27 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h @@ -42,7 +42,7 @@ /* Initialize file component */ LOCAL_DEF - TT_Error TTFile_Init( PEngine_Instance engine ); + TT_Error TTFile_Init( TT_Engine engine ); /* Done with file component */ LOCAL_DEF diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index a439247b7..0dc2f012e 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -99,11 +99,11 @@ void testRendering(GStateHandle gstate) { //temporär bis die Umstellung abgeschlossen ist enginePtr = LMemDerefHandles( trueTypeHandle, engine ); -/* error = TT_Init_Kerning_Extension(engine); + /* error = TT_Init_Kerning_Extension(engine); if(error) { _log("Fehler bei der Initialisierung des Kernings\r"); goto Fail; - }*/ + } */ error = TT_Open_Face(engine, "DejaVu.ttf", &face); if(error) { From b7478d11d3bdd2838e4a380b6039919a8364308b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 16 Aug 2022 19:44:24 +0200 Subject: [PATCH 060/246] Changed some references to TT_Engine to chunks. --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 22 +++----- .../testapps/ttf2/FreeType/ttextend.c | 9 ++-- .../testapps/ttf2/FreeType/ttextend.h | 2 +- .../testapps/ttf2/FreeType/ttmemory.h | 5 ++ Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 27 +++++----- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 2 +- .../testapps/ttf2/FreeType/ttraster.c | 22 +++++--- .../testapps/ttf2/FreeType/ttraster.h | 4 +- Appl/Breadbox/testapps/ttf2/out.txt | 54 +++++++++++++++++++ 9 files changed, 105 insertions(+), 42 deletions(-) create mode 100644 Appl/Breadbox/testapps/ttf2/out.txt diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index c8eaecab6..7b5d62cfe 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -112,11 +112,10 @@ EXPORT_FUNC TT_Error TT_Init_FreeType( TT_Engine* engine ) { - PEngine_Instance _engine; TT_Engine newEngine; TT_Error error; - ECCheckLMemHandle( trueTypeHandle ); + CHECK_LMEM( trueTypeHandle ); /* first of all, initialize memory sub-system */ error = TTMemory_Init(); @@ -124,10 +123,10 @@ return error; /* Allocate engine instance */ - if ( GALLOC( newEngine, sizeof ( TEngine_Instance ) ) ) + if ( GALLOC( newEngine, sizeof( TEngine_Instance ) ) ) return error; - ECCheckLMemChunk( DEREF( newEngine ) ); + CHECK_CHUNK( newEngine ); if ( !newEngine ) return TT_Err_Invalid_Engine; @@ -135,15 +134,11 @@ *engine = newEngine; #undef TT_FAIL -#undef GTT_FAIL -#define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok -#define GTT_FAIL( x ) ( error = x (*engine) ) != TT_Err_Ok +#define TT_FAIL( x ) ( error = x (*engine) ) != TT_Err_Ok /* Initalize components */ - _engine = DEREF( *engine ); - ECCheckBounds( _engine ); - if ( GTT_FAIL( TTFile_Init ) || - GTT_FAIL( TTCache_Init ) || + if ( TT_FAIL( TTFile_Init ) || + TT_FAIL( TTCache_Init ) || #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE TT_FAIL( TTExtend_Init ) || #endif @@ -152,10 +147,9 @@ goto Fail; #undef TT_FAIL -#undef GTT_FAIL /* create the engine lock */ - MUTEX_Create( _engine->lock ); + MUTEX_Create( ELEMENT( PEngine_Instance, engine, lock ) ); return TT_Err_Ok; Fail: @@ -198,7 +192,7 @@ MUTEX_Destroy( _engine->lock ); - TTRaster_Done( _engine ); + TTRaster_Done( engine ); TTObjs_Done ( _engine ); #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE TTExtend_Done( _engine ); diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index 603b47c8e..9ccd03671 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -44,20 +44,22 @@ /* Initialize the extension component */ LOCAL_FUNC - TT_Error TTExtend_Init( PEngine_Instance engine ) + TT_Error TTExtend_Init( TT_Engine engine ) { TT_Error error; PExtension_Registry exts; + + CHECK_CHUNK( engine ); if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) return error; - ECCheckBounds( exts ); + CHECK_POINTER( exts ); exts->num_extensions = 0; exts->cur_offset = 0; - engine->extension_component = (void*)exts; + ELEMENT( PEngine_Instance, engine, extension_component ) = (void*)exts; return TT_Err_Ok; } @@ -98,6 +100,7 @@ clazz = exts->classes + p; + clazz->id = id; clazz->size = size; clazz->build = create; clazz->destroy = destroy; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h index c922efed3..82aeb9ad0 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h @@ -133,7 +133,7 @@ #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE /* Initialize the extension component */ LOCAL_DEF - TT_Error TTExtend_Init( PEngine_Instance engine ); + TT_Error TTExtend_Init( TT_Engine engine ); /* Finalize the extension component */ LOCAL_DEF diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h index b72f78f8f..abc0d7256 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -114,6 +114,11 @@ #define ENGINE_ELEMENT( _handle_, _element_ ) \ ELEMENT( PEngine_Instance, _handle_, _element_ ) +#define CHECK_POINTER( _ptr_ ) ECCheckBounds( _ptr_ ) + +#define CHECK_LMEM( _handle_ ) ECCheckLMemHandle( _handle_ ) + +#define CHECK_CHUNK( _chunk_ ) ECCheckLMemChunk( DEREF( _chunk_ ) ) /* Allocate a block of memory of 'Size' bytes from the heap, and */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c index d51bd7f8c..f3f3706ba 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -1419,10 +1419,11 @@ }; LOCAL_FUNC - TT_Error TTObjs_Init( PEngine_Instance engine ) + TT_Error TTObjs_Init( TT_Engine engine ) { - PCache face_cache, exec_cache; - TT_Error error; + PCache face_cache, exec_cache; + TT_Error error; + PEngine_Instance _engine = DEREF( engine ); face_cache = 0; exec_cache = 0; @@ -1432,25 +1433,25 @@ goto Fail; /* create face cache */ - error = Cache_Create( engine, (PCache_Class)&objs_face_class, - face_cache, &engine->lock ); + error = Cache_Create( _engine, (PCache_Class)&objs_face_class, + face_cache, &_engine->lock ); if ( error ) goto Fail; - engine->objs_face_cache = face_cache; + _engine->objs_face_cache = face_cache; - error = Cache_Create( engine, (PCache_Class)&objs_exec_class, - exec_cache, &engine->lock ); + error = Cache_Create( _engine, (PCache_Class)&objs_exec_class, + exec_cache, &_engine->lock ); if ( error ) goto Fail; - engine->objs_exec_cache = exec_cache; + _engine->objs_exec_cache = exec_cache; - engine->objs_face_class = (PCache_Class)&objs_face_class; - engine->objs_instance_class = (PCache_Class)&objs_instance_class; - engine->objs_execution_class = (PCache_Class)&objs_exec_class; - engine->objs_glyph_class = (PCache_Class)&objs_glyph_class; + _engine->objs_face_class = (PCache_Class)&objs_face_class; + _engine->objs_instance_class = (PCache_Class)&objs_instance_class; + _engine->objs_execution_class = (PCache_Class)&objs_exec_class; + _engine->objs_glyph_class = (PCache_Class)&objs_glyph_class; goto Exit; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index 7f38e71b9..fdd06263b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -861,7 +861,7 @@ /* */ /********************************************************************/ - LOCAL_DEF TT_Error TTObjs_Init( PEngine_Instance engine ); + LOCAL_DEF TT_Error TTObjs_Init( TT_Engine engine ); LOCAL_DEF TT_Error TTObjs_Done( PEngine_Instance engine ); #ifdef __cplusplus diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 8cf9c46ed..4a7a2e1e7 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -2711,10 +2711,16 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, #undef ras LOCAL_FUNC - TT_Error TTRaster_Done( PEngine_Instance engine ) + TT_Error TTRaster_Done( TT_Engine engine ) { - TRaster_Instance* ras = (TRaster_Instance*)engine->raster_component; + TRaster_Instance* ras; + + + CHECK_CHUNK( engine ); + ras = (TRaster_Instance*)ELEMENT( PEngine_Instance, engine, raster_component ); + + CHECK_POINTER( ras ); if ( !ras ) return TT_Err_Ok; @@ -2722,7 +2728,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, FREE( ras->buff ); #ifndef TT_CONFIG_OPTION_STATIC_RASTER - FREE( engine->raster_component ); + FREE( ELEMENT( PEngine_Instance, engine, raster_component ) ); #endif return TT_Err_Ok; @@ -2730,20 +2736,20 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, LOCAL_FUNC - TT_Error TTRaster_Init( PEngine_Instance engine ) + TT_Error TTRaster_Init( TT_Engine engine ) { - TT_Error error; - + TT_Error error; TRaster_Instance* ras; + PEngine_Instance _engine = DEREF( engine ); #ifdef TT_CONFIG_OPTION_STATIC_RASTER ras = engine->raster_component = &cur_ras; #else - if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) + if ( ALLOC( _engine->raster_component, sizeof ( TRaster_Instance ) ) ) return error; - ras = (TRaster_Instance*)engine->raster_component; + ras = (TRaster_Instance*)_engine->raster_component; #endif if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h index b78b6d583..90d4192bf 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.h @@ -119,11 +119,11 @@ extern "C" { /* Initialize rasterizer */ LOCAL_DEF - TT_Error TTRaster_Init( PEngine_Instance engine ); + TT_Error TTRaster_Init( TT_Engine engine ); /* Finalize it */ LOCAL_DEF - TT_Error TTRaster_Done( PEngine_Instance engine ); + TT_Error TTRaster_Done( TT_Engine engine ); #ifdef __cplusplus diff --git a/Appl/Breadbox/testapps/ttf2/out.txt b/Appl/Breadbox/testapps/ttf2/out.txt new file mode 100644 index 000000000..2c4330302 --- /dev/null +++ b/Appl/Breadbox/testapps/ttf2/out.txt @@ -0,0 +1,54 @@ +FreeType/ttraster.c: if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) +FreeType/ttraster.c: if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) +FreeType/ttextend.c: if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) +FreeType/ttextend.c: if ( ALLOC( face->extension, registry->cur_offset ) ) +FreeType/ttapi.c: if ( ALLOC( outline->points, numPoints*2*sizeof ( TT_F26Dot6 ) ) || +FreeType/ttapi.c: ALLOC( outline->flags, numPoints *sizeof ( Byte ) ) || +FreeType/ttapi.c: ALLOC( outline->contours, numContours*sizeof ( UShort ) ) ) +FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) ) +FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern2->leftClass.classes, +FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern2->rightClass.classes, +FreeType/ftxkern.c: if ( ALLOC( kern2->array, array_size ) ) +FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern->tables, num_tables, TT_Kern_Subtable ) ) +FreeType/ttload.c: if ( ALLOC_ARRAY( face->ttcHeader.TableDirectory, +FreeType/ttload.c: if ( ALLOC_ARRAY( face->dirTables, +FreeType/ttload.c: if ( ALLOC_ARRAY( gaspranges, gas->numRanges, GaspRange ) || +FreeType/ttload.c: if ( ALLOC_ARRAY( *longs, num_longs, TLongMetrics ) || +FreeType/ttload.c: ALLOC_ARRAY( *shorts, num_shorts, TShortMetrics ) ) +FreeType/ttload.c: if ( ALLOC_ARRAY( face->glyphLocations, +FreeType/ttload.c: if ( ALLOC_ARRAY( face->glyphLocations, +FreeType/ttload.c: if ( ALLOC_ARRAY( names->names, +FreeType/ttload.c: if ( ALLOC( storage, bytes ) || +FreeType/ttload.c: if ( ALLOC_ARRAY( face->cvt, +FreeType/ttload.c: if ( ALLOC_ARRAY( face->cMaps, +FreeType/ttload.c: if ( ALLOC( face->fontProgram, +FreeType/ttload.c: if ( ALLOC( face->cvtProgram, +FreeType/ttload.c: if ( ALLOC( hdmx.records, sizeof ( TT_Hdmx_Record ) * hdmx.num_records ) ) +FreeType/ttload.c: if ( ALLOC( rec->widths, num_glyphs ) || +FreeType/ttfile.c: if ( ALLOC( files.frame_cache, FRAME_CACHE_SIZE ) ) +FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) +FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) +FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) +FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) +FreeType/ttfile.c: if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) +FreeType/ttfile.c: if ( ALLOC( stream_rec->name, len ) ) +FreeType/ttcmap.c: if ( ALLOC( cmap0->glyphIdArray, 256L ) || +FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, UShort ) || +FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap2->subHeaders, +FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, UShort ) || +FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap4->segments, +FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap4->glyphIdArray, l , UShort ) || +FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap6->glyphIdArray, +FreeType/ttobjs.c: if ( ALLOC( pts->org, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || +FreeType/ttobjs.c: ALLOC( pts->cur, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || +FreeType/ttobjs.c: ALLOC( pts->touch, maxPoints * sizeof ( Byte ) ) || +FreeType/ttobjs.c: ALLOC( pts->contours, maxContours * sizeof ( Short ) ) ) +FreeType/ttobjs.c: if ( ALLOC_ARRAY( exec->callStack, exec->callSize, TCallRecord ) ) +FreeType/ttobjs.c: if ( ALLOC( *buff, new_max * multiplier ) ) +FreeType/ttobjs.c: if ( ALLOC_ARRAY( ins->FDefs, ins->maxFDefs, TDefRecord ) || +FreeType/ttobjs.c: ALLOC_ARRAY( ins->IDefs, ins->maxIDefs, TDefRecord ) || +FreeType/ttobjs.c: ALLOC_ARRAY( ins->cvt, ins->cvtSize, Long ) || +FreeType/ttobjs.c: ALLOC_ARRAY( ins->storage, ins->storeSize, Long ) ) +FreeType/ttobjs.c: if ( ALLOC( face_cache, sizeof ( TCache ) ) || +FreeType/ttobjs.c: ALLOC( exec_cache, sizeof ( TCache ) ) ) + From a3fd716ffd9326c9959f1fdeb6250258fd6886f4 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 16 Aug 2022 22:16:22 +0200 Subject: [PATCH 061/246] Changed more references to TT_Engine to chunks. --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 19 +++++++------------ .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 11 +++++------ .../Breadbox/testapps/ttf2/FreeType/ttcache.h | 2 +- .../testapps/ttf2/FreeType/ttextend.c | 4 ++-- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c | 2 +- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h | 2 +- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 13 ++++++++----- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 2 +- 8 files changed, 26 insertions(+), 29 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 7b5d62cfe..abf9021ce 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -115,7 +115,6 @@ TT_Engine newEngine; TT_Error error; - CHECK_LMEM( trueTypeHandle ); /* first of all, initialize memory sub-system */ error = TTMemory_Init(); @@ -181,24 +180,20 @@ EXPORT_FUNC TT_Error TT_Done_FreeType( TT_Engine engine ) { - PEngine_Instance _engine; - - - ECCheckLMemChunk( DEREF( engine ) ); - _engine = DEREF( engine ); + CHECK_CHUNK( engine ); - if ( !engine || !_engine ) + if ( !engine ) return TT_Err_Ok; - MUTEX_Destroy( _engine->lock ); + MUTEX_Destroy( ELEMENT( PEngine_Instance, engine, lock ) ); TTRaster_Done( engine ); - TTObjs_Done ( _engine ); + TTObjs_Done ( engine ); #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - TTExtend_Done( _engine ); + TTExtend_Done( engine ); #endif - TTCache_Done ( _engine ); - TTFile_Done ( _engine ); + TTCache_Done ( engine ); + TTFile_Done ( engine ); GFREE( engine ); TTMemory_Done(); diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index 932608da5..4ee3ef656 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -35,6 +35,7 @@ /* The macro FREE_Elements aliases the current engine instance's */ /* free list_elements recycle list. */ #define FREE_Elements ( _engine->list_free_elements ) +#define GFREE_Elements ( ELEMENT( PEngine_Instance, engine, list_free_elements ) ) /* Redefinition of LOCK and UNLOCK macros for New_Element and Done_Element */ /* Note: The macros are redefined below for the cache functions */ @@ -458,18 +459,16 @@ LOCAL_FUNC TT_Error TTCache_Init( TT_Engine engine ) { - PEngine_Instance _engine = (PEngine_Instance)DEREF( engine ); - - ECCheckLMemChunk( _engine ); + CHECK_CHUNK( engine ); /* Create list elements mutex */ - FREE_Elements = NULL; + GFREE_Elements = NULL; return TT_Err_Ok; } LOCAL_FUNC - TT_Error TTCache_Done( PEngine_Instance _engine ) + TT_Error TTCache_Done( TT_Engine engine ) { /* We don't protect this function, as this is the end of the engine's */ /* execution.. */ @@ -477,7 +476,7 @@ /* frees the recycled list elements */ - element = FREE_Elements; + element = GFREE_Elements; while ( element ) { next = element->next; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h index 4b8575f55..1e89bced6 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h @@ -203,7 +203,7 @@ TT_Error TTCache_Init( TT_Engine engine ); LOCAL_DEF - TT_Error TTCache_Done( PEngine_Instance engine ); + TT_Error TTCache_Done( TT_Engine engine ); #ifdef __cplusplus diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index 9ccd03671..514b9a096 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -68,9 +68,9 @@ /* Finalize the extension component */ LOCAL_FUNC - TT_Error TTExtend_Done( PEngine_Instance engine ) + TT_Error TTExtend_Done( TT_Engine engine ) { - FREE( engine->extension_component ); + FREE( ELEMENT( PEngine_Instance, engine, extension_component ) ); return TT_Err_Ok; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c index 5ac0ae4c2..2d1cbfcc1 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c @@ -479,7 +479,7 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) + TT_Error TTFile_Done( TT_Engine engine ) { return TT_Err_Ok; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h index 0e92b3c27..895342618 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h @@ -46,7 +46,7 @@ /* Done with file component */ LOCAL_DEF - TT_Error TTFile_Done( PEngine_Instance engine ); + TT_Error TTFile_Done( TT_Engine engine ); /**********************************************************************/ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c index f3f3706ba..de3186473 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -1477,16 +1477,19 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TTObjs_Done( PEngine_Instance engine ) + TT_Error TTObjs_Done( TT_Engine engine ) { + CHECK_CHUNK( engine ); + + /* destroy all active faces and contexts before releasing the */ /* caches */ - Cache_Destroy( (TCache*)engine->objs_exec_cache ); - Cache_Destroy( (TCache*)engine->objs_face_cache ); + Cache_Destroy( (TCache*)ELEMENT( PEngine_Instance, engine, objs_exec_cache ) ); + Cache_Destroy( (TCache*)ELEMENT( PEngine_Instance, engine, objs_face_cache ) ); /* Now frees caches and cache classes */ - FREE( engine->objs_exec_cache ); - FREE( engine->objs_face_cache ); + FREE( ELEMENT( PEngine_Instance, engine, objs_exec_cache ) ); + FREE( ELEMENT( PEngine_Instance, engine, objs_face_cache ) ); return TT_Err_Ok; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index fdd06263b..be10e578a 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -862,7 +862,7 @@ /********************************************************************/ LOCAL_DEF TT_Error TTObjs_Init( TT_Engine engine ); - LOCAL_DEF TT_Error TTObjs_Done( PEngine_Instance engine ); + LOCAL_DEF TT_Error TTObjs_Done( TT_Engine engine ); #ifdef __cplusplus } From b449f9be9868193e5a336a0f7f3f8d03c546b78c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 18 Aug 2022 20:57:14 +0200 Subject: [PATCH 062/246] Fonts are retrieved via a FileHandle instead of the file name/path. --- .../testapps/ttf2/FreeType/freetype.h | 2 +- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 8 +- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c | 137 +++--------------- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h | 5 +- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 6 +- 5 files changed, 34 insertions(+), 124 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index 15414cc9d..ddb0a4d73 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -693,7 +693,7 @@ EXPORT_DEF TT_Error TT_Open_Face( TT_Engine engine, - const TT_Text* fontPathName, + FileHandle file, TT_Face* face ); diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index abf9021ce..af673cfad 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -222,7 +222,7 @@ EXPORT_FUNC TT_Error TT_Open_Face( TT_Engine engine, - const TT_Text* fontPathName, + FileHandle file, TT_Face* face ) { PEngine_Instance _engine; @@ -232,14 +232,16 @@ PFace _face; - ECCheckLMemChunk( DEREF( engine ) ); + CHECK_FILE( file ); + CHECK_CHUNK( engine ); + _engine = DEREF( engine ); if ( !engine || !_engine ) return TT_Err_Invalid_Engine; /* open the file */ - error = TT_Open_Stream( fontPathName, &stream ); + error = TT_Open_Stream( file, &stream ); if ( error ) return error; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c index 2d1cbfcc1..28edd956e 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c @@ -56,10 +56,6 @@ #include "ttmemory.h" #include "ttfile.h" /* our prototypes */ -#ifdef __GEOS__ -#include -#include -#endif /* ifdef __GEOS__ */ /* required by the tracing mode */ #undef TT_COMPONENT @@ -99,15 +95,8 @@ struct TStream_Rec_ { - Bool opened; /* is the stream handle opened ? */ - TT_Text* name; /* the file's pathname */ Long position; /* current position within the file */ - -#ifdef __GEOS__ FileHandle file; /* FreeGEOS file handle */ -#else - FILE* file; /* file handle */ -#endif /* ifdef __GEOS__ */ Long base; /* stream base in file */ Long size; /* stream size in file */ }; @@ -505,7 +494,7 @@ { PStream_Rec rec = STREAM2REC( input_stream ); - return TT_Open_Stream( rec->name, copy ); + return TT_Open_Stream( rec->file, copy ); } @@ -692,48 +681,19 @@ TT_Error Stream_Activate( PStream_Rec stream ) { - if ( !stream->opened ) - { -#ifdef __GEOS__ - if ( (stream->file = FileOpen( (TT_Text*)stream->name, FILE_ACCESS_R | FILE_DENY_W)) == NullHandle ) -#else - if ( (stream->file = fopen( (TT_Text*)stream->name, "rb" )) == 0 ) -#endif /* ifdef __GEOS__ */ - return TT_Err_Could_Not_ReOpen_File; + if ( !stream->file ) + return TT_Err_Could_Not_ReOpen_File; - stream->opened = TRUE; + /* A newly created stream has a size field of -1 */ + if ( stream->size < 0 ) + stream->size = FileSize( stream->file ); - /* A newly created stream has a size field of -1 */ - if ( stream->size < 0 ) - { -#ifdef __GEOS__ - stream->size = FileSize( stream->file ); -#else - fseek( stream->file, 0, SEEK_END ); - stream->size = ftell( stream->file ); - fseek( stream->file, 0, SEEK_SET ); -#endif /* ifdef __GEOS__ */ - } - - /* Reset cursor in file */ - if ( stream->position ) - { -#ifdef __GEOS__ - FilePos( stream->file, stream->position, FILE_POS_START); - if ( ThreadGetError() != NO_ERROR_RETURNED ) - { - /* error during seek */ - FileClose( stream->file, FALSE ); -#else - if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 ) - { - /* error during seek */ - fclose( stream->file ); -#endif /* ifdef __GEOS__ */ - stream->opened = FALSE; - return TT_Err_Could_Not_ReSeek_File; - } - } + /* Reset cursor in file */ + if ( stream->position ) + { + FilePos( stream->file, stream->position, FILE_POS_START); + if ( ThreadGetError() != NO_ERROR_RETURNED ) + return TT_Err_Could_Not_ReSeek_File; } return TT_Err_Ok; } @@ -760,19 +720,8 @@ static TT_Error Stream_Deactivate( PStream_Rec stream ) { - if ( stream->opened ) - { - /* Save its current position within the file */ -#ifdef __GEOS__ - stream->position = FilePos( stream->file, 0, FILE_POS_RELATIVE ); - FileClose( stream->file, FALSE ); -#else - stream->position = ftell( stream->file ); - fclose( stream->file ); -#endif /* ifdef __GEOS__ */ - stream->file = 0; - stream->opened = FALSE; - } + /* Save its current position within the file */ + stream->position = FilePos( stream->file, 0, FILE_POS_RELATIVE ); return TT_Err_Ok; } @@ -821,37 +770,28 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TT_Open_Stream( const TT_Text* filepathname, + TT_Error TT_Open_Stream( FileHandle file, TT_Stream* stream ) { Int len; TT_Error error; PStream_Rec stream_rec; + CHECK_FILE( file ); + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) return error; stream_rec = STREAM2REC( *stream ); -#ifdef __GEOS__ - stream_rec->file = NullHandle; -#else - stream_rec->file = NULL; -#endif /* ifdef __GEOS__ */ + stream_rec->file = file; stream_rec->size = -1L; stream_rec->base = 0; - stream_rec->opened = FALSE; stream_rec->position = 0; - len = strlen( filepathname ) + 1; - if ( ALLOC( stream_rec->name, len ) ) - goto Fail; - - strncpy( stream_rec->name, filepathname, len ); - error = Stream_Activate( stream_rec ); if ( error ) - goto Fail_Activate; + goto Fail; #ifndef TT_CONFIG_OPTION_THREAD_SAFE CUR_Stream = stream_rec; @@ -859,8 +799,6 @@ return TT_Err_Ok; - Fail_Activate: - FREE( stream_rec->name ); Fail: FREE( stream_rec ); return error; @@ -886,7 +824,6 @@ Stream_Deactivate( rec ); - FREE( rec->name ); FREE( rec ); HANDLE_Set( *stream, NULL ); @@ -943,12 +880,8 @@ { position += CUR_Stream->base; -#ifdef __GEOS__ FilePos( CUR_Stream->file, position, FILE_POS_START ); if ( ThreadGetError() != NO_ERROR_RETURNED ) -#else - if ( fseek( CUR_Stream->file, position, SEEK_SET ) ) -#endif /* ifdef __GEOS__ */ return TT_Err_Invalid_File_Offset; return TT_Err_Ok; @@ -1192,36 +1125,4 @@ } -/******************************************************************* - * - * Function : GET_ULong - * - * Description : Extracts an unsigned long from the frame. - * - * Input : None or current frame - * - * Output : Extracted ulong. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - ULong TT_Get_ULong( FRAME_ARG ) - { - ULong getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | - ((ULong)CUR_Frame.cursor[1] << 16) | - ((ULong)CUR_Frame.cursor[2] << 8 ) | - (ULong)CUR_Frame.cursor[3] ); - - CUR_Frame.cursor += 4; - - return getlong; - } -#endif - - /* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h index 895342618..30f1eeb0f 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.h @@ -59,7 +59,7 @@ /* Should only be used for a new face object's main stream. */ LOCAL_DEF - TT_Error TT_Open_Stream( const TT_Text* name, + TT_Error TT_Open_Stream( FileHandle file, TT_Stream* stream ); @@ -200,6 +200,9 @@ } +#define CHECK_FILE( _handle_ ) ECCheckFileHandle( _handle_ ) + + /* The macros FRAME_ARGS and FRAME_ARG let us build a thread-safe */ /* or re-entrant implementation depending on a single configuration */ /* define */ diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 0dc2f012e..933731be6 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -8,6 +8,7 @@ #include #include #include +#include #include "FreeType/freetype.h" @@ -85,6 +86,7 @@ void testRendering(GStateHandle gstate) { TT_Glyph_Metrics metrics; TT_CharMap charMap; TT_Face face; + FileHandle fHandle; TT_Error error; @@ -105,7 +107,9 @@ void testRendering(GStateHandle gstate) { goto Fail; } */ - error = TT_Open_Face(engine, "DejaVu.ttf", &face); + fHandle = FileOpen("DejaVu.ttf", FILE_ACCESS_R | FILE_DENY_W); + ECCheckFileHandle( fHandle ); + error = TT_Open_Face(engine, fHandle, &face); if(error) { _log("Fehler beim laden des Fonts\r"); goto Fail; From e1bf6eb79c4e4cc128989a5e89c89ada609ba318 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 18 Aug 2022 22:42:31 +0200 Subject: [PATCH 063/246] Remove unneeded files and functions. --- .../ttf2/FreeType/arch/amigaos/Makefile.gcc | 69 - .../ttf2/FreeType/arch/amigaos/freetype.c | 25 - .../ttf2/FreeType/arch/amigaos/ft_conf.h | 220 --- .../ttf2/FreeType/arch/ansi/freetype.c | 32 - .../ttf2/FreeType/arch/ansi/ft_conf.h | 227 --- .../ttf2/FreeType/arch/debugger/freetype.c | 32 - .../ttf2/FreeType/arch/debugger/ft_conf.h | 236 ---- .../ttf2/FreeType/arch/geos/ft_conf.h | 232 ---- .../testapps/ttf2/FreeType/arch/mac/README | 47 - .../ttf2/FreeType/arch/mac/freetype.c | 48 - .../testapps/ttf2/FreeType/arch/mac/ft_conf.h | 211 --- .../testapps/ttf2/FreeType/arch/mac/ttmmap.c | 1069 -------------- .../ttf2/FreeType/arch/msdos/Makefile.BC | 132 -- .../ttf2/FreeType/arch/msdos/Makefile.MS | 117 -- .../ttf2/FreeType/arch/msdos/Makefile.TC | 86 -- .../ttf2/FreeType/arch/msdos/Makefile.VC | 117 -- .../ttf2/FreeType/arch/msdos/Makefile.dm | 84 -- .../ttf2/FreeType/arch/msdos/Makefile.gcc | 92 -- .../ttf2/FreeType/arch/msdos/Makefile.wat | 88 -- .../ttf2/FreeType/arch/msdos/depend.dos | 107 -- .../ttf2/FreeType/arch/msdos/freetype.c | 39 - .../ttf2/FreeType/arch/msdos/ft_conf.h | 253 ---- .../ttf2/FreeType/arch/msdos/hugefile.c | 84 -- .../ttf2/FreeType/arch/msdos/hugemem.c | 496 ------- .../testapps/ttf2/FreeType/arch/msdos/makedep | 26 - .../ttf2/FreeType/arch/os2/Makefile.dm | 84 -- .../ttf2/FreeType/arch/os2/Makefile.emx | 91 -- .../ttf2/FreeType/arch/os2/Makefile.icc | 73 - .../ttf2/FreeType/arch/os2/Makefile.wat | 88 -- .../ttf2/FreeType/arch/os2/freetype.c | 32 - .../testapps/ttf2/FreeType/arch/os2/ft_conf.h | 239 ---- .../testapps/ttf2/FreeType/arch/os2/os2file.c | 1237 ----------------- .../ttf2/FreeType/arch/unix/.cvsignore | 1 - .../ttf2/FreeType/arch/unix/Makefile.in | 244 ---- .../ttf2/FreeType/arch/unix/freetype.c | 27 - .../testapps/ttf2/FreeType/arch/unix/ttmmap.c | 1027 -------------- .../testapps/ttf2/FreeType/arch/vms/README | 20 - .../ttf2/FreeType/arch/vms/descrip.mms | 155 --- .../testapps/ttf2/FreeType/arch/vms/ft_conf.h | 215 --- .../ttf2/FreeType/arch/win16/Makefile.BC | 180 --- .../ttf2/FreeType/arch/win16/Makefile.MS | 106 -- .../ttf2/FreeType/arch/win16/Makefile.VC | 175 --- .../ttf2/FreeType/arch/win16/depend.win | 109 -- .../ttf2/FreeType/arch/win16/freetype.c | 39 - .../ttf2/FreeType/arch/win16/ft_conf.h | 209 --- .../ttf2/FreeType/arch/win16/hugefile.c | 51 - .../ttf2/FreeType/arch/win16/hugemem.c | 539 ------- .../testapps/ttf2/FreeType/arch/win16/makedef | 24 - .../testapps/ttf2/FreeType/arch/win16/makedep | 32 - .../testapps/ttf2/FreeType/arch/win16/ttf.def | 127 -- .../ttf2/FreeType/arch/win32/Makefile.BC | 161 --- .../ttf2/FreeType/arch/win32/Makefile.CL | 165 --- .../ttf2/FreeType/arch/win32/Makefile.Min | 98 -- .../ttf2/FreeType/arch/win32/Makefile.VC | 195 --- .../ttf2/FreeType/arch/win32/Makefile.gcc | 96 -- .../ttf2/FreeType/arch/win32/depend.win | 103 -- .../ttf2/FreeType/arch/win32/freetype.c | 42 - .../ttf2/FreeType/arch/win32/freetype.dsp | 104 -- .../ttf2/FreeType/arch/win32/freetype.dsw | 29 - .../ttf2/FreeType/arch/win32/freetype.ide | Bin 35589 -> 0 bytes .../ttf2/FreeType/arch/win32/freetype.mak | 353 ----- .../ttf2/FreeType/arch/win32/ft_conf.h | 210 --- .../testapps/ttf2/FreeType/arch/win32/makedef | 24 - .../testapps/ttf2/FreeType/arch/win32/makedep | 29 - .../testapps/ttf2/FreeType/arch/win32/ttf.def | 127 -- .../testapps/ttf2/FreeType/freetype.h | 31 - Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 93 -- 67 files changed, 11153 deletions(-) delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.TC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.VC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.dm delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c delete mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.VC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/depend.win delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ft_conf.h delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c delete mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef delete mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.Min delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.ide delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.mak delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ft_conf.h delete mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef delete mode 100755 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep delete mode 100644 Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc deleted file mode 100644 index 94d01aa15..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/Makefile.gcc +++ /dev/null @@ -1,69 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library and test programs for amiga using ADE Enviroment. -# -# You will need GNU make. -# -# Use this file while in the lib directory with the following statement: -# -# make -f arch/amigaos/Makefile.gcc - -ARCH = arch/amigaos -FT_MAKEFILE = $(ARCH)/Makefile.gcc - -AR = ar -RM = rm - -CC = gcc - -CFLAGS = -Wall -pedantic -ansi -O2 -g -noixemul -I$(ARCH) -I. -Iextend - -SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ - extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ - extend/ftxgsub.c extend/ftxgpos.c extend/ftxgdef.c \ - extend/ftxopen.c -OBJS_X = $(SRC_X:.c=.o) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttextend.c ttfile.c ttgload.c ttinterp.c ttload.c \ - ttmemory.c ttmutex.c ttobjs.c ttraster.c -OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) - -SRC_S = $(ARCH)/freetype.c -OBJ_S = $(SRC_S:.c=.o) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: all debug clean distclean - - -all: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a - -debug: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a - - -$(OBJ_S): $(SRC_S) $(SRC_M) - - -libttf.a: $($(LIB_FILES)) - $(AR) src $@ $^ - -clean: - $(RM) $($(LIB_FILES)) - -distclean: clean - $(RM) dep.end libttf.a - -depend: $(SRC_S) $(SRC_M) $(SRC_X) - $(CC) -E -M $^ > dep.end - -ifeq (dep.end,$(wildcard dep.end)) - include dep.end -endif - -# end of Makefile.gcc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c deleted file mode 100644 index cdb9b6c72..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/freetype.c +++ /dev/null @@ -1,25 +0,0 @@ -/* This file is part of the FreeType project */ - -/* Single object library component for AmigaOS */ -#define TT_MAKE_OPTION_SINGLE_OBJECT - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttfile.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttmemory.c" -#include "ttmutex.c" -#include "ttobjs.c" -#include "ttraster.c" - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h deleted file mode 100644 index ea16de085..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/amigaos/ft_conf.h +++ /dev/null @@ -1,220 +0,0 @@ -/* This file is part of the FreeType project */ - -/* ft_conf.h for AmigaOS using ADE enviroment */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Define to empty if the keyword does not work. */ - -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ - -/* #undef HAVE_MMAP */ - -/* Define if you have the header file. */ - -#define HAVE_STDLIB_H - -/* Define if the X Window System is missing or not being used. */ - -#define X_DISPLAY_MISSING - -/* The number of bytes in a int. */ - -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ - -#define SIZEOF_LONG 4 - -/* Define if you have the getpagesize function. */ - -#define HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ - -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ - -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ - -#define HAVE_VALLOC - -/* Define if you have the header file. */ - -#define HAVE_FCNTL_H - -/* Define if you have the header file. */ - -#define HAVE_UNISTD_H - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c deleted file mode 100644 index f7d89e43d..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/freetype.c +++ /dev/null @@ -1,32 +0,0 @@ -/* This file is part of the FreeType project */ - -/* Single file library component for the ANSI target */ -#define TT_MAKE_OPTION_SINGLE_OBJECT - -/* first include common core components */ - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* then system-specific (or ANSI) components */ - -#include "ttfile.c" -#include "ttmemory.c" -#include "ttmutex.c" - -/* the extensions are compiled separately, but we need to */ -/* include the file ttextend.c if we want to support them */ - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h deleted file mode 100644 index 839a229da..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/ansi/ft_conf.h +++ /dev/null @@ -1,227 +0,0 @@ -/* This file is part of the FreeType project */ - -/* ft_conf.h for the ANSI Build */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. Unix-specific */ -#undef HAVE_FCNTL_H - -/* command.com can't pipe stderr into a file; any message would be */ -/* written into the graphics screen. */ -#define HAVE_PRINT_FUNCTION 1 - -#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) - - -/* The number of bytes in a int. We use the ANSI header file limits.h */ -/* for determining it since there is no easy way to guess. */ -/* */ -#include -#if UINT_MAX == 0xFFFF -#define SIZEOF_INT 2 -#elif UINT_MAX == 0xFFFFFFFF -#define SIZEOF_INT 4 -#else -#error "Unsupported number of bytes in `int' type!" -#endif - -/* We now try to guess the size of longs in the same way */ -/* */ -#if ULONG_MAX == 0xFFFFFFFF -#define SIZEOF_LONG 4 -#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF -#define SIZEOF_LONG 8 -#else -#error "Unsupported number of bytes in `long' type!" -#endif - - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#define TT_CONFIG_OPTION_STATIC_RASTER - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c deleted file mode 100644 index 294f1992f..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/freetype.c +++ /dev/null @@ -1,32 +0,0 @@ -/* This file is part of the FreeType project */ - -/* Single file library component for the debugging target */ -#define TT_MAKE_OPTION_SINGLE_OBJECT - -/* first include common core components */ - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* then system-specific (or ANSI) components */ - -#include "ttfile.c" -#include "ttmemory.c" -#include "ttmutex.c" - -/* the extensions are compiled separately, but we need to */ -/* include the file ttextend.c if we want to support them */ - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h deleted file mode 100644 index 5efa3876a..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/debugger/ft_conf.h +++ /dev/null @@ -1,236 +0,0 @@ -/* This file is part of the FreeType project */ - -/* ft_conf.h for a debugging build */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. Unix-specific */ -#undef HAVE_FCNTL_H - -/* command.com can't pipe stderr into a file; any message would be */ -/* written into the graphics screen. */ -#define HAVE_PRINT_FUNCTION 1 - -#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) - - -/* The number of bytes in a int. We use the ANSI header file limits.h */ -/* for determining it since there is no easy way to guess. */ -/* */ -#include -#if UINT_MAX == 0xFFFF -#define SIZEOF_INT 2 -#elif UINT_MAX == 0xFFFFFFFF -#define SIZEOF_INT 4 -#else -#error "Unsupported number of bytes in `int' type!" -#endif - -/* We now try to guess the size of longs in the same way */ -/* */ -#if ULONG_MAX == 0xFFFFFFFF -#define SIZEOF_LONG 4 -#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF -#define SIZEOF_LONG 8 -#else -#error "Unsupported number of bytes in `long' type!" -#endif - - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ -/* */ -/* For debugging, we use a jump table; this allows some interesting */ -/* things during development. */ - -#undef TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a `static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine. */ -/* */ -/* We use a static interpreter in the debugger; this helps in setting */ -/* data breakpoints to fixed memory addresses. */ - -#define TT_CONFIG_OPTION_STATIC_INTERPRETER - -/* an extra for the debugger */ -#define DEBUG_INTERPRETER - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ - -#define TT_CONFIG_OPTION_STATIC_RASTER - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode. */ -/* Set to DEBUG_LEVEL_TRACE for the debugger. */ -#define DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h deleted file mode 100644 index c4d48db1b..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/geos/ft_conf.h +++ /dev/null @@ -1,232 +0,0 @@ -/* This file is part of the FreeType project */ - -/* ft_conf.h for the FreeGEOS Build */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Under FreeGEOS we need this for the file operations. */ -#include -#include -#include - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. Unix-specific */ -#undef HAVE_FCNTL_H - -/* command.com can't pipe stderr into a file; any message would be */ -/* written into the graphics screen. */ -#define HAVE_PRINT_FUNCTION 1 - -#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) - - -/* The number of bytes in a int. We use the ANSI header file limits.h */ -/* for determining it since there is no easy way to guess. */ -/* */ -#include -#if UINT_MAX == 0xFFFF -#define SIZEOF_INT 2 -#elif UINT_MAX == 0xFFFFFFFF -#define SIZEOF_INT 4 -#else -#error "Unsupported number of bytes in `int' type!" -#endif - -/* We now try to guess the size of longs in the same way */ -/* */ -#if ULONG_MAX == 0xFFFFFFFF -#define SIZEOF_LONG 4 -#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFF -#define SIZEOF_LONG 8 -#else -#error "Unsupported number of bytes in `long' type!" -#endif - - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#undef TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#undef TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#define TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README deleted file mode 100644 index cb7962e88..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/README +++ /dev/null @@ -1,47 +0,0 @@ - -This is the readme of the freetype.hqx archive in the contrib/mac -subdirectory. Please note that the FreeType team does *not* support the -Macintosh platform due to lack of knowledge. All questions regarding the -code should be sent to both David Williss and the freetype-devel list. - - ----------------------------------------------------------------------------- - - -These are CodeWarrior projects for building the FreeType library on a Macintosh -I've only provided PPC projects here, but building for 68K shouldn't be hard. -There are two directories here (OK, "folders"). One contains a project for -building freetype.ppc.lib and the other is for freetype.ppc.dll. (I havn't -actually tested the DLL yet.) - -The Macintosh stores TrueType fonts in a "Fonts" folder under the "System" -folder. There is a standard MacOS API for finding this folder, so I use it. -However, the fonts aren't normal flat files. They have all the data in -resources in the resource fork. Each font is an 'sfnt' resource, and each -file can have more than one 'sfnt' resource. - -To get at them, I made a copy of ttmmap.c from the Unix implementation and -modified it to load/release the resource and lock/unlock the handle as needed. -This only required a change to the open and close functions. After that, it -works just as if it was using Unix memory mapping. - -One thing however. Because of the bizarre scheme for storing the fonts, I -made up a way of specifying the font filename. - - fonts:/fontfile/fontname - -Where fonts:/ is a literal string that means "the fonts folder", fontfile is -the name of the actual file and fontname is the name of the 'sfnt' resource. -Currently, this is the only thing it understands. It might be nice if some -day (2.0 maybe?) ttfile.c and ttmmap.c wern't mutialy exclusive and it could -decide which method to use based on the filename or something. - -Another thing that I had to change to make this work. It seems that Macintosh -TrueType fonts have no OS/2 table, so ttload.c needs to be modified to make -that nonfatal, at least on a Macintosh. - ---- - -David Williss -MicroImages, Inc. -dwilliss@microimages.com diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c deleted file mode 100644 index 9eb7df1b0..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/freetype.c +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is *not* part of the FreeType project, because the team */ -/* lacks the necessary expertise to support it. */ - -/* freetype.c for MacOS */ -/* single object library component for MacOS */ - -/* Written by Dave Willis on 1998-07-30. */ -/* Modified by Antoine Leca for the 1.3 release, but untested. */ - -#define TT_MAKE_OPTION_SINGLE_OBJECT - -/* Note, you should define the EXPORT_DEF and EXPORT_FUNC macros here */ -/* if you want to build a DLL. If undefined, the macros are defined */ -/* as "export" and "" (i.e. nothing), which is the normal behaviour. */ -/* The macros are placed before each high-level API function */ -/* declaration. You can then use them to take any compiler-specific */ -/* pragma for DLL-exported symbols. See 'ttconfig.h' for details. */ - - -/* first include common core components */ - -#define MAC_MAIN_OBJECT -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* then system-specific (or ANSI) components */ - -#include "ttmmap.c" /* Was "ttfile.c" */ -#include "ttmemory.c" -#include "ttmutex.c" - -/* finally, add some extensions */ - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h deleted file mode 100644 index ed80d02f1..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ft_conf.h +++ /dev/null @@ -1,211 +0,0 @@ -/* This file is *not* part of the FreeType project, because the team */ -/* lacks the necessary expertise to support it. */ - -/* ft_conf.h for MacOS */ - -/* Written by Dave Willis on 1998-07-30. */ -/* Modified by Antoine Leca for the 1.3 release, but untested. */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Define to empty if the 'const' keyword does not work. */ -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c deleted file mode 100644 index 3dfc62d03..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/mac/ttmmap.c +++ /dev/null @@ -1,1069 +0,0 @@ -/******************************************************************* - * - * ttmmap.c 2.0 - * - * Memory-Mapped file component ( replaces ttfile.c ). - * - * Copyright 1996-1998 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. - * - * Changes between 2.0 and 1.3 : - * - * - adopted new design/separation introduced in ttfile.c 2.0 - * - ******************************************************************/ - -#include "ttconfig.h" - -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - - -#ifdef HAVE_FCNTL_H -#include -#endif - -#include -#include - - -#include "freetype.h" -#include "tttypes.h" -#include "ttdebug.h" -#include "ttengine.h" -#include "ttmutex.h" -#include "ttmemory.h" -#include "ttfile.h" /* our prototypes */ - - /* This definition is mandatory for each file component! */ - EXPORT_FUNC - const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; - - /* It has proven useful to do some bounds checks during */ - /* development phase. Define DEBUG_FILE when compiling */ - /* this component to enable them. */ - -#ifdef DEBUG_FILE -#define CHECK_FRAME( frame, n ) \ - do { \ - if ( frame.cursor+n > frame.address + frame.size ) \ - Panic( "Frame boundary error!\n" ); \ - } while ( 0 ) -#else -#define CHECK_FRAME( frame, n ) \ - do { \ - } while( 0 ) -#endif - - struct _TFileMap - { - String* base; /* base address of mapped file */ - Int refcount; /* reference count for handle region */ - Long size; /* stream size in file */ - Long offset; /* offset in file */ - Handle handle; /* Macintosh style handle to lock/unlock */ - short resid; /* Id of resource file to close when done */ - }; - - typedef struct _TFileMap TFileMap; - -#define MAP_Address( map ) (Byte*)( (map)->base + (map)->offset ) - - /* The stream record structure */ - typedef struct _TStream_Rec - { - TFileMap* map; /* mapped file description */ - Long pos ; /* cursor in mapped file */ - } TStream_Rec; - - typedef TStream_Rec* PStream_Rec; - -#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /**** ****/ - /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ - /**** ****/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - - /* The TFile_Component structure holds all the data that was */ - /* previously declared static or global in this component. */ - /* */ - /* It is accessible through the 'engine.file_component' */ - /* variable in re-entrant builds, or directly through the */ - /* static 'files' variable in other builds. */ - - struct _TFile_Component - { - TMutex lock; /* used by the thread-safe build only */ - PStream_Rec stream; /* current stream */ - TFileFrame frame; /* current frame */ - }; - - typedef struct _TFile_Component TFile_Component; - -/* The macro CUR_Stream denotes the current input stream */ -/* Note that for the re-entrant version, the 'stream' name has been */ -/* chosen according to the macro STREAM_ARGS. */ - -/* The macro CUR_Frame denotes the current file frame */ -/* Note that for the re-entrant version, the 'frame' name has been */ -/* chosen according to the macro FRAME_ARGS. */ - -/* The macro STREAM_VAR is used when calling public functions */ -/* that need an 'optional' stream argument. */ - -#define CUR_Stream files.stream /* thread-safe macros */ -#define CUR_Frame files.frame - -#define STREAM_VARS /* void */ -#define STREAM_VAR /* void */ - - /* the 'files' variable is only defined in non-reentrant builds */ - - static TFile_Component files; - - - -/******************************************************************* - * - * Function : TTFile_Init - * - * Description : Initializes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) - { - MUTEX_Create( files.lock ); - files.stream = NULL; - ZERO_Frame( files.frame ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTFile_Done - * - * Description : Finalizes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) - { - MUTEX_Destroy( files.lock ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Use_Stream - * - * Description : Copies or duplicates a given stream. - * - * Input : org_stream original stream - * stream target stream (copy or duplicate) - * - * Output : Error code - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Use_Stream( TT_Stream org_stream, - TT_Stream* stream ) - { - MUTEX_Lock( files.lock ); - *stream = org_stream; - files.stream = STREAM2REC( org_stream ); /* set current stream */ - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Done_Stream - * - * Description : Releases a given stream. - * - * Input : stream - * - * Output : Error code - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Done_Stream( TT_Stream* stream ) - { - HANDLE_Set( *stream, NULL ); - MUTEX_Release( files.lock ); - - return TT_Err_Ok; - } - -#else /* TT_CONFIG_OPTION_THREAD_SAFE */ - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /******** ********/ - /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ - /******** ********/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - -#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ -#define CUR_Frame (*frame) - -#define STREAM_VARS stream, -#define STREAM_VAR stream - - -/******************************************************************* - * - * Function : TTFile_Init - * - * Description : Initializes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) - { - engine.file_component = NULL; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTFile_Done - * - * Description : Finalizes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) - { - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Use_Stream - * - * Description : Copies or duplicates a given stream. - * - * Input : org_stream original stream - * stream target stream (copy or duplicate) - * - * Output : Error code. The output stream is set to NULL in - * case of Failure. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Use_Stream( TT_Stream input_stream, - TT_Stream* copy ) - { - TT_Error error; - PStream_Rec stream_rec; - PStream_Rec copy_rec; - - - stream_rec = STREAM2REC( input_stream ); - - if ( ALLOC( copy_rec, sizeof ( TStream_Rec ) ) ) - goto Fail; - - HANDLE_Set( *copy, copy_rec ); - - copy_rec->map->refcount++; - copy_rec->pos = 0; - - return TT_Err_Ok; - - Fail: - HANDLE_Set( *copy, NULL ); - return error; - } - - -/******************************************************************* - * - * Function : TT_Done_Stream - * - * Description : Releases a given stream. - * - * Input : stream - * - * Output : error code - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Done_Stream( TT_Stream* stream ) - { - return TT_Close_Stream( stream ); - } - -#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ - - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /*********** ***********/ - /*********** C O M M O N I M P L E M E N T A T I O N ***********/ - /*********** ***********/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - -/******************************************************************* - * - * Function : AllocateMap - * - * Description : Allocates a new map from the table. - * - * Output : Pointer to new stream rec. NULL in case of failure. - * - ******************************************************************/ - - static - TFileMap* Allocate_Map( void ) - { - TFileMap* result; - - - if ( MEM_Alloc( result, sizeof ( TFileMap ) ) ) - return NULL; - - result->refcount = 1; - return result; - } - - -/******************************************************************* - * - * Function : ReleaseMap - * - * Description : Releases a used map to the table if reference i - * counter reaches zero. - * - * Input : map - * - * Output : None. - * - * Note : Called by TT_Close_File() - * - ******************************************************************/ - - static - void Release_Map ( TFileMap* map ) - { - map->refcount--; - if ( map->refcount <= 0 ) - { - /* MacOS System calls */ - HUnlock(map->handle); - ReleaseResource(map->handle); - CloseResFile(map->resid); - - FREE( map ); - } - } - - -/* Whadda ya mean "strdup undefined"? Fine, I'll define my own! */ -static char *mystrdup(const char *str) { - char *ret; - - if ( TT_Alloc(strlen(str) + 1, (void**)&ret) != 0 ) return(NULL); - strcpy(ret, str); - return(ret); - } - -/******************************************************************* - * - * Function : TT_Open_Stream - * - * Description : Opens the font file and saves the total file size. - * - * Input : error address of stream's error variable - * (re-entrant build only). - * filepathname pathname of the file to open - * stream address of target TT_Stream structure - * - * Output : SUCCESS on success, FAILURE on error. - * The target stream is set to -1 in case of failure. - * - ******************************************************************/ -/* -** This is not a totally generic implementation. It currently assumes the filename -** starts with "fonts:" and uses slashes instead of colons like Mac code normally -** would. Given a filename of the form "fonts:/filename/resname", Load the resource -** and lock the handle -** -** The "fonts:" at the beginning is just a convention I came up with to -** indicate the Fonts folder inside the current System folder (find via FindFolder()) -*/ - - LOCAL_FUNC - TT_Error TT_Open_Stream( const String* filepathname, - TT_Stream* stream ) - { - TT_Error error; - Int file; - PStream_Rec stream_rec; - TFileMap* map; - - int size, err = 0; - short vRefNum, res = -1; - Str255 FontName; - char *cp, *p, *fname, *sep; - Str63 myName; - long dirID; - - - if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) - return error; - - map = Allocate_Map(); - if ( !map ) - { - error = TT_Err_Out_Of_Memory; - goto Memory_Fail; - } - - stream_rec = STREAM2REC( *stream ); - - /* Find the dirID of the Fonts folder in the current System folder */ - if (FindFolder(kOnSystemDisk, kFontsFolderType, kDontCreateFolder, &vRefNum, &dirID)) - goto File_Fail; - - /* Break the name apart */ - fname = mystrdup(filepathname); /* Make a copy so we can muck with it */ - sep = ":/"; /* Things that can seperate file path componants */ - - strtok(fname, sep); /* Skip over "fonts:" */ - - if ((p = strtok(NULL, sep)) == NULL) /* Get filename */ - goto File_Fail; - strcpy(myName + 1, p); /* Make this a Pascal string (Yuck!) */ - myName[0] = strlen(p); - - if ((p = strtok(NULL, sep)) == NULL) /* Get res name */ - goto File_Fail; - strcpy(FontName+1, p); /* Make this a Pascal string (Yuck!) */ - FontName[0] = strlen(p); - - FREE( fname ); - - if ((cp = strchr(FontName, '.')) != NULL) /* Strip off ".ttf" , if any */ - *cp = 0; - - /* Read the font into a buffer */ - if ((map->resid = HOpenResFile(vRefNum, dirID, myName, fsRdPerm)) == -1) - goto File_Fail; - - if ((map->handle = Get1NamedResource('sfnt', FontName)) == NULL) - goto Map_Fail; - - HLock(map->handle); - map->base = *map->handle; - map->offset = 0; - map->size = GetResourceSizeOnDisk(map->handle); - - if ( map->base == NULL ) - goto Lock_Fail; - - stream_rec->map = map; - stream_rec->pos = 0; - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - CUR_Stream = stream_rec; -#endif - - return TT_Err_Ok; - - Lock_Fail: - ReleaseResource(map->handle); - - Map_Fail: - CloseResFile(map->resid); - - File_Fail: - error = TT_Err_Could_Not_Open_File; - FREE( map ); - - Memory_Fail: - FREE( *stream ); - FREE( fname ); - return error; - } - - -/******************************************************************* - * - * Function : TT_Close_Stream - * - * Description : Closes a stream. - * - * Input : stream - * - * Output : SUCCESS (always) - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TT_Close_Stream( TT_Stream* stream ) - { - PStream_Rec rec = STREAM2REC( *stream ); - - - Release_Map( rec->map ); - FREE( rec ); - - HANDLE_Set( *stream, NULL ); - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Flush_Stream - * - * Description : Flushes a stream, i.e., closes its file handle. - * - * Input : stream address of target TT_Stream structure - * - * Output : Error code - * - * NOTE : Never flush the current opened stream. This means that - * you should _never_ call this function between a - * TT_Use_Stream() and a TT_Done_Stream()! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Flush_Stream( TT_Stream* stream ) - { - /* XXX - DUMMY IMPLEMENTATION */ - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Stream_Size - * - * Description : Returns the length of a given stream, even if it - * is flushed. - * - * Input : stream the stream - * - * Output : Length of stream in bytes. - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_Stream_Size( TT_Stream stream ) - { - PStream_Rec rec = STREAM2REC( stream ); - - - if ( rec ) - return rec->map->size; - else - return 0; /* invalid stream - return 0 */ - } - - -/******************************************************************* - * - * Function : TT_Seek_File - * - * Description : Seeks the file cursor to a different position. - * - * Input : position new position in file - * - * Output : SUCCESS on success. FAILURE if out of range. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Seek_File( STREAM_ARGS Long position ) - { - if ( position > CUR_Stream->map->size ) - return TT_Err_Invalid_File_Offset; - - CUR_Stream->pos = position; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Skip_File - * - * Description : Skips forward the file cursor. - * - * Input : distance number of bytes to skip - * - * Output : see TT_Seek_File - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Skip_File( STREAM_ARGS Long distance ) - { - return TT_Seek_File( STREAM_VARS CUR_Stream->pos + distance ); - } - - -/******************************************************************* - * - * Function : TT_Read_File - * - * Description : Reads a chunk of the file and copies it to memory. - * - * Input : buffer target buffer - * count length in bytes to read - * - * Output : SUCCESS on success. FAILURE if out of range. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) - { - if ( CUR_Stream->pos + count > CUR_Stream->map->size ) - return TT_Err_Invalid_File_Read; - - MEM_Copy( buffer, - MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, count ); - CUR_Stream->pos += count; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Read_At_File - * - * Description : Reads file at a specified position. - * - * Input : position position to seek to before read - * buffer target buffer - * count number of bytes to read - * - * Output : SUCCESS on success. FAILURE if error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Read_At_File( STREAM_ARGS Long position, - void* buffer, - Long count ) - { - TT_Error error; - - - if ( (error = TT_Seek_File( STREAM_VARS position )) || - (error = TT_Read_File( STREAM_VARS buffer, count )) ) - return error; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_File_Pos - * - * Description : Returns current file seek pointer. - * - * Input : none - * - * Output : current file position - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_File_Pos( STREAM_ARG ) - { - return CUR_Stream->pos; - } - - -/******************************************************************* - * - * Function : TT_Access_Frame - * - * Description : Notifies the component that we're going to read - * 'size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : Error code - * - * Notes: The function fails if the byte range is not within the - * the file, or if there is not enough memory to cache - * the bytes properly (which usually means that aSize is - * too big in both cases). - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) - { - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - if ( CUR_Stream->pos + size > CUR_Stream->map->size ) - return TT_Err_Invalid_Frame_Access; - - CUR_Frame.size = size; - CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; - CUR_Frame.cursor = CUR_Frame.address; - - CUR_Stream->pos += size; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Check_And_Access_Frame - * - * Description : Notifies the component that we're going to read - * 'size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : Error code - * - * Notes: The function truncates 'size' if the byte range is not - * within the file. - * - * It will fail if there is not enough memory to cache - * the bytes properly (which usually means that aSize is - * too big). - * - * It will fail if you make two consecutive calls - * to TT_Access_Frame(), without a TT_Forget_Frame() between - * them. - * - * The only difference with TT_Access_Frame() is that we - * check that the frame is within the current file. We - * otherwise truncate it. The 'overflow' is set to zero. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) - { - TT_Error error; - Long readBytes; - - - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - readBytes = CUR_Stream->map->size - CUR_Stream->pos; - if ( size > readBytes ) - { - /* There is overflow, we allocate a new block then */ - if ( ALLOC( CUR_Frame.address, size ) ) - return error; - - CUR_Frame.size = size; - - /* copy the valid part */ - MEM_Copy( CUR_Frame.address, - MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, - readBytes ); - } - else - { - CUR_Frame.size = size; - CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; - } - - CUR_Frame.cursor = CUR_Frame.address; - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Forget_Frame - * - * Description : Releases a cached frame after reading. - * - * Input : None - * - * Output : SUCCESS on success. FAILURE on error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Forget_Frame( FRAME_ARG ) - { - if ( CUR_Frame.address == NULL ) - return TT_Err_Nested_Frame_Access; - - /* If we were using a duplicate in case of overflow, free it now */ - if ( CUR_Frame.address < (Byte*)CUR_Stream->map->base || - CUR_Frame.address >= (Byte*)CUR_Stream->map->base + - CUR_Stream->map->size ) - FREE( CUR_Frame.address ); - - ZERO_Frame( files.frame ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : GET_Byte - * - * Description : Extracts a byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted Byte - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - -#if 0 - - EXPORT_FUNC - Byte TT_Get_Byte( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Byte)(*CUR_Frame.cursor++); - } - -#endif - - -/******************************************************************* - * - * Function : GET_Char - * - * Description : Extracts a signed byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted char - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - - EXPORT_FUNC - Char TT_Get_Char( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Char)(*CUR_Frame.cursor++); - } - - -/******************************************************************* - * - * Function : GET_Short - * - * Description : Extracts a short from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted short - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - - EXPORT_FUNC - Short TT_Get_Short( FRAME_ARG ) - { - Short getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = ((Short)CUR_Frame.cursor[0] << 8) | - (Short)CUR_Frame.cursor[1]; - - CUR_Frame.cursor += 2; - - return getshort; - } - - -/******************************************************************* - * - * Function : GET_UShort - * - * Description : Extracts an unsigned short from the frame. - * - * Input : None or current frame - * - * Output : Extracted ushort - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - -#if 0 - - EXPORT_FUNC - UShort TT_Get_UShort( FRAME_ARG ) - { - UShort getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = ((UShort)CUR_Frame.cursor[0] << 8) | - (UShort)CUR_Frame.cursor[1]; - - CUR_Frame.cursor += 2; - - return getshort; - } - -#endif - - -/******************************************************************* - * - * Function : GET_Long - * - * Description : Extracts a long from the frame. - * - * Input : None or current frame - * - * Output : Extracted long - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_Get_Long( FRAME_ARG ) - { - Long getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ((Long)CUR_Frame.cursor[0] << 24) | - ((Long)CUR_Frame.cursor[1] << 16) | - ((Long)CUR_Frame.cursor[2] << 8 ) | - (Long)CUR_Frame.cursor[3]; - - CUR_Frame.cursor += 4; - - return getlong; - } - - -/******************************************************************* - * - * Function : GET_ULong - * - * Description : Extracts an unsigned long from the frame. - * - * Input : None - * - * Output : Extracted ulong - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - -#if 0 - - EXPORT_FUNC - ULong TT_Get_ULong( FRAME_ARG ) - { - ULong getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | - ((ULong)CUR_Frame.cursor[1] << 16) | - ((ULong)CUR_Frame.cursor[2] << 8 ) | - (ULong)CUR_Frame.cursor[3] ); - - CUR_Frame.cursor += 4; - - return getlong; - } - -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC deleted file mode 100644 index 62469c087..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.BC +++ /dev/null @@ -1,132 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for Borland C++ for MS-DOS, large model. -# Due to size constraints, it does not try to pack all modules into one -# (`single-object mode'). -# -# You will need Borland MAKE. -# Tested with Borland C++ v.3.1, 4.02, 5.0. -# -# Use this file while in the lib directory with the following statement: -# -# make -farch/msdos/Makefile.BC -# -# -# A debug version 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 -LIB = tlib /c /e - -# Credits go to Dave Hoo for pointing out that modern -# Borland compilers (from BC++ 3.1 on) can increase the limit on -# the length of identifiers. -!if ! $d(DEBUG) -CFLAGS = -ml -A -O2 -3 -i40 -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -I$(ARCH);.;extend -!else -CFLAGS = -v -N -ml -A -i40 -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig -I$(ARCH);.;extend -!endif - - -!if $d(BIGFONTS) -CFLAGS = $(CFLAGS) -DTT_HUGE_PTR=__huge - -TTFILE = $(ARCH)\.\hugefile.c -TTMEMORY = $(ARCH)\.\hugemem.c -!else -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -!endif -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -# Do not insert spaces before the \ at end of line, -# otherwise the substitution for TLIB command line will fail. -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ - extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c\ - extend\ftxsbit.c extend\ftxgsub.c extend\ftxgpos.c\ - extend\ftxopen.c extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c\ - ttgload.c ttinterp.c ttload.c ttobjs.c\ - ttraster.c ttextend.c ttdebug.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\.\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -# Since Borland's make does not handle $($(LIB_FILES)), and using -# -DLIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat -# by constructing TLIB's response file directly in the `all' target. -# -# Another solution, useful during debugging of part of the library, -# would be to include each .obj in the library as soon as it is compiled. -# It is commented out below. See Makefile.TC for an application. -.c.obj: - $(CC) -c -o$* @&&| - $(CFLAGS) $< -| -# $(LIB) libttf +-$*.obj - - -!if !$d(DEBUG) -# Skipped if DEBUG build -# (but it changes nothing, since we always build in multiple parts). -all: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(OBJS_M: = + ) -| - -!endif - - -debug: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(OBJS_M: = + ) -| - -$(OBJ_S): $(SRC_S) $(SRC_M) - -# Not used here because it excesses the capacity of COMMAND.COM... -libttf.lib: $(LIB_FILES) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(**: = + ) -| - -!if $d(BIGFONTS) -$(TTMEMORY:.c=.obj): $(TTMEMORY) - $(CC) -c -o$* @&&| - $(CFLAGS) -A- $*.c -| -!endif - - -clean: - -del *.obj - -del extend\*.obj - -del $(ARCH)\*.obj - -del libttf.bak - -del response - -distclean: clean - -del libttf.lib - -!include "$(ARCH)\depend.dos" - -# end of Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS deleted file mode 100644 index 611fd3a50..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.MS +++ /dev/null @@ -1,117 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library 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. -# Due to size constraints, it does not try to pack all modules into one. -# -# You will need NMAKE. -# -# Use this file while in the lib directory with the following statement: -# -# nmake /f arch\msdos\Makefile.MS -# -# -# A debug version 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 - -CC = cl /nologo -LIB = lib /noignorecase /nologo - -!ifndef DEBUG -CFLAGS = /Ox /AL /W2 /G2 /I$(ARCH) /I. /Iextend -!else -CFLAGS = /Zi /AL /W2 /G2 /I$(ARCH) /I. /Iextend -!endif - - -!ifndef BIGFONTS -CFLAGS = $(CFLAGS) /Za - -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -!else -CFLAGS = $(CFLAGS) /DTT_HUGE_PTR=__huge /Ze - -TTFILE = $(ARCH)\hugefile.c -TTMEMORY = $(ARCH)\hugemem.c -!endif - -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -# Do not insert spaces between the file names or at end of line, otherwise -# the substitution for LIB command line will fail. Thank you. -# -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ -extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c extend\ftxsbit.c\ -extend\ftxopen.c extend\ftxgsub.c extend\ftxgpos.c extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ -ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -# Since Microsoft's NMAKE does not handle $($(LIB_FILES)), and using -# LIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat -# by constructing LIB's response file directly in the `all' target. -# -# Another solution, useful during debugging of part of the library, -# would be to include each .obj in the library as soon as it is compiled. -# It is commented out below. See Makefile.TC for an application. -.c.obj: - @$(CC) /c /Fo$@ @<< - $(CFLAGS) $*.c -<< -# $(LIB) libttf +-$*.obj - - -!ifndef DEBUG -# Skipped if DEBUG build -# (but it changes nothing, since we always build in multiple parts). -all: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @<&| - -CC = gcc - -CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend -# CFLAGS = -Wall -ansi -O2 -s -I$(ARCH) -I. -Iextend - -SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ - extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ - extend/ftxgsub.c extend/ftxgpos.c extend/ftxopen.c \ - extend/ftxgdef.c extend/ftxerr18.c -OBJS_X = $(SRC_X:.c=.o) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttfile.c ttgload.c ttinterp.c ttload.c \ - ttmemory.c ttmutex.c ttobjs.c ttraster.c ttextend.c -OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) - -SRC_S = $(ARCH)/freetype.c -OBJ_S = $(SRC_S:.c=.o) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: all debug clean distclean depend - - -all: - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a - -debug: - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a - - -$(OBJ_S): $(SRC_S) $(SRC_M) - $(CC) $(CFLAGS) -c -o $@ $(SRC_S) - -libttf.a: $($(LIB_FILES)) - +-del $@ - ar src $@ @$(mktmp $(<:t"\n")\n) - -clean: --[ - del *.o - del extend\*.o - del $(ARCH)\*.o -] - -distclean: clean --[ - del dep.end - del libttf.a -] - -# depend: $(SRC_S) $(SRC_M) $(SRC_X) -# $(CC) -E -M @$(mktmp $(<:t"\n")\n) > dep.end - -# ifeq (dep.end,$(wildcard dep.end)) -# include dep.end -# endif - -# end of Makefile.dm diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc deleted file mode 100644 index 44f4a633b..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.gcc +++ /dev/null @@ -1,92 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for emx-gcc or djgpp under MSDOS. -# -# You will need GNU make. -# -# Use this file while in the lib 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 - -ifndef GETTEXT -GETTEXT=NO_GETTEXT -endif - -ifdef DEBUG -CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend -D$(GETTEXT) -else -CFLAGS = -Wall -ansi -pedantic -O2 -s -I$(ARCH) -I. -Iextend -D$(GETTEXT) -endif - - -TTFILE = ./ttfile.c -TTMEMORY = ./ttmemory.c -TTMUTEX = ./ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ - extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ - extend/ftxgsub.c extend/ftxgpos.c extend/ftxgdef.c \ - extend/ftxopen.c extend/ftxerr18.c -OBJS_X = $(SRC_X:.c=.o) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttgload.c ttinterp.c ttload.c ttobjs.c \ - ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) - -SRC_S = $(ARCH)/freetype.c -OBJ_S = $(SRC_S:.c=.o) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: all debug clean distclean depend - - -all: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a - -debug: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M DEBUG=1 libttf.a - -HAVE_GETTEXT: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S GETTEXT=HAVE_GETTEXT \ - libttf.a - -$(OBJ_S): $(SRC_S) $(SRC_M) - -libttf.a: $($(LIB_FILES)) - -del $@ - ar src $@ $^ - -clean: - -del *.o - -del extend\*.o - -del $(ARCH)\*.o - -del response - -distclean: clean - -del dep.end - -del libttf.a - -depend: $(SRS_S) $(SRC_M) $(SRC_X) - $(CC) -E -M $^ > dep.end - -ifeq (dep.end,$(wildcard dep.end)) - include dep.end -endif - -# end of Makefile.gcc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat deleted file mode 100644 index 7e5f6722b..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/Makefile.wat +++ /dev/null @@ -1,88 +0,0 @@ -# This file is part of the FreeType project -# -# This builds the Watcom library with Watcom's wcc386 under DOS -# -# You'll need Watcom's wmake -# -# -# Invoke by "wmake -f arch\msdos\Makefile.wat" while in the "lib" directory -# -# This will build "freetype\lib\libttf.lib" -# - -ARCH = arch\msdos -FT_MAKEFILE = $(ARCH)\Makefile.wat -FT_MAKE = wmake -h - - -.EXTENSIONS: -.EXTENSIONS: .lib .obj .c .h -.obj:.;.\extend;.\$(ARCH) -.c:.;.\extend;.\$(ARCH) -.h:.;.\extend;.\$(ARCH) - -CC = wcc386 - -CCFLAGS = /otexanl+ /s /w4 /zq /d3 -I$(ARCH) -I. -Iextend - - -# FIXME: should use something like OBJ = $(SRC:.c=.obj) - -SRC_X = ftxgasp.c ftxkern.c ftxpost.c & - ftxcmap.c ftxwidth.c ftxsbit.c ftxerr18.c & - ftxgsub.c ftxgpos.c ftxopen.c ftxgdef.c -OBJS_X = ftxgasp.obj ftxkern.obj ftxpost.obj & - ftxcmap.obj ftxwidth.obj ftxsbit.obj ftxerr18.obj & - ftxgsub.obj ftxgpos.obj ftxopen.obj ftxgdef.obj - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c & - ttfile.c ttgload.c ttinterp.c & - ttload.c ttmemory.c ttmutex.c ttobjs.c ttraster.c & - ttextend.c -OBJS_M = ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj ttdebug.obj & - ttfile.obj ttgload.obj ttinterp.obj & - ttload.obj ttmemory.obj ttmutex.obj ttobjs.obj ttraster.obj & - ttextend.obj $(OBJS_X) - -SRC_S = freetype.c -OBJ_S = freetype.obj -OBJS_S = $(OBJ_S) $(OBJ_X) - - -.c.obj: - $(CC) $(CCFLAGS) $[* /fo=$[*.obj - -libname = libttf -libfile = $(libname).lib -cmdfile = $(libname).lst - - -all: .symbolic - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S $(libfile) - -debug: .symbolic - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M $(libfile) - - -$(libfile): $($(LIB_FILES)) - wlib -q -n $(libfile) @$(cmdfile) - -# is this correct? Know nothing about wmake and the Watcom compiler... -$(OBJ_S): $(SRC_S) $(SRC_M) - $(CC) $(CCFLAGS) $(SRC_S) /fo=$(OBJ_S) - -$(cmdfile): $($(LIB_FILES)) - @for %i in ($($(LIB_FILES))) do @%append $(cmdfile) +-%i - -clean: .symbolic - @-erase $(OBJ_S) - @-erase $(OBJS_M) - @-erase $(cmdfile) - -distclean: .symbolic clean - @-erase $(libfile) - -new: .symbolic - @-wtouch *.c - -# end of Makefile.wat diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos deleted file mode 100644 index 4fb22dbfa..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/depend.dos +++ /dev/null @@ -1,107 +0,0 @@ -# This dependency file to be used with various MS-DOS compilers -# has been generated automatically with the script `makedep' on -# 03-Sep-1999. - -ttapi.obj: ttapi.c ttconfig.h arch\msdos\ft_conf.h freetype.h fterrid.h \ - ftnameid.h ttengine.h tttypes.h ttmutex.h ttcalc.h ttmemory.h \ - ttcache.h ttfile.h ttdebug.h ttobjs.h tttables.h ttcmap.h ttload.h \ - ttgload.h ttraster.h ttextend.h -ttcache.obj: ttcache.c ttengine.h tttypes.h ttconfig.h \ - arch\msdos\ft_conf.h freetype.h fterrid.h ftnameid.h ttmutex.h \ - ttmemory.h ttcache.h ttobjs.h tttables.h ttcmap.h ttdebug.h -ttcalc.obj: ttcalc.c ttcalc.h ttconfig.h arch\msdos\ft_conf.h freetype.h \ - fterrid.h ftnameid.h ttdebug.h tttypes.h tttables.h -ttcmap.obj: ttcmap.c ttobjs.h ttconfig.h arch\msdos\ft_conf.h ttengine.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ - tttables.h ttcmap.h ttdebug.h ttfile.h ttmemory.h ttload.h -ttdebug.obj: ttdebug.c ttdebug.h ttconfig.h arch\msdos\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h tttables.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h ttcmap.h -ttextend.obj: ttextend.c ttextend.h ttconfig.h arch\msdos\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttmemory.h -ttfile.obj: ttfile.c ttconfig.h arch\msdos\ft_conf.h freetype.h \ - fterrid.h ftnameid.h tttypes.h ttdebug.h ttengine.h ttmutex.h \ - ttmemory.h ttfile.h -ttgload.obj: ttgload.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ - ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h ttgload.h \ - ttmemory.h tttags.h ttload.h -ttinterp.obj: ttinterp.c freetype.h fterrid.h ftnameid.h tttypes.h \ - ttconfig.h arch\msdos\ft_conf.h ttdebug.h ttcalc.h ttmemory.h \ - ttinterp.h ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h \ - ttcmap.h -ttload.obj: ttload.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ - ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h \ - ttmemory.h tttags.h ttload.h -ttmemory.obj: ttmemory.c ttdebug.h ttconfig.h arch\msdos\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttmemory.h ttengine.h \ - ttmutex.h -ttmutex.obj: ttmutex.c ttmutex.h ttconfig.h arch\msdos\ft_conf.h -ttobjs.obj: ttobjs.c ttobjs.h ttconfig.h arch\msdos\ft_conf.h ttengine.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ - tttables.h ttcmap.h ttfile.h ttdebug.h ttcalc.h ttmemory.h ttload.h \ - ttinterp.h ttextend.h -ttraster.obj: ttraster.c ttraster.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttengine.h tttypes.h ttmutex.h \ - ttdebug.h ttcalc.h ttmemory.h -extend\ftxcmap.obj: extend\ftxcmap.c extend\ftxcmap.h freetype.h fterrid.h \ - ftnameid.h tttypes.h ttconfig.h arch\msdos\ft_conf.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h -extend\ftxerr18.obj: extend\ftxerr18.c ttconfig.h arch\msdos\ft_conf.h \ - extend\ftxerr18.h freetype.h fterrid.h ftnameid.h extend\ftxkern.h \ - extend\ftxpost.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h -extend\ftxgasp.obj: extend\ftxgasp.c extend\ftxgasp.h freetype.h fterrid.h \ - ftnameid.h tttypes.h ttconfig.h arch\msdos\ft_conf.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h -extend\ftxgdef.obj: extend\ftxgdef.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxgpos.obj: extend\ftxgpos.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxgsub.obj: extend\ftxgsub.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxkern.obj: extend\ftxkern.c extend\ftxkern.h freetype.h fterrid.h \ - ftnameid.h ttextend.h ttconfig.h arch\msdos\ft_conf.h tttypes.h \ - ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttdebug.h \ - ttmemory.h ttfile.h ttload.h tttags.h -extend\ftxopen.obj: extend\ftxopen.c tttypes.h ttconfig.h arch\msdos\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxpost.obj: extend\ftxpost.c extend\ftxpost.h freetype.h fterrid.h \ - ftnameid.h tttypes.h ttconfig.h arch\msdos\ft_conf.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttload.h ttfile.h \ - ttdebug.h tttags.h ttmemory.h ttextend.h -extend\ftxsbit.obj: extend\ftxsbit.c extend\ftxsbit.h freetype.h fterrid.h \ - ftnameid.h ttobjs.h ttconfig.h arch\msdos\ft_conf.h ttengine.h \ - tttypes.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h ttdebug.h \ - ttload.h ttmemory.h tttags.h ttextend.h -extend\ftxwidth.obj: extend\ftxwidth.c extend\ftxwidth.h freetype.h fterrid.h \ - ftnameid.h ttdebug.h ttconfig.h arch\msdos\ft_conf.h tttypes.h \ - ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h \ - tttags.h ttload.h -arch\msdos\freetype.obj: arch\msdos\freetype.c ttapi.c ttconfig.h \ - arch\msdos\ft_conf.h freetype.h fterrid.h ftnameid.h ttengine.h \ - tttypes.h ttmutex.h ttcalc.h ttmemory.h ttcache.h ttfile.h ttdebug.h \ - ttobjs.h tttables.h ttcmap.h ttload.h ttgload.h ttraster.h ttextend.h \ - ttcache.c ttcalc.c ttcmap.c ttdebug.c ttgload.c tttags.h ttinterp.c \ - ttinterp.h ttload.c ttobjs.c ttraster.c arch\msdos\hugefile.c \ - ttfile.c arch\msdos\hugemem.c ttmutex.c ttextend.c -arch\msdos\hugefile.obj: arch\msdos\hugefile.c ttconfig.h arch\msdos\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttfile.c ttdebug.h \ - ttengine.h ttmutex.h ttmemory.h ttfile.h -arch\msdos\hugemem.obj: arch\msdos\hugemem.c ttdebug.h ttconfig.h \ - arch\msdos\ft_conf.h tttypes.h freetype.h fterrid.h ftnameid.h \ - ttmemory.h ttengine.h ttmutex.h diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c deleted file mode 100644 index b6dc42b6d..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/freetype.c +++ /dev/null @@ -1,39 +0,0 @@ -/* This file is part of the FreeType project */ - -/* Single object library component for MSDOS. */ -/* Note that low-optimizing 16-bit compilers (such as Borland ones) can't */ -/* successfully compile this file, because it exceeds 64K of code size. */ -#define TT_MAKE_OPTION_SINGLE_OBJECT - -/* first include common core components */ - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* then system-specific (or ANSI) components */ - -#ifdef TT_HUGE_PTR -#include "arch/msdos/hugefile.c" -#include "arch/msdos/hugemem.c" -#else -#include "ttfile.c" -#include "ttmemory.c" -#endif -#include "ttmutex.c" - -/* finally, add some extensions */ - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h deleted file mode 100644 index 8333bfbb1..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/ft_conf.h +++ /dev/null @@ -1,253 +0,0 @@ -/* This file is part of the FreeType project */ - -/* ft_conf.h for MSDOS */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H - -/* Define if you have the header file. */ -#if defined( __EMX__ ) || defined( __DJGPP__ ) || defined( __GO32__ ) -/* some compilers are known to have ; */ -/* add yours if needed, and report to us the update. */ -#define HAVE_UNISTD_H -#else -/* most MS-DOS compilers lack */ -#undef HAVE_UNISTD_H -#endif - -/* Define if you need for console I/O functions. */ -#ifdef __EMX__ -#define HAVE_CONIO_H -#endif - -/* Define if you have the header file. */ -#undef HAVE_LOCALE_H - -/* Define if you have the header file. */ -#undef HAVE_LIBINTL_H - -/* Define if you have the libintl library. */ -#undef HAVE_LIBINTL - -/* DJGPP v.2 may feature the GNU gettext package, with some subtleties. */ -/* The macro HAVE_GETTEXT has to be set in the makefile. */ -#ifdef HAVE_GETTEXT -#define HAVE_LOCALE_H -#define HAVE_LIBINTL_H -#define HAVE_LIBINTL -#define LOCALEDIR "/usr/djgpp/share/locale" -/* Due to a name conflict, gettext is renamed gettext__ in DJGPP */ -#define gettext( str ) gettext__( str ) -#endif - -/* command.com can't pipe stderr into a file; any message would be */ -/* written into the graphics screen. */ -#define HAVE_PRINT_FUNCTION 1 - -#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) - -/* The number of bytes in a int. We use the ANSI header file limits.h */ -/* for determining it since there is no easy way to guess. */ -#include -#if UINT_MAX == 0xFFFF -#define SIZEOF_INT 2 -#elif UINT_MAX == 0xFFFFFFFF -#define SIZEOF_INT 4 -#else -#error "Unsupported number of bytes in `int' type!" -#endif - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c deleted file mode 100644 index ddf73ad75..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugefile.c +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************* - * - * hugefile.c - * - * File I/O Component (body) for dealing with "huge" objects under - * MS-DOS. Relies on the "default" version, with a small hook. - * - * Written by Antoine Leca based on ideas from Dave Hoo. - * Copyright 1999 by Dave Hoo, 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. - * - * NOTE - * - * This file #includes the normal version, to avoid discrepancies - * between versions. It uses only ANSI-mandated "tricks", so - * any ANSI-compliant compiler should be able to compile this file. - * - ******************************************************************/ - -#include "ttconfig.h" -#include "tttypes.h" - -/* Here we include , to have the proper definition of fread */ -#include - -/* Then, we divert the use of fread to our version */ -#undef fread -#define fread(ptr, size, n, stream) huge_fread(ptr, size, n, stream) - - LOCAL_FUNC - Long huge_fread ( void *ptr, size_t size, Long n, FILE *stream ); - -/* Now, we include the "normal" version of ttfile.c */ -/* The ANSI/ISO standard mandates that the include of */ -/* there have no bad effects. */ -#include "ttfile.c" - -/* Then, we define our implementation of fread that makes use of */ -/* "huge"-allocated memory. */ - -/******************************************************************* - * - * Function : huge_fread - * - * Description : replacement version of fread that handles - * "huge"-allocated memory. - * - * Input : See the reference for the runtime library function fread - * - * Output : See the reference for the runtime library function fread - * - * Notes : - * - ******************************************************************/ - - LOCAL_DEF - Long huge_fread ( void *ptr, size_t size, Long n, FILE *stream ) - { - char TT_HUGE_PTR * p = (char TT_HUGE_PTR *) ptr; - ULong left = (ULong)n * size; - size_t toRead; - - while ( left ) - { - toRead = (left > 0x8000) ? 0x8000 : left; - if ( (fread)( p, 1, toRead, stream ) != toRead) - return -1; - else - { - left -= (ULong) toRead; - p += toRead; - } - } - return n * size; - } - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c deleted file mode 100644 index 5083e49e2..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/hugemem.c +++ /dev/null @@ -1,496 +0,0 @@ -/******************************************************************* - * - * hugemem.c - * - * Memory management component (body) - * for dealing with "huge" objects with 16-bit MS-DOS. - * - * Written by Dave Hoo and Antoine Leca. - * Copyright 1999 by Dave Hoo, 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. - * - ******************************************************************/ - -#include - -#include "ttdebug.h" -#include "ttmemory.h" -#include "ttengine.h" - -#ifndef TT_HUGE_PTR -#error "This component needs TT_HUGE_PTR to be #defined." -#endif - -/* ---- Microsoft C compilers support ------------------------------------ */ - -#if defined( M_I86 ) || defined( _M_I86 ) - -#include -#define huge_alloc( size ) _halloc ( size, 1 ) -#define huge_free( block ) _hfree ( block ) - -#endif /* Microsoft compilers */ - -/* ---- Borland C compiler support --------------------------------------- */ - -#ifdef __TURBOC__ - -#include -#define huge_alloc( size ) farmalloc ( size ) -#define huge_free( block ) farfree ( block ) - -#endif - -#if !defined( huge_alloc ) || !defined( huge_free ) -#error "Your compiler is not (yet) supported. Check the source file!" -#endif - -#ifdef TT_CONFIG_OPTION_THREAD_SAFE -#error "This component needs static allocation and is not re-entrant." -#endif - -/* required by the tracing mode */ -#undef TT_COMPONENT -#define TT_COMPONENT trace_memory - - -#ifdef DEBUG_MEMORY - -#include - -#define MAX_TRACKED_BLOCKS 1024 - - struct TMemRec_ - { - void* base; - Long size; - }; - - typedef struct TMemRec_ TMemRec; - - static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; - - static Int num_alloc; - static Int num_free; - static Int num_realloc; /* counts only `real' reallocations - (i.e., an existing buffer will be resized - to a value larger than zero */ - - static Int fail_alloc; - static Int fail_realloc; - static Int fail_free; - -#else - - /* We need a tracing stack of the calls to big chunks of memory, */ - /* in order to call the matching version of free(). */ - -#define MAX_TRACKED_BIGCHUNKS 16 - - struct TMemRec_ - { - void* base; - Long size; - }; - - typedef struct TMemRec_ TMemRec; - - static TMemRec pointers[MAX_TRACKED_BIGCHUNKS + 1]; - -#endif /* DEBUG_MEMORY */ - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - Long TTMemory_Allocated; - Long TTMemory_MaxAllocated; -#endif - - -/******************************************************************* - * - * Function : TT_Alloc - * - * Description : Allocates memory from the heap buffer. - * - * Input : Size size of the memory to be allocated - * P pointer to a buffer pointer - * - * Output : Error code. - * - * NOTE : The newly allocated block should _always_ be zeroed - * on return. Many parts of the engine rely on this to - * work properly. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Alloc( ULong Size, void** P ) - { - Int i; - - - if ( !P ) - return TT_Err_Invalid_Argument; - /* Also see below for another case of "invalid argument". */ - - if ( Size > 0 ) - { - if ( Size > ( UINT_MAX & ~0xFu ) ) - *P = (void*)huge_alloc( Size ); - else - *P = (void*)malloc( Size ); - if ( !*P ) - return TT_Err_Out_Of_Memory; - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated += Size; - TTMemory_MaxAllocated += Size; -#endif - -#ifdef DEBUG_MEMORY - - num_alloc++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_alloc++; - else - { - pointers[i].base = *P; - pointers[i].size = Size; - } - -#else - - if ( Size > ( UINT_MAX & ~0xFu ) ) - { - i = 0; - while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) - i++; - - if ( i >= MAX_TRACKED_BIGCHUNKS ) - /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ - return TT_Err_Invalid_Argument; - else - { - pointers[i].base = *P; - pointers[i].size = Size; - } - } - -#endif /* DEBUG_MEMORY */ - - if ( Size > ( UINT_MAX & ~0xFu ) ) - { - char TT_HUGE_PTR * p = (char TT_HUGE_PTR *) *P; - ULong left = (ULong)Size; - size_t toClear; - - while ( left ) - { - toClear = (left > 0xFF00) ? 0xFF00 : left; - MEM_Set( p, 0, toClear ); - left -= (ULong) toClear; - p += toClear; - } - } - else - MEM_Set( *P, 0, Size ); - } - else - *P = NULL; - - return TT_Err_Ok; - } - - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - - -/******************************************************************* - * - * Function : TT_Realloc - * - * Description : Reallocates memory from the heap buffer. - * - * Input : Size new size of the memory to be allocated; - * if zero, TT_Free() will be called - * P pointer to a buffer pointer; if *P == NULL, - * TT_Alloc() will be called - * - * Output : Error code. - * - * NOTES : It's not necessary to zero the memory in case the - * reallocated buffer is larger than before -- the - * application has to take care of this. - * - * If the memory request fails, TT_Free() will be - * called on *P, and TT_Err_Out_Of_Memory returned. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Realloc( ULong Size, void** P ) - { - void* Q; - -#ifdef DEBUG_MEMORY - Int i; -#endif - - - if ( !P ) - return TT_Err_Invalid_Argument; - - if ( !*P ) - return TT_Alloc( Size, P ); - - if ( Size == 0 ) - return TT_Free( P ); - - if ( Size > ( UINT_MAX & ~0xFu ) ) - Q = NULL; /* Do not even try to deal with big chunks of memory. */ - else - Q = (void*)realloc( *P, Size ); - if ( !Q ) - { - TT_Free( *P ); - return TT_Err_Out_Of_Memory; - } - -#ifdef DEBUG_MEMORY - - num_realloc++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_realloc++; - else - { -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated += Size - pointers[i].size; - if ( Size > pointers[i].size ) - TTMemory_MaxAllocated += Size - pointers[i].size; -#endif - - pointers[i].base = Q; - pointers[i].size = Size; - } -#endif /* DEBUG_MEMORY */ - - *P = Q; - - return TT_Err_Ok; - } - - -#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ - - -/******************************************************************* - * - * Function : TT_Free - * - * Description : Releases a previously allocated block of memory. - * - * Input : P pointer to memory block - * - * Output : Always SUCCESS. - * - * Note : The pointer must _always_ be set to NULL by this function. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Free( void** P ) - { - Int i; - Long Size = 0; - - - if ( !P || !*P ) - return TT_Err_Ok; - -#ifdef DEBUG_MEMORY - - num_free++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_free++; - else - { -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated -= pointers[i].size; -#endif - - Size = pointers[i].size; - pointers[i].base = NULL; - pointers[i].size = 0; - } - -#else - - i = 0; - while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != *P ) - i++; - - /* If we did not found the pointer, then this is a "small" chunk. */ - - if ( i < MAX_TRACKED_BIGCHUNKS ) - { - Size = pointers[i].size; - pointers[i].base = NULL; - pointers[i].base = NULL; - } - -#endif /* DEBUG_MEMORY */ - - if ( Size > ( UINT_MAX & ~0xFu ) ) - huge_free( *P ); - else - free( *P ); - - *P = NULL; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTMemory_Init - * - * Description : Initializes the memory. - * - * Output : Always SUCCESS. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTMemory_Init( void ) - { -#ifdef DEBUG_MEMORY - Int i; - - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - pointers[i].base = NULL; - pointers[i].size = 0; - } - - num_alloc = 0; - num_realloc = 0; - num_free = 0; - - fail_alloc = 0; - fail_realloc = 0; - fail_free = 0; -#else - Int i; - - for ( i = 0; i < MAX_TRACKED_BIGCHUNKS; i++ ) - { - pointers[i].base = NULL; - pointers[i].size = 0; - } -#endif - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated = 0; - TTMemory_MaxAllocated = 0; -#endif - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTMemory_Done - * - * Description : Finalizes memory usage. - * - * Output : Always SUCCESS. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTMemory_Done( void ) - { -#ifdef DEBUG_MEMORY - Int i, num_leaked, tot_leaked; - - - num_leaked = 0; - tot_leaked = 0; - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - if ( pointers[i].base ) - { - num_leaked ++; - tot_leaked += pointers[i].size; - } - } - - fprintf( stderr, - "%d memory allocations, of which %d failed\n", - num_alloc, - fail_alloc ); - - fprintf( stderr, - "%d memory reallocations, of which %d failed\n", - num_realloc, - fail_realloc ); - - fprintf( stderr, - "%d memory frees, of which %d failed\n", - num_free, - fail_free ); - - if ( num_leaked > 0 ) - { - fprintf( stderr, - "There are %d leaked memory blocks, totalizing %d bytes\n", - num_leaked, tot_leaked ); - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - if ( pointers[i].base ) - { - fprintf( stderr, - "index: %4d (base: $%08lx, size: %08ld)\n", - i, - (long)pointers[i].base, - pointers[i].size ); - } - } - } - else - fprintf( stderr, "No memory leaks !\n" ); - -#endif /* DEBUG_MEMORY */ - - return TT_Err_Ok; - } - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep b/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep deleted file mode 100755 index 32b3a5f32..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/msdos/makedep +++ /dev/null @@ -1,26 +0,0 @@ -# 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 -Iarch/msdos -I. *.c | \ - sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.dos - -(cd ../.. - gcc -MM -Iarch/msdos -I. -Iextend extend/*.c | \ - sed -e "s/^\(.*\)\.o:/extend\\\\\1.obj:/" -e "s:/:\\\\:g") >> depend.dos - -(cd ../.. - gcc -MM -Iarch/msdos -I. -Iextend \ - -DTT_HUGE_PTR -Dhuge_alloc -Dhuge_free arch/msdos/*.c | \ - sed -e "s/^\(.*\)\.o:/arch\\\\msdos\\\\\1.obj:/" \ - -e "s:/:\\\\:g") >> depend.dos - -# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm deleted file mode 100644 index f4f02ecbd..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.dm +++ /dev/null @@ -1,84 +0,0 @@ -# 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 lib 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 - -CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend -# CFLAGS = -Wall -ansi -O2 -s -I$(ARCH) -I. -Iextend - -TTFILE = $(ARCH)/os2file.c -TTMEMORY = ./ttmemory.c -TTMUTEX = ./ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ - extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ - extend/ftxgsub.c extend/ftxgpos.c extend/ftxopen.c \ - extend/ftxgdef.c -OBJS_X = $(SRC_X:.c=.o) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttgload.c ttinterp.c ttload.c ttobjs.c \ - ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) - -SRC_S = $(ARCH)/freetype.c -OBJ_S = $(SRC_S:.c=.o) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: all debug clean distclean depend - - -all: - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a - -debug: - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a - - -$(OBJ_S): $(SRC_S) $(SRC_M) - $(CC) $(CFLAGS) -c -o $@ $(SRC_S) - - -libttf.a: $($(LIB_FILES)) - +-del $@ - ar src $@ @$(mktmp $(<:t"\n")\n) - -clean: - -+del $(subst,/,\ $($(LIB_FILES))) - -distclean: clean - -+del dep.end libttf.a - -# depend: $(SRC_S) $(SRC_M) $(SRC_X) -# $(CC) -E -M @$(mktmp $(<:t"\n")\n) > dep.end - -# ifeq (dep.end,$(wildcard dep.end)) -# include dep.end -# endif - -# end of Makefile.dm diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx deleted file mode 100644 index fe40be192..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.emx +++ /dev/null @@ -1,91 +0,0 @@ -# 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 lib directory with the following statement: -# -# make -f arch/os2/Makefile.emx - -ARCH = arch/os2 -FT_MAKEFILE = $(ARCH)/Makefile.emx - -CC = gcc - -#CFLAGS = -W -Wall -O0 -g -ansi -pedantic -I$(ARCH) -I. -Iextend - -CFLAGS = -Wall -O3 -fno-inline -fomit-frame-pointer \ - -g -ansi -pedantic -I$(ARCH) -I. -Iextend - -#CFLAGS = -Wall -ansi -pedantic -O2 -s -I$(ARCH) -I. -Iextend - -TTFILE = $(ARCH)/os2file.c -TTMEMORY = ./ttmemory.c -TTMUTEX = ./ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ - extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ - extend/ftxgsub.c extend/ftxgpos.c extend/ftxopen.c \ - extend/ftxgdef.c -OBJS_X = $(SRC_X:.c=.o) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttgload.c ttinterp.c ttload.c ttobjs.c \ - ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) - -SRC_S = $(ARCH)/freetype.c -OBJ_S = $(SRC_S:.c=.o) -OBJS_S = $(OBJ_S) $(OBJS_X) - -SRCD_S = $(ARCH)/freetypd.c -OBJD_S = $(SRCD_S:.c=.o) -OBJDS_S = $(OBJD_S) $(OBJS_X) - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: all debug clean distclean depend - - -all: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a - -debug: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M libttf.a - -debugger: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJDS_S libttfd.a - -$(OBJ_S): $(SRC_S) $(SRC_M) -$(OBJD_S): $(SRCD_S) $(SRC_M) - -libttf.a: $($(LIB_FILES)) - -del $@ - ar src $@ $^ - -libttfd.a: $(OBJDS) - -libttfd.a: $(OBJDS) - -del $@ - ar src $@ $^ - -clean: - -del $(subst /,\,$(OBJS_S)) - -del $(subst /,\,$(OBJS_M)) - -distclean: clean - -del dep.end - -del libttf.a - -depend: $(SRC_S) $(SRC_M) $(SRC_X) - $(CC) -E -M $^ > dep.end - -ifeq (dep.end,$(wildcard dep.end)) - include dep.end -endif - -# end of Makefile.emx diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc deleted file mode 100644 index d774b5422..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.icc +++ /dev/null @@ -1,73 +0,0 @@ -# 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 lib 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 -CFLAGS = -O+ -Ti- -Tm- -Sa -W3 -Wpro- -Wcnd- -Q+ -Iarch\os2 -I. -Iextend - -# NOTE: Optimizations are discarded, as it seems that Visual Age -# is buggy when producing ttraster.obj. The resulting code -# crashes under some circumstances (performing vertical dropout -# control when rendering smoothed outlines)! - -TTFILE = $(ARCH)\os2file.c -TTMEMORY = .\ttmemory.c -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c \ - extend\ftxcmap.c extend\ftxwidth.c extend\ftxsbit.c \ - extend\ftxgsub.c extend\ftxgpos.c extend\ftxopen.c \ - extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c \ - ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -all: - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_S)" libttf.lib - -debug: - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_M)" libttf.lib - - -$(OBJ_S): $(SRC_S) $(SRC_M) - $(CC) -C $(CFLAGS) /Fo$@ $*.c - -$(OBJS_X): - $(CC) -C $(CFLAGS) /Fo$@ $*.c - -$(ARCH)\os2file.obj: - $(CC) -C $(CFLAGS) /Fo$@ $*.c - -libttf.lib: $(LIB_FILES) - !ilib /nologo /noignorecase /nobackup $@ +$?,, - -clean: - -del *.obj - -del extend\*.obj - -del arch\os2\*.obj - -distclean: clean - -del libttf.lib - -# end of Makefile.icc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat deleted file mode 100644 index f6cbb1c0c..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/Makefile.wat +++ /dev/null @@ -1,88 +0,0 @@ -# This file is part of the FreeType project. -# -# This builds the Watcom library with Watcom's wcc386 under OS/2. -# -# You'll need Watcom's wmake. -# -# -# Invoke by "wmake -f arch\os2\Makefile.wat" when in the "lib" directory -# -# This will build "freetype\lib\libttf.lib" - -ARCH = arch\os2 -FT_MAKEFILE = $(ARCH)\Makefile.wat -FT_MAKE = wmake -h - - -.EXTENSIONS: -.EXTENSIONS: .lib .obj .c .h -.obj:.;.\extend;.\$(ARCH) -.c:.;.\extend;.\$(ARCH) -.h:.;.\extend;.\$(ARCH) - -CC = wcc386 - -CCFLAGS = /otexanl+ /s /w5 /zq -Iarch\os2 -I. -Iextend - -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -TTMUTEX = .\ttmutex.c - -TTFILE_OBJ = ttfile.obj -TTMEMORY_OBJ = ttmemory.obj -TTMUTEX_OBJ = ttmutex.obj - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) -PORT_OBJS = $(TTFILE_OBJ) $(TTMEMORY_OBJ) $(TTMUTEX_OBJ) - -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c & - extend\ftxcmap.c extend\ftxwidth.c extend\ftxsbit.c & - extend\ftxgsub.c extend\ftxgpos.c extend\ftxopen.c & - extend\ftxgdef.c - -OBJS_X = extend\ftxgasp.obj extend\ftxkern.obj extend\ftxpost.obj & - extend\ftxcmap.obj extend\ftxwidth.obj extend\ftxsbit.obj & - extend\ftxgsub.obj extend\ftxgpos.obj extend\ftxopen.obj & - extend\ftxgdef.obj - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c & - ttgload.c ttinterp.c ttload.c ttobjs.c & - ttraster.c ttextend.c $(PORT) - -OBJS_M = ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj & - ttgload.obj ttinterp.obj ttload.obj ttobjs.obj & - ttraster.obj ttextend.obj $(PORT_OBJS) $(OBJS_X) - -SRC_S = freetype.c -OBJ_S = freetype.obj -OBJS_S = $(OBJ_S) $(OBJS_X) - - -.c.obj: - $(CC) $(CCFLAGS) $[* /fo=$[*.obj - -all: .symbolic - $(FT_MAKE) -f $(FT_MAKEFILE) libttf.lib - -debug: .symbolic - $(FT_MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJS_M)" libttf.lib - - -libttf.lib: $(OBJS_M) - wlib -q -n libttf.lib $(OBJS_M) - -# is this correct? Know nothing about wmake and the Watcom compiler... -$(OBJ_S): $(SRC_S) $(SRC_M) - $(CC) $(CCFLAGS) $(SRC_S) /fo=$(OBJ_S) - -clean: .symbolic - @-erase $(OBJS_M) - @-erase *.err - -distclean: .symbolic clean - @-erase libttf.lib - -new: .symbolic - @-wtouch *.c - -# end of Makefile.wat diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c deleted file mode 100644 index 8fdcaa704..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/freetype.c +++ /dev/null @@ -1,32 +0,0 @@ -/* This file is part of the FreeType project */ - -/* Single file library component for OS/2 */ -#define TT_MAKE_OPTION_SINGLE_OBJECT - -/* first include common core components */ - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* then system-specific (or ANSI) components */ - -#include "os2file.c" -#include "ttmemory.c" -#include "ttmutex.c" - -/* the extensions are compiled separately, but we need to */ -/* include the file ttextend.c if we want to support them */ - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h deleted file mode 100644 index 14905cba4..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/ft_conf.h +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************* - * - * ft_conf.h (OS/2 version) - * - * High-level interface specification. - * - * Copyright 1996-1998 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. - * - * - * This file is used to contain the definition of several - * configuration-specific macros. - * - ******************************************************************/ - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - - -/**********************************************************************/ -/* */ -/* We begin by a series of macros that are automatically set by the */ -/* 'configure' script on Unix. They must be set manually on OS/2, */ -/* so here they are : */ -/* */ -/**********************************************************************/ - -#define OS2 - -/* Define to empty if the keyword "const" does not work. */ -/* #undef const */ - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define if you need for console I/O functions. */ -#if defined(__EMX__) || defined(__IBMC__) -#define HAVE_CONIO_H -#endif - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c deleted file mode 100644 index 87545b1d6..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/os2/os2file.c +++ /dev/null @@ -1,1237 +0,0 @@ -/******************************************************************* - * - * os2file.c (OS2 version) 2.1 - * - * File I/O Component (body). - * - * 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. - * - * NOTES: - * - * This implementation relies on the OS/2 file API. It was provided - * by the PM FreeType DLL author, Michal Necasek. - * - ******************************************************************/ - -#include "ttconfig.h" - -#include /* !Mike! */ - -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "freetype.h" -#include "tttypes.h" -#include "ttdebug.h" -#include "ttengine.h" -#include "ttmutex.h" -#include "ttmemory.h" -#include "ttfile.h" /* our prototypes */ - - -/* For now, we don't define additional error messages in the core library */ -/* to report open-on demand errors. Define these errors as standard ones. */ - -#define TT_Err_Could_Not_ReOpen_File TT_Err_Could_Not_Open_File -#define TT_Err_Could_Not_ReSeek_File TT_Err_Could_Not_Open_File - - - /* This definition is mandatory for each file component! */ - EXPORT_FUNC - const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; - - -/* It has proven useful to do some bounds checks during development phase. */ -/* They should probably be undefined for speed reasons in a later release. */ - -#if 0 -#define CHECK_FRAME( frame, n ) \ - do { \ - if ( frame.cursor + n > frame.address + frame.size ) \ - Panic( "Frame boundary error!\n" ); \ - } while ( 0 ) -#else -#define CHECK_FRAME( frame, n ) \ - do { \ - } while ( 0 ) -#endif - - - /* Because a stream can be flushed, i.e., its file handle can be */ - /* closed to save system resources, we must keep the stream's file */ - /* pathname to be able to re-open it on demand when it is flushed. */ - - struct _TStream_Rec - { - Bool opened; /* is the stream handle opened ? */ - String* name; /* the file's pathname */ - Long position; /* current pos. within the file */ - - HFILE file; /* file handle !Mike! */ - Long base; /* stream base in file */ - Long size; /* stream size in file */ - }; - - typedef struct _TStream_Rec TStream_Rec; - typedef TStream_Rec* PStream_Rec; - - - /* We support embedded TrueType files by allowing them to be */ - /* inside any file, at any location, hence the 'base' argument. */ - /* Note, however, that the current implementation does not allow you */ - /* to specify a 'base' index when opening a file. */ - /* (will come later) */ - /* I still don't know if this will turn out useful... - DavidT */ - -#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) - - static TT_Error Stream_Activate ( PStream_Rec stream ); - static TT_Error Stream_Deactivate( PStream_Rec stream ); - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /**** ****/ - /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ - /**** ****/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - - /* In non-reentrant builds, we allocate a single block where we'll */ - /* place all the frames smaller than FRAME_CACHE_SIZE, rather than */ - /* allocating a new block on each access. Bigger frames will be */ - /* malloced normally in the heap. */ - /* */ - /* See TT_Access_Frame() and TT_Forget_Frame() for details. */ - -#define FRAME_CACHE_SIZE 2048 - - /* The TFile_Component structure holds all the data that was */ - /* previously declared static or global in this component. */ - /* */ - /* It is accessible through the 'engine.file_component' */ - /* variable in re-entrant builds, or directly through the */ - /* static 'files' variable in other builds. */ - - struct _TFile_Component - { - TMutex lock; /* used by the thread-safe build only */ - Byte* frame_cache; /* frame cache */ - PStream_Rec stream; /* current stream */ - TFileFrame frame; /* current frame */ - }; - - typedef struct _TFile_Component TFile_Component; - - static TFile_Component files; - -#define CUR_Stream files.stream -#define CUR_Frame files.frame - -#define STREAM_VARS /* void */ -#define STREAM_VAR /* void */ - -/* The macro CUR_Stream denotes the current input stream. */ -/* Note that for the re-entrant version, the 'stream' name has been */ -/* chosen according to the macro STREAM_ARGS. */ - -/* The macro CUR_Frame denotes the current file frame. */ -/* Note that for the re-entrant version, the 'frame' name has been */ -/* chosen according to the macro FRAME_ARGS. */ - -/* The macro STREAM_VAR is used when calling public functions */ -/* that need an 'optional' stream argument. */ - - -/******************************************************************* - * - * Function : TTFile_Init - * - * Description : Initializes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) - { - TT_Error error; - - MUTEX_Create( files.lock ); - files.stream = NULL; - ZERO_Frame( files.frame ); - - if ( ALLOC( files.frame_cache, FRAME_CACHE_SIZE ) ) - return error; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTFile_Done - * - * Description : Finalizes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) - { - FREE( files.frame_cache ); - MUTEX_Destroy( files.lock ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Use_Stream - * - * Description : Copies or duplicates a given stream. - * - * Input : org_stream original stream - * stream target stream (copy or duplicate) - * - * Output : Error code. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Use_Stream( TT_Stream org_stream, - TT_Stream* stream ) - { - MUTEX_Lock( files.lock ); /* lock file mutex */ - - *stream = org_stream; /* copy the stream */ - files.stream = STREAM2REC( org_stream ); /* set current stream */ - - Stream_Activate( files.stream ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Done_Stream - * - * Description : Releases a given stream. - * - * Input : stream target stream - * - * Output : Error code. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Done_Stream( TT_Stream* stream ) - { - HANDLE_Set( *stream, NULL ); - MUTEX_Release( files.lock ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Access_Frame - * - * Description : Notifies the component that we're going to read - * 'size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : SUCCESS on success. FAILURE on error. - * - * Notes: The function fails if the byte range is not within the - * the file, or if there is not enough memory to cache - * the bytes properly (which usually means that `size' is - * too big in both cases). - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) - { - TT_Error error; - - - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - if ( size <= FRAME_CACHE_SIZE ) - { - /* use the cache */ - CUR_Frame.address = files.frame_cache; - CUR_Frame.size = FRAME_CACHE_SIZE; - } - else - { - if ( ALLOC( CUR_Frame.address, size ) ) - return error; - CUR_Frame.size = size; - } - - error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); - if ( error ) - { - if ( size > FRAME_CACHE_SIZE ) - FREE( CUR_Frame.address ); - CUR_Frame.address = NULL; - CUR_Frame.size = 0; - } - - CUR_Frame.cursor = CUR_Frame.address; - return error; - } - - -/******************************************************************* - * - * Function : TT_Check_And_Access_Frame - * - * Description : Notifies the component that we're going to read - * `size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : SUCCESS on success. FAILURE on error. - * - * Notes: The function truncates `size' if the byte range is not - * within the file. - * - * It will fail if there is not enough memory to cache - * the bytes properly (which usually means that `size' is - * too big). - * - * It will fail if you make two consecutive calls - * to TT_Access_Frame(), without a TT_Forget_Frame() between - * them. - * - * The only difference with TT_Access_Frame() is that we - * check that the frame is within the current file. We - * otherwise truncate it. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) - { - TT_Error error; - Long readBytes, requested; - - - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - if ( size <= FRAME_CACHE_SIZE ) - { - /* use the cache */ - CUR_Frame.address = files.frame_cache; - CUR_Frame.size = FRAME_CACHE_SIZE; - } - else - { - if ( ALLOC( CUR_Frame.address, size ) ) - return error; - CUR_Frame.size = size; - } - - requested = size; - readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); - if ( size > readBytes ) - size = readBytes; - - error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); - if ( error ) - { - if ( requested > FRAME_CACHE_SIZE ) - FREE( CUR_Frame.address ); - CUR_Frame.address = NULL; - CUR_Frame.size = 0; - } - - CUR_Frame.cursor = CUR_Frame.address; - return error; - } - - -/******************************************************************* - * - * Function : TT_Forget_Frame - * - * Description : Releases a cached frame after reading. - * - * Input : None - * - * Output : SUCCESS on success. FAILURE on error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Forget_Frame( FRAME_ARG ) - { - if ( CUR_Frame.address == NULL ) - return TT_Err_Nested_Frame_Access; - - if ( CUR_Frame.size > FRAME_CACHE_SIZE ) - FREE( CUR_Frame.address ); - - ZERO_Frame( CUR_Frame ); - - return TT_Err_Ok; - } - - -#else /* TT_CONFIG_OPTION_THREAD_SAFE */ - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /******** ********/ - /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ - /******** ********/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - -/* a simple macro to access the file component's data */ -#define files ( *((TFile_Component*)engine.file_component) ) - -#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ -#define CUR_Frame (*frame) - -#define STREAM_VARS stream, -#define STREAM_VAR stream - - -/******************************************************************* - * - * Function : TTFile_Init - * - * Description : Initializes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) - { - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTFile_Done - * - * Description : Finalizes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) - { - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Use_Stream - * - * Description : Duplicates a stream for a new usage. - * - * Input : input_stream source stream to duplicate - * copy address of target duplicate stream - * - * Output : error code. - * The target stream is set to NULL in case of failure. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Use_Stream( TT_Stream input_stream, - TT_Stream* copy ) - { - PStream_Rec rec = STREAM2REC( input_stream ); - - return TT_Open_Stream( rec->name, copy ); - } - - -/******************************************************************* - * - * Function : TT_Done_Stream - * - * Description : Releases a given stream. - * - * Input : stream target stream - * - * Output : - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Done_Stream( TT_Stream* stream ) - { - return TT_Close_Stream( stream ); - } - - -/******************************************************************* - * - * Function : TT_Access_Frame - * - * Description : Notifies the component that we're going to read - * 'size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : SUCCESS on success. FAILURE on error. - * - * Notes: The function fails if the byte range is not within the - * the file, or if there is not enough memory to cache - * the bytes properly (which usually means that `size' is - * too big in both cases). - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS int size ) - { - TT_Error error; - - - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - if ( ALLOC( CUR_Frame.address, size ) ) - return error; - CUR_Frame.size = size; - - error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); - if ( error ) - { - FREE( CUR_Frame.address ); - CUR_Frame.size = 0; - } - - CUR_Frame.cursor = CUR_Frame.address; - return error; - } - - -/******************************************************************* - * - * Function : TT_Check_And_Access_Frame - * - * Description : Notifies the component that we're going to read - * `size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : SUCCESS on success. FAILURE on error. - * - * Notes: The function truncates `size' if the byte range is not - * within the file. - * - * It will fail if there is not enough memory to cache - * the bytes properly (which usually means that `size' is - * too big). - * - * It will fail if you make two consecutive calls - * to TT_Access_Frame(), without a TT_Forget_Frame() between - * them. - * - * The only difference with TT_Access_Frame() is that we - * check that the frame is within the current file. We - * otherwise truncate it. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS int size ) - { - TT_Error error; - Long readBytes; - - - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - if ( ALLOC( CUR_Frame.address, size ) ) - return error; - CUR_Frame.size = size; - - readBytes = CUR_Stream->size - TT_File_Pos( STREAM_VAR ); - if ( size > readBytes ) - size = readBytes; - - error = TT_Read_File( STREAM_VARS (void*)CUR_Frame.address, size ); - if ( error ) - { - FREE( CUR_Frame.address ); - CUR_Frame.size = 0; - } - - CUR_Frame.cursor = CUR_Frame.address; - return error; - } - - -/******************************************************************* - * - * Function : TT_Forget_Frame - * - * Description : Releases a cached frame after reading. - * - * Input : None - * - * Output : SUCCESS on success. FAILURE on error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Forget_Frame( FRAME_ARG ) - { - if ( CUR_Frame.address == NULL ) - return TT_Err_Nested_Frame_Access; - - FREE( CUR_Frame.address ); - ZERO_Frame( CUR_Frame ); - - return TT_Err_Ok; - } - -#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ - - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /*********** ***********/ - /*********** C O M M O N I M P L E M E N T A T I O N ***********/ - /*********** ***********/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - -/******************************************************************* - * - * Function : Stream_Activate - * - * Description : activates a stream, this will either: - * - open a new file handle if the stream is closed - * - move the stream to the head of the linked list - * - * Input : stream the stream to activate - * - * Output : error condition. - * - * Note : this function is also called with fresh new streams - * created by TT_Open_Stream(). They have their 'size' - * field set to -1. - * - ******************************************************************/ - - static TT_Error Stream_Activate( PStream_Rec stream ) - { - ULONG ulAction; /* !Mike! */ - - if ( !stream->opened ) - { -#if 0 - if ( !(stream->file = fopen( stream->name, "rb" )) ) /* !Mike! */ -#endif - -/* XXX : Strange. GCC/EMX wants an (Byte*) for the file name? */ -#ifdef __EMX__ - - if ( DosOpen( (Byte*)stream->name, &(stream->file), - &ulAction, 0, - 0, OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) ) - return TT_Err_Could_Not_ReOpen_File; - -#else - - if ( DosOpen( stream->name, &(stream->file), - &ulAction, 0, - 0, OPEN_ACTION_OPEN_IF_EXISTS, - OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) ) - return TT_Err_Could_Not_ReOpen_File; - -#endif /* __EMX__ */ - - stream->opened = TRUE; - - /* A newly created stream has a size field of -1 */ - if ( stream->size < 0 ) - { -#if 0 - fseek( stream->file, 0, SEEK_END ); /* !Mike! */ - stream->size = ftell( stream->file ); -#endif - - DosSetFilePtr( stream->file, 0, FILE_END, (ULONG *)&(stream->size) ); -#if 0 - fseek( stream->file, 0, SEEK_SET ); -#endif - - DosSetFilePtr( stream->file, 0, FILE_BEGIN, &ulAction ); - } - - /* Reset cursor in file */ - if ( stream->position ) - { -#if 0 /* !Mike! */ - if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 ) -#endif - - if ( DosSetFilePtr( stream->file, stream->position, - FILE_BEGIN, &ulAction ) ) - { - /* error during seek */ -#if 0 - fclose( stream->file ); /* !Mike! */ -#endif - - DosClose( stream->file ); - stream->opened = FALSE; - return TT_Err_Could_Not_ReSeek_File; - } - } - } - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : Stream_DeActivate - * - * Description : deactivates a stream, this will: - * - close its file handle if it was opened - * - remove it from the opened list if necessary - * - * Input : stream the stream to deactivate - * - * Output : Error condition - * - * Note : the function is called whenever a stream is deleted - * (_not_ when a stream handle's is closed due to an - * activation). However, the stream record isn't - * destroyed by it... - * - ******************************************************************/ - - static TT_Error Stream_Deactivate( PStream_Rec stream ) - { - if ( stream->opened ) - { - /* Save its current position within the file */ -#if 0 - stream->position = ftell( stream->file ); /* !Mike! */ -#endif - - DosSetFilePtr( stream->file, 0, FILE_CURRENT, - (ULONG *)&(stream->position) ); -#if 0 - fclose( stream->file ); /* !Mike! */ -#endif - - DosClose( stream->file ); - stream->file = 0; - stream->opened = FALSE; - } - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Stream_Size - * - * Description : Returns the length of a given stream, even if it - * is flushed. - * - * Input : stream the stream - * - * Output : length of stream in bytes. - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_Stream_Size( TT_Stream stream ) - { - PStream_Rec rec = STREAM2REC( stream ); - - - if ( rec ) - return rec->size; - else - return 0; /* invalid stream - return 0 */ - } - - -/******************************************************************* - * - * Function : TT_Open_Stream - * - * Description : Opens the font file and saves the total file size. - * - * Input : error address of stream's error variable - * (re-entrant build only) - * filepathname pathname of the file to open - * stream address of target TT_Stream structure - * - * Output : SUCCESS on sucess, FAILURE on error. - * The target stream is set to -1 in case of failure. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TT_Open_Stream( const String* filepathname, - TT_Stream* stream ) - { - int len; - TT_Error error; - PStream_Rec stream_rec; - - - if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) - return error; - - stream_rec = STREAM2REC( *stream ); - - stream_rec->file = NULLHANDLE; /* !Mike! */ - stream_rec->size = -1; - stream_rec->base = 0; - stream_rec->opened = FALSE; - stream_rec->position = 0; - - len = strlen( filepathname ) + 1; - if ( ALLOC( stream_rec->name, len ) ) - goto Fail; - - strncpy( (String*)stream_rec->name, filepathname, len ); - - error = Stream_Activate( stream_rec ); - if ( error ) - goto Fail_Activate; - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - CUR_Stream = stream_rec; -#endif - - return TT_Err_Ok; - - Fail_Activate: - FREE( stream_rec->name ); - Fail: - FREE( stream_rec ); - return error; - } - - -/******************************************************************* - * - * Function : TT_Close_Stream - * - * Description : Closes a stream. - * - * Input : stream address of target TT_Stream structure - * - * Output : SUCCESS (always). - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TT_Close_Stream( TT_Stream* stream ) - { - PStream_Rec rec = STREAM2REC( *stream ); - - - Stream_Deactivate( rec ); - FREE( rec->name ); - FREE( rec ); - - HANDLE_Set( *stream, NULL ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Flush_Stream - * - * Description : Flushes a stream, i.e., closes its file handle. - * - * Input : stream address of target TT_Stream structure - * - * Output : Error code - * - * NOTE : Never flush the current opened stream. This means that - * you should _never_ call this function between a - * TT_Use_Stream() and a TT_Done_Stream()! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Flush_Stream( TT_Stream* stream ) - { - PStream_Rec rec = STREAM2REC( *stream ); - - - if ( rec ) - { - Stream_Deactivate( rec ); - return TT_Err_Ok; - } - else - return TT_Err_Invalid_Argument; - } - - -/******************************************************************* - * - * Function : TT_Seek_File - * - * Description : Seeks the file cursor to a different position. - * - * Input : position new position in file - * - * Output : SUCCESS on success. FAILURE if out of range. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Seek_File( STREAM_ARGS long position ) - { - ULONG ibActual; /* !Mike! */ - - - position += CUR_Stream->base; - -#if 0 - if ( fseek( CUR_Stream->file, position, SEEK_SET ) ) /* !Mike! */ -#endif - - if ( DosSetFilePtr( CUR_Stream->file, position, FILE_BEGIN , &ibActual ) ) - return TT_Err_Invalid_File_Offset; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Skip_File - * - * Description : Skips forward the file cursor. - * - * Input : distance number of bytes to skip - * - * Output : see TT_Seek_File() - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Skip_File( STREAM_ARGS long distance ) - { - ULONG ibActual; /* !Mike! */ - - -#if 0 - return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) - - CUR_Stream->base + distance ); /* !Mike! */ -#endif - - DosSetFilePtr( CUR_Stream->file, 0, FILE_CURRENT, &ibActual ); - return TT_Seek_File( STREAM_VARS ibActual - CUR_Stream->base + distance ); - } - - -/******************************************************************* - * - * Function : TT_Read_File - * - * Description : Reads a chunk of the file and copies it to memory. - * - * Input : buffer target buffer - * count length in bytes to read - * - * Output : SUCCESS on success. FAILURE if out of range. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Read_File( STREAM_ARGS void* buffer, long count ) - { - ULONG cbActual; /* !Mike! */ - -#if 0 /* !Mike! */ - if ( fread( buffer, 1, count, CUR_Stream->file ) != (unsigned long)count ) -#endif - - DosRead( CUR_Stream->file, buffer, count, &cbActual ); - if ( cbActual != (unsigned long)count ) - return TT_Err_Invalid_File_Read; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Read_At_File - * - * Description : Reads file at a specified position. - * - * Input : position position to seek to before read - * buffer target buffer - * count number of bytes to read - * - * Output : SUCCESS on success. FAILURE if error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Read_At_File( STREAM_ARGS long position, - void* buffer, - long count ) - { - TT_Error error; - - - if ( ( error = TT_Seek_File( STREAM_VARS position ) ) || - ( error = TT_Read_File( STREAM_VARS buffer, count ) ) ) - return error; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_File_Pos - * - * Description : Returns current file seek pointer. - * - * Input : none - * - * Output : current file position - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_File_Pos( STREAM_ARG ) - { - ULONG ibActual; /* !Mike! */ - - -#if 0 - return ftell( CUR_Stream->file ) - CUR_Stream->base; /* !Mike! */ -#endif - - DosSetFilePtr( CUR_Stream->file, 0, FILE_CURRENT, &ibActual ); - return ibActual - CUR_Stream->base; - } - - -/******************************************************************* - * - * Function : GET_Byte - * - * Description : Extracts a byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted Byte. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - Byte TT_Get_Byte( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Byte)(*CUR_Frame.cursor++); - } -#endif - -/******************************************************************* - * - * Function : GET_Char - * - * Description : Extracts a signed byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted char. - * - ******************************************************************/ - - EXPORT_FUNC - Char TT_Get_Char( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Char)(*CUR_Frame.cursor++); - } - - -/******************************************************************* - * - * Function : GET_Short - * - * Description : Extracts a short from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted short. - * - ******************************************************************/ - - EXPORT_FUNC - short TT_Get_Short( FRAME_ARG ) - { - short getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = ((short)CUR_Frame.cursor[0] << 8) | - (short)CUR_Frame.cursor[1]; - - CUR_Frame.cursor += 2; - - return getshort; - } - - -/******************************************************************* - * - * Function : GET_UShort - * - * Description : Extracts an unsigned short from the frame. - * - * Input : None or current frame - * - * Output : Extracted ushort. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - unsigned short TT_Get_UShort( FRAME_ARG ) - { - unsigned short getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = ((unsigned short)CUR_Frame.cursor[0] << 8) | - (unsigned short)CUR_Frame.cursor[1]; - - CUR_Frame.cursor += 2; - - return getshort; - } -#endif - -/******************************************************************* - * - * Function : GET_Long - * - * Description : Extracts a long from the frame. - * - * Input : None or current frame - * - * Output : Extracted long. - * - ******************************************************************/ - - EXPORT_FUNC - long TT_Get_Long( FRAME_ARG ) - { - long getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ((long)CUR_Frame.cursor[0] << 24) | - ((long)CUR_Frame.cursor[1] << 16) | - ((long)CUR_Frame.cursor[2] << 8 ) | - (long)CUR_Frame.cursor[3]; - - CUR_Frame.cursor += 4; - - return getlong; - } - - -/******************************************************************* - * - * Function : GET_ULong - * - * Description : Extracts an unsigned long from the frame. - * - * Input : None - * - * Output : Extracted ulong. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - unsigned long TT_Get_ULong( FRAME_ARG ) - { - unsigned long getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ( ((unsigned long)CUR_Frame.cursor[0] << 24) | - ((unsigned long)CUR_Frame.cursor[1] << 16) | - ((unsigned long)CUR_Frame.cursor[2] << 8 ) | - (unsigned long)CUR_Frame.cursor[3] ); - - CUR_Frame.cursor += 4; - - return getlong; - } -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore deleted file mode 100644 index a8f619d84..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in deleted file mode 100644 index ce70fae7e..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/Makefile.in +++ /dev/null @@ -1,244 +0,0 @@ -# This file is part of the FreeType project. -# -# lib/arch/unix/Makefile.in - -ARCH = arch/unix -FT_MAKEFILE = $(ARCH)/Makefile - -RM = @RM@ -RMF = @RM@ -f -RMDIR = @RMDIR@ -LN_S = @LN_S@ - -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ - -VPATH = @srcdir@/../.. -srcdir = @srcdir@/../.. - -top_builddir=.. - -CC = @CC@ -CPP = @CPP@ - -LIBTOOL = $(top_builddir)/libtool -MKINSTALLDIRS = $(srcdir)/../mkinstalldirs - -version_info = @version_info@ - -include $(top_builddir)/MakeSub - -############### PORTABILITY COMPONENTS ######################## - -# location of memory component -MEMSRC = ttmemory.c - -# location of file component -FILESRC = @TT_FILE_COMPONENT@ - -# location of mutex component -MUTEXSRC = ttmutex.c - -# location of default extensions -FTEXTDIR = $(srcdir)/extend - - -# default extensions sources -EXTSRC = $(FTEXTDIR)/ftxkern.c \ - $(FTEXTDIR)/ftxgasp.c \ - $(FTEXTDIR)/ftxpost.c \ - $(FTEXTDIR)/ftxcmap.c \ - $(FTEXTDIR)/ftxsbit.c \ - $(FTEXTDIR)/ftxwidth.c \ - $(FTEXTDIR)/ftxerr18.c \ - $(FTEXTDIR)/ftxgsub.c \ - $(FTEXTDIR)/ftxgpos.c \ - $(FTEXTDIR)/ftxgdef.c \ - $(FTEXTDIR)/ftxopen.c - -EXTOBJ = ftxkern.lo \ - ftxgasp.lo \ - ftxpost.lo \ - ftxcmap.lo \ - ftxsbit.lo \ - ftxwidth.lo \ - ftxerr18.lo \ - ftxgsub.lo \ - ftxgpos.lo \ - ftxgdef.lo \ - ftxopen.lo - -# all engine sources -SRC_M = $(srcdir)/ttapi.c \ - $(srcdir)/ttcache.c \ - $(srcdir)/ttcalc.c \ - $(srcdir)/ttcmap.c \ - $(srcdir)/ttdebug.c \ - $(srcdir)/ttextend.c \ - $(srcdir)/ttgload.c \ - $(srcdir)/ttinterp.c \ - $(srcdir)/ttload.c \ - $(srcdir)/ttobjs.c \ - $(srcdir)/ttraster.c \ - $(srcdir)/$(FILESRC) \ - $(srcdir)/$(MEMSRC) \ - $(srcdir)/$(MUTEXSRC) -SRC_S = $(srcdir)/$(ARCH)/freetype.c - -# all header files -HEADERS = $(srcdir)/freetype.h \ - $(srcdir)/fterrid.h \ - $(srcdir)/ftnameid.h \ - $(FTEXTDIR)/ftxkern.h \ - $(FTEXTDIR)/ftxgasp.h \ - $(FTEXTDIR)/ftxcmap.h \ - $(FTEXTDIR)/ftxsbit.h \ - $(FTEXTDIR)/ftxpost.h \ - $(FTEXTDIR)/ftxwidth.h \ - $(FTEXTDIR)/ftxerr18.h \ - $(FTEXTDIR)/ftxgsub.h \ - $(FTEXTDIR)/ftxgpos.h \ - $(FTEXTDIR)/ftxgdef.h \ - $(FTEXTDIR)/ftxopen.h - -# all engine objects -OBJ_M = ttapi.lo \ - ttcache.lo \ - ttcalc.lo \ - ttcmap.lo \ - ttdebug.lo \ - ttextend.lo \ - ttgload.lo \ - ttinterp.lo \ - ttload.lo \ - ttobjs.lo \ - ttraster.lo \ - file.lo \ - memory.lo \ - mutex.lo \ - $(EXTOBJ) -OBJ_S = freetype.lo $(EXTOBJ) - - -# include paths -INCLUDES = -I. -I$(top_builddir) -I$(srcdir) -I$(FTEXTDIR) - -# C flags -CFLAGS = @CFLAGS@ @XX_CFLAGS@ -CPPFLAGS = @CPPFLAGS@ -FT_CFLAGS = $(CFLAGS) $(INCLUDES) - -# linker flags -FT_LIBS = @LIBS@ - -# i18n stuff -LOCALEDIR = @LOCALEDIR@ - - -all: do_link - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJ_S)" libttf.la - -debug: do_link - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES="$(OBJ_M)" libttf.la - - -do_link: - -$(RMF) memory.c file.c mutex.c - $(LN_S) $(srcdir)/$(MEMSRC) memory.c - $(LN_S) $(srcdir)/$(FILESRC) file.c - $(LN_S) $(srcdir)/$(MUTEXSRC) mutex.c - - -.SUFFIXES: .lo -.c.lo: - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $< - -ftxkern.lo: $(FTEXTDIR)/ftxkern.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxkern.c - -ftxgasp.lo: $(FTEXTDIR)/ftxgasp.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgasp.c - -ftxpost.lo: $(FTEXTDIR)/ftxpost.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxpost.c - -ftxcmap.lo: $(FTEXTDIR)/ftxcmap.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxcmap.c - -ftxsbit.lo: $(FTEXTDIR)/ftxsbit.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxsbit.c - -ftxwidth.lo: $(FTEXTDIR)/ftxwidth.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxwidth.c - -ftxerr18.lo: $(FTEXTDIR)/ftxerr18.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) \ - -DLOCALEDIR='"$(LOCALEDIR)"' \ - $(FTEXTDIR)/ftxerr18.c - -ftxgsub.lo: $(FTEXTDIR)/ftxgsub.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgsub.c - -ftxgpos.lo: $(FTEXTDIR)/ftxgpos.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgpos.c - -ftxgdef.lo: $(FTEXTDIR)/ftxgdef.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxgdef.c - -ftxopen.lo: $(FTEXTDIR)/ftxopen.c - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) $(FTEXTDIR)/ftxopen.c - -freetype.lo: $(SRC_S) $(SRC_M) - $(LIBTOOL) --mode=compile $(CC) -c $(FT_CFLAGS) \ - -DLOCALEDIR='"$(LOCALEDIR)"' \ - -DTT_MAKE_OPTION_SINGLE_OBJECT \ - $(SRC_S) - -libttf.la: $(LIB_FILES) - $(LIBTOOL) --mode=link $(CC) -o libttf.la $(LIB_FILES) \ - -rpath $(libdir) \ - -version-info $(version_info) $(FT_LIBS) - -install: libttf.la - $(MKINSTALLDIRS) $(libdir) $(includedir)/freetype - $(LIBTOOL) --mode=install $(INSTALL) libttf.la $(libdir) - -for P in $(HEADERS) ; do \ - $(INSTALL_DATA) $$P $(includedir)/freetype ; \ - done - -uninstall: - -$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/libttf.la - -$(RMF) $(includedir)/freetype/* - -$(RMDIR) $(includedir)/freetype - -clean: - -$(RMF) $(OBJ_S) $(OBJ_M) *.o - -distclean: clean - -$(RMF) file.c memory.c mutex.c - -$(RMF) libttf.la - -$(RMF) *.orig *~ core *.core - -$(RMF) $(ARCH)/Makefile - -$(RMF) .libs/* - -$(RMDIR) .libs - -depend: do_link - (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_S) $(SRC_M) $(EXTSRC) ; do \ - $(CPP) $(CPPFLAGS) $(INCLUDES) $$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`.lo: /" ; \ - 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 diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c deleted file mode 100644 index 5f41ff6aa..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/freetype.c +++ /dev/null @@ -1,27 +0,0 @@ -/* This file is part of the FreeType project */ - -/* Single object library component for Unix */ - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* The Makefile creates proper links to following three files */ - -#include "file.c" -#include "memory.c" -#include "mutex.c" - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c deleted file mode 100644 index 0378dc2a2..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/unix/ttmmap.c +++ /dev/null @@ -1,1027 +0,0 @@ -/******************************************************************* - * - * ttmmap.c 2.0 - * - * Memory-Mapped file component ( replaces ttfile.c ). - * - * 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. - * - * Changes between 2.0 and 1.3 : - * - * - adopted new design/separation introduced in ttfile.c 2.0 - * - ******************************************************************/ - -#include "ttconfig.h" - -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include -#ifndef MAP_FILE -#define MAP_FILE 0x00 -#endif - -/* - * The prototype for munmap() is not provided on SunOS. This needs to - * have a check added later to see if the GNU C library is being used. - * If so, then this prototype is not needed. - */ -#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4) - extern int munmap( caddr_t addr, int len ); -#endif - -#include -#ifdef HAVE_FCNTL_H -#include -#endif - - -#include "freetype.h" -#include "tttypes.h" -#include "ttdebug.h" -#include "ttengine.h" -#include "ttmutex.h" -#include "ttmemory.h" -#include "ttfile.h" /* our prototypes */ - - /* This definition is mandatory for each file component! */ - EXPORT_FUNC - const TFileFrame TT_Null_FileFrame = { NULL, 0, 0 }; - - /* It has proven useful to do some bounds checks during */ - /* development phase. Define DEBUG_FILE when compiling */ - /* this component to enable them. */ - -#ifdef DEBUG_FILE -#define CHECK_FRAME( frame, n ) \ - do { \ - if ( frame.cursor + n > frame.address + frame.size ) \ - Panic( "Frame boundary error!\n" ); \ - } while ( 0 ) -#else -#define CHECK_FRAME( frame, n ) \ - do { \ - } while( 0 ) -#endif - - struct _TFileMap - { - String* base; /* base address of mapped file */ - Int refcount; /* reference count for mmaped region */ - Long size; /* stream size in file */ - Long offset; /* offset in file */ - }; - - typedef struct _TFileMap TFileMap; - -#define MAP_Address( map ) (Byte*)( (map)->base + (map)->offset ) - - /* The stream record structure */ - typedef struct _TStream_Rec - { - TFileMap* map; /* mapped file description */ - Long pos ; /* cursor in mapped file */ - } TStream_Rec; - - typedef TStream_Rec* PStream_Rec; - -#define STREAM2REC( x ) ( (TStream_Rec*)HANDLE_Val( x ) ) - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /**** ****/ - /**** N O N R E E N T R A N T I M P L E M E N T A T I O N ****/ - /**** ****/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - - /* The TFile_Component structure holds all the data that was */ - /* previously declared static or global in this component. */ - /* */ - /* It is accessible through the 'engine.file_component' */ - /* variable in re-entrant builds, or directly through the */ - /* static 'files' variable in other builds. */ - - struct _TFile_Component - { - TMutex lock; /* used by the thread-safe build only */ - PStream_Rec stream; /* current stream */ - TFileFrame frame; /* current frame */ - }; - - typedef struct _TFile_Component TFile_Component; - -/* The macro CUR_Stream denotes the current input stream */ -/* Note that for the re-entrant version, the 'stream' name has been */ -/* chosen according to the macro STREAM_ARGS. */ - -/* The macro CUR_Frame denotes the current file frame */ -/* Note that for the re-entrant version, the 'frame' name has been */ -/* chosen according to the macro FRAME_ARGS. */ - -/* The macro STREAM_VAR is used when calling public functions */ -/* that need an 'optional' stream argument. */ - -#define CUR_Stream files.stream /* thread-safe macros */ -#define CUR_Frame files.frame - -#define STREAM_VARS /* void */ -#define STREAM_VAR /* void */ - - /* the 'files' variable is only defined in non-reentrant builds */ - - static TFile_Component files; - - - -/******************************************************************* - * - * Function : TTFile_Init - * - * Description : Initializes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) - { - MUTEX_Create( files.lock ); - files.stream = NULL; - ZERO_Frame( files.frame ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTFile_Done - * - * Description : Finalizes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) - { - MUTEX_Destroy( files.lock ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Use_Stream - * - * Description : Copies or duplicates a given stream. - * - * Input : org_stream original stream - * stream target stream (copy or duplicate) - * - * Output : Error code - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Use_Stream( TT_Stream org_stream, - TT_Stream* stream ) - { - MUTEX_Lock( files.lock ); - *stream = org_stream; - files.stream = STREAM2REC( org_stream ); /* set current stream */ - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Done_Stream - * - * Description : Releases a given stream. - * - * Input : stream - * - * Output : Error code - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Done_Stream( TT_Stream* stream ) - { - HANDLE_Set( *stream, NULL ); - MUTEX_Release( files.lock ); - - return TT_Err_Ok; - } - -#else /* TT_CONFIG_OPTION_THREAD_SAFE */ - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /******** ********/ - /******** R E E N T R A N T I M P L E M E N T A T I O N ********/ - /******** ********/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - -#define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ -#define CUR_Frame (*frame) - -#define STREAM_VARS stream, -#define STREAM_VAR stream - - -/******************************************************************* - * - * Function : TTFile_Init - * - * Description : Initializes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Init( PEngine_Instance engine ) - { - engine.file_component = NULL; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTFile_Done - * - * Description : Finalizes the File component. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTFile_Done( PEngine_Instance engine ) - { - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Use_Stream - * - * Description : Copies or duplicates a given stream. - * - * Input : org_stream original stream - * stream target stream (copy or duplicate) - * - * Output : Error code. The output stream is set to NULL in - * case of Failure. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Use_Stream( TT_Stream input_stream, - TT_Stream* copy ) - { - TT_Error error; - PStream_Rec stream_rec; - PStream_Rec copy_rec; - - - stream_rec = STREAM2REC( input_stream ); - - if ( ALLOC( copy_rec, sizeof ( TStream_Rec ) ) ) - goto Fail; - - HANDLE_Set( *copy, copy_rec ); - - copy_rec->map->refcount++; - copy_rec->pos = 0; - - return TT_Err_Ok; - - Fail: - HANDLE_Set( *copy, NULL ); - return error; - } - - -/******************************************************************* - * - * Function : TT_Done_Stream - * - * Description : Releases a given stream. - * - * Input : stream - * - * Output : error code - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Done_Stream( TT_Stream* stream ) - { - return TT_Close_Stream( stream ); - } - -#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ - - - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - /*********** ***********/ - /*********** C O M M O N I M P L E M E N T A T I O N ***********/ - /*********** ***********/ - /*******************************************************************/ - /*******************************************************************/ - /*******************************************************************/ - -/******************************************************************* - * - * Function : AllocateMap - * - * Description : Allocates a new map from the table. - * - * Output : Pointer to new stream rec. NULL in case of failure. - * - ******************************************************************/ - - static - TFileMap* Allocate_Map( void ) - { - TFileMap* result; - - - if ( MEM_Alloc( result, sizeof ( TFileMap ) ) ) - return NULL; - - result->refcount = 1; - return result; - } - - -/******************************************************************* - * - * Function : ReleaseMap - * - * Description : Releases a used map to the table if reference i - * counter reaches zero. - * - * Input : map - * - * Output : None. - * - * Note : Called by TT_Close_File() - * - ******************************************************************/ - - static - void Release_Map ( TFileMap* map ) - { - map->refcount--; - if ( map->refcount <= 0 ) - { - munmap ( (void*)map->base, map->size ); - FREE( map ); - } - } - - -/******************************************************************* - * - * Function : TT_Open_Stream - * - * Description : Opens the font file and saves the total file size. - * - * Input : error address of stream's error variable - * (re-entrant build only). - * filepathname pathname of the file to open - * stream address of target TT_Stream structure - * - * Output : SUCCESS on success, FAILURE on error. - * The target stream is set to -1 in case of failure. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TT_Open_Stream( const String* filepathname, - TT_Stream* stream ) - { - TT_Error error; - Int file; - PStream_Rec stream_rec; - TFileMap* map; - struct stat stat_buf; - - - if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) - return error; - - map = Allocate_Map(); - if ( !map ) - { - error = TT_Err_Out_Of_Memory; - goto Memory_Fail; - } - - stream_rec = STREAM2REC( *stream ); - - file = open( (String*)filepathname, O_RDONLY ); - if ( file < 0 ) - goto File_Fail; - - if ( fstat( file, &stat_buf ) < 0 ) - goto Map_Fail; - - map->offset = 0; - map->size = stat_buf.st_size + map->offset; - map->base = mmap( NULL, - map->size, - PROT_READ, - MAP_FILE | MAP_PRIVATE, - file, - 0 ); - - if ( (long)map->base == -1 ) - goto Map_Fail; - - close( file ); - - stream_rec->map = map; - stream_rec->pos = 0; - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - CUR_Stream = stream_rec; -#endif - - return TT_Err_Ok; - - Map_Fail: - close( file ); - - File_Fail: - error = TT_Err_Could_Not_Open_File; - FREE( map ); - - Memory_Fail: - FREE( *stream ); - return error; - } - - -/******************************************************************* - * - * Function : TT_Close_Stream - * - * Description : Closes a stream. - * - * Input : stream - * - * Output : SUCCESS (always) - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TT_Close_Stream( TT_Stream* stream ) - { - PStream_Rec rec = STREAM2REC( *stream ); - - - Release_Map( rec->map ); - FREE( rec ); - - HANDLE_Set( *stream, NULL ); - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Flush_Stream - * - * Description : Flushes a stream, i.e., closes its file handle. - * - * Input : stream address of target TT_Stream structure - * - * Output : Error code - * - * NOTE : Never flush the current opened stream. This means that - * you should _never_ call this function between a - * TT_Use_Stream() and a TT_Done_Stream()! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Flush_Stream( TT_Stream* stream ) - { - /* XXX - DUMMY IMPLEMENTATION */ - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Stream_Size - * - * Description : Returns the length of a given stream, even if it - * is flushed. - * - * Input : stream the stream - * - * Output : Length of stream in bytes. - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_Stream_Size( TT_Stream stream ) - { - PStream_Rec rec = STREAM2REC( stream ); - - - if ( rec ) - return rec->map->size; - else - return 0; /* invalid stream - return 0 */ - } - - -/******************************************************************* - * - * Function : TT_Seek_File - * - * Description : Seeks the file cursor to a different position. - * - * Input : position new position in file - * - * Output : SUCCESS on success. FAILURE if out of range. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Seek_File( STREAM_ARGS Long position ) - { - if ( position > CUR_Stream->map->size ) - return TT_Err_Invalid_File_Offset; - - CUR_Stream->pos = position; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Skip_File - * - * Description : Skips forward the file cursor. - * - * Input : distance number of bytes to skip - * - * Output : see TT_Seek_File - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Skip_File( STREAM_ARGS Long distance ) - { - return TT_Seek_File( STREAM_VARS CUR_Stream->pos + distance ); - } - - -/******************************************************************* - * - * Function : TT_Read_File - * - * Description : Reads a chunk of the file and copies it to memory. - * - * Input : buffer target buffer - * count length in bytes to read - * - * Output : SUCCESS on success. FAILURE if out of range. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) - { - if ( CUR_Stream->pos + count > CUR_Stream->map->size ) - return TT_Err_Invalid_File_Read; - - MEM_Copy( buffer, - MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, count ); - CUR_Stream->pos += count; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Read_At_File - * - * Description : Reads file at a specified position. - * - * Input : position position to seek to before read - * buffer target buffer - * count number of bytes to read - * - * Output : SUCCESS on success. FAILURE if error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Read_At_File( STREAM_ARGS Long position, - void* buffer, - Long count ) - { - TT_Error error; - - - if ( (error = TT_Seek_File( STREAM_VARS position )) || - (error = TT_Read_File( STREAM_VARS buffer, count )) ) - return error; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_File_Pos - * - * Description : Returns current file seek pointer. - * - * Input : none - * - * Output : current file position - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_File_Pos( STREAM_ARG ) - { - return CUR_Stream->pos; - } - - -/******************************************************************* - * - * Function : TT_Access_Frame - * - * Description : Notifies the component that we're going to read - * 'size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : Error code - * - * Notes: The function fails if the byte range is not within the - * the file, or if there is not enough memory to cache - * the bytes properly (which usually means that aSize is - * too big in both cases). - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) - { - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - if ( CUR_Stream->pos + size > CUR_Stream->map->size ) - return TT_Err_Invalid_Frame_Access; - - CUR_Frame.size = size; - CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; - CUR_Frame.cursor = CUR_Frame.address; - - CUR_Stream->pos += size; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Check_And_Access_Frame - * - * Description : Notifies the component that we're going to read - * 'size' bytes from the current file position. - * This function should load/cache/map these bytes - * so that they will be addressed by the GET_xxx() - * functions easily. - * - * Input : size number of bytes to access. - * - * Output : Error code - * - * Notes: The function truncates 'size' if the byte range is not - * within the file. - * - * It will fail if there is not enough memory to cache - * the bytes properly (which usually means that aSize is - * too big). - * - * It will fail if you make two consecutive calls - * to TT_Access_Frame(), without a TT_Forget_Frame() between - * them. - * - * The only difference with TT_Access_Frame() is that we - * check that the frame is within the current file. We - * otherwise truncate it. The 'overflow' is set to zero. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ) - { - TT_Error error; - Long readBytes; - - - if ( CUR_Frame.address != NULL ) - return TT_Err_Nested_Frame_Access; - - readBytes = CUR_Stream->map->size - CUR_Stream->pos; - if ( size > readBytes ) - { - /* There is overflow, we allocate a new block then */ - if ( ALLOC( CUR_Frame.address, size ) ) - return error; - - CUR_Frame.size = size; - - /* copy the valid part */ - MEM_Copy( CUR_Frame.address, - MAP_Address( CUR_Stream->map ) + CUR_Stream->pos, - readBytes ); - } - else - { - CUR_Frame.size = size; - CUR_Frame.address = MAP_Address( CUR_Stream->map ) + CUR_Stream->pos; - } - - CUR_Frame.cursor = CUR_Frame.address; - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TT_Forget_Frame - * - * Description : Releases a cached frame after reading. - * - * Input : None - * - * Output : SUCCESS on success. FAILURE on error. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Forget_Frame( FRAME_ARG ) - { - if ( CUR_Frame.address == NULL ) - return TT_Err_Nested_Frame_Access; - - /* If we were using a duplicate in case of overflow, free it now */ - if ( CUR_Frame.address < (Byte*)CUR_Stream->map->base || - CUR_Frame.address >= (Byte*)CUR_Stream->map->base + - CUR_Stream->map->size ) - FREE( CUR_Frame.address ); - - ZERO_Frame( files.frame ); - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : GET_Byte - * - * Description : Extracts a byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted Byte - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - -#if 0 - - EXPORT_FUNC - Byte TT_Get_Byte( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Byte)(*CUR_Frame.cursor++); - } - -#endif - - -/******************************************************************* - * - * Function : GET_Char - * - * Description : Extracts a signed byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted char - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - - EXPORT_FUNC - Char TT_Get_Char( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Char)(*CUR_Frame.cursor++); - } - - -/******************************************************************* - * - * Function : GET_Short - * - * Description : Extracts a short from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted short - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - - EXPORT_FUNC - Short TT_Get_Short( FRAME_ARG ) - { - Short getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = ((Short)CUR_Frame.cursor[0] << 8) | - (Short)CUR_Frame.cursor[1]; - - CUR_Frame.cursor += 2; - - return getshort; - } - - -/******************************************************************* - * - * Function : GET_UShort - * - * Description : Extracts an unsigned short from the frame. - * - * Input : None or current frame - * - * Output : Extracted ushort - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - -#if 0 - - EXPORT_FUNC - UShort TT_Get_UShort( FRAME_ARG ) - { - UShort getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = ((UShort)CUR_Frame.cursor[0] << 8) | - (UShort)CUR_Frame.cursor[1]; - - CUR_Frame.cursor += 2; - - return getshort; - } - -#endif - - -/******************************************************************* - * - * Function : GET_Long - * - * Description : Extracts a long from the frame. - * - * Input : None or current frame - * - * Output : Extracted long - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - - EXPORT_FUNC - Long TT_Get_Long( FRAME_ARG ) - { - Long getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ((Long)CUR_Frame.cursor[0] << 24) | - ((Long)CUR_Frame.cursor[1] << 16) | - ((Long)CUR_Frame.cursor[2] << 8 ) | - (Long)CUR_Frame.cursor[3]; - - CUR_Frame.cursor += 4; - - return getlong; - } - - -/******************************************************************* - * - * Function : GET_ULong - * - * Description : Extracts an unsigned long from the frame. - * - * Input : None - * - * Output : Extracted ulong - * - * NOTES : We consider that the programmer is intelligent enough - * not to try to get a byte that is out of the frame. Hence, - * we provide no bounds check here. (A misbehaving client - * could easily page fault using this call.) - * - ******************************************************************/ - -#if 0 - - EXPORT_FUNC - ULong TT_Get_ULong( FRAME_ARG ) - { - ULong getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | - ((ULong)CUR_Frame.cursor[1] << 16) | - ((ULong)CUR_Frame.cursor[2] << 8 ) | - (ULong)CUR_Frame.cursor[3] ); - - CUR_Frame.cursor += 4; - - return getlong; - } - -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README deleted file mode 100644 index 4d929652e..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/README +++ /dev/null @@ -1,20 +0,0 @@ -This directory contains two files for compiling the FreeType library under -VMS: - - ft_conf.h the configuration file for the FreeType library - descrip.mms a makefile to be used with either MMS or MMK - -The files are such designed that after unpacking of freetype-1.2 one can -give the command - - MMS/DESCR=[.LIB.ARCH.VMS] - -to build the libraries. (Of course, for MMK use `MMK' on the command line -instead of `MMS'.) The makefile contains a `clean' target, but no `install' -target since I'm note sure where to install the library and the include -files. - -I did NOT do the test programs but I tested it with my own programs. - - - Jouk Jansen diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms deleted file mode 100644 index 2c087fd5c..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/descrip.mms +++ /dev/null @@ -1,155 +0,0 @@ -# This file is part of the FreeType project. -# -# DESCRIP.MMS: Make file for VMS using MMS or MMK -# Created by Jouk Jansen (joukj@hrem.stm.tudelft.nl) - -ARCH = arch.unix - -CC = cc - -############### PORTABILITY COMPONENTS ######################## - -# location of memory component -MEMSRC = ttmemory.c - -# location of file component -FILESRC = ttfile.c - -# location of mutex component -MUTEXSRC = ttmutex.c - -# location of default extensions -FTEXTDIR = [.lib.extend] - -# default extensions sources -EXTSRC = $(FTEXTDIR)ftxkern.c \ - $(FTEXTDIR)ftxgasp.c \ - $(FTEXTDIR)ftxpost.c \ - $(FTEXTDIR)ftxcmap.c \ - $(FTEXTDIR)ftxsbit.c \ - $(FTEXTDIR)ftxwidth.c \ - $(FTEXTDIR)ftxerr18.c \ - $(FTEXTDIR)ftxgsub.c \ - $(FTEXTDIR)ftxgpos.c \ - $(FTEXTDIR)ftxopen.c \ - $(FTEXTDIR)ftxgdef.c - -EXTOBJ = [.lib]ftxkern.obj, \ - [.lib]ftxgasp.obj, \ - [.lib]ftxpost.obj, \ - [.lib]ftxcmap.obj, \ - [.lib]ftxsbit.obj, \ - [.lib]ftxwidth.obj, \ - [.lib]ftxerr18.obj, \ - [.lib]ftxgsub.obj, \ - [.lib]ftxgpos.obj, \ - [.lib]ftxopen.obj, \ - [.lib]ftxgdef.obj - -# all engine sources -SRC_M = [.lib]ttapi.c \ - [.lib]ttcache.c \ - [.lib]ttcalc.c \ - [.lib]ttcmap.c \ - [.lib]ttdebug.c \ - [.lib]ttextend.c \ - [.lib]ttgload.c \ - [.lib]ttinterp.c \ - [.lib]ttload.c \ - [.lib]ttobjs.c \ - [.lib]ttraster.c \ - [.lib]$(FILESRC) \ - [.lib]$(MEMSRC) \ - [.lib]$(MUTEXSRC) -SRC_S = [.lib.$(ARCH)]freetype.c - -# all header files with path -HEADERS = [.lib]freetype.h \ - [.lib]fterrid.h \ - [.lib]ftnameid.h \ - $(FTEXTDIR)ftxkern.h \ - $(FTEXTDIR)ftxgasp.h \ - $(FTEXTDIR)ftxcmap.h \ - $(FTEXTDIR)ftxsbit.h \ - $(FTEXTDIR)ftxpost.h \ - $(FTEXTDIR)ftxwidth.h \ - $(FTEXTDIR)ftxerr18.h \ - $(FTEXTDIR)ftxgsub.h \ - $(FTEXTDIR)ftxgpos.h \ - $(FTEXTDIR)ftxgdef.h \ - $(FTEXTDIR)ftxopen.h - -# all engine objects -OBJ_M = [.lib]ttapi.obj, \ - [.lib]ttcache.obj, \ - [.lib]ttcalc.obj, \ - [.lib]ttcmap.obj, \ - [.lib]ttdebug.obj, \ - [.lib]ttextend.obj, \ - [.lib]ttgload.obj, \ - [.lib]ttinterp.obj, \ - [.lib]ttload.obj, \ - [.lib]ttobjs.obj, \ - [.lib]ttraster.obj, \ - [.lib]file.obj, \ - [.lib]memory.obj, \ - [.lib]mutex.obj, \ - $(EXTOBJ) -OBJ_S = [.lib]freetype.obj - - -# include paths -INCLUDES = /include=([.lib],[],$(FTEXTDIR)) - -# C flags -CFLAGS = $(INCLUDES)/obj=[.lib] - -all : do_link [.lib]libttf.olb - library/compress [.lib]libttf.olb - -do_link : - if f$search( "[.lib]memory.c" ) .nes. "" then set file/remove [.lib]memory.c; - if f$search( "[.lib]file.c" ) .nes. "" then set file/remove [.lib]file.c; - if f$search( "[.lib]mutex.c" ) .nes. "" then set file/remove [.lib]mutex.c; - if f$search( "[.lib]ft_conf.h" ) .nes. "" then set file/remove [.lib]ft_conf.h; - set file/enter=[.lib]memory.c [.lib]$(MEMSRC) - set file/enter=[.lib]file.c [.lib]$(FILESRC) - set file/enter=[.lib]mutex.c [.lib]$(MUTEXSRC) - set file/enter=[.lib]ft_conf.h [.lib.arch.vms]ft_conf.h - -[.lib]ftxkern.obj : $(FTEXTDIR)ftxkern.c - -[.lib]ftxgasp.obj : $(FTEXTDIR)ftxgasp.c - -[.lib]ftxpost.obj : $(FTEXTDIR)ftxpost.c - -[.lib]ftxcmap.obj : $(FTEXTDIR)ftxcmap.c - -[.lib]ftxsbit.obj : $(FTEXTDIR)ftxsbit.c - -[.lib]ftxwidth.obj : $(FTEXTDIR)ftxwidth.c - -[.lib]ftxerr18.obj : $(FTEXTDIR)ftxerr18.c - -[.lib]ftxgsub.obj : $(FTEXTDIR)ftxgsub.c - -[.lib]ftxgpos.obj : $(FTEXTDIR)ftxgpos.c - -[.lib]ftxgdef.obj : $(FTEXTDIR)ftxgdef.c - -[.lib]ftxopen.obj : $(FTEXTDIR)ftxopen.c - -[.lib]freetype.obj : $(SRC_S) $(SRC_M) - - -[.lib]libttf.olb : $(OBJ_M) - library/create [.lib]libttf.olb $(OBJ_M) - - -clean : - delete [.lib]*.obj;* - delete [.lib]*.olb;* - if f$search( "[.lib]memory.c" ) .nes. "" then set file/remove [.lib]memory.c; - if f$search( "[.lib]file.c" ) .nes. "" then set file/remove [.lib]file.c; - if f$search( "[.lib]mutex.c" ) .nes. "" then set file/remove [.lib]mutex.c; - if f$search( "[.lib]ft_conf.h" ) .nes. "" then set file/remove [.lib]ft_conf.h; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h b/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h deleted file mode 100644 index a000e6233..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/vms/ft_conf.h +++ /dev/null @@ -1,215 +0,0 @@ -/* This file is part of the FreeType project */ - -/* ft_conf.h for VMS using MMS or MMK */ - - -/* we need the following because there are some typedefs in this file */ - -#ifndef FT_CONF_H -#define FT_CONF_H - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you have a working `mmap' system call. */ -/* #undef HAVE_MMAP */ - -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if the X Window System is missing or not being used. */ -/* #undef X_DISPLAY_MISSING */ - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/* Define if you have the getpagesize function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY 1 - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the header file. */ -#define HAVE_LOCALE_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_LIBINTL_H */ - -/* Define if you have the libintl library. */ -/* #undef HAVE_LIBINTL */ - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #undef HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -/* #undef TT_CONFIG_OPTION_THREAD_SAFE */ - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -/* #undef DEBUG_LEVEL_TRACE */ - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -/* #undef DEBUG_LEVEL_ERROR */ - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC deleted file mode 100644 index e13c9ca18..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.BC +++ /dev/null @@ -1,180 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for Borland C++ for 16-bit Windows, large model. -# Due to size constraints, it does not try to pack all modules into one. -# -# You will need Borland MAKE. -# Tested with Borland C++ v.4.0 and 5.0. -# -# Use this file while in the lib directory with the following statement: -# -# make -farch/win16/Makefile.BC -# -# -# A DLL version of the library can be built with -# -# make -DDLL -farch/win16/Makefile.BC dll -# -# 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/win16/Makefile.BC - -ARCH = arch\win16 -FT_MAKEFILE = $(ARCH)\Makefile.BC -FT_DLL = ft13_16.dll - -CC = bcc -LIB = tlib /c /e -IMPLIB = implib -c -o - -SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig - -# Credits go to Dave Hoo for pointing out that modern -# Borland compilers (from BC++ 3.1 on) can increase the limit on -# the length of identifiers. -!if ! $d(DEBUG) -CFLAGS = -O2 -3 -ml -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) -DLLFLAGS = -ml -WD -lC -!else -CFLAGS = -v -N -ml -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) -DLLFLAGS = -v -ml -WD -lC -!endif - -CFLAGS = $(CFLAGS) -W - -FT_DEF = $(FT_DLL:.dll=.def) -!if $d(DLL) -CFLAGS = $(CFLAGS) -WD -!endif - - -!if $d(BIGFONTS) -CFLAGS = $(CFLAGS) -DTT_HUGE_PTR=__huge - -TTFILE = $(ARCH)\hugefile.c -TTMEMORY = $(ARCH)\hugemem.c -!else -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -!endif -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -# Do not insert spaces before the \ at end of line, -# otherwise the substitution for TLIB command line will fail. -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ - extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c\ - extend\ftxsbit.c extend\ftxgsub.c extend\ftxgpos.c\ - extend\ftxopen.c extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c\ - ttgload.c ttinterp.c ttload.c ttobjs.c\ - ttraster.c ttextend.c ttdebug.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -# Since Borland make does not handle $($(LIB_FILES)), and using -# -DLIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat -# by constructing TLIB's response file directly in the `all' target. -# -# Another solution, useful during debugging of part of the library, -# would be to include each .obj in the library as soon as it is compiled. -# See ../msdos/Makefile.TC for an application. -.c.obj: - @$(CC) -c -o$* @&&| - $(CFLAGS) $< -| - - -!if ! $d(DEBUG) -# Skipped if DEBUG build -# (but it changes nothing, since we always build in multiple parts). -all: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(OBJS_M: = + ) -| -!endif - -debug: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(OBJS_M: = + ) -| - -$(FT_DEF): $(ARCH)\ttf.def - -copy $(ARCH)\ttf.def $(FT_DEF) - -dll $(FT_DLL): $(OBJS_M) $(FT_DEF) -!if $d(DLL) - $(CC) -e$(FT_DLL) @&&| - $(DLLFLAGS) $(OBJS_M) -| - $(IMPLIB) libttf $(FT_DEF) -!else -# Re-invoke with flag set. Unfortunately, this discards the other flags. - make -DDLL -f$(ARCH)/Makefile.BC dll -!endif - -install: $(FT_DLL) -!if $d(INSTALL_DIR) - copy $(FT_DLL) $(INSTALL_DIR) -!else - copy $(FT_DLL) C:\WINDOWS -!endif - - -$(OBJ_S): $(SRC_S) $(SRC_M) - -# Not used here because it excesses the capacity of COMMAND.COM... -libttf.lib: $(LIB_FILES) - -del libttf.lib - echo -+$(**: =-+)> response - $(LIB) libttf.lib @&&| -+ $(**: = + ) -| - -!if $d(BIGFONTS) -$(TTMEMORY:.c=.obj): $(TTMEMORY) - $(CC) -c -o$* @&&| - $(CFLAGS) -A- $*.c -| - -$(TTFILE:.c=.obj): $(TTFILE) - $(CC) -c -o$* @&&| - $(CFLAGS) -A- $*.c -| -!endif - - -clean: - -del *.obj - -del extend\*.obj - -del $(ARCH)\*.obj - -del libttf.bak - -del response - -del *.def - -distclean: clean - -del libttf.lib - -del *.dll - -del $(FT_DEF) - -del C:\WINDOWS\$(FT_DLL) -!if $d(INSTALL_DIR) - -del $(INSTALL_DIR)\$(FT_DLL) -!endif - -!include "$(ARCH)\depend.win" - -# end of Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS deleted file mode 100644 index 847bdb916..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/Makefile.MS +++ /dev/null @@ -1,106 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for Microsoft C for Windows, large model. -# It also works for Visual C++ 1.x 16-bit compilers, but you should -# instead use the Makefile customized for it, Makefile.VC. -# Due to size constraints, it does not try to pack all modules into one. -# -# You will need NMAKE. -# -# Use this file while in the lib 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 - -CC = cl /nologo -LIB = lib /noignorecase /nologo - -!ifndef DEBUG -CFLAGS = /Ox /AL /Za /W2 /G2 -I$(ARCH) -I. -Iextend -!else -CFLAGS = /Zi /AL /Za /W2 /G2 -I$(ARCH) -I. -Iextend -!endif - -# Use /Gw instead with Microsoft C version 6 -CFLAGS = $(CFLAGS) /GA - - -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -# Do not insert spaces between the file names or at end of line, otherwise -# the substitution for LIB command line will fail. Thank you. -# -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ -extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c extend\ftxsbit.c\ -extend\ftxopen.c extend\ftxgsub.c extend\ftxgpos.c extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ -ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -# Since Microsoft's NMAKE does not handle $($(LIB_FILES)), and using -# LIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat -# by constructing LIB's response file directly in the `all' target. -# -# Another solution, useful during debugging of part of the library, -# would be to include each .obj in the library as soon as it is compiled. -# See ..\msdos\Makefile.TC for an application. -.c.obj: - $(CC) /c /Fo$@ @<< - $(CFLAGS) $*.c -<< - - -!ifndef DEBUG -# Skipped if DEBUG build -# (but it changes nothing, since we always build in multiple parts). -all: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @< header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define if you need for console I/O functions. */ -#undef HAVE_CONIO_H - -/* Define if you have the header file. */ -#undef HAVE_LOCALE_H - -/* Define if you have the header file. */ -#undef HAVE_LIBINTL_H - -/* Define if you have the libintl library. */ -#undef HAVE_LIBINTL - -/* command.com can't pipe stderr into a file; any message would be */ -/* written into the graphics screen. */ -#define HAVE_PRINT_FUNCTION 1 - -#define Print( format, ap ) vfprintf( stdout, (format), (ap) ) - -/* The number of bytes in a int. */ -#define SIZEOF_INT 2 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#undef LONG64 -#undef INT64 - -#endif /* FT_CONF_H */ - -/* End of ft_conf.h */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c deleted file mode 100644 index fbc9bfc96..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugefile.c +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************* - * - * hugefile.c - * - * File I/O Component (body) for dealing with "huge" objects - * under 16-bit Windows. Relies on the "default" version, with - * a small hook. Requires Windows 3.1+. - * - * Written by Antoine Leca based on ideas from Dave Hoo. - * Copyright 1999 by Dave Hoo, 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. - * - * NOTE - * - * This file #includes the normal version, to avoid discrepancies - * between versions. It uses only ANSI-mandated "tricks", so - * any ANSI-compliant compiler should be able to compile this file. - * - ******************************************************************/ - -#include "ttconfig.h" -#include "tttypes.h" - -#include - - /* Here we include , to have the proper definition of fread */ -#include - - /* Some compilers define fileno(), some define _fileno()... */ -#ifndef _fileno -#define _fileno(stream) fileno(stream) -#endif - - /* Then, we divert the use of fread to the Windows version */ -#undef fread -#define fread(ptr, size, n, stream) \ - _hread( _fileno(stream), (char TT_HUGE_PTR *) ptr, (ULong)n * size ) - - - /* Now, we include the "normal" version of `ttfile.c' */ - /* The ANSI/ISO standard mandates that the include of */ - /* there have no bad effects. */ -#include "ttfile.c" - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c deleted file mode 100644 index ea2a342e8..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/hugemem.c +++ /dev/null @@ -1,539 +0,0 @@ -/******************************************************************* - * - * hugemem.c - * - * Memory management component (body) - * for dealing with "huge" objects with 16-bit Windows. - * - * Written by Antoine Leca based on ideas from Dave Hoo. - * Copyright 1999 by Dave Hoo, 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. - * - ******************************************************************/ - -#include -#include - -#include "ttdebug.h" -#include "ttmemory.h" -#include "ttengine.h" - -#ifndef TT_HUGE_PTR -#error "This component needs TT_HUGE_PTR to be #defined." -#endif - -#ifdef TT_CONFIG_OPTION_THREAD_SAFE -#error "This component needs static allocation and is not re-entrant." -#endif - - /* If the memory reclaimed is abobve this limit, alloc directly from */ - /* global heap. Else, alloc using malloc (using suballocation). */ -#ifndef MEMORY_MIN_GLOBAL -#define MEMORY_MIN_GLOBAL 4096 -#endif - -/* required by the tracing mode */ -#undef TT_COMPONENT -#define TT_COMPONENT trace_memory - - -#ifdef DEBUG_MEMORY - -#include - -#define MAX_TRACKED_BLOCKS 1024 - - struct TMemRec_ - { - void* base; - Long size; - }; - - typedef struct TMemRec_ TMemRec; - - static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; - - static Int num_alloc; - static Int num_free; - static Int num_realloc; /* counts only `real' reallocations - (i.e., an existing buffer will be resized - to a value larger than zero */ - - static Int fail_alloc; - static Int fail_realloc; - static Int fail_free; - -#else - - /* We need a tracing stack of the calls to big chunks of memory, */ - /* in order to call the matching version of free(). */ - -#define MAX_TRACKED_BIGCHUNKS 64 - - struct TMemRec_ - { - void* base; - }; - - typedef struct TMemRec_ TMemRec; - - static TMemRec pointers[MAX_TRACKED_BIGCHUNKS + 1]; - -#endif /* DEBUG_MEMORY */ - - -#ifndef TT_CONFIG_REENTRANT - Long TTMemory_Allocated; - Long TTMemory_MaxAllocated; -#endif - - -/******************************************************************* - * - * Function : TT_Alloc - * - * Description : Allocates memory from the heap buffer. - * - * Input : Size size of the memory to be allocated - * P pointer to a buffer pointer - * - * Output : Error code. - * - * NOTE : The newly allocated block should _always_ be zeroed - * on return. Many parts of the engine rely on this to - * work properly. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Alloc( ULong Size, void** P ) - { - Int i; - - - if ( !P ) - return TT_Err_Invalid_Argument; - /* Also see below for another case of "invalid argument". */ - - if ( Size > 0 ) - { - if ( Size >= MEMORY_MIN_GLOBAL ) - { - HANDLE hMem; - - hMem = GlobalAlloc( GMEM_ZEROINIT, Size ); - if ( !hMem ) - return TT_Err_Out_Of_Memory; - - *P = (void*)GlobalLock( hMem ); - } - else - *P = (void*)malloc( Size ); - - if ( !*P ) - return TT_Err_Out_Of_Memory; - -#ifndef TT_CONFIG_REENTRANT - TTMemory_MaxAllocated += Size; - TTMemory_Allocated += Size; -#endif - -#ifdef DEBUG_MEMORY - - num_alloc++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_alloc++; - else - { - pointers[i].base = *P; - pointers[i].size = Size; - } - -#else - - if ( Size >= MEMORY_MIN_GLOBAL ) - { - i = 0; - while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) - i++; - - if ( i >= MAX_TRACKED_BIGCHUNKS ) - /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ - return TT_Err_Invalid_Argument; - else - pointers[i].base = *P; - } - -#endif /* DEBUG_MEMORY */ - - /* The nice thing about GlobalAlloc is that it zeroes the memory. */ - - if ( Size < MEMORY_MIN_GLOBAL ) - MEM_Set( *P, 0, Size ); - - } - else - *P = NULL; - - return TT_Err_Ok; - } - - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - - -/******************************************************************* - * - * Function : TT_Realloc - * - * Description : Reallocates memory from the heap buffer. - * - * Input : Size new size of the memory to be allocated; - * if zero, TT_Free() will be called - * P pointer to a buffer pointer; if *P == NULL, - * TT_Alloc() will be called - * - * Output : Error code. - * - * NOTES : It's not necessary to zero the memory in case the - * reallocated buffer is larger than before -- the - * application has to take care of this. - * - * If the memory request fails, TT_Free() will be - * called on *P, and TT_Err_Out_Of_Memory returned. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Realloc( ULong Size, void** P ) - { - ULong oldSize; - void* Q; - Int i; - - - if ( !P ) - return TT_Err_Invalid_Argument; - - if ( !*P ) - return TT_Alloc( Size, P ); - - if ( Size == 0 ) - return TT_Free( P ); - -#ifdef DEBUG_MEMORY - - num_realloc++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_realloc++; - else - oldSize = pointers[i].size; - -#else - - i = 0; - while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != *P ) - i++; - - /* If we did not found the pointer, then this is a "small" chunk. */ - - if ( i < MAX_TRACKED_BIGCHUNKS ) - { - /* Signal we found a big one. Real size does not matter. */ - oldSize = MEMORY_MIN_GLOBAL; - } - -#endif /* DEBUG_MEMORY */ - - if ( oldSize >= MEMORY_MIN_GLOBAL ) - { - /* Deal with a big chunk. */ - HANDLE hMem, hNewMem; - - hMem = GlobalHandle ( (ULong)*P >> 16 ) & 0xFFFF; - if ( !hMem ) /* Bad call... */ - return TT_Err_Invalid_Argument; - - GlobalUnlock( hMem ); - hNewMem = GlobalReAlloc( hMem, Size, 0 ); - if ( hNewMem ) - *P = (void*)GlobalLock( hNewMem ); - } - if ( Size >= MEMORY_MIN_GLOBAL ) - { - /* A small chunk crosses the limit... */ - - if( TT_Alloc( Size, &Q ) != TT_Err_Ok ) - Q = NULL; /* Failed to create the new block. */ - else - MEM_Copy( Q, *P, oldSize ); - - /* We need to register the new entry. */ -#ifndef DEBUG_MEMORY - - i = 0; - while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != NULL ) - i++; - - if ( i >= MAX_TRACKED_BIGCHUNKS ) - /* We fail badly here. Increase MAX_TRACKED_BIGCHUNKS if needed. */ - return TT_Err_Invalid_Argument; -#endif /* DEBUG_MEMORY */ - } - else - Q = (void*)realloc( *P, Size ); - - if ( !Q ) - { - TT_Free( *P ); - return TT_Err_Out_Of_Memory; - } - -#ifdef DEBUG_MEMORY - - if ( i < MAX_TRACKED_BLOCKS ) - { -#ifndef TT_CONFIG_REENTRANT - TTMemory_Allocated += Size - pointers[i].size; - if ( Size > pointers[i].size ) - TTMemory_MaxAllocated += Size - pointers[i].size; -#endif - - pointers[i].base = Q; - pointers[i].size = Size; - } -#else - if ( i < MAX_TRACKED_BIGCHUNKS ) - { - pointers[i].base = Q; - } -#endif /* DEBUG_MEMORY */ - - *P = Q; - - return TT_Err_Ok; - } - - -#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ - - -/******************************************************************* - * - * Function : TT_Free - * - * Description : Releases a previously allocated block of memory. - * - * Input : P pointer to memory block - * - * Output : Always SUCCESS. - * - * Note : The pointer must _always_ be set to NULL by this function. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Free( void** P ) - { - Int i; - Long Size = 0; - - - if ( !P || !*P ) - return TT_Err_Ok; - -#ifdef DEBUG_MEMORY - - num_free++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_free++; - else - { -#ifndef TT_CONFIG_REENTRANT - TTMemory_Allocated -= pointers[i].size; -#endif - - Size = pointers[i].size; - pointers[i].base = NULL; - pointers[i].size = 0; - } - -#else - - i = 0; - while ( i < MAX_TRACKED_BIGCHUNKS && pointers[i].base != *P ) - i++; - - /* If we did not found the pointer, then this is a "small" chunk. */ - - if ( i < MAX_TRACKED_BIGCHUNKS ) - { - pointers[i].base = NULL; - /* Signal we found a big one. Real size does not matter. */ - Size = MEMORY_MIN_GLOBAL; - } - -#endif /* DEBUG_MEMORY */ - - if ( Size >= MEMORY_MIN_GLOBAL ) - { - HANDLE hMem; - - hMem = GlobalHandle ( (ULong)*P >> 16 ) & 0xFFFF; - if ( !hMem ) /* Bad call... */ - return TT_Err_Invalid_Argument; - - GlobalUnlock( hMem ); - GlobalFree ( hMem ); - } - else - free( *P ); - - *P = NULL; - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTMemory_Init - * - * Description : Initializes the memory. - * - * Output : Always SUCCESS. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTMemory_Init( void ) - { -#ifdef DEBUG_MEMORY - Int i; - - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - pointers[i].base = NULL; - pointers[i].size = 0; - } - - num_alloc = 0; - num_realloc = 0; - num_free = 0; - - fail_alloc = 0; - fail_realloc = 0; - fail_free = 0; -#else - Int i; - - for ( i = 0; i < MAX_TRACKED_BIGCHUNKS; i++ ) - { - pointers[i].base = NULL; - } -#endif - - -#ifndef TT_CONFIG_REENTRANT - TTMemory_Allocated = 0; - TTMemory_MaxAllocated = 0; -#endif - - return TT_Err_Ok; - } - - -/******************************************************************* - * - * Function : TTMemory_Done - * - * Description : Finalizes memory usage. - * - * Output : Always SUCCESS. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error TTMemory_Done( void ) - { -#ifdef DEBUG_MEMORY - Int i, num_leaked, tot_leaked; - - - num_leaked = 0; - tot_leaked = 0; - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - if ( pointers[i].base ) - { - num_leaked ++; - tot_leaked += pointers[i].size; - } - } - - fprintf( stderr, - "%d memory allocations, of which %d failed\n", - num_alloc, - fail_alloc ); - - fprintf( stderr, - "%d memory reallocations, of which %d failed\n", - num_realloc, - fail_realloc ); - - fprintf( stderr, - "%d memory frees, of which %d failed\n", - num_free, - fail_free ); - - if ( num_leaked > 0 ) - { - fprintf( stderr, - "There are %d leaked memory blocks, totalizing %d bytes\n", - num_leaked, tot_leaked ); - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - if ( pointers[i].base ) - { - fprintf( stderr, - "index: %4d (base: $%08lx, size: %08ld)\n", - i, - (long)pointers[i].base, - pointers[i].size ); - } - } - } - else - fprintf( stderr, "No memory leaks !\n" ); - -#endif /* DEBUG_MEMORY */ - - return TT_Err_Ok; - } - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef deleted file mode 100755 index 77feda125..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedef +++ /dev/null @@ -1,24 +0,0 @@ -# makedef -# -# This shell script creates a .DEF file necessary for building as DLL -# on the Windows 16-bit platform. - -echo "\ -; This definition file to be used to built the library as DLL -; has been generated automatically with the script \`makedef' on -; `date +%d-%b-%Y`. - -LIBRARY ft13_16 -DESCRIPTION 'FreeType 1.3 16-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE -EXPORTS -" > ttf.def - -(cd ../.. - sed -n -e "/^ *EXPORT_DEF/!d ; n ; s/(.*$//" \ - -e "s/;$//" -e "s/ const / /" -e "s/ *[a-zA-Z][a-zA-Z_\*]* //" \ - -e "s/ *//g" -e "s/^\(.*\)/ _\1/" -e "p" *.h extend/*.h) >> ttf.def - -# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep deleted file mode 100755 index 691a20e58..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/makedep +++ /dev/null @@ -1,32 +0,0 @@ -# makedep -# -# This shell script creates a dependency file necessary for older compilers -# on the Windows 16-bit platform. - -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 -Iarch/win16 -I. \ - *.c | \ - sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.win - -(cd ../.. - gcc -MM -Iarch/win16 -I. -Iextend \ - extend/*.c | \ - sed -e "s/^\(.*\)\.o:/extend\\\\\1.obj:/" -e "s:/:\\\\:g") >> depend.win - -echo "!ifndef __MAKE__" >> depend.win - -(cd ../.. - gcc -MM -Iarch/win16 -I. -Iextend -DTT_HUGE_PTR \ - arch/win16/*.c | \ - sed -e "s/^\(.*\)\.o:/arch\\\\win16\\\\\1.obj:/" \ - -e "s:/:\\\\:g") >> depend.win - -echo "!endif" >> depend.win - -# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def deleted file mode 100644 index b7651afc7..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win16/ttf.def +++ /dev/null @@ -1,127 +0,0 @@ -; This definition file to be used to built the library as DLL -; has been generated automatically with the script `makedef' on -; 02-Sep-1999. - -LIBRARY ft13_16 -DESCRIPTION 'FreeType 1.3 16-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE -EXPORTS - - _TT_FreeType_Version - _TT_Init_FreeType - _TT_Done_FreeType - _TT_Set_Raster_Gray_Palette - _TT_Open_Face - _TT_Open_Collection - _TT_Get_Face_Properties - _TT_Set_Face_Pointer - _TT_Get_Face_Pointer - _TT_Flush_Face - _TT_Get_Face_Metrics - _TT_Close_Face - _TT_Get_Font_Data - _TT_New_Instance - _TT_Set_Instance_Resolutions - _TT_Set_Instance_CharSize - _TT_Set_Instance_CharSizes - _TT_Set_Instance_PixelSizes - _TT_Set_Instance_Transform_Flags - _TT_Get_Instance_Metrics - _TT_Set_Instance_Pointer - _TT_Get_Instance_Pointer - _TT_Done_Instance - _TT_New_Glyph - _TT_Done_Glyph - _TT_Load_Glyph - _TT_Get_Glyph_Outline - _TT_Get_Glyph_Metrics - _TT_Get_Glyph_Big_Metrics - _TT_Get_Glyph_Bitmap - _TT_Get_Glyph_Pixmap - _TT_New_Outline - _TT_Done_Outline - _TT_Copy_Outline - _TT_Get_Outline_Bitmap - _TT_Get_Outline_Pixmap - _TT_Get_Outline_BBox - _TT_Transform_Outline - _TT_Translate_Outline - _TT_Transform_Vector - _TT_MulDiv - _TT_MulFix - _TT_Get_CharMap_Count - _TT_Get_CharMap_ID - _TT_Get_CharMap - _TT_Char_Index - _TT_Get_Name_Count - _TT_Get_Name_ID - _TT_Get_Name_String - _TT_Register_Extension - _TT_Extension_Get - _TT_Use_Stream - _TT_Done_Stream - _TT_Flush_Stream - _TT_Read_File - _TT_Seek_File - _TT_Skip_File - _TT_Read_At_File - _TT_File_Pos - _TT_Stream_Size - _TT_Null_FileFrame - _TT_Access_Frame - _TT_Check_And_Access_Frame - _TT_Forget_Frame - _TT_Get_Char - _TT_Get_Short - _TT_Get_Long - _TT_LookUp_Table - _TT_Alloc - _TT_Realloc - _TT_Free - _TT_CharMap_First - _TT_CharMap_Next - _TT_CharMap_Last - _TT_ErrToString18 - _TT_Get_Face_Gasp_Flags - _TT_Init_GDEF_Extension - _TT_Load_GDEF_Table - _TT_GDEF_Get_Glyph_Property - _TT_GDEF_Build_ClassDefinition - _TT_Init_GPOS_Extension - _TT_Load_GPOS_Table - _TT_GPOS_Select_Script - _TT_GPOS_Select_Language - _TT_GPOS_Select_Feature - _TT_GPOS_Query_Scripts - _TT_GPOS_Query_Languages - _TT_GPOS_Query_Features - _TT_GPOS_Add_Feature - _TT_GPOS_Clear_Features - _TT_Init_GSUB_Extension - _TT_Load_GSUB_Table - _TT_GSUB_Select_Script - _TT_GSUB_Select_Language - _TT_GSUB_Select_Feature - _TT_GSUB_Query_Scripts - _TT_GSUB_Query_Languages - _TT_GSUB_Query_Features - _TT_GSUB_Add_Feature - _TT_GSUB_Clear_Features - _TT_GSUB_Register_Alternate_Function - _TT_GSUB_Apply_String - _TT_GSUB_Add_String - _TT_Init_Kerning_Extension - _TT_Get_Kerning_Directory - _TT_Load_Kerning_Table - _TT_Init_Post_Extension - _TT_Load_PS_Names - _TT_Get_PS_Name - _TT_Init_SBit_Extension - _TT_Get_Face_Bitmaps - _TT_New_SBit_Image - _TT_Done_SBit_Image - _TT_Get_SBit_Strike - _TT_Load_Glyph_Bitmap - _TT_Get_Face_Widths diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC deleted file mode 100644 index e72f23007..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.BC +++ /dev/null @@ -1,161 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for Borland C++ for Win32. -# -# You will need Borland MAKE. -# Tested with Borland C++ v.5.0 and Borland C++ builder 4.0. -# Does not work with Borland C++ 4.0, since it needs __declspec. -# -# Use this file while in the lib directory with the following statement: -# -# make -farch/win32/Makefile.BC -# -# -# A DLL version of the library can be built with -# -# make -DDLL -farch/win32/Makefile.BC dll -# -# 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 -LIB = tlib /c /e -IMPLIB = implib -c - -SPURIOUS_WARNINGS = -w-nak -w-par -w-use -w-aus -w-stu -w-stv -w-cln -w-sig - -!if ! $d(DEBUG) -CFLAGS = -O2 -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) -DLLFLAGS = -WD -!else -CFLAGS = -v -A -i40 -I$(ARCH);.;extend $(SPURIOUS_WARNINGS) -DLLFLAGS = -v -WD -!endif - -FT_DEF = $(FT_DLL:.dll=.def) -!if $d(DLL) -CFLAGS = $(CFLAGS) \ - -DEXPORT_DEF=__declspec(dllexport) -DEXPORT_FUNC=__declspec(dllexport) -!endif - - -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -# Do not insert spaces before the \ at end of line, -# otherwise the substitution for TLIB command line will fail. -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ - extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c\ - extend\ftxsbit.c extend\ftxgsub.c extend\ftxgpos.c\ - extend\ftxopen.c extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c\ - ttgload.c ttinterp.c ttload.c ttobjs.c\ - ttraster.c ttextend.c ttdebug.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -# Since Borland make does not handle $($(LIB_FILES)), and using -# -DLIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat -# by constructing TLIB's response file directly in the `all' target. -# -# Another solution, useful during debugging of part of the library, -# would be to include each .obj in the library as soon as it is compiled. -# See ../msdos/Makefile.TC for an application. -.c.obj: - $(CC) -c -o$* @&&| - $(CFLAGS) $< -| - - -!if ! $d(DEBUG) -# Skipped if DEBUG build -all: $(OBJS_S) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(OBJS_S: = + ) -| - -dll $(FT_DLL): $(OBJS_S) $(FT_DEF) -!if $d(DLL) - $(CC) @&&| - $(DLLFLAGS) -e$(FT_DLL) $(OBJS_S) -| - $(IMPLIB) libttf $(FT_DLL) -!else - $(MAKE) -DDLL -f$(FT_MAKEFILE) dll # Re-invoke with flag set. -!endif -!endif - -debug: $(OBJS_M) - -del libttf.lib - $(LIB) libttf.lib @&&| -+ $(OBJS_M: = + ) -| - -!ifdef DEBUG -dll $(FT_DLL): $(OBJS_M) $(FT_DEF) -!if $d(DLL) - $(CC) @&&| - $(DLLFLAGS) -e$(FT_DLL) $(OBJS_M) -| - $(IMPLIB) libttf $(FT_DLL) -!else - $(MAKE) -DDEBUG -DDLL -f$(FT_MAKEFILE) dll -!endif -!endif - -install: $(FT_DLL) -!ifdef INSTALL_DIR - copy $(FT_DLL) $(INSTALL_DIR) -!else - copy $(FT_DLL) C:\WINDOWS -!endif - -$(OBJ_S): $(SRC_S) $(SRC_M) - -# Not used here because it excesses the capacity of COMMAND.COM... -libttf.lib: $(LIB_FILES) - -del libttf.lib - echo -+$(**: =-+)> response - $(LIB) libttf.lib @&&| -+ $(**: = + ) -| - -$(FT_DEF): $(ARCH)\ttf.def - -copy $(ARCH)\ttf.def $(FT_DEF) - -clean: - -del *.obj - -del extend\*.obj - -del $(ARCH)\*.obj - -del libttf.bak - -del response - -del *.def - -del *.tds - -distclean: clean - -del libttf.lib - -del *.dll - -del $(FT_DEF) - -del C:\WINDOWS\$(FT_DLL) -!if $d(INSTALL_DIR) - -del $(INSTALL_DIR)\$(FT_DLL) -!endif - -!include "$(ARCH)\depend.win" - -# end of Makefile diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL deleted file mode 100644 index 72c060a6b..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.CL +++ /dev/null @@ -1,165 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for Microsoft Visual C++ for 32-bit Windows. -# -# You will need NMAKE. -# -# Use this file while in the lib directory with the following statement: -# -# nmake /f arch\win32\Makefile.CL -# -# -# A DLL version of the library can be built with -# -# nmake DLL=1 /f arch\win32\Makefile.CL dll -# -# Debug versions can be obtained with -# -# nmake DEBUG=1 /f arch\win32\Makefile.CL - -ARCH = arch\win32 -FT_MAKEFILE = $(ARCH)\Makefile.CL -FT_DLL = ft13_32.dll - -CC = cl /nologo -LIB = lib /nologo -LINK = link /nologo - -CFLAGS = /Za /W2 -I$(ARCH) -I. -Iextend - -!ifndef DEBUG -CFLAGS = $(CFLAGS) /Ox -DLLFLAGS = /RELEASE -!else -CFLAGS = $(CFLAGS) /Zi /Ge -DLLFLAGS = /DEBUG -!endif - -!ifdef DLL -CFLAGS = $(CFLAGS) /GD \ - /DEXPORT_DEF=__declspec(dllexport) /DEXPORT_FUNC=__declspec(dllexport) -!else -CFLAGS = $(CFLAGS) /GA -!endif - - -TTFILE = .\ttfile.c -TTMEMORY = .\ttmemory.c -TTMUTEX = .\ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -# Do not insert spaces between the file names or at end of line, otherwise -# the substitution for LIB command line will fail. Thank you. -# -SRC_X = extend\ftxgasp.c extend\ftxkern.c extend\ftxpost.c\ -extend\ftxcmap.c extend\ftxwidth.c extend\ftxerr18.c extend\ftxsbit.c\ -extend\ftxopen.c extend\ftxgsub.c extend\ftxgpos.c extend\ftxgdef.c -OBJS_X = $(SRC_X:.c=.obj) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c\ -ttgload.c ttinterp.c ttload.c ttobjs.c ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.obj) $(OBJS_X) - -SRC_S = $(ARCH)\freetype.c -OBJ_S = $(SRC_S:.c=.obj) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -# Since Microsoft's NMAKE does not handle $($(LIB_FILES)), and using -# LIB_FILES="$(OBJS_S)" will excess the capacity of COMMAND.COM, we cheat -# by constructing LIB's response file directly in the `all' target. -# -# Another solution, useful during debugging of part of the library, -# would be to include each .obj in the library as soon as it is compiled. -# See ..\msdos\Makefile.TC for an application. -.c.obj: - @$(CC) /c /Fo$@ @<< - $(CFLAGS) $*.c -<< - - -!ifndef DEBUG -# Skipped if DEBUG build -all: $(OBJS_S) - -del libttf.lib - $(LIB) /OUT:libttf.lib @< dep.end - -ifeq (dep.end,$(wildcard dep.end)) - include dep.end -endif - -# end of Makefile.Min diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC deleted file mode 100644 index f84fb23a1..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.VC +++ /dev/null @@ -1,195 +0,0 @@ -# Visual C++ 2.x, 4.x, 5.0 and 6.0 makefile for freetype -# adapted from suns example makefile (related to the TCL script language) - -# Does not depend on the presence of any environment variables in -# order to compile freetype; all needed information is derived from -# location of the compiler directories. - -# -# Project directories -# -# ROOT = top of source tree -# -# TMPDIR = location where .obj files should be stored during build -# -# TOOLS32 = location of VC++ 32-bit development tools. Note that the -# VC++ 2.0 header files are broken, so you need to use the -# ones that come with the developer network CD's, or later -# versions of VC++. -# - -ROOT = ..\.. -TMPDIR = . -#TOOLS32 = c:\msdev # VC++ 2.x,4.x -#TOOLS32 = c:\Program Files\devstudio\vc # VC++ 5.x -TOOLS32 = c:\Program Files\Microsoft Visual Studio\Vc98 # VC++ 6.x -INSTALLDIR = c:\WINNT\SYSTEM32 - -# Set this to the appropriate value of /MACHINE: for your platform -MACHINE = IX86 - -# Comment the following line to compile with symbols -NODEBUG=1 - - -###################################################################### -# Do not modify below this line -###################################################################### - -TTF = ttf -TTFLIB = $(TTF).lib -TTFDLL = $(TTF).dll - -TTFOBJS = \ - $(TMPDIR)\ttapi.obj \ - $(TMPDIR)\ttcache.obj \ - $(TMPDIR)\ttcalc.obj \ - $(TMPDIR)\ttcmap.obj \ - $(TMPDIR)\ttdebug.obj \ - $(TMPDIR)\ttfile.obj \ - $(TMPDIR)\ttgload.obj \ - $(TMPDIR)\ttinterp.obj \ - $(TMPDIR)\ttload.obj \ - $(TMPDIR)\ttmemory.obj \ - $(TMPDIR)\ttmutex.obj \ - $(TMPDIR)\ttobjs.obj \ - $(TMPDIR)\ttraster.obj \ - $(TMPDIR)\ttextend.obj \ - $(TMPDIR)\ftxcmap.obj \ - $(TMPDIR)\ftxgasp.obj \ - $(TMPDIR)\ftxkern.obj \ - $(TMPDIR)\ftxpost.obj \ - $(TMPDIR)\ftxwidth.obj \ - $(TMPDIR)\ftxerr18.obj - - -PATH=$(TOOLS32)\bin;$(PATH) - -cc32 = "$(TOOLS32)\bin\cl.exe" -link32 = "$(TOOLS32)\bin\link.exe" -include32 = "-I$(TOOLS32)\include" -I$(ROOT)\arch\win32 -CP = copy -RM = del - -TTF_INCLUDES = -I$(ROOT) -TTF_DEFINES = -nologo -D__WIN32__ -D__WIN32DLL__ - -TTF_CFLAGS = $(cdebug) $(cflags) $(cvarsdll) $(include32) \ - $(TTF_INCLUDES) $(TTF_DEFINES) -CON_CFLAGS = $(cdebug) $(cflags) $(cvars) $(include32) -DCONSOLE -DOS_CFLAGS = $(cdebug) $(cflags) $(include16) -AL - -###################################################################### -# Link flags -###################################################################### - -!IFDEF NODEBUG -ldebug = /RELEASE -!ELSE -ldebug = -debug:full -debugtype:cv -!ENDIF - -# declarations common to all linker options -lcommon = /NODEFAULTLIB /RELEASE /NOLOGO - -# declarations for use on Intel i386, i486, and Pentium systems -!IF "$(MACHINE)" == "IX86" -DLLENTRY = @12 -lflags = $(lcommon) /MACHINE:$(MACHINE) -!ELSE -lflags = $(lcommon) /MACHINE:$(MACHINE) -!ENDIF - -conlflags = $(lflags) -subsystem:console -entry:mainCRTStartup -guilflags = $(lflags) -subsystem:windows -entry:WinMainCRTStartup -dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll - -!IF "$(MACHINE)" == "PPC" -libc = libc.lib -libcdll = crtdll.lib -!ELSE -libc = libc.lib oldnames.lib -libcdll = msvcrt.lib oldnames.lib -!ENDIF - -baselibs = kernel32.lib $(optlibs) advapi32.lib -winlibs = $(baselibs) user32.lib gdi32.lib comdlg32.lib winspool.lib - -guilibs = $(libc) $(winlibs) -conlibs = $(libc) $(baselibs) -guilibsdll = $(libcdll) $(winlibs) -conlibsdll = $(libcdll) $(baselibs) - -###################################################################### -# Compile flags -###################################################################### - -!IFDEF NODEBUG -cdebug = -O2 -Gs -GD -!ELSE -cdebug = -Z7 -Od -WX -!ENDIF - -# declarations common to all compiler options -ccommon = -c -W3 -nologo -YX -Dtry=__try -Dexcept=__except - -# NEED BYTEORDER INFORMATION HERE !! -!IF "$(MACHINE)" == "IX86" -cflags = $(ccommon) -D_X86_=1 -!ELSE -!IF "$(MACHINE)" == "MIPS" -cflags = $(ccommon) -D_MIPS_=1 -!ELSE -!IF "$(MACHINE)" == "PPC" -cflags = $(ccommon) -D_PPC_=1 -!ELSE -!IF "$(MACHINE)" == "ALPHA" -cflags = $(ccommon) -D_ALPHA_=1 -!ENDIF -!ENDIF -!ENDIF -!ENDIF - -cvars = -DWIN32 -D_WIN32 -cvarsmt = $(cvars) -D_MT -cvarsdll = $(cvarsmt) -D_DLL - -###################################################################### -# Project specific targets -###################################################################### - -release: $(TTFDLL) -all: $(TTFDLL) - -install: $(TTFDLL) - -@md $(INSTALLDIR) - -@$(CP) $(TTFDLL) $(INSTALLDIR) - - - -$(TTFDLL): $(TTFOBJS) ttf.def - $(link32) $(ldebug) $(dlllflags) \ - $(guilibsdll) -out:$(TTFDLL) -def:ttf.def $(TTFOBJS) - -#ttf.def: $(TTFOBJS) -# ..\..\tcl8.0.4\win\release\dumpexts -o $@ ttf.dll $(TTFOBJS) - - -# -# Implicit rules -# - -{$(ROOT)\extend}.c{$(TMPDIR)}.obj: - $(cc32) $(TTF_CFLAGS) -Fo$(TMPDIR)\ $< - -{$(ROOT)}.c{$(TMPDIR)}.obj: - $(cc32) $(TTF_CFLAGS) -Fo$(TMPDIR)\ $< - - -clean: - -@del *.exp - -@del *.lib - -@del *.dll - -@del $(TMPDIR)\*.obj - -@del *.pch - -@del *.pdb diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc deleted file mode 100644 index db4c715e6..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/Makefile.gcc +++ /dev/null @@ -1,96 +0,0 @@ -# This file is part of the FreeType project. -# -# It builds the library for gcc under Win32. -# This Makefile will fail with MinGW32 ports of gcc and make under -# bare-bones Windows 9X, because of the limitations of command.com. -# Use Makefile.min instead. -# -# You will need GNU make. -# -# Use this file while in the lib 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 - -ifndef GETTEXT -GETTEXT=NO_GETTEXT -endif - -ifdef DEBUG -CFLAGS = -Wall -O2 -g -ansi -pedantic -I$(ARCH) -I. -Iextend -D$(GETTEXT) -else -CFLAGS = -Wall -ansi -pedantic -O2 -s -I$(ARCH) -I. -Iextend -D$(GETTEXT) -endif - - -TTFILE = ./ttfile.c -TTMEMORY = ./ttmemory.c -TTMUTEX = ./ttmutex.c - -PORT = $(TTFILE) $(TTMEMORY) $(TTMUTEX) - -SRC_X = extend/ftxgasp.c extend/ftxkern.c extend/ftxpost.c \ - extend/ftxcmap.c extend/ftxwidth.c extend/ftxsbit.c \ - extend/ftxgsub.c extend/ftxgpos.c extend/ftxgdef.c \ - extend/ftxopen.c extend/ftxerr18.c -OBJS_X = $(SRC_X:.c=.o) - -SRC_M = ttapi.c ttcache.c ttcalc.c ttcmap.c ttdebug.c \ - ttgload.c ttinterp.c ttload.c ttobjs.c \ - ttraster.c ttextend.c $(PORT) -OBJS_M = $(SRC_M:.c=.o) $(OBJS_X) - -SRC_S = $(ARCH)/freetype.c -OBJ_S = $(SRC_S:.c=.o) -OBJS_S = $(OBJ_S) $(OBJS_X) - - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -.PHONY: all debug clean distclean depend - - -all: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S libttf.a - -debug: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_M DEBUG=1 libttf.a - -HAVE_GETTEXT: - $(MAKE) -f $(FT_MAKEFILE) LIB_FILES=OBJS_S GETTEXT=HAVE_GETTEXT \ - libttf.a - -$(OBJ_S): $(SRC_S) $(SRC_M) - -libttf.a: $($(LIB_FILES)) - -del $@ - ar src $@ $^ - -clean: - -del *.o - -del extend\*.o - -del $(subst /,\,$(ARCH)/*.o) - -del response - -distclean: clean - -del dep.end - -del libttf.a - -depend: $(SRS_S) $(SRC_M) $(SRC_X) - $(CC) -E -M $^ > dep.end - -ifeq (dep.end,$(wildcard dep.end)) - include dep.end -endif - -# end of Makefile.gcc diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win deleted file mode 100644 index 813a0eebc..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/depend.win +++ /dev/null @@ -1,103 +0,0 @@ -# This dependency file to be used with various Win32 compilers -# has been generated automatically with the script `makedep' on -# 03-Sep-1999. - -ttapi.obj: ttapi.c ttconfig.h arch\win32\ft_conf.h freetype.h fterrid.h \ - ftnameid.h ttengine.h tttypes.h ttmutex.h ttcalc.h ttmemory.h \ - ttcache.h ttfile.h ttdebug.h ttobjs.h tttables.h ttcmap.h ttload.h \ - ttgload.h ttraster.h ttextend.h -ttcache.obj: ttcache.c ttengine.h tttypes.h ttconfig.h \ - arch\win32\ft_conf.h freetype.h fterrid.h ftnameid.h ttmutex.h \ - ttmemory.h ttcache.h ttobjs.h tttables.h ttcmap.h ttdebug.h -ttcalc.obj: ttcalc.c ttcalc.h ttconfig.h arch\win32\ft_conf.h freetype.h \ - fterrid.h ftnameid.h ttdebug.h tttypes.h tttables.h -ttcmap.obj: ttcmap.c ttobjs.h ttconfig.h arch\win32\ft_conf.h ttengine.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ - tttables.h ttcmap.h ttdebug.h ttfile.h ttmemory.h ttload.h -ttdebug.obj: ttdebug.c ttdebug.h ttconfig.h arch\win32\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h tttables.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h ttcmap.h -ttextend.obj: ttextend.c ttextend.h ttconfig.h arch\win32\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttmemory.h -ttfile.obj: ttfile.c ttconfig.h arch\win32\ft_conf.h freetype.h \ - fterrid.h ftnameid.h tttypes.h ttdebug.h ttengine.h ttmutex.h \ - ttmemory.h ttfile.h -ttgload.obj: ttgload.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ - ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h ttgload.h \ - ttmemory.h tttags.h ttload.h -ttinterp.obj: ttinterp.c freetype.h fterrid.h ftnameid.h tttypes.h \ - ttconfig.h arch\win32\ft_conf.h ttdebug.h ttcalc.h ttmemory.h \ - ttinterp.h ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h \ - ttcmap.h -ttload.obj: ttload.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttdebug.h ttcalc.h ttfile.h \ - ttengine.h ttmutex.h tttables.h ttobjs.h ttcache.h ttcmap.h \ - ttmemory.h tttags.h ttload.h -ttmemory.obj: ttmemory.c ttdebug.h ttconfig.h arch\win32\ft_conf.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttmemory.h ttengine.h \ - ttmutex.h -ttmutex.obj: ttmutex.c ttmutex.h ttconfig.h arch\win32\ft_conf.h -ttobjs.obj: ttobjs.c ttobjs.h ttconfig.h arch\win32\ft_conf.h ttengine.h \ - tttypes.h freetype.h fterrid.h ftnameid.h ttmutex.h ttcache.h \ - tttables.h ttcmap.h ttfile.h ttdebug.h ttcalc.h ttmemory.h ttload.h \ - ttinterp.h ttextend.h -ttraster.obj: ttraster.c ttraster.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttengine.h tttypes.h ttmutex.h \ - ttdebug.h ttcalc.h ttmemory.h -extend\ftxcmap.obj: extend\ftxcmap.c extend\ftxcmap.h freetype.h fterrid.h \ - ftnameid.h tttypes.h ttconfig.h arch\win32\ft_conf.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h -extend\ftxerr18.obj: extend\ftxerr18.c ttconfig.h arch\win32\ft_conf.h \ - extend\ftxerr18.h freetype.h fterrid.h ftnameid.h extend\ftxkern.h \ - extend\ftxpost.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h -extend\ftxgasp.obj: extend\ftxgasp.c extend\ftxgasp.h freetype.h fterrid.h \ - ftnameid.h tttypes.h ttconfig.h arch\win32\ft_conf.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h -extend\ftxgdef.obj: extend\ftxgdef.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxgpos.obj: extend\ftxgpos.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxgsub.obj: extend\ftxgsub.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h tttags.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxkern.obj: extend\ftxkern.c extend\ftxkern.h freetype.h fterrid.h \ - ftnameid.h ttextend.h ttconfig.h arch\win32\ft_conf.h tttypes.h \ - ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttdebug.h \ - ttmemory.h ttfile.h ttload.h tttags.h -extend\ftxopen.obj: extend\ftxopen.c tttypes.h ttconfig.h arch\win32\ft_conf.h \ - freetype.h fterrid.h ftnameid.h ttload.h ttobjs.h ttengine.h \ - ttmutex.h ttcache.h tttables.h ttcmap.h ttextend.h ttmemory.h \ - ttfile.h ttdebug.h extend\ftxopen.h extend\ftxgdef.h extend\ftxgsub.h \ - extend\ftxgpos.h extend\ftxopenf.h -extend\ftxpost.obj: extend\ftxpost.c extend\ftxpost.h freetype.h fterrid.h \ - ftnameid.h tttypes.h ttconfig.h arch\win32\ft_conf.h ttobjs.h \ - ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttload.h ttfile.h \ - ttdebug.h tttags.h ttmemory.h ttextend.h -extend\ftxsbit.obj: extend\ftxsbit.c extend\ftxsbit.h freetype.h fterrid.h \ - ftnameid.h ttobjs.h ttconfig.h arch\win32\ft_conf.h ttengine.h \ - tttypes.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h ttdebug.h \ - ttload.h ttmemory.h tttags.h ttextend.h -extend\ftxwidth.obj: extend\ftxwidth.c extend\ftxwidth.h freetype.h fterrid.h \ - ftnameid.h ttdebug.h ttconfig.h arch\win32\ft_conf.h tttypes.h \ - ttobjs.h ttengine.h ttmutex.h ttcache.h tttables.h ttcmap.h ttfile.h \ - tttags.h ttload.h -!ifndef __MAKE__ -arch\win32\freetype.obj: arch\win32\freetype.c ttapi.c ttconfig.h \ - arch\win32\ft_conf.h freetype.h fterrid.h ftnameid.h ttengine.h \ - tttypes.h ttmutex.h ttcalc.h ttmemory.h ttcache.h ttfile.h ttdebug.h \ - ttobjs.h tttables.h ttcmap.h ttload.h ttgload.h ttraster.h ttextend.h \ - ttcache.c ttcalc.c ttcmap.c ttdebug.c ttgload.c tttags.h ttinterp.c \ - ttinterp.h ttload.c ttobjs.c ttraster.c ttfile.c ttmemory.c ttmutex.c \ - ttextend.c -!endif diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c deleted file mode 100644 index f3bf03993..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.c +++ /dev/null @@ -1,42 +0,0 @@ -/* This file is part of the FreeType project */ - -/* single object library component for Win32 */ -#define TT_MAKE_OPTION_SINGLE_OBJECT - -/* Note, you should define the EXPORT_DEF and EXPORT_FUNC macros */ -/* here if you want to build a Win32 DLL. If undefined, the */ -/* macros default to "extern"/"" (nothing), which is suitable */ -/* for static libraries. See `ttconfig.h' for details. */ - -/* The macro EXPORT_DEF is placed before each high-level API */ -/* function declaration, and EXPORT_FUNC before each definition */ -/* (body). You can then use it to take any compiler-specific */ -/* pragma for DLL-exported symbols */ - -/* first include common core components */ - -#include "ttapi.c" -#include "ttcache.c" -#include "ttcalc.c" -#include "ttcmap.c" -#include "ttdebug.c" -#include "ttgload.c" -#include "ttinterp.c" -#include "ttload.c" -#include "ttobjs.c" -#include "ttraster.c" - -/* then system-specific (or ANSI) components */ - -#include "ttfile.c" -#include "ttmemory.c" -#include "ttmutex.c" - -/* finally, add some extensions */ - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE -#include "ttextend.c" -#endif - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp deleted file mode 100644 index ecf6b1f6b..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsp +++ /dev/null @@ -1,104 +0,0 @@ -# Microsoft Developer Studio Project File - Name="freetype" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=freetype - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "freetype.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "freetype.mak" CFG="freetype - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "freetype - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "freetype - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe - -!IF "$(CFG)" == "freetype - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O1 /I "." /I "..\.." /I "..\..\extend" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "freetype - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /Zi /O1 /I "." /I "..\.." /I "..\..\extend" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# SUBTRACT CPP /YX -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "freetype - Win32 Release" -# Name "freetype - Win32 Debug" -# Begin Source File - -SOURCE=.\freetype.c -# End Source File -# Begin Source File - -SOURCE=..\..\Extend\Ftxcmap.c -# End Source File -# Begin Source File - -SOURCE=..\..\Extend\ftxerr18.c -# End Source File -# Begin Source File - -SOURCE=..\..\Extend\Ftxgasp.c -# End Source File -# Begin Source File - -SOURCE=..\..\Extend\Ftxkern.c -# End Source File -# Begin Source File - -SOURCE=..\..\Extend\ftxpost.c -# End Source File -# End Target -# End Project diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw deleted file mode 100644 index 0fb561d5d..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "freetype"=.\freetype.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.ide b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/freetype.ide deleted file mode 100644 index ee7c13cb0867765dcc3c81fe617a2f2f0aa76f17..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35589 zcmeHwdtg=7neRF$C&>xqod5v>9Pkh$h8P|qDk^#MFoc){MMNMZAqj>gCI>`(AwI{d zAhnKtjAO0iOdaZ2YpG=z$J;s`+p*Sm9BZB4UdQqFdcEF`WgKVf*m{4zZ>?|dot@-p z|Cs;o2jBkA+Ut9*_u6aiy;3(cGSE5Lov1(a%tY(R(C(hDRHCVWpeJvNnPsBpDRbi4 z4_~_fHe>2CjVariZK{lkN6hhsuP^v{)Bs9v{|j?#=GXai4CH-3X69x@!24bNdkXX$ zz^8%V1Re)|3-}E1+rSgRzXYBH{uS_9;9mou1O7MQcYxmoJ`emG;P-%k3w#0iec%s( ze+PUK_(R}Jz#jo$2L2fM6X4$iUjhCD@KxYXfv*9727Dd(kHDV;|2yy(!2bb!1NcwC zH-Y~Qd<*zLfxiU)FW}q2{|$Tx_(5<-je#D}Y;pR|2;I zw*z+oJApfaUBGT&4{#T-7uW&p1NH-V1Fr%O0QUgDg1mYZ_$R=}fPV@kynU}RNvQ_f zYEW*bc6hk4V*hZ@NUFNJT6n5NgU?fHs;jr+f6x9@&tUh~U8()UL!&9HuSzVXz@NG1Vg}FOFT0LN2ONyS zogBL)1(E9;=~A8SsuZFo13LT6Iw!|2OhM%O2R%7)GF@(F-IYr3OYykSi?yfi!^SL$(6<|ZMngBj$@SqdUBKO zsBPaM8I_PR%#X`9$#olAo7dHu8^!i28Q=W)1t!_DvHh~z)8xR;i-N*0zlsT00W^hWfh`$@a$PmW>UK?I=I`pOAT=>Y}Y{ zMwc!1JEero5j7sOGPCiTfqL|+BPpquNtr)te3Tu`&@}^H`%&c zOwN5BtiaCRra`#pEDCRpOyYgs>83(>tVwEC|1K8(wKC!N`KwKU{nL18E)qTE^3dSx zLB}&Z;yU4^JWOaDDvoK}JJ{ZZfjz|sHK`9(^01*ioOM++4|R4UJGv9#PFQwZM$6@) z#OIxDJk}Agb|$(kcVZW{7mI((Yt^3db!%JrtI zGBvxFJj>;Y&gYqJ>PLDyQ$4JdoY>1;K+WQ*mof=?0#un&lZ6UC+SNJ8JJv3r4i!p} zNB!L!_ojyTrdm5weYQY5>l7SKXbd&Yhj3 znCX1QRY*RKDwN1fXL!H0S1C`a8pjc>t$sVJ;`YYw{?rf}?;S4B_#~^q@?|{IXZtZp zU!^?h`aA`~lc-RxQIw(02YDKHjBEtdh157@(XK)7(TGpc3hZ?1`crri z8SA&r^GbQz_IdNgmgScghbZe4pU4$7eTfRosXTmQSHL5>^&724o`OVAxjfPPJn(zx z9`}e;E>HSn;zl?hrTr>d0r2CBP5s`H(V>yCY5K9`U!|-R_`Ehvmfxo7doG{3nxNpP z$#QD>%W8wqRA>{083e4`ZbOun%Zh~0hlGJgm2jm(fzK-Ix`qbFxb7U{YKDS3L|$>* z@o=?6LFVpKJ1WR#%wb`wl;seg$>ucQE zva~ZMZr@JVYRhHGXG~nzu=mi!r62`K^Dg9^%UmuIDR7ZuT|?vc`Zdk#_6!fXxlNTU zA^AM0iRe_Se3wCU$Eo`OriTac)dB|Sf`*wnT+wVbCb zG92bs@>$yI;ZmT&RLt{JJ^RnL3qUop+vy9(CPQQNw%x?Y^Bk#$Jr$wrT2c|2`c>rt?Uz%@$+pFfpy#p#CEq^xWDd^u)U zYCBo5c%-W`m9p-sJei*D6c*`v@p!{^CTo*xqY9a*WY))2YR_I|A=w-s*H0BV#42A` z=RlXRIXQn z*WB2?m5&j%Ee%`i>d)SaC;8@04UJnzvCK5s3oT4zgRJ$cj!ZQ8Po-l!mhi+8tAlIB z3crUR-O%FvsFby4)e%f{S7%ori^R@tD`h=e`GR@93v(J~P24qFu30N&1j??PPupNT zLpq2CS=aXYK4tnxQ{DYTP~voOU0fma)0V?_^c>={t!rFYSI7v|AuKdXPXE@Wi)-%+ z!McknA!d#6$?_c===;b00)-%-T`TwbxTm1t+wJJ6udQF(h~DHGXP5g93Vu4s*IW-aQ|0)$ zH=!_wZ$oV>`4%`n?q4Vb?XGFwSla-`GRMa~4h3IdDwXQ&m2%5>eB1|7@YCDTv96_~ zv5l4;ANNWWe7;nwe-PQnl5+zf_fr&nyB!_QJq*USUUAPwA;`C}Zhbq`Tjcn-FQeew z?dWK$ZHI&4bbQ>qQ3&c|heLg~o;Jw-j?ee0`=)LTT}Y($o%=%yL7z4>ZrIp%xu0j; zLsAHq)rL(Sjhn&tGncpAXHp32Yuwz?*up|}eB6stScHDst(>>@?CQa?8F2Hw2j>DQn;O|KOUKV0 zCGd~*cUphAx2Av{#22!Rd~su23%Q>V9}}`a zsQg^mYwFluzp-4+QX%Ti z1v*e+r7k*Km9oF7d@--z?dV`GwZo-B@u^bwK$S1p1{xacHmw0)x8vhJsY1}MYg3+G z?xiY3z44=?L)tm=yVdFAeyc((z$g6+_?jFa_hc1<`lP=C-zvw)eOrYfUq|g4Cf6(# zz8cxvRX)FM`1N8am@V)X2WF z@<%7ApRF6)JLpHI)6YFP;4_skF{?WZV$$zcm=YF}uMEpb8yCnY}$IrcWg^Bn_vAjZlyR%y(`|v)$_9K3J zuj%hj^+8}$oR6mp>ofG%|EIrS4h&{|A>(@)r!wZo!gA|zXLsyS?4j6+*sHNqvHZ+M znN68HGjGiNLgsfef0bFCwLWWC)}gG2vQA{Zn)PAU^z8GpFU{VU{Z#f#+3#fMO^NS{ zABsN|e>VPl{DXLLPIbPu5+sHJFk(d|V~6}?{cyP}HXy5il%_ZB}@{Ce>R#dAy6mmDa0 zpya8NmrC9#$uB*xbXV!|(w~%mSUPvwh0}ITJ3j3v(|$K?*7Wt$2d5vM{+;RXOwXUO zV#c-^x6gQD#;Y@Cm2E3~r0fS}r^;r{+&1%(nLn6$YUZq2b+dNQIy&pbtT&OK*-K|{ znSE&XN%IrxqZ&@Ilr7UeQwj-opX=QJu&y4xp`CO zwahy@@5H<}=jBaFEKO`l97;T%_(>uxBhztS?1y-5GVoYl8iHO>clrEH% zjtupVbncP2_(r$Z+4uW`kL%{F$o%w-eCy!f3iA9tjxN0A;5?fOTi^FQ?aLl$~^m;4$U8%o+9wPI7VOb zB>J%GjF^PU*ZgpPKkfYeA?h4`vU*Fv`@=DMODEOKn2GgL!C1Z1!28k|z0)Vrn>36m z8{;qi8>?>ycz!fSU)d!3s_+0EHFM0e$V{_+yG&9qSbF~U?Reg-Zv?%pwylMVZ2D({ z_vJBqXNC2~v4@WamTPPbd#frl8(e$=5)Z1ve0WcX_$nFZryPV;2=Ya*HC zIGKf>41Y}|Q!!5FbWeuACX%TfCv%1;!(S80EE*@nalw}LnfS$*H2FdzUM-kD5Lt{n zVX(Yah&fGo$?*op8jd4jU>QD_MJ-QdedOBJOxNCi;o4iK3xCYM9+2U}zeSkkJr7~} zGu_<}wp*z#ExFW?NUqmnFkfU2$o1Q>!HhcL=wCW|(%Jsd(f@Qb z4oADepA9+_^mp$5$Br83YnDsUp{Uir&(Zyk?gb@W@96E0-s<9aI(pF2yBxjN(c2uo z3Y72}7rw{QI~~2k(LPW@j|=Z|wAazkx%e&@zR%I4j^6L+1CIWoquq{P>F72`4>)=a zDB)g5N8SDF9NpvYKj^|YIy&U&9WMSBM{jobZ*cT#cmF0A{;Z>e?*8W;{i35^a`AuU z=tGYFv7-+=`ejhUBaVK>-RDG!@T4nmP6!B`cn~Q6l zLl5a|F8tG}@B{FwqpyR)P4k)y|IE=ZIsPwFAO1h&=pT^+np}aUT=+UiuLfn0`++Oi zJKg=?xUkMOYA}A;g=w9iEW;f;4_Sg=W9KeQamUVG_-pJK%=@hoN;gDSV}F}_xo%Fju@p1L>5Pf7}}xFg9ey4RqGpO!G5+i0ZR3VWdK zaFSbHw8O0|@^PzbZT}rfZbk7vx0(tsKb+)N(!wo=liVtL2Ku=bls9G9;UxEZI*=gl zmM@>UY0^yRIx!QcnX8!-E)31waHjG57#0e@kqKtD7LH~**M)n$3vh>NA2$5ejkM>=H$8X#y7_QY zJ`@72`~-h?A%5|in?IEw<)&_&AN9CH9}XJ+O2LPG`QWMHhQrA&=xza>%m*z{Er?I5 z2wHKp6>%Y)mEIOu<2c`#E4H$(!7p1`7eeO8Xc(IA|7zc~a)m3O_7vfA*Gf29CDuly zjmM^a?YOkBb7?<_4~Dc{HX`k87+kn--Q50PUM_Z>Z9VMw!6IG{mM7PZcyj%WITRa| z&cynE@i_lkVphHxzql2k@|QvWZcpCwYyc0J|CMJucwEzn<(DEaM3zT)L|?%dTpbw)Gak)& zIpd>@%2-G2VC>P@%dwAQm6^*kcVu3ld4J}UnJ;9%mHAO-SyoL}b5?iO!K??fp3ZtP z>+P)4?A2Je1LT+Iugq`Ff4D$G?(%%WqlM35D6c8Pc2?0dMX!K%6dN;K+*&eF@@`3C zX;o=!X{z+W(vzikXGbtna<$Y<+gkdlXy7WWF)6HbP6ZtVjhW?}xJnuUAHSl-tn1^C zKNep}p}hdlMfSP(#W(O2j4y)l#f!&7UIKX(&cg2m0#VSW z$b5I3x&`97?hc978ADtRxUF4MLQv-t#3pc$I;$tp$=Q#B)tL#MOVjFH7SPEhO$)xC zGgKj{)tLpI%hT#STVnaFPT>VkgRgV8yF+4iWu7-8H^jFGY>k~OsaD&V%7n#61j;pbdkgbGc+GM*H5bRV#G89cc;;LW`)x#Ql9x&GRC}wN0wC z9WfoiooRH|h-$k`YSU5-o#@>F?6Aywre$d;EhXT&%;ymue&@0oF_!}`;eDx-?T&-G z1>#GD6iEHCc1sbr-P5^B>@E-4od%vxkH;zX@^B|&x`>Ei9-igpA$1GHm#Gk_wL2Yg z{hrR}#qK#~H}3GJt=luebCt)VD#*i+N3ktu_5kq>K&TB;w?O=CA+{b`yJd*OU;>bQ zzL@!Zt{K7|-n4dSf@j$05gkT&c(?+#-pmNF8~1H`wVhJ8KzyZ;VEN8M+;yJLBVu=z zxgK|T)7qU4o*O(Ks|ssYxWfY-ZUnsvIDm*qA={nWrEY=vc|ytp+SXH(@^P|>V5OXW=2qRFhv_m(Bx&`7FSt?hXmIUH%n^foRh`9rJA0;NySsT!4 z>&$%UywlUUY6H`)q3~xe#$jJ)Q4~-R6+p3h;c^<53l~ z8$3wlC?l3=EGcyh#4ol~uD0w>N8INo)X4)$@I+_+5GXo@OBMJ!H|Q-;n}?Oq`Jkt> zriEp6fI@O<9mQ5E_D?-vmBMc_Oa!SU1rbqmC0H_hF(Iu{}COB3qkp(@n* z&?o3@b^1uG&NHF&k0;d0I!2ve{sf(u1a#W`se;b0dOA~*Kkepm+~G}YcQJVW+~ZLd z8~wSW@a1h__iPS8KN#ao-S~AEAGEQtWofN6frw?Vbgmr#&83p@-3Y z6EVkuVmG0&q|`kgtlb*KeaqANuGrlqA2jo(wYvm7&v-nliHF}1z728$INmOGj|Xda zDdKo^jvaR@H?kgHCLcocp0&FSJUmus>;(Fsafb)(Jco#1g8KDP`(f%9h+itCFwhS# zN8ER)QpUS(v3t23*yGzhdkl}Lz=hv0^H87ff{_RNX!$Po#vSSwh;LRQP@CQri2EDQ z?!#jDijduN#_*^L+6^8eG~OLUzv|!=v)rSL-23&oKgH zlRv&ww?KTmrE;})S0RqaDp|Wn#O_Y{+?e-ly}AHAJaTDly*h%Wm zpl*S9r;y;h;zGm~Ql()&zbJOQL+QO}43DV5Me{ieHhJ*Vml=VbLLaDGAl~KQbmhAm zaZh-5&QY%GKI!MqH7n^X?AXy)I;T19*x( z9#x@sOAy0v!nZM^2y5poH38}ti0`vhuGVe~;>tXou}!plW617C@XYjhRE6rFg_zku zNQUfEw?O=QOXX_qwjyqhr}KKTd$W8=O1Eu?b;%eWRWTP*^MDE9eEw!cO)$OGEfBxS zQg^My2?)dHc~geB2cL_SMps7fj=m9Ho^fZ!&ogSU>iK6_@l0fd2e2KX1y5c)4_HYU+bi-kychG{%WKH*%Ria_M*i}G%>~B_UM@%$t}Xl$)ETkdwZmfK(T@{AJb%nhUxvjRJg+Ul7MFnp+JOnjCE*c%gk88#~( z?q=^xq+a6EOL+yvwQ5@t*bIY*zNr9cJRt!N>jW5>EW`bwZm?KhsTZ0SJ4nZO$h73-O)XK7h8qcj|5MZ3mA+q3r^QYH@hiRVS7WUV2cqEFJQ_PO zwK5#Iq@N$p6xYoMKg!B*pv&agFdpKvC~7znRG8{;!P9k%)$Z+DT zVC`_=4W81Xv7m7r_ygdaRl&+|pe~)n&Na&FQ7glNecB{4`#oO$VP!ZGm_CWjwaV&I zE5nJyj7ek;c)a?<%5b7lK8ef?!peE9f|cRKWWgjd2Zfb$P#?<8>v%iAF0wE3c;pw6 z;%HO!K=g^|o6+eR>oac5cq-$U8M9(7u|u)rv3Fu~Gutw6&pd&TxE5qxnsry!vstII zDzdj^-<$oN><_XR#ka+e#=jT;FkYRrGpDs5lP8o_CbkoH7&}?woUbAK>v&Ia>70QG z-`M8t?>x-@GSPMNe-7^P>l1$A!LKa%Wdy%s;1>t{N`P54V{E5fmUiN3y4gjC-& z{5}SKY(Qb~^-)6gQG)2}n~sp`qmGxMkBu=5zCKE*KGq6bGqk>x1@z6w?_;R2Y_?(W z^-)6gF^7o0f3px$|CkdmLm!)X7<_${P<<>xqOY$UA=Sr{dLR1O9fZNxM+wz82fvBF zzPSjgKGyWI$S}IUbowZv`sU#`(btziNcGXuD(GW369(TuN~k{OIMLU)03p>!OFN)X zJJq1hTfeXEjS_@P>#a70yk9~{{HZDQL%?h(LFdRL4_meU>Oh?}mH|%8D$5<#gPj>NR zSuDw6kXjLtVmybGS>VpWTkv+E;s6zvL#?_rQGsuE}$KoNLuwH?9M6J(X*lTxR5wAD7>_6y_~U!RKSgVGntgn2oW`;=-j<2CtUqC?nJCr^12#L{;wW4COx)*!sI76F?XVSuHOxwrUjCsM9HI^> zT@>LllbYVyX(VU6oU#kDVVmV?(u!jS@Q>{zEHx*TzpZiG3p0P`Nd8ia>yq4QQ)%^f zZkiT0S6WzjHJHm~_JwHbDmU7|=A~(1^Q3{Xg|mT$+ZNv}3im?X`;R{VFMaZnbc2 zRX2w;-?j7?n_Z}+<12j=if}OwBF&Rk=X6bq-IO*duF=*5!&a)p6~&bVuYYO`7hyM!IXRs)wbPq>)-8Qe5*_DfMz`Nb3C# zJB8&W4BZL-as6MV)Wc;VDaNx6P->Y-*_TgwALk^ysoV09)T&Lst>q$Rmk6ws+B!QV z#aOjiGqscEWgi&USKvYbRqT25RrZkUf*@KPFx% z_Bbwu?Ol|{-bG@MJrR2$l~jAHLy~KqJ$kxYB(?WZNljyINRsiI#@Y#Os$^Z7Ua!ve zdNy}BUhw&Zt$}rm<;@l^+p6K+bahZGLVY+Zor7%9^^%pW1Ys$husdm`!*V13O(fNr zMyhdAsirhp*d$p}kfYP1Av_b`KGrDkQ;imiTV3O0ti+{A4*$M~$WQM%kSkk8?j2=%2k zjW4aA+85P!Ng8dJ{NCEyLUloNm@TtS>O!z%*ZgP?N!85zmREz?MT(txI2SuYQu_l^ z9U^ts1X7zqQqKjXHi^`dfRyIar6H+cx-JzdmVem8%R*A|grBa}*r?PuR$nO4t-7CZ{pB2M)w}x8fdtb8y zBir*O(%jh=l6o%S<+gEBnmgM=QbAkWMT*=1 zVOu*wQpq>`zHx_01;+rj)ftis+UgXkiCWRlkkmlH)=rTMPJ`4|SEw&iTkMOvq%UIb z>*G#1ecd6OPX}yvi%mXssFd3536;3oWQq59{V*S|R8q@sSIFK+0eic|9v^U2O6~Qg zvDcf{USG&w!$0}u*C+OZk7a7FKaIV9vB%LtUat^W{k4+aA$yG08ogWW1=nyiSFQ?4 z-5v1qs&P{4dBO$5sH~l&?GEPc891TeYJscG&zOEAX zFqK9sB~lkp;NjkoRCmC`z2l_R!+mLH2K!`Yz}NqDE*XBKHSGB{As>S2y+(Wpt|Dul z*`G#g|D;marjfdKQmF%Jqz;Ue($c>!By}v1x7Ur6(!9MsO|N^s^t$?3#}{_Od3i&~ zW-u>r5Sv^$QYrQH#*oze0Z(rnC#9a=l*ZGW#(1jlF9%n{4~A?8Jv}HkgDb}B>CGXj zRsZa_sGG-0=|1eCP=EIBqHlY%`$Mjm&&I6U-x<}t*jqyOp5OCTuh+dr?D;PUl^Z<< z`8Kl(`@ptz_!;t-Ud=SLAVp2r3S!#sqGV6Qm0KNQx#|Dy3coGZxBL%M?D z)uC{0C|nl`^9-+`JkRn9h8sg+p6wNk=NVtY@Y+zAXMP3adG=Q@d~qnuv%rG!JQFM! z=J7$naBC=hNhr*7!Giqlp)k+P3dZy3tYDZ&W)ZYJd1MyBUUB|{3u}Aiky!){^Qfd? zn8!^Kv_IrIVg!3NhDR|0f1r5*@LJ-XPJdO)P?yHi$bg1aB>F_^qS9+dI>Kh?i}vnm=Os);fB~(UYL`D{l(E0Hxz=L3!f=N8bXa;#qiWpS0D{+Z{dW=qX1l z_u35J4NCrpUHDBGF571vX#-{aosK^1==+W?!W;jL-{I&3p!Dw*7sjWKR#5{e84tMd z(=Pmu3n%ePKjXJJdIXd?_5&9-2W z=zd3^aP%!lXWeS~S{=RJ(UXpza header file. */ -#define HAVE_STDLIB_H - -/* Define if you have the getpagesize function. */ -#undef HAVE_GETPAGESIZE - -/* Define if you have the memcpy function. */ -#define HAVE_MEMCPY - -/* Define if you have the memmove function. */ -#define HAVE_MEMMOVE - -/* Define if you have the valloc function. */ -#undef HAVE_VALLOC - -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define if you have the header file. */ -#undef HAVE_UNISTD_H - -/* The number of bytes in a int. */ -#define SIZEOF_INT 4 - -/* The number of bytes in a long. */ -#define SIZEOF_LONG 4 - -/**********************************************************************/ -/* */ -/* The following configuration macros can be tweaked manually by */ -/* a developer to turn on or off certain features or options in the */ -/* TrueType engine. This may be useful to tune it for specific */ -/* purposes.. */ -/* */ -/**********************************************************************/ - - -/*************************************************************************/ -/* Define this if the underlying operating system uses a different */ -/* character width than 8bit for file names. You must then also supply */ -/* a typedef declaration for defining 'TT_Text'. Default is off. */ - -/* #define HAVE_TT_TEXT */ - - -/*************************************************************************/ -/* Define this if you want to generate code to support engine extensions */ -/* Default is on, but if you're satisfied by the basic services provided */ -/* by the engine and need no extensions, undefine this configuration */ -/* macro to save a few more bytes. */ - -#define TT_CONFIG_OPTION_EXTEND_ENGINE - - -/*************************************************************************/ -/* Define this if you want to generate code to support gray-scaling, */ -/* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can */ -/* disable it if you don't need it. */ - -#define TT_CONFIG_OPTION_GRAY_SCALING - - -/*************************************************************************/ -/* Define this if you want to completely disable the use of the bytecode */ -/* interpreter. Doing so will produce a much smaller library, but the */ -/* quality of the rendered glyphs will enormously suffer from this. */ -/* */ -/* This switch was introduced due to the Apple patents issue which */ -/* emerged recently on the FreeType lists. We still do not have Apple's */ -/* opinion on the subject and will change this as soon as we have. */ - -#undef TT_CONFIG_OPTION_NO_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to use a big 'switch' statement within the */ -/* bytecode interpreter. Because some non-optimizing compilers are not */ -/* able to produce jump tables from such statements, undefining this */ -/* configuration macro will generate the appropriate C jump table in */ -/* ttinterp.c. If you use an optimizing compiler, you should leave it */ -/* defined for better performance and code compactness.. */ - -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the TrueType */ -/* bytecode interpreter. This will produce much bigger code, which */ -/* _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_INTERPRETER - - -/*************************************************************************/ -/* Define this if you want to build a 'static' version of the scan-line */ -/* converter (the component which in charge of converting outlines into */ -/* bitmaps). This will produce a bigger object file for "ttraster.c", */ -/* which _may_ be faster on some architectures.. */ -/* */ -/* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ -/* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER - - -/*************************************************************************/ -/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ -/* version of the library. */ - -#undef TT_CONFIG_OPTION_THREAD_SAFE - - -/**********************************************************************/ -/* */ -/* The following macros are used to define the debug level, as well */ -/* as individual tracing levels for each component. There are */ -/* currently three modes of operation : */ -/* */ -/* - trace mode (define DEBUG_LEVEL_TRACE) */ -/* */ -/* The engine prints all error messages, as well as tracing */ -/* ones, filtered by each component's level */ -/* */ -/* - debug mode (define DEBUG_LEVEL_ERROR) */ -/* */ -/* Disable tracing, but keeps error output and assertion */ -/* checks. */ -/* */ -/* - release mode (don't define anything) */ -/* */ -/* Don't include error-checking or tracing code in the */ -/* engine's code. Ideal for releases. */ -/* */ -/* NOTE : */ -/* */ -/* Each component's tracing level is defined in its own source. */ -/* */ -/**********************************************************************/ - -/* Define if you want to use the tracing debug mode */ -#undef DEBUG_LEVEL_TRACE - -/* Define if you want to use the error debug mode - ignored if */ -/* DEBUG_LEVEL_TRACE is defined */ -#undef DEBUG_LEVEL_ERROR - - -/**************************************************************************/ -/* Definition of various integer sizes. These types are used by ttcalc */ -/* and ttinterp (for the 64-bit integers) only.. */ - -#if SIZEOF_INT == 4 - - typedef signed int TT_Int32; - typedef unsigned int TT_Word32; - -#elif SIZEOF_LONG == 4 - - typedef signed long TT_Int32; - typedef unsigned long TT_Word32; - -#else -#error "no 32bit type found" -#endif - -#if SIZEOF_LONG == 8 - -/* LONG64 must be defined when a 64-bit type is available */ -/* INT64 must then be defined to this type.. */ -#define LONG64 -#define INT64 long - -#else - -/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ -/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ -/* will produce many -ansi warnings during library compilation. */ -#ifdef TT_USE_LONG_LONG - -#define LONG64 -#define INT64 long long - -#endif /* TT_USE_LONG_LONG */ -#endif - -#endif /* FT_CONF_H */ - - -/* END */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef deleted file mode 100755 index 92f5b2ac6..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedef +++ /dev/null @@ -1,24 +0,0 @@ -# makedef -# -# This shell script creates a .DEF file necessary for building as DLL -# on the Windows 32-bit platform. - -echo "\ -; This definition file to be used to built the library as DLL -; has been generated automatically with the script \`makedef' on -; `date +%d-%b-%Y`. - -LIBRARY ft13_32 -DESCRIPTION 'FreeType 1.3 32-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE -EXPORTS -" > ttf.def - -(cd ../.. - sed -n -e "/^ *EXPORT_DEF/!d ; n ; s/(.*$//" \ - -e "s/;$//" -e "s/ const / /" -e "s/ *[a-zA-Z][a-zA-Z_\*]* //" \ - -e "s/ *//g" -e "s/^/ /" -e "p" *.h extend/*.h) >> ttf.def - -# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep deleted file mode 100755 index 9fcae2490..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/makedep +++ /dev/null @@ -1,29 +0,0 @@ -# makedep -# -# This shell script creates a dependency file necessary for some compilers -# on the Win32 platform. - -echo "\ -# This dependency file to be used with various Win32 compilers -# has been generated automatically with the script \`makedep' on -# `date +%d-%b-%Y`. -" > depend.win - -(cd ../.. - gcc -MM -Iarch/win32 -I. *.c | \ - sed -e "s/\.o:/.obj:/" -e "s:/:\\\\:g") >> depend.win - -(cd ../.. - gcc -MM -Iarch/win32 -I. -Iextend extend/*.c | \ - sed -e "s/^\(.*\)\.o:/extend\\\\\1.obj:/" -e "s:/:\\\\:g") >> depend.win - -echo "!ifndef __MAKE__" >> depend.win - -(cd ../.. - gcc -MM -Iarch/win32 -I. -Iextend arch/win32/*.c | \ - sed -e "s/^\(.*\)\.o:/arch\\\\win32\\\\\1.obj:/" \ - -e "s:/:\\\\:g") >> depend.win - -echo "!endif" >> depend.win - -# eof diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def b/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def deleted file mode 100644 index f34788659..000000000 --- a/Appl/Breadbox/testapps/ttf2/FreeType/arch/win32/ttf.def +++ /dev/null @@ -1,127 +0,0 @@ -; This definition file to be used to built the library as DLL -; has been generated automatically with the script `makedef' on -; 03-Sep-1999. - -LIBRARY ft13_32 -DESCRIPTION 'FreeType 1.3 32-bit DLL © 1996-1999 Turner, Wilhelm, Lemberg' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE -EXPORTS - - TT_FreeType_Version - TT_Init_FreeType - TT_Done_FreeType - TT_Set_Raster_Gray_Palette - TT_Open_Face - TT_Open_Collection - TT_Get_Face_Properties - TT_Set_Face_Pointer - TT_Get_Face_Pointer - TT_Flush_Face - TT_Get_Face_Metrics - TT_Close_Face - TT_Get_Font_Data - TT_New_Instance - TT_Set_Instance_Resolutions - TT_Set_Instance_CharSize - TT_Set_Instance_CharSizes - TT_Set_Instance_PixelSizes - TT_Set_Instance_Transform_Flags - TT_Get_Instance_Metrics - TT_Set_Instance_Pointer - TT_Get_Instance_Pointer - TT_Done_Instance - TT_New_Glyph - TT_Done_Glyph - TT_Load_Glyph - TT_Get_Glyph_Outline - TT_Get_Glyph_Metrics - TT_Get_Glyph_Big_Metrics - TT_Get_Glyph_Bitmap - TT_Get_Glyph_Pixmap - TT_New_Outline - TT_Done_Outline - TT_Copy_Outline - TT_Get_Outline_Bitmap - TT_Get_Outline_Pixmap - TT_Get_Outline_BBox - TT_Transform_Outline - TT_Translate_Outline - TT_Transform_Vector - TT_MulDiv - TT_MulFix - TT_Get_CharMap_Count - TT_Get_CharMap_ID - TT_Get_CharMap - TT_Char_Index - TT_Get_Name_Count - TT_Get_Name_ID - TT_Get_Name_String - TT_Register_Extension - TT_Extension_Get - TT_Use_Stream - TT_Done_Stream - TT_Flush_Stream - TT_Read_File - TT_Seek_File - TT_Skip_File - TT_Read_At_File - TT_File_Pos - TT_Stream_Size - TT_Null_FileFrame - TT_Access_Frame - TT_Check_And_Access_Frame - TT_Forget_Frame - TT_Get_Char - TT_Get_Short - TT_Get_Long - TT_LookUp_Table - TT_Alloc - TT_Realloc - TT_Free - TT_CharMap_First - TT_CharMap_Next - TT_CharMap_Last - TT_ErrToString18 - TT_Get_Face_Gasp_Flags - TT_Init_GDEF_Extension - TT_Load_GDEF_Table - TT_GDEF_Get_Glyph_Property - TT_GDEF_Build_ClassDefinition - TT_Init_GPOS_Extension - TT_Load_GPOS_Table - TT_GPOS_Select_Script - TT_GPOS_Select_Language - TT_GPOS_Select_Feature - TT_GPOS_Query_Scripts - TT_GPOS_Query_Languages - TT_GPOS_Query_Features - TT_GPOS_Add_Feature - TT_GPOS_Clear_Features - TT_Init_GSUB_Extension - TT_Load_GSUB_Table - TT_GSUB_Select_Script - TT_GSUB_Select_Language - TT_GSUB_Select_Feature - TT_GSUB_Query_Scripts - TT_GSUB_Query_Languages - TT_GSUB_Query_Features - TT_GSUB_Add_Feature - TT_GSUB_Clear_Features - TT_GSUB_Register_Alternate_Function - TT_GSUB_Apply_String - TT_GSUB_Add_String - TT_Init_Kerning_Extension - TT_Get_Kerning_Directory - TT_Load_Kerning_Table - TT_Init_Post_Extension - TT_Load_PS_Names - TT_Get_PS_Name - TT_Init_SBit_Extension - TT_Get_Face_Bitmaps - TT_New_SBit_Image - TT_Done_SBit_Image - TT_Get_SBit_Strike - TT_Load_Glyph_Bitmap - TT_Get_Face_Widths diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h index ddb0a4d73..efe9b5838 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/freetype.h @@ -1078,22 +1078,6 @@ /* ----------------- character mapping support --------------- */ - /* Return the number of character mappings found in this file. */ - /* Returns -1 in case of failure (invalid face handle). */ - /* */ - /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ - /* */ - /* It is retained for backwards compatibility only and will */ - /* fail on 16bit systems. */ - /* */ - /* You can now get the charmap count in the `num_CharMaps' */ - /* field of a face's properties. */ - /* */ - - EXPORT_DEF - int TT_Get_CharMap_Count( TT_Face face ); - - /* Return the ID of charmap number `charmapIndex' of a given face */ /* used to enumerate the charmaps present in a TrueType file. */ @@ -1129,21 +1113,6 @@ /* --------------------- names table support ------------------- */ - /* Return the number of name strings found in the name table. */ - /* Returns -1 in case of failure (invalid face handle). */ - /* */ - /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ - /* */ - /* It is retained for backwards compatibility only and will */ - /* fail on 16bit systems. */ - /* */ - /* You can now get the number of name strings in a face with */ - /* the `num_Names' field of its properties. */ - - EXPORT_DEF - int TT_Get_Name_Count( TT_Face face ); - - /* Return the ID of the name number `nameIndex' of a given face */ /* used to enumerate the charmaps present in a TrueType file. */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index af673cfad..fb5c1ff7d 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -1960,34 +1960,6 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, /* ----------------- character mappings support ------------- */ -/******************************************************************* - * - * Function : TT_Get_CharMap_Count - * - * Description : Returns the number of charmaps in a given face. - * - * Input : face face object handle - * - * Output : Number of tables. -1 in case of error (bad handle). - * - * Note : DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! - * - * It is retained for backwards compatibility only and will - * fail on 16bit systems. - * - * MT-Safe : YES ! - * - ******************************************************************/ - - EXPORT_FUNC - int TT_Get_CharMap_Count( TT_Face face ) - { - PFace faze = HANDLE_Face( face ); - - return ( faze ? faze->numCMaps : -1 ); - } - - /******************************************************************* * * Function : TT_Get_CharMap_ID @@ -2126,41 +2098,6 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, } -/******************************************************************* - * - * Function : TT_Get_Name_Count - * - * Description : Returns the number of strings found in the - * name table. - * - * Input : face face handle - * - * Output : number of strings. - * - * Notes : Returns -1 on error (invalid handle). - * - * DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! - * - * It is retained for backwards compatibility only and will - * fail on 16bit systems. - * - * MT-Safe : YES! - * - ******************************************************************/ - - EXPORT_FUNC - int TT_Get_Name_Count( TT_Face face ) - { - PFace faze = HANDLE_Face( face ); - - - if ( !faze ) - return -1; - - return faze->nameTable.numNameRecords; - } - - /******************************************************************* * * Function : TT_Get_Name_ID @@ -2319,34 +2256,4 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, } - /************************ callback definition ******************/ - - /* Register a new callback to the TrueType engine -- this should */ - /* only be used by higher-level libraries, not typical clients */ - /* */ - /* This is not part of the current FreeType release, thus */ - /* undefined... */ - -#if 0 - EXPORT_FUNC - TT_Error TT_Register_Callback( TT_Engine engine, - int callback_id, - void* callback_ptr ) - { - PEngine_Instance eng = HANDLE_Engine( engine ); - - - if ( !eng ) - return TT_Err_Invalid_Argument; - - /* currently, we only support one callback */ - if (callback_id != TT_Callback_Glyph_Outline_Load) - return TT_Err_Invalid_Argument; - - eng->glCallback = (TT_Glyph_Loader_Callback)callback_ptr; - return TT_Err_Ok; - } -#endif /* 0 */ - - /* END */ From 9c83a3ac0d142a72c25137ad5845bf53e781b6df Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 19 Aug 2022 20:38:11 +0200 Subject: [PATCH 064/246] Further references to TEngine_Instance changed to chunk. --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 32 ++++----- .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 2 +- .../testapps/ttf2/FreeType/ttengine.h | 1 + .../testapps/ttf2/FreeType/ttextend.c | 19 +++--- .../testapps/ttf2/FreeType/ttextend.h | 2 +- .../testapps/ttf2/FreeType/ttmemory.h | 3 - Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 68 ++++--------------- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 6 +- .../testapps/ttf2/FreeType/ttraster.c | 9 ++- 9 files changed, 45 insertions(+), 97 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index fb5c1ff7d..7ad1a6a60 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -148,7 +148,7 @@ #undef TT_FAIL /* create the engine lock */ - MUTEX_Create( ELEMENT( PEngine_Instance, engine, lock ) ); + MUTEX_Create( ENGINE_ELEMENT( lock ) ); return TT_Err_Ok; Fail: @@ -185,7 +185,7 @@ if ( !engine ) return TT_Err_Ok; - MUTEX_Destroy( ELEMENT( PEngine_Instance, engine, lock ) ); + MUTEX_Destroy( ENGINE_ELEMENT( lock ) ); TTRaster_Done( engine ); TTObjs_Done ( engine ); @@ -225,7 +225,6 @@ FileHandle file, TT_Face* face ) { - PEngine_Instance _engine; TFont_Input input; TT_Error error; TT_Stream stream; @@ -235,9 +234,7 @@ CHECK_FILE( file ); CHECK_CHUNK( engine ); - _engine = DEREF( engine ); - - if ( !engine || !_engine ) + if ( !engine ) return TT_Err_Invalid_Engine; /* open the file */ @@ -247,10 +244,10 @@ input.stream = stream; input.fontIndex = 0; - input.engine = _engine; + input.engine = engine; /* Create and load the new face object - this is thread-safe */ - error = CACHE_New( _engine->objs_face_cache, + error = CACHE_New( ENGINE_ELEMENT( objs_face_cache ), _face, &input ); @@ -563,7 +560,8 @@ EXPORT_FUNC TT_Error TT_Close_Face( TT_Face face ) { - PFace _face = HANDLE_Face( face ); + PFace _face = HANDLE_Face( face ); + TT_Engine engine = _face->engine; if ( !_face ) @@ -572,7 +570,7 @@ TT_Close_Stream( &_face->stream ); /* delete the face object -- this is thread-safe */ - return CACHE_Done( ENGINE_ELEMENT(_face->engine, objs_face_cache), _face ); + return CACHE_Done( ENGINE_ELEMENT( objs_face_cache ), _face ); } @@ -1380,7 +1378,6 @@ TT_F26Dot6 xOffset, TT_F26Dot6 yOffset ) { - PEngine_Instance _engine; TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1394,7 +1391,7 @@ //engine = _glyph->face->engine; //HANDLE_Set(engine,_engine); - _engine = _glyph->face->engine; + engine = _glyph->face->engine; outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1431,7 +1428,6 @@ MemHandle bitmapBlock, Handle regionPath ) { - PEngine_Instance _engine; TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1487,7 +1483,6 @@ GStateHandle gstate, TT_UShort controlFlags ) { - PEngine_Instance _engine; TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1640,19 +1635,18 @@ TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine = DEREF( engine ); TT_Error error; - if ( !_engine ) + if ( !engine ) return TT_Err_Invalid_Engine; if ( !outline || !map ) return TT_Err_Invalid_Argument; - MUTEX_Lock( _engine->raster_lock ); - error = RENDER_Glyph( outline, map ); - MUTEX_Release( _engine->raster_lock ); + MUTEX_Lock( ENGINE_ELEMENT( raster_lock ) ); + error = Render_Glyph( ENGINE_ELEMENT( raster_component ), outline, map ); + MUTEX_Release( ENGINE_ELEMENT( raster_lock ) ); return error; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index 4ee3ef656..688857958 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -35,7 +35,7 @@ /* The macro FREE_Elements aliases the current engine instance's */ /* free list_elements recycle list. */ #define FREE_Elements ( _engine->list_free_elements ) -#define GFREE_Elements ( ELEMENT( PEngine_Instance, engine, list_free_elements ) ) +#define GFREE_Elements ( ENGINE_ELEMENT( list_free_elements ) ) /* Redefinition of LOCK and UNLOCK macros for New_Element and Done_Element */ /* Note: The macros are redefined below for the cache functions */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h index eff09089f..8a98fa9bd 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h @@ -78,6 +78,7 @@ typedef struct TEngine_Instance_ TEngine_Instance; typedef TEngine_Instance* PEngine_Instance; +#define ENGINE_ELEMENT( _element_ ) ELEMENT( PEngine_Instance, engine, _element_ ) #ifdef TT_CONFIG_OPTION_THREAD_SAFE /* for re-entrant builds */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index 514b9a096..026c70838 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -59,7 +59,7 @@ exts->num_extensions = 0; exts->cur_offset = 0; - ELEMENT( PEngine_Instance, engine, extension_component ) = (void*)exts; + ENGINE_ELEMENT( extension_component ) = (void*)exts; return TT_Err_Ok; } @@ -70,7 +70,7 @@ LOCAL_FUNC TT_Error TTExtend_Done( TT_Engine engine ) { - FREE( ELEMENT( PEngine_Instance, engine, extension_component ) ); + FREE( ENGINE_ELEMENT( extension_component ) ); return TT_Err_Ok; } @@ -78,7 +78,7 @@ /* Register a new extension */ EXPORT_FUNC - TT_Error TT_Register_Extension( PEngine_Instance engine, + TT_Error TT_Register_Extension( TT_Engine engine, Long id, Long size, PExt_Constructor create, @@ -89,7 +89,7 @@ Int p; - exts = (PExtension_Registry)engine->extension_component; + exts = (PExtension_Registry)ENGINE_ELEMENT( extension_component ); if ( !exts ) return TT_Err_Ok; @@ -120,6 +120,7 @@ Long extension_id, void** extension_block ) { + TT_Engine engine = face->engine; PExtension_Registry registry; PExtension_Class clazz; Int n; @@ -128,7 +129,7 @@ if ( !face->extension ) return TT_Err_Extensions_Unsupported; - registry = face->engine->extension_component; + registry = ENGINE_ELEMENT( extension_component ); for ( n = 0; n < face->n_extensions; n++ ) { @@ -150,14 +151,14 @@ LOCAL_FUNC TT_Error Extension_Destroy( PFace face ) { - PEngine_Instance engine = face->engine; + TT_Engine engine = face->engine; PExtension_Registry registry; PExtension_Class clazz; Int n; PByte ext; - registry = (PExtension_Registry)engine->extension_component; + registry = (PExtension_Registry)ENGINE_ELEMENT( extension_component ); for ( n = 0; n < face->n_extensions; n++ ) { @@ -183,7 +184,7 @@ LOCAL_FUNC TT_Error Extension_Create( PFace face ) { - PEngine_Instance engine = face->engine; + TT_Engine engine = face->engine; PExtension_Registry registry; PExtension_Class clazz; TT_Error error; @@ -191,7 +192,7 @@ PByte ext; - registry = (PExtension_Registry)engine->extension_component; + registry = (PExtension_Registry)ENGINE_ELEMENT( extension_component ); face->n_extensions = registry->num_extensions; if ( ALLOC( face->extension, registry->cur_offset ) ) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h index 82aeb9ad0..0b323affa 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h @@ -123,7 +123,7 @@ /* Register a new extension. Called by extension */ /* service initializers. */ EXPORT_DEF - TT_Error TT_Register_Extension( PEngine_Instance engine, + TT_Error TT_Register_Extension( TT_Engine engine, Long id, Long size, PExt_Constructor create, diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h index abc0d7256..4df205468 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttmemory.h @@ -111,9 +111,6 @@ #define ELEMENT( _typ_, _handle_, _element_ ) \ ( ((_typ_)DEREF(_handle_))->_element_ ) -#define ENGINE_ELEMENT( _handle_, _element_ ) \ - ELEMENT( PEngine_Instance, _handle_, _element_ ) - #define CHECK_POINTER( _ptr_ ) ECCheckBounds( _ptr_ ) #define CHECK_LMEM( _handle_ ) ECCheckLMemHandle( _handle_ ) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c index de3186473..b2d76e785 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -45,7 +45,7 @@ LOCAL_FUNC PExecution_Context New_Context( PFace face ) { - PEngine_Instance engine; + TT_Engine engine; PExecution_Context exec; @@ -53,7 +53,7 @@ return NULL; engine = face->engine; - CACHE_New( engine->objs_exec_cache, exec, face ); + CACHE_New( ENGINE_ELEMENT( objs_exec_cache ), exec, face ); return exec; } @@ -69,59 +69,17 @@ LOCAL_FUNC TT_Error Done_Context( PExecution_Context exec ) { - PEngine_Instance engine; + TT_Engine engine; if ( !exec ) return TT_Err_Ok; engine = exec->face->engine; - return CACHE_Done( engine->objs_exec_cache, exec ); + return CACHE_Done( ENGINE_ELEMENT( objs_exec_cache ), exec ); } -#if 0 - -/******************************************************************* - * - * Function : New_Instance - * - * Description : Creates a new instance for a given face object. - * - ******************************************************************/ - - LOCAL_FUNC - PInstance New_Instance( PFace face ) - { - PInstance ins; - - - if ( !face ) - return NULL; - - CACHE_New( &face->instances, ins, face ); - - return ins; - } - - -/******************************************************************* - * - * Function : Done_Instance - * - * Description : Discards an instance. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error Done_Instance( PInstance instance ) - { - return CACHE_Done( &instance->owner->instances, instance ); - } - -#endif - - /******************************************************************* * * * GLYPH ZONE FUNCTIONS * @@ -1182,7 +1140,7 @@ TT_Error Face_Create( void* _face, void* _input ) { - PEngine_Instance engine; + TT_Engine engine; TFont_Input* input = (TFont_Input*)_input; PFace face = (PFace)_face; @@ -1196,13 +1154,13 @@ MUTEX_Create( face->lock ); - Cache_Create( engine, - engine->objs_instance_class, + Cache_Create( DEREF( engine ), + ENGINE_ELEMENT( objs_instance_class ), &face->instances, &face->lock ); - Cache_Create( engine, - engine->objs_glyph_class, + Cache_Create( DEREF( engine ), + ENGINE_ELEMENT( objs_glyph_class ), &face->glyphs, &face->lock ); @@ -1484,12 +1442,12 @@ /* destroy all active faces and contexts before releasing the */ /* caches */ - Cache_Destroy( (TCache*)ELEMENT( PEngine_Instance, engine, objs_exec_cache ) ); - Cache_Destroy( (TCache*)ELEMENT( PEngine_Instance, engine, objs_face_cache ) ); + Cache_Destroy( (TCache*)ENGINE_ELEMENT( objs_exec_cache ) ); + Cache_Destroy( (TCache*)ENGINE_ELEMENT( objs_face_cache ) ); /* Now frees caches and cache classes */ - FREE( ELEMENT( PEngine_Instance, engine, objs_exec_cache ) ); - FREE( ELEMENT( PEngine_Instance, engine, objs_face_cache ) ); + FREE( ENGINE_ELEMENT( objs_exec_cache ) ); + FREE( ENGINE_ELEMENT( objs_face_cache ) ); return TT_Err_Ok; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index be10e578a..68e83b041 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -478,8 +478,7 @@ struct TFace_ { /* parent engine instance for the face object */ - PEngine_Instance engine; - //TT_Engine engine; + TT_Engine engine; /* i/o stream */ TT_Stream stream; @@ -775,8 +774,7 @@ { TT_Stream stream; /* input stream */ ULong fontIndex; /* index of font in collection */ - PEngine_Instance engine; /* parent engine instance */ - + TT_Engine engine; /* parent engine instance */ }; typedef struct TFont_Input_ TFont_Input; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c index 4a7a2e1e7..a1ee1a157 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttraster.c @@ -2718,7 +2718,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, CHECK_CHUNK( engine ); - ras = (TRaster_Instance*)ELEMENT( PEngine_Instance, engine, raster_component ); + ras = (TRaster_Instance*)ENGINE_ELEMENT( raster_component ); CHECK_POINTER( ras ); @@ -2728,7 +2728,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, FREE( ras->buff ); #ifndef TT_CONFIG_OPTION_STATIC_RASTER - FREE( ELEMENT( PEngine_Instance, engine, raster_component ) ); + FREE( ENGINE_ELEMENT( raster_component ) ); #endif return TT_Err_Ok; @@ -2740,16 +2740,15 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, { TT_Error error; TRaster_Instance* ras; - PEngine_Instance _engine = DEREF( engine ); #ifdef TT_CONFIG_OPTION_STATIC_RASTER ras = engine->raster_component = &cur_ras; #else - if ( ALLOC( _engine->raster_component, sizeof ( TRaster_Instance ) ) ) + if ( ALLOC( ENGINE_ELEMENT( raster_component ), sizeof ( TRaster_Instance ) ) ) return error; - ras = (TRaster_Instance*)_engine->raster_component; + ras = (TRaster_Instance*)ENGINE_ELEMENT( raster_component ); #endif if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) From 8f9fc33e8d3a7ea9993a38843c5b07f0ce66b1a5 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 19 Aug 2022 23:12:01 +0200 Subject: [PATCH 065/246] All relevant references to TT_Engine changed to chunk. --- .../Breadbox/testapps/ttf2/FreeType/ftxkern.c | 9 ++-- .../Breadbox/testapps/ttf2/FreeType/ttcache.c | 34 ++++++------ .../Breadbox/testapps/ttf2/FreeType/ttcache.h | 10 ++-- .../testapps/ttf2/FreeType/ttextend.h | 2 +- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 28 +++++----- Appl/Breadbox/testapps/ttf2/out.txt | 54 ------------------- 6 files changed, 41 insertions(+), 96 deletions(-) delete mode 100644 Appl/Breadbox/testapps/ttf2/out.txt diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c index 70c908b7c..c319c5516 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c @@ -544,18 +544,15 @@ EXPORT_FUNC TT_Error TT_Init_Kerning_Extension( TT_Engine engine ) { - PEngine_Instance _engine; TT_Error error; - ECCheckLMemChunk( DEREF( engine ) ); - - _engine = DEREF( engine ); + CHECK_CHUNK( engine ); - if ( !engine || !_engine ) + if ( !engine ) return TT_Err_Invalid_Engine; - error = TT_Register_Extension( _engine, + error = TT_Register_Extension( engine, KERNING_ID, sizeof ( TT_Kerning ), Kerning_Create, diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c index 688857958..a54aeb46a 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.c @@ -60,16 +60,16 @@ ******************************************************************/ static - PList_Element Element_New( PEngine_Instance _engine ) + PList_Element Element_New( TT_Engine engine ) { PList_Element element; - LOCK(); - if ( FREE_Elements ) + MUTEX_Lock( ENGINE_ELEMENT( lock ) ); + if ( GFREE_Elements ) { - element = (PList_Element)FREE_Elements; - FREE_Elements = element->next; + element = (PList_Element)GFREE_Elements; + GFREE_Elements = element->next; } else { @@ -81,7 +81,7 @@ } /* Note: in case of failure, Alloc sets the pointer to NULL */ - UNLOCK(); + MUTEX_Release( ENGINE_ELEMENT( lock ) ); return element; } @@ -102,14 +102,14 @@ ******************************************************************/ static - void Element_Done( PEngine_Instance _engine, - PList_Element element ) + void Element_Done( TT_Engine engine, + PList_Element element ) { - LOCK(); + MUTEX_Lock( ENGINE_ELEMENT( lock ) ); /* Simply add the list element to the recycle list */ - element->next = (PList_Element)FREE_Elements; - FREE_Elements = element; - UNLOCK(); + element->next = (PList_Element)GFREE_Elements; + GFREE_Elements = element; + MUTEX_Release( ENGINE_ELEMENT( lock ) ); } @@ -147,12 +147,12 @@ ******************************************************************/ LOCAL_FUNC - TT_Error Cache_Create( PEngine_Instance _engine, - PCache_Class clazz, - TCache* cache, - TMutex* lock ) + TT_Error Cache_Create( TT_Engine engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ) { - cache->engine = _engine; + cache->engine = engine; cache->clazz = clazz; cache->lock = lock; cache->idle_count = 0; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h index 1e89bced6..ac7d74347 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcache.h @@ -143,7 +143,7 @@ struct TCache_ { - PEngine_Instance engine; + TT_Engine engine; PCache_Class clazz; /* 'class' is a reserved word in C++ */ TMutex* lock; TSingle_List active; @@ -166,10 +166,10 @@ /* doesn't need protection */ LOCAL_DEF - TT_Error Cache_Create( PEngine_Instance engine, - PCache_Class clazz, - TCache* cache, - TMutex* lock ); + TT_Error Cache_Create( TT_Engine engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ); /* Destroys a cache and all its listed objects */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h index 0b323affa..609dd508b 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.h @@ -137,7 +137,7 @@ /* Finalize the extension component */ LOCAL_DEF - TT_Error TTExtend_Done( PEngine_Instance engine ); + TT_Error TTExtend_Done( TT_Engine engine ); /* Create an extension within a face object. Called by the */ /* face object constructor. */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c index b2d76e785..297dd6ccd 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -1154,12 +1154,12 @@ MUTEX_Create( face->lock ); - Cache_Create( DEREF( engine ), + Cache_Create( engine, ENGINE_ELEMENT( objs_instance_class ), &face->instances, &face->lock ); - Cache_Create( DEREF( engine ), + Cache_Create( engine, ENGINE_ELEMENT( objs_glyph_class ), &face->glyphs, &face->lock ); @@ -1381,7 +1381,9 @@ { PCache face_cache, exec_cache; TT_Error error; - PEngine_Instance _engine = DEREF( engine ); + + + CHECK_CHUNK( engine ); face_cache = 0; exec_cache = 0; @@ -1391,25 +1393,25 @@ goto Fail; /* create face cache */ - error = Cache_Create( _engine, (PCache_Class)&objs_face_class, - face_cache, &_engine->lock ); + error = Cache_Create( engine, (PCache_Class)&objs_face_class, + face_cache, &ENGINE_ELEMENT( lock ) ); if ( error ) goto Fail; - _engine->objs_face_cache = face_cache; + ENGINE_ELEMENT( objs_face_cache ) = face_cache; - error = Cache_Create( _engine, (PCache_Class)&objs_exec_class, - exec_cache, &_engine->lock ); + error = Cache_Create( engine, (PCache_Class)&objs_exec_class, + exec_cache, &ENGINE_ELEMENT( lock ) ); if ( error ) goto Fail; - _engine->objs_exec_cache = exec_cache; + ENGINE_ELEMENT( objs_exec_cache ) = exec_cache; - _engine->objs_face_class = (PCache_Class)&objs_face_class; - _engine->objs_instance_class = (PCache_Class)&objs_instance_class; - _engine->objs_execution_class = (PCache_Class)&objs_exec_class; - _engine->objs_glyph_class = (PCache_Class)&objs_glyph_class; + ENGINE_ELEMENT( objs_face_class ) = (PCache_Class)&objs_face_class; + ENGINE_ELEMENT( objs_instance_class ) = (PCache_Class)&objs_instance_class; + ENGINE_ELEMENT( objs_execution_class ) = (PCache_Class)&objs_exec_class; + ENGINE_ELEMENT( objs_glyph_class ) = (PCache_Class)&objs_glyph_class; goto Exit; diff --git a/Appl/Breadbox/testapps/ttf2/out.txt b/Appl/Breadbox/testapps/ttf2/out.txt deleted file mode 100644 index 2c4330302..000000000 --- a/Appl/Breadbox/testapps/ttf2/out.txt +++ /dev/null @@ -1,54 +0,0 @@ -FreeType/ttraster.c: if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) -FreeType/ttraster.c: if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) -FreeType/ttextend.c: if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) -FreeType/ttextend.c: if ( ALLOC( face->extension, registry->cur_offset ) ) -FreeType/ttapi.c: if ( ALLOC( outline->points, numPoints*2*sizeof ( TT_F26Dot6 ) ) || -FreeType/ttapi.c: ALLOC( outline->flags, numPoints *sizeof ( Byte ) ) || -FreeType/ttapi.c: ALLOC( outline->contours, numContours*sizeof ( UShort ) ) ) -FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) ) -FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern2->leftClass.classes, -FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern2->rightClass.classes, -FreeType/ftxkern.c: if ( ALLOC( kern2->array, array_size ) ) -FreeType/ftxkern.c: if ( ALLOC_ARRAY( kern->tables, num_tables, TT_Kern_Subtable ) ) -FreeType/ttload.c: if ( ALLOC_ARRAY( face->ttcHeader.TableDirectory, -FreeType/ttload.c: if ( ALLOC_ARRAY( face->dirTables, -FreeType/ttload.c: if ( ALLOC_ARRAY( gaspranges, gas->numRanges, GaspRange ) || -FreeType/ttload.c: if ( ALLOC_ARRAY( *longs, num_longs, TLongMetrics ) || -FreeType/ttload.c: ALLOC_ARRAY( *shorts, num_shorts, TShortMetrics ) ) -FreeType/ttload.c: if ( ALLOC_ARRAY( face->glyphLocations, -FreeType/ttload.c: if ( ALLOC_ARRAY( face->glyphLocations, -FreeType/ttload.c: if ( ALLOC_ARRAY( names->names, -FreeType/ttload.c: if ( ALLOC( storage, bytes ) || -FreeType/ttload.c: if ( ALLOC_ARRAY( face->cvt, -FreeType/ttload.c: if ( ALLOC_ARRAY( face->cMaps, -FreeType/ttload.c: if ( ALLOC( face->fontProgram, -FreeType/ttload.c: if ( ALLOC( face->cvtProgram, -FreeType/ttload.c: if ( ALLOC( hdmx.records, sizeof ( TT_Hdmx_Record ) * hdmx.num_records ) ) -FreeType/ttload.c: if ( ALLOC( rec->widths, num_glyphs ) || -FreeType/ttfile.c: if ( ALLOC( files.frame_cache, FRAME_CACHE_SIZE ) ) -FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) -FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) -FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) -FreeType/ttfile.c: if ( ALLOC( CUR_Frame.address, size ) ) -FreeType/ttfile.c: if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) -FreeType/ttfile.c: if ( ALLOC( stream_rec->name, len ) ) -FreeType/ttcmap.c: if ( ALLOC( cmap0->glyphIdArray, 256L ) || -FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap2->subHeaderKeys, 256, UShort ) || -FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap2->subHeaders, -FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap2->glyphIdArray, l, UShort ) || -FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap4->segments, -FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap4->glyphIdArray, l , UShort ) || -FreeType/ttcmap.c: if ( ALLOC_ARRAY( cmap6->glyphIdArray, -FreeType/ttobjs.c: if ( ALLOC( pts->org, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || -FreeType/ttobjs.c: ALLOC( pts->cur, maxPoints * 2 * sizeof ( TT_F26Dot6 ) ) || -FreeType/ttobjs.c: ALLOC( pts->touch, maxPoints * sizeof ( Byte ) ) || -FreeType/ttobjs.c: ALLOC( pts->contours, maxContours * sizeof ( Short ) ) ) -FreeType/ttobjs.c: if ( ALLOC_ARRAY( exec->callStack, exec->callSize, TCallRecord ) ) -FreeType/ttobjs.c: if ( ALLOC( *buff, new_max * multiplier ) ) -FreeType/ttobjs.c: if ( ALLOC_ARRAY( ins->FDefs, ins->maxFDefs, TDefRecord ) || -FreeType/ttobjs.c: ALLOC_ARRAY( ins->IDefs, ins->maxIDefs, TDefRecord ) || -FreeType/ttobjs.c: ALLOC_ARRAY( ins->cvt, ins->cvtSize, Long ) || -FreeType/ttobjs.c: ALLOC_ARRAY( ins->storage, ins->storeSize, Long ) ) -FreeType/ttobjs.c: if ( ALLOC( face_cache, sizeof ( TCache ) ) || -FreeType/ttobjs.c: ALLOC( exec_cache, sizeof ( TCache ) ) ) - From 86c708d27b86f95ae1ea2a17b119dee9a280d1cf Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 22 Aug 2022 21:38:19 +0200 Subject: [PATCH 066/246] Move Extension_Registry from heap to chunk. --- .../testapps/ttf2/FreeType/ttengine.h | 26 ++++---- .../testapps/ttf2/FreeType/ttextend.c | 63 ++++++++++--------- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 2 +- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h index 8a98fa9bd..4ed12e351 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h @@ -49,24 +49,24 @@ struct TEngine_Instance_ { - TMutex lock; /* engine lock */ + TMutex lock; /* engine lock */ - void* list_free_elements; + void* list_free_elements; - void* objs_face_class; /* the face cache class */ - void* objs_instance_class; /* the instance cache class */ - void* objs_execution_class; /* the context cache class */ - void* objs_glyph_class; /* the glyph cache class */ + void* objs_face_class; /* the face cache class */ + void* objs_instance_class; /* the instance cache class */ + void* objs_execution_class; /* the context cache class */ + void* objs_glyph_class; /* the glyph cache class */ - void* objs_face_cache; /* these caches are used to track */ - void* objs_exec_cache; /* the current face and execution */ - /* context objects */ + void* objs_face_cache; /* these caches are used to track */ + void* objs_exec_cache; /* the current face and execution */ + /* context objects */ - void* file_component; /* ttfile implementation dependent */ + void* file_component; /* ttfile implementation dependent */ - TMutex raster_lock; /* mutex for this engine's render pool */ - void* raster_component; /* ttraster implementation depedent */ - void* extension_component; /* extensions dependent */ + TMutex raster_lock; /* mutex for this engine's render pool */ + void* raster_component; /* ttraster implementation depedent */ + ChunkHandle extension_component; /* extensions dependent */ }; /* NOTE : The raster's lock is only acquired by the Render_Glyph and */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index 026c70838..74dc6654a 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -38,7 +38,10 @@ typedef struct TExtension_Registry_ TExtension_Registry; typedef TExtension_Registry* PExtension_Registry; + typedef ChunkHandle CExtension_Registry; + #define EXTENSION_ELEMENT( _ext_element_ ) \ + ELEMENT( PExtension_Registry, registry, _ext_element_ ) /* Initialize the extension component */ @@ -47,19 +50,19 @@ TT_Error TTExtend_Init( TT_Engine engine ) { TT_Error error; - PExtension_Registry exts; + CExtension_Registry registry; CHECK_CHUNK( engine ); - if ( ALLOC( exts, sizeof ( TExtension_Registry ) ) ) + if ( GALLOC( registry, sizeof ( TExtension_Registry ) ) ) return error; - CHECK_POINTER( exts ); + CHECK_CHUNK( registry ); - exts->num_extensions = 0; - exts->cur_offset = 0; - ENGINE_ELEMENT( extension_component ) = (void*)exts; + EXTENSION_ELEMENT( num_extensions ) = 0; + EXTENSION_ELEMENT( cur_offset ) = 0; + ENGINE_ELEMENT( extension_component ) = registry; return TT_Err_Ok; } @@ -70,7 +73,9 @@ LOCAL_FUNC TT_Error TTExtend_Done( TT_Engine engine ) { - FREE( ENGINE_ELEMENT( extension_component ) ); + CHECK_CHUNK( engine ); + + GFREE( ENGINE_ELEMENT( extension_component ) ); return TT_Err_Ok; } @@ -84,30 +89,32 @@ PExt_Constructor create, PExt_Destructor destroy ) { - PExtension_Registry exts; + CExtension_Registry registry; PExtension_Class clazz; Int p; - exts = (PExtension_Registry)ENGINE_ELEMENT( extension_component ); - if ( !exts ) + CHECK_CHUNK( engine ); + + registry = (CExtension_Registry)ENGINE_ELEMENT( extension_component ); + if ( !registry ) return TT_Err_Ok; - p = exts->num_extensions; + p = EXTENSION_ELEMENT( num_extensions ); if ( p >= TT_MAX_EXTENSIONS ) return TT_Err_Too_Many_Extensions; - clazz = exts->classes + p; + clazz = EXTENSION_ELEMENT( classes + p ); clazz->id = id; clazz->size = size; clazz->build = create; clazz->destroy = destroy; - clazz->offset = exts->cur_offset; + clazz->offset = EXTENSION_ELEMENT( cur_offset ); - exts->num_extensions++; - exts->cur_offset += ( size + ALIGNMENT-1 ) & -ALIGNMENT; + EXTENSION_ELEMENT( num_extensions++ ); + EXTENSION_ELEMENT( cur_offset ) += ( size + ALIGNMENT-1 ) & -ALIGNMENT; return TT_Err_Ok; } @@ -121,7 +128,7 @@ void** extension_block ) { TT_Engine engine = face->engine; - PExtension_Registry registry; + CExtension_Registry registry; PExtension_Class clazz; Int n; @@ -133,10 +140,10 @@ for ( n = 0; n < face->n_extensions; n++ ) { - clazz = registry->classes + n; + clazz = EXTENSION_ELEMENT( classes + n ); if ( clazz->id == extension_id ) { - *extension_block = (PByte)face->extension + clazz->offset; + *extension_block = (PByte)DEREF( face->extension ) + clazz->offset; return TT_Err_Ok; } } @@ -152,7 +159,7 @@ TT_Error Extension_Destroy( PFace face ) { TT_Engine engine = face->engine; - PExtension_Registry registry; + CExtension_Registry registry; PExtension_Class clazz; Int n; PByte ext; @@ -162,8 +169,8 @@ for ( n = 0; n < face->n_extensions; n++ ) { - clazz = registry->classes + n; - ext = (PByte)face->extension + clazz->offset; + clazz = EXTENSION_ELEMENT( classes + n ); + ext = (PByte)DEREF( face->extension ) + clazz->offset; /* the destructor is optional */ if ( clazz->destroy ) @@ -171,7 +178,7 @@ } /* destroy the face's extension block too */ - FREE( face->extension ); + GFREE( face->extension ); face->n_extensions = 0; return TT_Err_Ok; @@ -185,23 +192,23 @@ TT_Error Extension_Create( PFace face ) { TT_Engine engine = face->engine; - PExtension_Registry registry; + CExtension_Registry registry; PExtension_Class clazz; TT_Error error; Int n; PByte ext; - registry = (PExtension_Registry)ENGINE_ELEMENT( extension_component ); + registry = (CExtension_Registry)ENGINE_ELEMENT( extension_component ); - face->n_extensions = registry->num_extensions; - if ( ALLOC( face->extension, registry->cur_offset ) ) + face->n_extensions = EXTENSION_ELEMENT( num_extensions ); + if ( GALLOC( face->extension, EXTENSION_ELEMENT( cur_offset ) ) ) return error; for ( n = 0; n < face->n_extensions; n++ ) { - clazz = registry->classes + n; - ext = (PByte)face->extension + clazz->offset; + clazz = EXTENSION_ELEMENT( classes + n ); + ext = (PByte)DEREF( face->extension ) + clazz->offset; error = clazz->build( (void*)ext, face ); if ( error ) goto Fail; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index 68e83b041..e6ae355af 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -569,7 +569,7 @@ /* A typeless pointer to the face object extensions defined */ /* in the 'ttextend.*' files. */ - void* extension; + ChunkHandle extension; Int n_extensions; /* number of extensions */ /* Use extensions to provide additional capabilities to the */ From dddfc39b6b1c27ce6c6a668283264261324bbed5 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 25 Aug 2022 19:55:58 +0200 Subject: [PATCH 067/246] fix typo --- Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c index 74dc6654a..5790d516a 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttextend.c @@ -165,7 +165,7 @@ PByte ext; - registry = (PExtension_Registry)ENGINE_ELEMENT( extension_component ); + registry = (CExtension_Registry)ENGINE_ELEMENT( extension_component ); for ( n = 0; n < face->n_extensions; n++ ) { From 5448edbbc8eb1a9d6100595639b8bac47725d8da Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 26 Aug 2022 23:26:17 +0200 Subject: [PATCH 068/246] file_component from TEngine_Instance removed. --- Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c | 2 -- Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h | 2 -- Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c | 3 --- 3 files changed, 7 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c index 7ad1a6a60..1abda131e 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttapi.c @@ -45,10 +45,8 @@ #ifdef TT_STATIC_RASTER #define RAS_OPS /* void */ -#define RAS_OP /* void */ #else #define RAS_OPS ((TRaster_Instance*)_engine->raster_component), -#define RAS_OP ((TRaster_Instance*)_engine->raster_component) #endif /* TT_STATIC_RASTER */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h index 4ed12e351..362eea946 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttengine.h @@ -62,8 +62,6 @@ void* objs_exec_cache; /* the current face and execution */ /* context objects */ - void* file_component; /* ttfile implementation dependent */ - TMutex raster_lock; /* mutex for this engine's render pool */ void* raster_component; /* ttraster implementation depedent */ ChunkHandle extension_component; /* extensions dependent */ diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c index 28edd956e..c03d84e43 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttfile.c @@ -434,9 +434,6 @@ /*******************************************************************/ /*******************************************************************/ -/* a simple macro to access the file component's data */ -#define files ( *((TFile_Component*)engine.file_component) ) - #define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ #define CUR_Frame (*frame) From 40a2f458bcdf317908b9429e603be2743869bfe6 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 28 Aug 2022 18:25:50 +0200 Subject: [PATCH 069/246] Move TT_Kern_0 from heap to lmem. --- Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c | 18 ++++++++++-------- Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h | 11 +++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c index c319c5516..2f4286fa5 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c @@ -76,20 +76,22 @@ FORGET_Frame(); - if ( ALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) ) + if ( GALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) ) return error; + CHECK_CHUNK( kern0->pairs ); + if ( ACCESS_Frame( num_pairs * 6L ) ) goto Fail; for ( n = 0; n < num_pairs; n++ ) { - kern0->pairs[n].left = GET_UShort(); - kern0->pairs[n].right = GET_UShort(); - kern0->pairs[n].value = GET_UShort(); + ((TT_Kern_0_Pair*)DEREF(kern0->pairs))[n].left = GET_UShort(); + ((TT_Kern_0_Pair*)DEREF(kern0->pairs))[n].right = GET_UShort(); + ((TT_Kern_0_Pair*)DEREF(kern0->pairs))[n].value = GET_UShort(); - if ( kern0->pairs[n].left >= input->numGlyphs || - kern0->pairs[n].right >= input->numGlyphs ) + if (((TT_Kern_0_Pair*)DEREF(kern0->pairs))[n].left >= input->numGlyphs || + ((TT_Kern_0_Pair*)DEREF(kern0->pairs))[n].right >= input->numGlyphs ) { FORGET_Frame(); error = TT_Err_Invalid_Kerning_Table; @@ -105,7 +107,7 @@ return TT_Err_Ok; Fail: - FREE( kern0->pairs ); + GFREE( kern0->pairs ); return error; } @@ -391,7 +393,7 @@ switch ( sub->format ) { case 0: - FREE( sub->t.kern0.pairs ); + GFREE( sub->t.kern0.pairs ); sub->t.kern0.nPairs = 0; sub->t.kern0.searchRange = 0; sub->t.kern0.entrySelector = 0; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h index 719ec6e51..13ad847b2 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h @@ -72,13 +72,12 @@ extern "C" { struct TT_Kern_0_ { - TT_UShort nPairs; /* number of kerning pairs */ + TT_UShort nPairs; /* number of kerning pairs */ - TT_UShort searchRange; /* these values are defined by the TT spec */ - TT_UShort entrySelector; /* for table searchs. */ - TT_UShort rangeShift; - - TT_Kern_0_Pair* pairs; /* a table of nPairs `pairs' */ + TT_UShort searchRange; /* these values are defined by the TT spec */ + TT_UShort entrySelector; /* for table searchs. */ + TT_UShort rangeShift; + ChunkHandle pairs; /* a table of nPairs `pairs' */ }; typedef struct TT_Kern_0_ TT_Kern_0; From 8abea5280a695aece0ffd47f8ebcd178b00acc4f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 30 Aug 2022 20:34:49 +0200 Subject: [PATCH 070/246] Move TT_Kerning.tables from heap to lmem. --- .../Breadbox/testapps/ttf2/FreeType/ftxkern.c | 22 ++++++++++--------- .../Breadbox/testapps/ttf2/FreeType/ftxkern.h | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c index 2f4286fa5..c70c1e343 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c @@ -227,14 +227,16 @@ array_size = left_max + right_max + 2; - if ( ALLOC( kern2->array, array_size ) ) + if ( GALLOC( kern2->array, array_size ) ) goto Fail_Right; + CHECK_CHUNK( kern2->array ); + if ( ACCESS_Frame( array_size ) ) goto Fail_Array; for ( n = 0; n < array_size/2; n++ ) - kern2->array[n] = GET_Short(); + ((TT_FWord*)DEREF( kern2->array ))[n] = GET_Short(); FORGET_Frame(); @@ -243,7 +245,7 @@ return TT_Err_Ok; Fail_Array: - FREE( kern2->array ); + GFREE( kern2->array ); Fail_Right: FREE( kern2->rightClass.classes ); @@ -298,7 +300,7 @@ kern->version = 0; kern->nTables = 0; - kern->tables = NULL; + kern->tables = NullChunk; table = TT_LookUp_Table( face, TTAG_kern ); if ( table < 0 ) @@ -315,14 +317,14 @@ /* we don't set kern->nTables until we have allocated the array */ - if ( ALLOC_ARRAY( kern->tables, num_tables, TT_Kern_Subtable ) ) + if ( GALLOC_ARRAY( kern->tables, num_tables, TT_Kern_Subtable ) ) return error; kern->nTables = num_tables; /* now load the directory entries, but do _not_ load the tables ! */ - sub = kern->tables; + sub = (TT_Kern_Subtable*)DEREF(kern->tables); for ( table = 0; table < num_tables; table++ ) { @@ -385,7 +387,7 @@ /* scan the table directory and release loaded entries */ - sub = kern->tables; + sub = (TT_Kern_Subtable*)DEREF( kern->tables ); for ( n = 0; n < kern->nTables; n++ ) { if ( sub->loaded ) @@ -409,7 +411,7 @@ sub->t.kern2.rightClass.firstGlyph = 0; sub->t.kern2.rightClass.nGlyphs = 0; - FREE( sub->t.kern2.array ); + GFREE( sub->t.kern2.array ); sub->t.kern2.rowWidth = 0; break; @@ -427,7 +429,7 @@ sub++; } - FREE( kern->tables ); + GFREE( kern->tables ); kern->nTables = 0; return TT_Err_Ok; @@ -515,7 +517,7 @@ if ( kern_index >= kern->nTables ) return TT_Err_Invalid_Argument; - sub = kern->tables + kern_index; + sub = (TT_Kern_Subtable*)DEREF( kern->tables ) + kern_index; if ( sub->format != 0 && sub->format != 2 ) return TT_Err_Invalid_Kerning_Table_Format; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h index 13ad847b2..5603b71e6 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h @@ -104,7 +104,7 @@ extern "C" { TT_UShort rowWidth; /* length of one row in bytes */ TT_Kern_2_Class leftClass; /* left class table */ TT_Kern_2_Class rightClass; /* right class table */ - TT_FWord* array; /* 2-dimensional kerning values array */ + ChunkHandle array; /* 2-dimensional kerning values array */ }; typedef struct TT_Kern_2_ TT_Kern_2; @@ -137,7 +137,7 @@ extern "C" { TT_UShort version; /* kern table version number. starts at 0 */ TT_UShort nTables; /* number of tables */ - TT_Kern_Subtable* tables; /* the kerning sub-tables */ + ChunkHandle tables; /* the kerning sub-tables */ }; typedef struct TT_Kerning_ TT_Kerning; From f99daa0ab695655c9e03fdaf3bf79091e707629f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 30 Aug 2022 21:35:05 +0200 Subject: [PATCH 071/246] Move TT_Kern_2_Class.class from heap to lmem. --- .../Breadbox/testapps/ttf2/FreeType/ftxkern.c | 32 +++++++++++-------- .../Breadbox/testapps/ttf2/FreeType/ftxkern.h | 10 +++--- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c index c70c1e343..0031cb0dd 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.c @@ -170,18 +170,20 @@ FORGET_Frame(); - if ( ALLOC_ARRAY( kern2->leftClass.classes, - kern2->leftClass.nGlyphs, - UShort ) ) + if ( GALLOC_ARRAY( kern2->leftClass.classes, + kern2->leftClass.nGlyphs, + UShort ) ) return error; + CHECK_CHUNK( kern2->leftClass.classes ); + /* load left offsets */ if ( ACCESS_Frame( kern2->leftClass.nGlyphs * 2L ) ) goto Fail_Left; for ( n = 0; n < kern2->leftClass.nGlyphs; n++ ) - kern2->leftClass.classes[n] = GET_UShort(); + ((TT_UShort*)DEREF( kern2->leftClass.classes ))[n] = GET_UShort(); FORGET_Frame(); @@ -196,18 +198,20 @@ FORGET_Frame(); - if ( ALLOC_ARRAY( kern2->rightClass.classes, - kern2->rightClass.nGlyphs, - UShort ) ) + if ( GALLOC_ARRAY( kern2->rightClass.classes, + kern2->rightClass.nGlyphs, + UShort ) ) goto Fail_Left; + CHECK_CHUNK( kern2->rightClass.classes ); + /* load right offsets */ if ( ACCESS_Frame( kern2->rightClass.nGlyphs * 2L ) ) goto Fail_Right; for ( n = 0; n < kern2->rightClass.nGlyphs; n++ ) - kern2->rightClass.classes[n] = GET_UShort(); + ((TT_UShort*)DEREF( kern2->rightClass.classes ))[n] = GET_UShort(); FORGET_Frame(); @@ -220,10 +224,10 @@ left_max = right_max = 0; for ( n = 0; n < kern2->leftClass.nGlyphs; n++ ) - left_max = MAX( left_max, kern2->leftClass.classes[n] ); + left_max = MAX( left_max, ((TT_UShort*)DEREF( kern2->leftClass.classes ))[n] ); for ( n = 0; n < kern2->rightClass.nGlyphs; n++ ) - right_max = MAX( right_max, kern2->leftClass.classes[n] ); + right_max = MAX( right_max, ((TT_UShort*)DEREF( kern2->leftClass.classes ))[n] ); array_size = left_max + right_max + 2; @@ -248,11 +252,11 @@ GFREE( kern2->array ); Fail_Right: - FREE( kern2->rightClass.classes ); + GFREE( kern2->rightClass.classes ); kern2->rightClass.nGlyphs = 0; Fail_Left: - FREE( kern2->leftClass.classes ); + GFREE( kern2->leftClass.classes ); kern2->leftClass.nGlyphs = 0; return error; @@ -403,11 +407,11 @@ break; case 2: - FREE( sub->t.kern2.leftClass.classes ); + GFREE( sub->t.kern2.leftClass.classes ); sub->t.kern2.leftClass.firstGlyph = 0; sub->t.kern2.leftClass.nGlyphs = 0; - FREE( sub->t.kern2.rightClass.classes ); + GFREE( sub->t.kern2.rightClass.classes ); sub->t.kern2.rightClass.firstGlyph = 0; sub->t.kern2.rightClass.nGlyphs = 0; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h index 5603b71e6..81c671fa5 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ftxkern.h @@ -87,11 +87,11 @@ extern "C" { struct TT_Kern_2_Class_ { - TT_UShort firstGlyph; /* first glyph in range */ - TT_UShort nGlyphs; /* number of glyphs in range */ - TT_UShort* classes; /* a table giving for each ranged glyph */ - /* its class offset in the subtable pairs */ - /* two-dimensional array */ + TT_UShort firstGlyph; /* first glyph in range */ + TT_UShort nGlyphs; /* number of glyphs in range */ + ChunkHandle classes; /* a table giving for each ranged glyph */ + /* its class offset in the subtable pairs */ + /* two-dimensional array */ }; typedef struct TT_Kern_2_Class_ TT_Kern_2_Class; From 7246da8f71caf7198ebeb2d116cdf55b080930c5 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 1 Sep 2022 20:58:41 +0200 Subject: [PATCH 072/246] Move T_Face.cvt, T_Face.cvtProgram and T_Face.fontProgram from heap to lmem. --- Appl/Breadbox/testapps/ttf2/FreeType/ttload.c | 28 ++++++++++--------- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 14 +++++----- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h | 14 +++++----- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c index 981386995..4cc37856e 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c @@ -1013,17 +1013,19 @@ PTRACE2(( "is missing!\n" )); face->cvtSize = 0; - face->cvt = NULL; + face->cvt = NullHandle; return TT_Err_Ok; } face->cvtSize = face->dirTables[n].Length / 2; - if ( ALLOC_ARRAY( face->cvt, - face->cvtSize, - Short ) ) + if ( GALLOC_ARRAY( face->cvt, + face->cvtSize, + Short ) ) return error; + CHECK_CHUNK( face->cvt ); + if ( FILE_Seek( face->dirTables[n].Offset ) || ACCESS_Frame( face->cvtSize * 2L ) ) return error; @@ -1031,7 +1033,7 @@ limit = face->cvtSize; for ( n = 0; n < limit; n++ ) - face->cvt[n] = GET_Short(); + ((PByte)DEREF( face->cvt ))[n] = GET_Short(); FORGET_Frame(); @@ -1160,7 +1162,7 @@ /* The font program is optional */ if ( ( n = TT_LookUp_Table( face, TTAG_fpgm ) ) < 0 ) { - face->fontProgram = NULL; + face->fontProgram = NullHandle; face->fontPgmSize = 0; PTRACE2(( "is missing!\n" )); @@ -1169,10 +1171,10 @@ { face->fontPgmSize = face->dirTables[n].Length; - if ( ALLOC( face->fontProgram, - face->fontPgmSize ) || + if ( GALLOC( face->fontProgram, + face->fontPgmSize ) || FILE_Read_At( face->dirTables[n].Offset, - (void*)face->fontProgram, + DEREF( face->fontProgram ), face->fontPgmSize ) ) return error; @@ -1183,7 +1185,7 @@ if ( ( n = TT_LookUp_Table( face, TTAG_prep ) ) < 0 ) { - face->cvtProgram = NULL; + face->cvtProgram = NullHandle; face->cvtPgmSize = 0; PTRACE2(( "is missing!\n" )); @@ -1192,10 +1194,10 @@ { face->cvtPgmSize = face->dirTables[n].Length; - if ( ALLOC( face->cvtProgram, - face->cvtPgmSize ) || + if ( GALLOC( face->cvtProgram, + face->cvtPgmSize ) || FILE_Read_At( face->dirTables[n].Offset, - (void*)face->cvtProgram, + DEREF( face->cvtProgram ), face->cvtPgmSize ) ) return error; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c index 297dd6ccd..448d5fa59 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -846,7 +846,7 @@ /* allow font program execution */ Set_CodeRange( exec, TT_CodeRange_Font, - face->fontProgram, + DEREF( face->fontProgram ), face->fontPgmSize ); /* disable CVT and glyph programs coderange */ @@ -939,7 +939,7 @@ /* We use by default the y ppem to scale the CVT. */ for ( i = 0; i < ins->cvtSize; i++ ) - ins->cvt[i] = TT_MulDiv( face->cvt[i], + ins->cvt[i] = TT_MulDiv( ((PByte)DEREF( face->cvt ))[i], ins->metrics.scale1, ins->metrics.scale2 ); @@ -973,7 +973,7 @@ Set_CodeRange( exec, TT_CodeRange_Cvt, - face->cvtProgram, + DEREF( face->cvtProgram ), face->cvtPgmSize ); Clear_CodeRange( exec, TT_CodeRange_Glyph ); @@ -1075,7 +1075,7 @@ face->numCMaps = 0; /* freeing the CVT */ - FREE( face->cvt ); + GFREE( face->cvt ); face->cvtSize = 0; /* freeing the horizontal metrics */ @@ -1085,14 +1085,14 @@ /* freeing the vertical ones, if any */ if (face->verticalInfo) { - FREE( face->verticalHeader.long_metrics ); + //FREE( face->verticalHeader.long_metrics ); FREE( face->verticalHeader.short_metrics ); face->verticalInfo = 0; } /* freeing the programs */ - FREE( face->fontProgram ); - FREE( face->cvtProgram ); + GFREE( face->fontProgram ); + GFREE( face->cvtProgram ); face->fontPgmSize = 0; face->cvtPgmSize = 0; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h index e6ae355af..9a4f09383 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.h @@ -540,16 +540,16 @@ /* NOTE : The "hmtx" is now part of the horizontal header */ /* the font program, if any */ - ULong fontPgmSize; - PByte fontProgram; + ULong fontPgmSize; + ChunkHandle fontProgram; /* the cvt program, if any */ - ULong cvtPgmSize; - PByte cvtProgram; + ULong cvtPgmSize; + ChunkHandle cvtProgram; /* the original, unscaled, control value table */ - ULong cvtSize; - PShort cvt; + ULong cvtSize; + ChunkHandle cvt; /* The following values _must_ be set by the */ /* maximum profile loader */ @@ -570,7 +570,7 @@ /* A typeless pointer to the face object extensions defined */ /* in the 'ttextend.*' files. */ ChunkHandle extension; - Int n_extensions; /* number of extensions */ + Int n_extensions; /* number of extensions */ /* Use extensions to provide additional capabilities to the */ /* engine. Read the developer's guide in the documentation */ From dac26cb0cf75b6e261cc810fd020f02fda71b34f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 1 Sep 2022 21:08:16 +0200 Subject: [PATCH 073/246] Typecasts corrected. --- Appl/Breadbox/testapps/ttf2/FreeType/ttload.c | 6 +++--- Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c index 4cc37856e..04b77cf73 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttload.c @@ -1033,7 +1033,7 @@ limit = face->cvtSize; for ( n = 0; n < limit; n++ ) - ((PByte)DEREF( face->cvt ))[n] = GET_Short(); + ((PShort)DEREF( face->cvt ))[n] = GET_Short(); FORGET_Frame(); @@ -1174,7 +1174,7 @@ if ( GALLOC( face->fontProgram, face->fontPgmSize ) || FILE_Read_At( face->dirTables[n].Offset, - DEREF( face->fontProgram ), + (PByte)DEREF( face->fontProgram ), face->fontPgmSize ) ) return error; @@ -1197,7 +1197,7 @@ if ( GALLOC( face->cvtProgram, face->cvtPgmSize ) || FILE_Read_At( face->dirTables[n].Offset, - DEREF( face->cvtProgram ), + (PByte)DEREF( face->cvtProgram ), face->cvtPgmSize ) ) return error; diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c index 448d5fa59..a42dd3298 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttobjs.c @@ -939,7 +939,7 @@ /* We use by default the y ppem to scale the CVT. */ for ( i = 0; i < ins->cvtSize; i++ ) - ins->cvt[i] = TT_MulDiv( ((PByte)DEREF( face->cvt ))[i], + ins->cvt[i] = TT_MulDiv( ((PShort)DEREF( face->cvt ))[i], ins->metrics.scale1, ins->metrics.scale2 ); @@ -973,7 +973,7 @@ Set_CodeRange( exec, TT_CodeRange_Cvt, - DEREF( face->cvtProgram ), + (PByte)DEREF( face->cvtProgram ), face->cvtPgmSize ); Clear_CodeRange( exec, TT_CodeRange_Glyph ); @@ -1085,7 +1085,7 @@ /* freeing the vertical ones, if any */ if (face->verticalInfo) { - //FREE( face->verticalHeader.long_metrics ); + FREE( face->verticalHeader.long_metrics ); FREE( face->verticalHeader.short_metrics ); face->verticalInfo = 0; } From 2ca24e38270c84a7a1814efcae34547061ec885c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 4 Sep 2022 19:44:26 +0200 Subject: [PATCH 074/246] Move TCMap0.glyphIdArray from heap to chunk --- Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c | 6 +++--- Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c index 13d06c679..f5f24a8df 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.c @@ -74,7 +74,7 @@ case 0: cmap0 = &cmap->c.cmap0; - if ( ALLOC( cmap0->glyphIdArray, 256L ) || + if ( GALLOC( cmap0->glyphIdArray, 256L ) || FILE_Read( (void*)cmap0->glyphIdArray, 256L ) ) goto Fail; @@ -255,7 +255,7 @@ switch ( cmap->format ) { case 0: - FREE( cmap->c.cmap0.glyphIdArray ); + GFREE( cmap->c.cmap0.glyphIdArray ); break; case 2: @@ -344,7 +344,7 @@ PCMap0 cmap0 ) { if ( charCode <= 0xFF ) - return cmap0->glyphIdArray[charCode]; + return ((PByte)DEREF( cmap0->glyphIdArray ))[charCode]; else return 0; } diff --git a/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h index 43ca7887c..3f6be1089 100644 --- a/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h +++ b/Appl/Breadbox/testapps/ttf2/FreeType/ttcmap.h @@ -31,7 +31,7 @@ struct TCMap0_ { - PByte glyphIdArray; + ChunkHandle glyphIdArray; }; typedef struct TCMap0_ TCMap0; From 084da048af5db50442b05bacf5ba3d58d5eed3b5 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 7 Sep 2022 22:06:31 +0200 Subject: [PATCH 075/246] Testprogram extendet to test more scenarios --- Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc | 28 +++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc index 933731be6..c532308ea 100644 --- a/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc +++ b/Appl/Breadbox/testapps/ttf2/Ui/ttf2.goc @@ -12,7 +12,7 @@ #include "FreeType/freetype.h" -#define FONT_SIZE 30 +#define FONT_SIZE 16 TT_Engine engine; @@ -23,7 +23,7 @@ void* enginePtr; //nur temprär bis die Umstellung abgeschlossen ist typedef struct { Bitmap b; - char data[20 * 3]; + char data[24 * 3]; } Bmp; @class TtfProcessClass, GenProcessClass; @@ -134,7 +134,7 @@ void testRendering(GStateHandle gstate) { goto Fail; } - error = TT_Set_Instance_CharSize(instance, 36*64); + error = TT_Set_Instance_CharSize(instance, FONT_SIZE * 64); if(error) { _log("Fehler beim setzen der Pointsize\r"); goto Fail; @@ -147,11 +147,17 @@ void testRendering(GStateHandle gstate) { } TT_Get_CharMap(face, 0, &charMap); - - charIndex = TT_Char_Index(charMap, 65); - -// DrawBitmap( gstate, instance, glyph); - DrawRegion( gstate, instance, glyph, charIndex); + charIndex = TT_Char_Index(charMap, 84); //T + DrawRegion( gstate, instance, glyph, charIndex, 60); + charIndex = TT_Char_Index(charMap, 101); //e + DrawRegion( gstate, instance, glyph, charIndex, 80); + charIndex = TT_Char_Index(charMap, 115); //s + DrawRegion( gstate, instance, glyph, charIndex, 100); + charIndex = TT_Char_Index(charMap, 116); //t + DrawRegion( gstate, instance, glyph, charIndex, 120); + + DrawBitmap( gstate, instance, glyph); + Fail: TT_Done_FreeType(engine); @@ -170,7 +176,7 @@ void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { for(characterId = 1; characterId <= 200; characterId++ ) { TT_Error error; int posX = ( characterId % 16 ) * FONT_SIZE + FONT_SIZE/2; - int posY = ( characterId / 16 ) * FONT_SIZE + FONT_SIZE; + int posY = ( characterId / 16 ) * 2 * FONT_SIZE + 100; memset(&bmp, 0, sizeof(Bmp)); bmp.b.B_compact = BMC_UNCOMPACTED; @@ -203,7 +209,7 @@ void DrawBitmap( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph ) { } } -void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word characterId ) { +void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word characterId, word x ) { char tmpStr[40]; TT_Raster_Map regionmap; TT_Glyph_Metrics metrics; @@ -231,7 +237,7 @@ void DrawRegion( GStateHandle gstate, TT_Instance instance, TT_Glyph glyph, word if( TT_Get_Glyph_Region( glyph, ®ionmap, 0, 0 ) ) return; - GrDrawRegion(gstate, 60, 60, region, 0, 0); + GrDrawRegion(gstate, x, 40, region, 0, 0); free(region); } From 9da20ac08f7721eb7620284cfa7d4fe054157fdd Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 16 Oct 2022 10:24:50 +0200 Subject: [PATCH 076/246] Temporary refactoring of the memory management of the truetype driver --- Driver/Font/TrueType/Adapter/ttadapter.c | 32 +- Driver/Font/TrueType/Adapter/ttadapter.h | 6 +- Driver/Font/TrueType/FreeType/freetype.h | 120 +- Driver/Font/TrueType/FreeType/ft_conf.h | 20 +- Driver/Font/TrueType/FreeType/ftxkern.c | 12 +- Driver/Font/TrueType/FreeType/ftxkern.h | 2 +- Driver/Font/TrueType/FreeType/ttapi.c | 352 +-- Driver/Font/TrueType/FreeType/ttcache.c | 13 +- Driver/Font/TrueType/FreeType/ttcalc.c | 1 - Driver/Font/TrueType/FreeType/ttcmap.c | 1 - Driver/Font/TrueType/FreeType/ttconfig.h | 18 +- Driver/Font/TrueType/FreeType/ttdebug.c | 404 ---- Driver/Font/TrueType/FreeType/ttdebug.h | 170 -- Driver/Font/TrueType/FreeType/ttengine.h | 11 +- Driver/Font/TrueType/FreeType/ttextend.c | 1 - Driver/Font/TrueType/FreeType/ttfile.c | 136 +- Driver/Font/TrueType/FreeType/ttfile.h | 8 +- Driver/Font/TrueType/FreeType/ttgload.c | 65 +- Driver/Font/TrueType/FreeType/ttinterp.c | 18 +- Driver/Font/TrueType/FreeType/ttload.c | 163 -- Driver/Font/TrueType/FreeType/ttmemory.c | 333 +-- Driver/Font/TrueType/FreeType/ttmemory.h | 79 +- Driver/Font/TrueType/FreeType/ttobjs.c | 52 +- Driver/Font/TrueType/FreeType/ttraster.c | 258 +-- Driver/Font/TrueType/FreeType/ttraster.h | 6 +- Driver/Font/TrueType/Main/ansic_malloc.asm | 790 ------- Driver/Font/TrueType/Main/ansic_string.asm | 1936 ----------------- Driver/Font/TrueType/Main/mainManager.asm | 5 +- .../Font/TrueType/Main/truetypeVariable.def | 26 +- Installed/Driver/Font/TrueType/Makefile | 21 +- .../Driver/Font/TrueType/dependencies.mk | 143 +- 31 files changed, 319 insertions(+), 4883 deletions(-) delete mode 100644 Driver/Font/TrueType/FreeType/ttdebug.c delete mode 100644 Driver/Font/TrueType/FreeType/ttdebug.h delete mode 100644 Driver/Font/TrueType/Main/ansic_malloc.asm delete mode 100644 Driver/Font/TrueType/Main/ansic_string.asm diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 839d70312..b7d49d3b9 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -20,6 +20,7 @@ ***********************************************************************/ #include "ttadapter.h" +#include /******************************************************************** @@ -46,9 +47,9 @@ TT_Error _pascal Init_FreeType() { TT_Error error; - - - error = TT_Init_FreeType( &engineHandle ); + + + error = TT_Init_FreeType(); if ( error != TT_Err_Ok ) return error; @@ -81,5 +82,28 @@ TT_Error _pascal Init_FreeType() TT_Error _pascal Exit_FreeType() { - return TT_Done_FreeType( engineHandle ); + return TT_Done_FreeType(); +} + + +/******************************************************************** + * Char_Metrics + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * / /22 JK Initial Revision + *******************************************************************/ +TT_Error _pascal Char_Metrics() { + return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 5a0693722..dcf262cb0 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -21,13 +21,15 @@ #define _TTADAPTER_H_ #include +#include +#include #include "../FreeType/freetype.h" +#include "../FreeType/ttengine.h" /*********************************************************************** * global dgoup objects ***********************************************************************/ -extern MemHandle trueTypeHandle; -extern ChunkHandle engineHandle; +extern TEngine_Instance engineInstance; #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index f2a79f02c..4933faf6b 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -26,16 +26,13 @@ #define FREETYPE_H -#define TT_FREETYPE_MAJOR 1 -#define TT_FREETYPE_MINOR 3 - - #include "fterrid.h" #include "ftnameid.h" + #ifdef __GEOS__ #include -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ /* To make freetype.h independent from configuration files we check */ /* whether EXPORT_DEF has been defined already. */ @@ -108,7 +105,7 @@ /* in 26.6 fractional pixels if it */ /* was. */ - + struct TT_UnitVector_ /* guess what... */ { TT_F2Dot14 x; @@ -346,12 +343,12 @@ int width; /* number of pixels per line */ int flow; /* bitmap orientation */ - void* bitmap; /* bit/pixmap/region buffer */ + void* bitmap; /* bit/pixmap buffer */ #ifndef __GEOS__ long size; /* bit/pixmap size in bytes */ #else int size; /* bit/pixmap/region size in bytes */ -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ }; typedef struct TT_Raster_Map_ TT_Raster_Map; @@ -622,27 +619,12 @@ /* NOTE: Some macros are defined in tttypes.h to perform */ /* automatic type conversions for library hackers... */ - //TODO: soll TT_*_ ersetzen - struct GTT_Stream_ { MemHandle z; }; - struct GTT_Face_ { MemHandle z; }; - struct GTT_Instance_ { MemHandle z; }; - struct GTT_Glyph_ { MemHandle z; }; - struct GTT_CharMap_ { MemHandle z; }; - struct TT_Stream_ { void* z; }; struct TT_Face_ { void* z; }; struct TT_Instance_ { void* z; }; struct TT_Glyph_ { void* z; }; struct TT_CharMap_ { void* z; }; - //TODO: soll TT_* ersetzen - typedef struct GTT_Stream_ GTT_Stream; - typedef struct GTT_Face_ GTT_Face; - typedef struct GTT_Instance_ GTT_Instance; - typedef struct GTT_Glyph_ GTT_Glyph; - typedef struct GTT_CharMap_ GTT_CharMap; - - typedef ChunkHandle TT_Engine; /* handle to engine instance */ typedef struct TT_Stream_ TT_Stream; /* stream handle type */ typedef struct TT_Face_ TT_Face; /* face handle type */ typedef struct TT_Instance_ TT_Instance; /* instance handle type */ @@ -654,10 +636,11 @@ typedef long TT_Error; - #ifdef __GEOS__ /* Flags for control path generation for FreeGEOS. */ + #ifdef __GEOS__ + #define GEOS_TTF_POSTSCRIPT 0x0002 #define GEOS_TTF_SAVE_STATE 0x0001 @@ -674,38 +657,17 @@ /* */ /*******************************************************************/ - /* Get version information. */ - - EXPORT_DEF - TT_Error TT_FreeType_Version( int *major, - int *minor ); - /* Initialize the engine. */ EXPORT_DEF - TT_Error TT_Init_FreeType( TT_Engine* engine ); + TT_Error TT_Init_FreeType( void ); /* Finalize the engine, and release all allocated objects. */ EXPORT_DEF - TT_Error TT_Done_FreeType( TT_Engine engine ); - - - /* Set the gray level palette. This is an array of 5 bytes used */ - /* to produce the font smoothed pixmaps. By convention: */ - /* */ - /* palette[0] = background (white) */ - /* palette[1] = light */ - /* palette[2] = medium */ - /* palette[3] = dark */ - /* palette[4] = foreground (black) */ - /* */ - - EXPORT_DEF - TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, - TT_Byte* palette ); + TT_Error TT_Done_FreeType( void ); /* ----------------------- face management ----------------------- */ @@ -721,9 +683,8 @@ /* `max_Faces' field. */ EXPORT_DEF - TT_Error TT_Open_Face( TT_Engine engine, - const TT_Text* fontPathName, - TT_Face* face ); + TT_Error TT_Open_Face( const FileHandle file, + TT_Face* face ); /* Return face properties in the `properties' structure. */ @@ -965,21 +926,6 @@ TT_F26Dot6 yOffset ); - /* Render the glyph into a pixmap, with given position offsets. */ - /* */ - /* Note: Only use integer pixel offsets to preserve the fine */ - /* hinting of the glyph and the `correct' anti-aliasing */ - /* (where vertical and horizontal stems aren't grayed). This */ - /* means that `xOffset' and `yOffset' must be multiples */ - /* of 64! */ - - EXPORT_DEF - TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, - TT_Raster_Map* map, - TT_F26Dot6 xOffset, - TT_F26Dot6 yOffset ); - - /* Render the glyph into a region, with given position offsets. */ /* */ /* Note: Only use integer pixel offsets to preserve the fine */ @@ -1037,23 +983,14 @@ /* Render an outline into a bitmap. */ EXPORT_DEF - TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, - TT_Outline* outline, + TT_Error TT_Get_Outline_Bitmap( TT_Outline* outline, TT_Raster_Map* map ); - /* Render an outline into a pixmap. */ - - EXPORT_DEF - TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, - TT_Outline* outline, - TT_Raster_Map* map ); - /* Render an outline into a region. */ EXPORT_DEF - TT_Error TT_Get_Outline_Region( TT_Engine engine, - TT_Outline* outline, + TT_Error TT_Get_Outline_Region( TT_Outline* outline, TT_Raster_Map* map ); @@ -1107,22 +1044,6 @@ /* ----------------- character mapping support --------------- */ - /* Return the number of character mappings found in this file. */ - /* Returns -1 in case of failure (invalid face handle). */ - /* */ - /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ - /* */ - /* It is retained for backwards compatibility only and will */ - /* fail on 16bit systems. */ - /* */ - /* You can now get the charmap count in the `num_CharMaps' */ - /* field of a face's properties. */ - /* */ - - EXPORT_DEF - int TT_Get_CharMap_Count( TT_Face face ); - - /* Return the ID of charmap number `charmapIndex' of a given face */ /* used to enumerate the charmaps present in a TrueType file. */ @@ -1158,21 +1079,6 @@ /* --------------------- names table support ------------------- */ - /* Return the number of name strings found in the name table. */ - /* Returns -1 in case of failure (invalid face handle). */ - /* */ - /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ - /* */ - /* It is retained for backwards compatibility only and will */ - /* fail on 16bit systems. */ - /* */ - /* You can now get the number of name strings in a face with */ - /* the `num_Names' field of its properties. */ - - EXPORT_DEF - int TT_Get_Name_Count( TT_Face face ); - - /* Return the ID of the name number `nameIndex' of a given face */ /* used to enumerate the charmaps present in a TrueType file. */ diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index 87f3c02ab..ffdd3f005 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -1,6 +1,6 @@ /* This file is part of the FreeType project */ -/* ft_conf.h for the FreeGEOS Build */ +/* ft_conf.h for FreeGEOS build */ /* we need the following because there are some typedefs in this file */ @@ -8,18 +8,22 @@ #ifndef FT_CONF_H #define FT_CONF_H -/* Under FreeGEOS we need this for the file operations, render regions and manage memory. */ +/* Under FreeGEOS we need some special includes. */ #include #include #include #include #include -#include #include +#include + + +/* FreeGEOS specific constants and definitions. */ +#define MAX_LMEM_CHUNKSIZE 32000 /* MemHandle to our global memory block under FreeGEOS. In this memory block */ /* we hold all dynamically allocated FreeType structures we need. */ -extern MemHandle trueTypeHandle; +extern MemHandle trueTypeHandle; /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -42,8 +46,8 @@ extern MemHandle trueTypeHandle; /* Define if you have the valloc function. */ #undef HAVE_VALLOC -/* Define if you have the header file. Unix-specific */ -#undef HAVE_FCNTL_H +/* Define if you have the header file. */ +#define HAVE_FCNTL_H /* command.com can't pipe stderr into a file; any message would be */ /* written into the graphics screen. */ @@ -119,7 +123,7 @@ extern MemHandle trueTypeHandle; /* emerged recently on the FreeType lists. We still do not have Apple's */ /* opinion on the subject and will change this as soon as we have. */ -#undef TT_CONFIG_OPTION_NO_INTERPRETER +#undef TT_CONFIG_OPTION_NO_INTERPRETER /*************************************************************************/ @@ -151,7 +155,7 @@ extern MemHandle trueTypeHandle; /* */ /* Do NOT DEFINE THIS is you build a thread-safe version of the engine */ /* */ -#undef TT_CONFIG_OPTION_STATIC_RASTER +#undef TT_CONFIG_OPTION_STATIC_RASTER /*************************************************************************/ diff --git a/Driver/Font/TrueType/FreeType/ftxkern.c b/Driver/Font/TrueType/FreeType/ftxkern.c index 6d6c9f9a0..0225d4ffd 100644 --- a/Driver/Font/TrueType/FreeType/ftxkern.c +++ b/Driver/Font/TrueType/FreeType/ftxkern.c @@ -22,7 +22,6 @@ #include "ttextend.h" #include "tttypes.h" -#include "ttdebug.h" #include "ttmemory.h" #include "ttfile.h" #include "ttobjs.h" @@ -35,6 +34,10 @@ #define KERNING_ID Build_Extension_ID( 'k', 'e', 'r', 'n' ) +#ifdef __GEOS__ +extern TEngine_Instance engineInstance; +#endif /* __GEOS__ */ + /******************************************************************* * @@ -542,11 +545,10 @@ EXPORT_FUNC - TT_Error TT_Init_Kerning_Extension( TT_Engine engine ) + TT_Error TT_Init_Kerning_Extension( void ) { - PEngine_Instance _engine = HANDLE_Engine( engine ); - - TT_Error error; + PEngine_Instance _engine = &engineInstance; + TT_Error error; if ( !_engine ) diff --git a/Driver/Font/TrueType/FreeType/ftxkern.h b/Driver/Font/TrueType/FreeType/ftxkern.h index 719ec6e51..3dd26fad3 100644 --- a/Driver/Font/TrueType/FreeType/ftxkern.h +++ b/Driver/Font/TrueType/FreeType/ftxkern.h @@ -150,7 +150,7 @@ extern "C" { /* Initialize Kerning extension, must be called after */ /* TT_Init_FreeType(). There is no need for a finalizer */ EXPORT_DEF - TT_Error TT_Init_Kerning_Extension( TT_Engine engine ); + TT_Error TT_Init_Kerning_Extension( void ); /* Note on the implemented mechanism: */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 1ea57a91b..74d67a1ce 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -42,13 +42,15 @@ #undef TT_COMPONENT #define TT_COMPONENT trace_api +#ifdef __GEOS__ +extern TEngine_Instance engineInstance; +#endif /* __GEOS__ */ + #ifdef TT_STATIC_RASTER #define RAS_OPS /* void */ -#define RAS_OP /* void */ #else #define RAS_OPS ((TRaster_Instance*)_engine->raster_component), -#define RAS_OP ((TRaster_Instance*)_engine->raster_component) #endif /* TT_STATIC_RASTER */ @@ -63,33 +65,6 @@ -/******************************************************************* - * - * Function : TT_FreeType_Version - * - * Description : Returns the major and minor version of the library. - * - * Input : major, minor addresses - * - * Output : Error code. - * - * MT-Note : YES! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_FreeType_Version( int *major, int *minor ) - { - if ( !major || !minor ) - return TT_Err_Invalid_Argument; - - *major = TT_FREETYPE_MAJOR; - *minor = TT_FREETYPE_MINOR; - - return TT_Err_Ok; - } - - /******************************************************************* * * Function : TT_Init_FreeType @@ -97,37 +72,32 @@ * Description : The library's engine initializer. This function * must be called prior to any call. * - * Input : engine pointer to a FreeType engine instance + * Input : void * * Output : Error code. * * MT-Note : This function should be called each time you want - * to create a TT_Engine. It is not necessarily thread - * safe depending on the implementations of ttmemory, + * to create an TEngine_Instance. It is not necessarily + * thread safe depending on the implementations of ttmemory, * ttfile and ttmutex, so take care. Their default * implementations are safe, however. * ******************************************************************/ EXPORT_FUNC - TT_Error TT_Init_FreeType( TT_Engine* engine ) + TT_Error TT_Init_FreeType( void ) { - PEngine_Instance _engine; + PEngine_Instance _engine = &engineInstance; + TT_Error error; - TT_Error error; - /* first of all, initialize memory sub-system */ error = TTMemory_Init(); if ( error ) return error; - /* Allocate engine instance */ - if ( GALLOC( *engine, sizeof ( TEngine_Instance ) ) ) - return error; - #undef TT_FAIL -#define TT_FAIL( x ) ( error = x (*engine) ) != TT_Err_Ok +#define TT_FAIL( x ) ( error = x (_engine) ) != TT_Err_Ok /* Initalize components */ if ( TT_FAIL( TTFile_Init ) || @@ -142,14 +112,11 @@ #undef TT_FAIL /* create the engine lock */ - _engine = (PEngine_Instance)DEREF( engine ); MUTEX_Create( _engine->lock ); - return TT_Err_Ok; Fail: - TT_Done_FreeType( *engine ); - *engine = NullChunk; + TT_Done_FreeType(); return error; } @@ -162,7 +129,7 @@ * will discard all active face and glyph objects * from the heap. * - * Input : engine FreeType engine instance + * Input : void * * Output : Error code. * @@ -174,25 +141,23 @@ ******************************************************************/ EXPORT_FUNC - TT_Error TT_Done_FreeType( TT_Engine engine ) + TT_Error TT_Done_FreeType( void ) { - PEngine_Instance _engine; + PEngine_Instance _engine = &engineInstance; - if ( !engine ) + if ( !_engine ) return TT_Err_Ok; - _engine = (PEngine_Instance)DEREF( engine ); MUTEX_Destroy( _engine->lock ); - TTRaster_Done( engine ); - TTObjs_Done ( engine ); + TTRaster_Done( _engine ); + TTObjs_Done ( _engine ); #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - TTExtend_Done( engine ); + TTExtend_Done( _engine ); #endif - TTCache_Done ( engine ); - TTFile_Done ( engine ); - GFREE( engine ); + TTCache_Done ( _engine ); + TTFile_Done ( _engine ); TTMemory_Done(); @@ -200,51 +165,13 @@ } -#ifdef TT_CONFIG_OPTION_GRAY_SCALING - -/******************************************************************* - * - * Function : TT_Set_Raster_Gray_Palette - * - * Description : Sets the gray-levels palette used for font - * smoothing. - * - * Input : engine FreeType engine instance - * palette address of palette (a 5 byte array) - * - * Output : Invalid argument if 'palette' is NULL. - * - * MT-Note: NO! Unprotected modification of an engine's palette. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, - Byte* palette ) - { - int i; - - - if ( !palette ) - return TT_Err_Invalid_Argument; - - for ( i = 0; i < 5; i++ ) - HANDLE_Engine( engine )->raster_palette[i] = (Byte)palette[i]; - - return TT_Err_Ok; - } - -#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ - - /******************************************************************* * * Function : TT_Open_Face * * Description : Creates a new face object from a given font file. * - * Input : engine FreeType engine instance - * fontPathName the font file's pathname + * Input : fontPathName the font file's pathname * face adress of returned face handle * * Output : Error code. @@ -256,11 +183,10 @@ ******************************************************************/ EXPORT_FUNC - TT_Error TT_Open_Face( TT_Engine engine, - const TT_Text* fontPathName, - TT_Face* face ) + TT_Error TT_Open_Face( const FileHandle file, + TT_Face* face ) { - PEngine_Instance _engine; + PEngine_Instance _engine = &engineInstance; TFont_Input input; TT_Error error; @@ -268,11 +194,11 @@ PFace _face; - if ( !engine ) + if ( !_engine ) return TT_Err_Invalid_Engine; /* open the file */ - error = TT_Open_Stream( fontPathName, &stream ); + error = TT_Open_Stream( file, &stream ); if ( error ) return error; @@ -281,7 +207,6 @@ input.engine = _engine; /* Create and load the new face object - this is thread-safe */ - _engine = (PEngine_Instance)DEREF( engine ); error = CACHE_New( _engine->objs_face_cache, _face, &input ); @@ -1284,70 +1209,6 @@ TT_F26Dot6 yOffset ) { PEngine_Instance _engine; - TT_Engine engine; - TT_Error error; - PGlyph _glyph = HANDLE_Glyph( glyph ); - - TT_Outline outline; - - - if ( !_glyph ) - return TT_Err_Invalid_Glyph_Handle; - - _engine = _glyph->face->engine; - // HANDLE_Set( engine, _engine ); - - outline = _glyph->outline; - /* XXX : For now, use only dropout mode 2 */ - /* outline.dropout_mode = _glyph->scan_type; */ - outline.dropout_mode = 2; - - TT_Translate_Outline( &outline, xOffset, yOffset ); - error = TT_Get_Outline_Bitmap( engine, &outline, map ); - TT_Translate_Outline( &outline, -xOffset, -yOffset ); - - return error; - } - - -#ifdef TT_CONFIG_OPTION_GRAY_SCALING - -/******************************************************************* - * - * Function : TT_Get_Glyph_Pixmap - * - * Description : Produces a grayscaled pixmap from a glyph - * outline. - * - * Input : glyph the glyph container's handle - * map target pixmap description block - * xOffset x offset in fractional pixels (26.6 format) - * yOffset y offset in fractional pixels (26.6 format) - * - * Output : Error code. - * - * Note : Only use integer pixel offsets to preserve the fine - * hinting of the glyph and the 'correct' anti-aliasing - * (where vertical and horizontal stems aren't grayed). - * This means that xOffset and yOffset must be multiples - * of 64! - * - * You can experiment with offsets of +32 to get 'blurred' - * versions of the glyphs (a nice effect at large sizes that - * some graphic designers may appreciate :) - * - * MT-Safe : NO! Glyph containers can't be shared. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, - TT_Raster_Map* map, - TT_F26Dot6 xOffset, - TT_F26Dot6 yOffset ) - { - PEngine_Instance _engine; - TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1358,7 +1219,6 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - HANDLE_Set(engine,_engine); outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1366,13 +1226,12 @@ outline.dropout_mode = 2; TT_Translate_Outline( &outline, xOffset, yOffset ); - error = TT_Get_Outline_Pixmap( engine, &outline, map ); + error = TT_Get_Outline_Bitmap( &outline, map ); TT_Translate_Outline( &outline, -xOffset, -yOffset ); return error; } -#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ #ifdef __GEOS__ @@ -1412,7 +1271,6 @@ TT_F26Dot6 yOffset ) { PEngine_Instance _engine; - TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); TT_Matrix flipmatrix = HORIZONTAL_FLIP_MATRIX; @@ -1424,7 +1282,6 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - // HANDLE_Set(engine,_engine); outline = _glyph->outline; /* XXX : For now, use only dropout mode 2 */ @@ -1433,14 +1290,15 @@ TT_Transform_Outline( &outline, &flipmatrix ); TT_Translate_Outline( &outline, xOffset, yOffset + map->rows * 64 ); - error = TT_Get_Outline_Region( engine, &outline, map ); + error = TT_Get_Outline_Region( &outline, map ); TT_Translate_Outline( &outline, -xOffset, -yOffset - map->rows * 64 ); TT_Transform_Outline( &outline, &flipmatrix ); return error; } - /******************************************************************* + + /******************************************************************* * * Function : TT_Get_Glyph_In_Region * @@ -1462,7 +1320,6 @@ Handle regionPath ) { PEngine_Instance _engine; - TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1472,7 +1329,6 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - // HANDLE_Set(engine,_engine); outline = _glyph->outline; @@ -1518,7 +1374,6 @@ TT_UShort controlFlags ) { PEngine_Instance _engine; - TT_Engine engine; TT_Error error; PGlyph _glyph = HANDLE_Glyph( glyph ); @@ -1528,7 +1383,6 @@ return TT_Err_Invalid_Glyph_Handle; _engine = _glyph->face->engine; - // HANDLE_Set(engine,_engine); outline = _glyph->outline; @@ -1666,11 +1520,10 @@ ******************************************************************/ EXPORT_FUNC - TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, - TT_Outline* outline, + TT_Error TT_Get_Outline_Bitmap( TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine; // = HANDLE_Engine( engine ); + PEngine_Instance _engine = &engineInstance; TT_Error error; @@ -1688,47 +1541,6 @@ } -#ifdef TT_CONFIG_OPTION_GRAY_SCALING - -/******************************************************************* - * - * Function : TT_Get_Outline_Pixmap - * - * Description : Render a TrueType outline into a pixmap. - * Note that the pixmap must be created by the caller. - * - * Input : outline the outline to render - * map the target bitmap - * - * Output : Error code - * - * MT-Safe : YES! - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, - TT_Outline* outline, - TT_Raster_Map* map ) - { - PEngine_Instance _engine = HANDLE_Engine( engine ); - TT_Error error; - - - if ( !_engine ) - return TT_Err_Invalid_Engine; - - if ( !outline || !map ) - return TT_Err_Invalid_Argument; - - MUTEX_Lock( _engine->raster_lock ); - error = RENDER_Gray_Glyph( outline, map, _engine->raster_palette ); - MUTEX_Release( _engine->raster_lock ); - return error; - } - -#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ - #ifdef __GEOS__ /******************************************************************* @@ -1747,11 +1559,10 @@ * ******************************************************************/ EXPORT_FUNC -TT_Error TT_Get_Outline_Region( TT_Engine engine, - TT_Outline* outline, +TT_Error TT_Get_Outline_Region( TT_Outline* outline, TT_Raster_Map* map ) { - PEngine_Instance _engine; // = HANDLE_Engine( engine ); + PEngine_Instance _engine = &engineInstance; TT_Error error; @@ -1989,34 +1800,6 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, /* ----------------- character mappings support ------------- */ -/******************************************************************* - * - * Function : TT_Get_CharMap_Count - * - * Description : Returns the number of charmaps in a given face. - * - * Input : face face object handle - * - * Output : Number of tables. -1 in case of error (bad handle). - * - * Note : DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! - * - * It is retained for backwards compatibility only and will - * fail on 16bit systems. - * - * MT-Safe : YES ! - * - ******************************************************************/ - - EXPORT_FUNC - int TT_Get_CharMap_Count( TT_Face face ) - { - PFace faze = HANDLE_Face( face ); - - return ( faze ? faze->numCMaps : -1 ); - } - - /******************************************************************* * * Function : TT_Get_CharMap_ID @@ -2155,41 +1938,6 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, } -/******************************************************************* - * - * Function : TT_Get_Name_Count - * - * Description : Returns the number of strings found in the - * name table. - * - * Input : face face handle - * - * Output : number of strings. - * - * Notes : Returns -1 on error (invalid handle). - * - * DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! - * - * It is retained for backwards compatibility only and will - * fail on 16bit systems. - * - * MT-Safe : YES! - * - ******************************************************************/ - - EXPORT_FUNC - int TT_Get_Name_Count( TT_Face face ) - { - PFace faze = HANDLE_Face( face ); - - - if ( !faze ) - return -1; - - return faze->nameTable.numNameRecords; - } - - /******************************************************************* * * Function : TT_Get_Name_ID @@ -2348,34 +2096,4 @@ TT_Error TT_Get_Outline_Region( TT_Engine engine, } - /************************ callback definition ******************/ - - /* Register a new callback to the TrueType engine -- this should */ - /* only be used by higher-level libraries, not typical clients */ - /* */ - /* This is not part of the current FreeType release, thus */ - /* undefined... */ - -#if 0 - EXPORT_FUNC - TT_Error TT_Register_Callback( TT_Engine engine, - int callback_id, - void* callback_ptr ) - { - PEngine_Instance eng = HANDLE_Engine( engine ); - - - if ( !eng ) - return TT_Err_Invalid_Argument; - - /* currently, we only support one callback */ - if (callback_id != TT_Callback_Glyph_Outline_Load) - return TT_Err_Invalid_Argument; - - eng->glCallback = (TT_Glyph_Loader_Callback)callback_ptr; - return TT_Err_Ok; - } -#endif /* 0 */ - - /* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcache.c b/Driver/Font/TrueType/FreeType/ttcache.c index 719f74ac2..2ea6f67f4 100644 --- a/Driver/Font/TrueType/FreeType/ttcache.c +++ b/Driver/Font/TrueType/FreeType/ttcache.c @@ -24,7 +24,6 @@ #include "ttmemory.h" #include "ttcache.h" #include "ttobjs.h" -#include "ttdebug.h" /* required by the tracing mode */ #undef TT_COMPONENT @@ -202,7 +201,7 @@ ProcCallFixedOrMovable_cdecl( destroy, current->data ); #else destroy( current->data ); -#endif +#endif /* __GEOS__ */ FREE( current->data ); Element_Done( cache->engine, current ); @@ -286,7 +285,11 @@ reset = cache->clazz->reset; if ( reset ) { +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( reset, object, parent_object ); +#else error = reset( object, parent_object ); +#endif /* __GEOS__ */ if ( error ) { LOCK(); @@ -316,7 +319,7 @@ error = ProcCallFixedOrMovable_cdecl( build, object, parent_object ); #else error = build( object, parent_object ); -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ if ( error ) { Element_Done( cache->engine, current ); @@ -410,7 +413,7 @@ ProcCallFixedOrMovable_cdecl( cache->clazz->done, element->data ); #else cache->clazz->done( element->data ); -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ FREE( element->data ); Element_Done( cache->engine, element ); } @@ -426,7 +429,7 @@ error = ProcCallFixedOrMovable_cdecl( finalize, element->data ); #else error = finalize( element->data ); -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ if ( error ) goto Exit; diff --git a/Driver/Font/TrueType/FreeType/ttcalc.c b/Driver/Font/TrueType/FreeType/ttcalc.c index 0d7fcbc51..98b6acff9 100644 --- a/Driver/Font/TrueType/FreeType/ttcalc.c +++ b/Driver/Font/TrueType/FreeType/ttcalc.c @@ -16,7 +16,6 @@ ******************************************************************/ #include "ttcalc.h" -#include "ttdebug.h" #include "tttables.h" /* required by the tracing mode */ diff --git a/Driver/Font/TrueType/FreeType/ttcmap.c b/Driver/Font/TrueType/FreeType/ttcmap.c index 13d06c679..9f0b9b182 100644 --- a/Driver/Font/TrueType/FreeType/ttcmap.c +++ b/Driver/Font/TrueType/FreeType/ttcmap.c @@ -16,7 +16,6 @@ ******************************************************************/ #include "ttobjs.h" -#include "ttdebug.h" #include "ttfile.h" #include "ttmemory.h" #include "ttload.h" diff --git a/Driver/Font/TrueType/FreeType/ttconfig.h b/Driver/Font/TrueType/FreeType/ttconfig.h index 7cdbf28e5..5e7a946e2 100644 --- a/Driver/Font/TrueType/FreeType/ttconfig.h +++ b/Driver/Font/TrueType/FreeType/ttconfig.h @@ -40,7 +40,7 @@ /* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ /* version of the library. */ -#define TT_CONFIG_OPTION_THREAD_SAFE +/* #define TT_CONFIG_OPTION_THREAD_SAFE */ @@ -73,10 +73,6 @@ * * Please consult ttdebug.h for more details. */ -/* #define DEBUG_LEVEL_TRACE */ -/* #define DEBUG_LEVEL_ERROR */ - - /* ------------ special debugging -------------------------------------- */ @@ -164,7 +160,7 @@ /* The number of extensions available. Don't change this value */ /* except if you add new extensions to the engine. */ -#define TT_MAX_EXTENSIONS 2 +#define TT_MAX_EXTENSIONS 1 @@ -236,13 +232,13 @@ /* any developer to quickly switch from one mode to the other */ /* without messing with "ttconfig.h" each time. */ /* */ -//#ifndef TT_MAKE_OPTION_SINGLE_OBJECT +#ifndef TT_MAKE_OPTION_SINGLE_OBJECT #define LOCAL_FUNC /* void */ #define LOCAL_DEF extern -// #else -// #define LOCAL_FUNC static -// #define LOCAL_DEF static -// #endif +#else +#define LOCAL_FUNC static +#define LOCAL_DEF static +#endif /*************************************************************************/ diff --git a/Driver/Font/TrueType/FreeType/ttdebug.c b/Driver/Font/TrueType/FreeType/ttdebug.c deleted file mode 100644 index 6b65154a7..000000000 --- a/Driver/Font/TrueType/FreeType/ttdebug.c +++ /dev/null @@ -1,404 +0,0 @@ -/* Simple debugging component. Temporary */ - -#include "ttdebug.h" -#include "tttables.h" -#include "ttobjs.h" - - -#ifdef DEBUG_LEVEL_TRACE - char tt_trace_levels[trace_max]; -#endif - -#if defined( DEBUG_LEVEL_ERROR ) || defined( DEBUG_LEVEL_TRACE ) - -#include -#include -#include - - - static String tempStr[128]; - - static const String* OpStr[256] = - { - "SVTCA y", /* Set vectors to coordinate axis y */ - "SVTCA x", /* Set vectors to coordinate axis x */ - "SPvTCA y", /* Set Proj. vec. to coord. axis y */ - "SPvTCA x", /* Set Proj. vec. to coord. axis x */ - "SFvTCA y", /* Set Free. vec. to coord. axis y */ - "SFvTCA x", /* Set Free. vec. to coord. axis x */ - "SPvTL //", /* Set Proj. vec. parallel to segment */ - "SPvTL +", /* Set Proj. vec. normal to segment */ - "SFvTL //", /* Set Free. vec. parallel to segment */ - "SFvTL +", /* Set Free. vec. normal to segment */ - "SPvFS", /* Set Proj. vec. from stack */ - "SFvFS", /* Set Free. vec. from stack */ - "GPV", /* Get projection vector */ - "GFV", /* Get freedom vector */ - "SFvTPv", /* Set free. vec. to proj. vec. */ - "ISECT", /* compute intersection */ - - "SRP0", /* Set reference point 0 */ - "SRP1", /* Set reference point 1 */ - "SRP2", /* Set reference point 2 */ - "SZP0", /* Set Zone Pointer 0 */ - "SZP1", /* Set Zone Pointer 1 */ - "SZP2", /* Set Zone Pointer 2 */ - "SZPS", /* Set all zone pointers */ - "SLOOP", /* Set loop counter */ - "RTG", /* Round to Grid */ - "RTHG", /* Round to Half-Grid */ - "SMD", /* Set Minimum Distance */ - "ELSE", /* Else */ - "JMPR", /* Jump Relative */ - "SCvTCi", /* Set CVT */ - "SSwCi", /* */ - "SSW", /* */ - - "DUP", - "POP", - "CLEAR", - "SWAP", - "DEPTH", - "CINDEX", - "MINDEX", - "AlignPTS", - "INS_$28", - "UTP", - "LOOPCALL", - "CALL", - "FDEF", - "ENDF", - "MDAP[-]", - "MDAP[r]", - - "IUP[y]", - "IUP[x]", - "SHP[0]", - "SHP[1]", - "SHC[0]", - "SHC[1]", - "SHZ[0]", - "SHZ[1]", - "SHPIX", - "IP", - "MSIRP[0]", - "MSIRP[1]", - "AlignRP", - "RTDG", - "MIAP[-]", - "MIAP[r]", - - "NPushB", - "NPushW", - "WS", - "RS", - "WCvtP", - "RCvt", - "GC[0]", - "GC[1]", - "SCFS", - "MD[0]", - "MD[1]", - "MPPEM", - "MPS", - "FlipON", - "FlipOFF", - "DEBUG", - - "LT", - "LTEQ", - "GT", - "GTEQ", - "EQ", - "NEQ", - "ODD", - "EVEN", - "IF", - "EIF", - "AND", - "OR", - "NOT", - "DeltaP1", - "SDB", - "SDS", - - "ADD", - "SUB", - "DIV", - "MUL", - "ABS", - "NEG", - "FLOOR", - "CEILING", - "ROUND[G]", - "ROUND[B]", - "ROUND[W]", - "ROUND[?]", - "NROUND[G]", - "NROUND[B]", - "NROUND[W]", - "NROUND[?]", - - "WCvtF", - "DeltaP2", - "DeltaP3", - "DeltaC1", - "DeltaC2", - "DeltaC3", - "SROUND", - "S45Round", - "JROT", - "JROF", - "ROFF", - "INS_$7B", - "RUTG", - "RDTG", - "SANGW", - "AA", - - "FlipPT", - "FlipRgON", - "FlipRgOFF", - "INS_$83", - "INS_$84", - "ScanCTRL", - "SDPVTL[0]", - "SDPVTL[1]", - "GetINFO", - "IDEF", - "ROLL", - "MAX", - "MIN", - "ScanTYPE", - "IntCTRL", - "INS_$8F", - - "INS_$90", - "INS_$91", - "INS_$92", - "INS_$93", - "INS_$94", - "INS_$95", - "INS_$96", - "INS_$97", - "INS_$98", - "INS_$99", - "INS_$9A", - "INS_$9B", - "INS_$9C", - "INS_$9D", - "INS_$9E", - "INS_$9F", - - "INS_$A0", - "INS_$A1", - "INS_$A2", - "INS_$A3", - "INS_$A4", - "INS_$A5", - "INS_$A6", - "INS_$A7", - "INS_$A8", - "INS_$A9", - "INS_$AA", - "INS_$AB", - "INS_$AC", - "INS_$AD", - "INS_$AE", - "INS_$AF", - - "PushB[0]", - "PushB[1]", - "PushB[2]", - "PushB[3]", - "PushB[4]", - "PushB[5]", - "PushB[6]", - "PushB[7]", - "PushW[0]", - "PushW[1]", - "PushW[2]", - "PushW[3]", - "PushW[4]", - "PushW[5]", - "PushW[6]", - "PushW[7]", - - "MDRP[G]", - "MDRP[B]", - "MDRP[W]", - "MDRP[?]", - "MDRP[rG]", - "MDRP[rB]", - "MDRP[rW]", - "MDRP[r?]", - "MDRP[mG]", - "MDRP[mB]", - "MDRP[mW]", - "MDRP[m?]", - "MDRP[mrG]", - "MDRP[mrB]", - "MDRP[mrW]", - "MDRP[mr?]", - "MDRP[pG]", - "MDRP[pB]", - - "MDRP[pW]", - "MDRP[p?]", - "MDRP[prG]", - "MDRP[prB]", - "MDRP[prW]", - "MDRP[pr?]", - "MDRP[pmG]", - "MDRP[pmB]", - "MDRP[pmW]", - "MDRP[pm?]", - "MDRP[pmrG]", - "MDRP[pmrB]", - "MDRP[pmrW]", - "MDRP[pmr?]", - - "MIRP[G]", - "MIRP[B]", - "MIRP[W]", - "MIRP[?]", - "MIRP[rG]", - "MIRP[rB]", - "MIRP[rW]", - "MIRP[r?]", - "MIRP[mG]", - "MIRP[mB]", - "MIRP[mW]", - "MIRP[m?]", - "MIRP[mrG]", - "MIRP[mrB]", - "MIRP[mrW]", - "MIRP[mr?]", - "MIRP[pG]", - "MIRP[pB]", - - "MIRP[pW]", - "MIRP[p?]", - "MIRP[prG]", - "MIRP[prB]", - "MIRP[prW]", - "MIRP[pr?]", - "MIRP[pmG]", - "MIRP[pmB]", - "MIRP[pmW]", - "MIRP[pm?]", - "MIRP[pmrG]", - "MIRP[pmrB]", - "MIRP[pmrW]", - "MIRP[pmr?]" - }; - - - const String* Cur_U_Line( void* _exec ) - { - String s[32]; - - Int op, i, n; - - PExecution_Context exec; - - - exec = _exec; - - op = exec->code[exec->IP]; - - sprintf( tempStr, "%s", OpStr[op] ); - - if ( op == 0x40 ) - { - n = exec->code[exec->IP + 1]; - sprintf( s, "(%d)", n ); - strncat( tempStr, s, 8 ); - - if ( n > 20 ) n = 20; /* limit output */ - - for ( i = 0; i < n; i++ ) - { - sprintf( s, " $%02hx", exec->code[exec->IP + i + 2] ); - strncat( tempStr, s, 8 ); - } - } - else if ( op == 0x41 ) - { - n = exec->code[exec->IP + 1]; - sprintf( s, "(%d)", n ); - strncat( tempStr, s, 8 ); - - if ( n > 20 ) n = 20; /* limit output */ - - for ( i = 0; i < n; i++ ) - { - sprintf( s, " $%02hx%02hx", exec->code[exec->IP + i*2 + 2], - exec->code[exec->IP + i*2 + 3] ); - strncat( tempStr, s, 8 ); - } - } - else if ( (op & 0xF8) == 0xB0 ) - { - n = op - 0xB0; - - for ( i = 0; i <= n; i++ ) - { - sprintf( s, " $%02hx", exec->code[exec->IP + i + 1] ); - strncat( tempStr, s, 8 ); - } - } - else if ( (op & 0xF8) == 0xB8 ) - { - n = op-0xB8; - - for ( i = 0; i <= n; i++ ) - { - sprintf( s, " $%02hx%02hx", exec->code[exec->IP + i*2 + 1], - exec->code[exec->IP + i*2 + 2] ); - strncat( tempStr, s, 8 ); - } - } - - return (String*)tempStr; - } - - - /* the Print() function is defined in ttconfig.h; */ - /* it defaults to vprintf on systems which have it */ - - void TT_Message( const String* fmt, ... ) - { - va_list ap; - - va_start( ap, fmt ); - Print( fmt, ap ); - va_end( ap ); - } - - - void TT_Panic( const String* fmt, ... ) - { - va_list ap; - - va_start( ap, fmt ); - Print( fmt, ap ); - va_end( ap ); - - exit( EXIT_FAILURE ); - } - -#endif /* defined( DEBUG_LEVEL_ERROR ) || defined( DEBUG_LEVEL_TRACE ) */ - -#if defined( DEBUG_LEVEL_TRACE ) - - /* use this function to set the values of tt_trace_levels */ - - void set_tt_trace_levels( int index, char value ) - { - tt_trace_levels[index] = value; - } - -#endif - -/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttdebug.h b/Driver/Font/TrueType/FreeType/ttdebug.h deleted file mode 100644 index ac132512b..000000000 --- a/Driver/Font/TrueType/FreeType/ttdebug.h +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************* - * - * ttdebug.h - * - * Debugging and Logging component (specification) - * - * 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. - * - * - * This component contains various macros and functions used to - * ease the debugging of the FreeType engine. Its main purpose - * is in assertion checking, tracing, and error detection. - * - * There are now three debugging modes: - * - * - trace mode: - * - * Error and trace messages are sent to the log file - * (which can be the standard error output). Define - * DEBUG_LEVEL_TRACE to enable this mode. - * - * - error mode: - * - * Only error messages are generated. Define - * DEBUG_LEVEL_ERROR to enable this mode. - * - * - release mode: - * - * Error messages are neither sent nor generated. The code is - * free from any debugging parts. - * - ******************************************************************/ - -#ifndef TTDEBUG_H -#define TTDEBUG_H - -#include "ttconfig.h" -#include "tttypes.h" - - -#ifdef __cplusplus - extern "C" { -#endif - - -#if defined( DEBUG_LEVEL_TRACE ) - - typedef enum Trace_Component_ - { - trace_any = 0, - trace_api, - trace_interp, - trace_load, - trace_gload, - trace_memory, - trace_file, - trace_mutex, - trace_cache, - trace_calc, - trace_cmap, - trace_extend, - trace_objs, - trace_raster, - - trace_bitmap, - trace_max - - } Trace_Component; - - - /* Here we define an array to hold the trace levels per component. */ - /* Since it is globally defined, all array members are set to 0. */ - /* You should set the values in this array either in your program */ - /* or with your debugger. */ - /* */ - /* Currently, up to eight levels (PTRACE0-PTRACE7, see below) are */ - /* used in some parts of the engine. */ - /* */ - /* For example, to have all tracing messages in the raster */ - /* component, say */ - /* */ - /* #define DEBUG_LEVEL_TRACE */ - /* #include "ttdebug.h" */ - /* */ - /* ... */ - /* set_tt_trace_levels( trace_raster, 7 ) */ - /* */ - /* in your code before initializing the FreeType engine. */ - /* */ - /* Maybe it is better to define DEBUG_LEVEL_TRACE in ttconfig.h... */ - - extern char tt_trace_levels[trace_max]; - - /* IMPORTANT: */ - /* */ - /* Each component must define the macro TT_COMPONENT */ - /* to a valid Trace_Component value before using any */ - /* PTRACEx macro. */ - /* */ - -#define PTRACE( level, varformat ) \ - if ( tt_trace_levels[TT_COMPONENT] >= level ) TT_Message##varformat - -#elif defined( DEBUG_LEVEL_ERROR ) - -#define PTRACE( level, varformat ) /* nothing */ - -#else /* RELEASE MODE */ - -#define TT_Assert( condition, action ) /* nothing */ - -#define PTRACE( level, varformat ) /* nothing */ -#define PERROR( varformat ) /* nothing */ -#define PANIC( varformat ) /* nothing */ - -#endif - - -/************************************************************************/ -/* */ -/* Define macros and fuctions that are common to the debug and trace */ -/* modes. */ -/* */ - -#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) - - -#define TT_Assert( condition, action ) if ( !(condition) ) ( action ) - - void TT_Message( const String* fmt, ... ); - void TT_Panic ( const String* fmt, ... ); - /* print a message and exit */ - - const String* Cur_U_Line( void* exec ); - -#define PERROR( varformat ) TT_Message##varformat -#define PANIC( varformat ) TT_Panic##varformat - -#endif - -#if defined( DEBUG_LEVEL_TRACE ) - - void set_tt_trace_levels( int index, char value ); - -#endif - - -#define PTRACE0( varformat ) PTRACE( 0, varformat ) -#define PTRACE1( varformat ) PTRACE( 1, varformat ) -#define PTRACE2( varformat ) PTRACE( 2, varformat ) -#define PTRACE3( varformat ) PTRACE( 3, varformat ) -#define PTRACE4( varformat ) PTRACE( 4, varformat ) -#define PTRACE5( varformat ) PTRACE( 5, varformat ) -#define PTRACE6( varformat ) PTRACE( 6, varformat ) -#define PTRACE7( varformat ) PTRACE( 7, varformat ) - - -#ifdef __cplusplus - } -#endif - - -#endif /* TTDEBUG_H */ diff --git a/Driver/Font/TrueType/FreeType/ttengine.h b/Driver/Font/TrueType/FreeType/ttengine.h index 0c00b0485..a8d3c98bf 100644 --- a/Driver/Font/TrueType/FreeType/ttengine.h +++ b/Driver/Font/TrueType/FreeType/ttengine.h @@ -62,16 +62,9 @@ void* objs_exec_cache; /* the current face and execution */ /* context objects */ - void* file_component; /* ttfile implementation dependent */ - - TMutex raster_lock; /* mutex for this engine's render pool */ - void* raster_component; /* ttraster implementation depedent */ - + TMutex raster_lock; /* mutex for this engine's render pool */ + void* raster_component; /* ttraster implementation depedent */ void* extension_component; /* extensions dependent */ - -#if 0 - TT_Glyph_Loader_Callback glCallback; /* glyph loader callback, if any */ -#endif }; /* NOTE : The raster's lock is only acquired by the Render_Glyph and */ diff --git a/Driver/Font/TrueType/FreeType/ttextend.c b/Driver/Font/TrueType/FreeType/ttextend.c index d0a1d384d..0c66c29d9 100644 --- a/Driver/Font/TrueType/FreeType/ttextend.c +++ b/Driver/Font/TrueType/FreeType/ttextend.c @@ -40,7 +40,6 @@ typedef TExtension_Registry* PExtension_Registry; - /* Initialize the extension component */ LOCAL_FUNC diff --git a/Driver/Font/TrueType/FreeType/ttfile.c b/Driver/Font/TrueType/FreeType/ttfile.c index 5ac0ae4c2..b4a913b5d 100644 --- a/Driver/Font/TrueType/FreeType/ttfile.c +++ b/Driver/Font/TrueType/FreeType/ttfile.c @@ -50,16 +50,11 @@ #include "freetype.h" #include "tttypes.h" -#include "ttdebug.h" #include "ttengine.h" #include "ttmutex.h" #include "ttmemory.h" #include "ttfile.h" /* our prototypes */ -#ifdef __GEOS__ -#include -#include -#endif /* ifdef __GEOS__ */ /* required by the tracing mode */ #undef TT_COMPONENT @@ -99,17 +94,10 @@ struct TStream_Rec_ { - Bool opened; /* is the stream handle opened ? */ - TT_Text* name; /* the file's pathname */ - Long position; /* current position within the file */ - -#ifdef __GEOS__ - FileHandle file; /* FreeGEOS file handle */ -#else - FILE* file; /* file handle */ -#endif /* ifdef __GEOS__ */ - Long base; /* stream base in file */ - Long size; /* stream size in file */ + Long position; /* current position within the file */ + FILE* file; /* file handle */ + Long base; /* stream base in file */ + Long size; /* stream size in file */ }; /* We support embedded TrueType files by allowing them to be */ @@ -445,9 +433,6 @@ /*******************************************************************/ /*******************************************************************/ -/* a simple macro to access the file component's data */ -#define files ( *((TFile_Component*)engine.file_component) ) - #define CUR_Stream STREAM2REC( stream ) /* re-entrant macros */ #define CUR_Frame (*frame) @@ -464,7 +449,7 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TTFile_Init( TT_Engine engine ) + TT_Error TTFile_Init( PEngine_Instance engine ) { return TT_Err_Ok; } @@ -505,7 +490,7 @@ { PStream_Rec rec = STREAM2REC( input_stream ); - return TT_Open_Stream( rec->name, copy ); + return TT_Open_Stream( rec->file, copy ); } @@ -690,50 +675,21 @@ * ******************************************************************/ - TT_Error Stream_Activate( PStream_Rec stream ) + static TT_Error Stream_Activate( PStream_Rec stream ) { - if ( !stream->opened ) - { -#ifdef __GEOS__ - if ( (stream->file = FileOpen( (TT_Text*)stream->name, FILE_ACCESS_R | FILE_DENY_W)) == NullHandle ) -#else - if ( (stream->file = fopen( (TT_Text*)stream->name, "rb" )) == 0 ) -#endif /* ifdef __GEOS__ */ - return TT_Err_Could_Not_ReOpen_File; + if ( !stream->file ) + return TT_Err_Could_Not_ReOpen_File; - stream->opened = TRUE; + /* A newly created stream has a size field of -1 */ + if ( stream->size < 0 ) + stream->size = FileSize( stream->file ); - /* A newly created stream has a size field of -1 */ - if ( stream->size < 0 ) - { -#ifdef __GEOS__ - stream->size = FileSize( stream->file ); -#else - fseek( stream->file, 0, SEEK_END ); - stream->size = ftell( stream->file ); - fseek( stream->file, 0, SEEK_SET ); -#endif /* ifdef __GEOS__ */ - } - - /* Reset cursor in file */ - if ( stream->position ) - { -#ifdef __GEOS__ - FilePos( stream->file, stream->position, FILE_POS_START); - if ( ThreadGetError() != NO_ERROR_RETURNED ) - { - /* error during seek */ - FileClose( stream->file, FALSE ); -#else - if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 ) - { - /* error during seek */ - fclose( stream->file ); -#endif /* ifdef __GEOS__ */ - stream->opened = FALSE; - return TT_Err_Could_Not_ReSeek_File; - } - } + /* Reset cursor in file */ + if ( stream->position ) + { + FilePos( stream->file, stream->position, FILE_POS_START); + if ( ThreadGetError() != NO_ERROR_RETURNED ) + return TT_Err_Could_Not_ReSeek_File; } return TT_Err_Ok; } @@ -760,19 +716,8 @@ static TT_Error Stream_Deactivate( PStream_Rec stream ) { - if ( stream->opened ) - { - /* Save its current position within the file */ -#ifdef __GEOS__ - stream->position = FilePos( stream->file, 0, FILE_POS_RELATIVE ); - FileClose( stream->file, FALSE ); -#else - stream->position = ftell( stream->file ); - fclose( stream->file ); -#endif /* ifdef __GEOS__ */ - stream->file = 0; - stream->opened = FALSE; - } + /* Save its current position within the file */ + stream->position = FilePos( stream->file, 0, FILE_POS_RELATIVE ); return TT_Err_Ok; } @@ -821,37 +766,28 @@ ******************************************************************/ LOCAL_FUNC - TT_Error TT_Open_Stream( const TT_Text* filepathname, - TT_Stream* stream ) + TT_Error TT_Open_Stream( const FileHandle file, + TT_Stream* stream ) { Int len; TT_Error error; PStream_Rec stream_rec; + CHECK_FILE( file ); + if ( ALLOC( *stream, sizeof ( TStream_Rec ) ) ) return error; stream_rec = STREAM2REC( *stream ); -#ifdef __GEOS__ - stream_rec->file = NullHandle; -#else - stream_rec->file = NULL; -#endif /* ifdef __GEOS__ */ + stream_rec->file = file; stream_rec->size = -1L; stream_rec->base = 0; - stream_rec->opened = FALSE; stream_rec->position = 0; - len = strlen( filepathname ) + 1; - if ( ALLOC( stream_rec->name, len ) ) - goto Fail; - - strncpy( stream_rec->name, filepathname, len ); - error = Stream_Activate( stream_rec ); if ( error ) - goto Fail_Activate; + goto Fail; #ifndef TT_CONFIG_OPTION_THREAD_SAFE CUR_Stream = stream_rec; @@ -859,8 +795,6 @@ return TT_Err_Ok; - Fail_Activate: - FREE( stream_rec->name ); Fail: FREE( stream_rec ); return error; @@ -886,7 +820,6 @@ Stream_Deactivate( rec ); - FREE( rec->name ); FREE( rec ); HANDLE_Set( *stream, NULL ); @@ -943,12 +876,8 @@ { position += CUR_Stream->base; -#ifdef __GEOS__ FilePos( CUR_Stream->file, position, FILE_POS_START ); if ( ThreadGetError() != NO_ERROR_RETURNED ) -#else - if ( fseek( CUR_Stream->file, position, SEEK_SET ) ) -#endif /* ifdef __GEOS__ */ return TT_Err_Invalid_File_Offset; return TT_Err_Ok; @@ -970,13 +899,8 @@ EXPORT_FUNC TT_Error TT_Skip_File( STREAM_ARGS Long distance ) { -#ifdef __GEOS__ return TT_Seek_File( STREAM_VARS FilePos( CUR_Stream->file, 0, FILE_POS_RELATIVE ) - CUR_Stream->base + distance ); -#else - return TT_Seek_File( STREAM_VARS ftell( CUR_Stream->file ) - - CUR_Stream->base + distance ); -#endif /* ifdef __GEOS__ */ } @@ -996,11 +920,7 @@ EXPORT_FUNC TT_Error TT_Read_File( STREAM_ARGS void* buffer, Long count ) { - #ifdef __GEOS__ if ( FileRead( CUR_Stream->file, buffer, count, FALSE ) != (ULong)count ) - #else - if ( fread( buffer, 1, count, CUR_Stream->file ) != (ULong)count ) - #endif /* ifdef __GEOS__ */ return TT_Err_Invalid_File_Read; return TT_Err_Ok; @@ -1052,11 +972,7 @@ EXPORT_FUNC Long TT_File_Pos( STREAM_ARG ) { - #ifdef __GEOS__ return FilePos( CUR_Stream->file, 0, FILE_POS_RELATIVE ) - CUR_Stream->base; - #else - return ftell( CUR_Stream->file ) - CUR_Stream->base; - #endif /* ifdef __GEOS__ */ } diff --git a/Driver/Font/TrueType/FreeType/ttfile.h b/Driver/Font/TrueType/FreeType/ttfile.h index 64fb233c1..0c47ffc22 100644 --- a/Driver/Font/TrueType/FreeType/ttfile.h +++ b/Driver/Font/TrueType/FreeType/ttfile.h @@ -34,7 +34,6 @@ #include "ttconfig.h" #include "freetype.h" #include "ttengine.h" -#include "ttdebug.h" #ifdef __cplusplus extern "C" { @@ -59,8 +58,8 @@ /* Should only be used for a new face object's main stream. */ LOCAL_DEF - TT_Error TT_Open_Stream( const TT_Text* name, - TT_Stream* stream ); + TT_Error TT_Open_Stream( const FileHandle file, + TT_Stream* stream ); /* Closes, then discards, a stream when it's no longer needed. */ @@ -200,6 +199,9 @@ } +#define CHECK_FILE( _handle_ ) ECCheckFileHandle( _handle_ ) + + /* The macros FRAME_ARGS and FRAME_ARG let us build a thread-safe */ /* or re-entrant implementation depending on a single configuration */ /* define */ diff --git a/Driver/Font/TrueType/FreeType/ttgload.c b/Driver/Font/TrueType/FreeType/ttgload.c index a10418e51..0c58cf196 100644 --- a/Driver/Font/TrueType/FreeType/ttgload.c +++ b/Driver/Font/TrueType/FreeType/ttgload.c @@ -16,7 +16,6 @@ ******************************************************************/ #include "tttypes.h" -#include "ttdebug.h" #include "ttcalc.h" #include "ttfile.h" @@ -204,11 +203,7 @@ /* simple check */ if ( n_contours > left_contours ) - { - PTRACE0(( "ERROR: Glyph index %ld has %d contours > left %d\n", - subg->index, n_contours, left_contours )); return TT_Err_Too_Many_Contours; - } /* preparing the execution context */ @@ -218,14 +213,9 @@ if ( ACCESS_Frame( (n_contours + 1) * 2L ) ) return error; - PTRACE4(( " Contour endpoints:" )); - for ( k = 0; k < n_contours; k++ ) - { exec->pts.contours[k] = GET_UShort(); - PTRACE4(( " %d", exec->pts.contours[k] )); - } - PTRACE4(( "\n" )); + if ( n_contours > 0 ) n_points = exec->pts.contours[n_contours - 1] + 1; @@ -237,20 +227,12 @@ FORGET_Frame(); if ( n_points > left_points ) - { - PTRACE0(( "ERROR: Too many points in glyph %ld\n", subg->index )); return TT_Err_Too_Many_Points; - } /* loading instructions */ - PTRACE4(( " Instructions size: %d\n", n_ins )); - if ( n_ins > face->maxProfile.maxSizeOfInstructions ) - { - PTRACE0(( "ERROR: Too many instructions!\n" )); return TT_Err_Too_Many_Ins; - } if ( FILE_Read( exec->glyphIns, n_ins ) ) return error; @@ -447,14 +429,8 @@ n_ins = GET_UShort(); /* read size of instructions */ FORGET_Frame(); - PTRACE4(( " Instructions size: %d\n", n_ins )); - if ( n_ins > exec->face->maxProfile.maxSizeOfInstructions ) - { - PTRACE0(( "ERROR: Too many instructions in composite glyph %ld\n", - subg->index )); return TT_Err_Too_Many_Ins; - } if ( FILE_Read( exec->glyphIns, n_ins ) ) return error; @@ -633,10 +609,7 @@ table = TT_LookUp_Table( face, TTAG_glyf ); if ( table < 0 ) - { - PTRACE0(( "ERROR: There is no glyph table in this font file!\n" )); return TT_Err_Glyf_Table_Missing; - } glyph_offset = face->dirTables[table].Offset; @@ -740,32 +713,6 @@ phase = Load_Header; - - /* The cache callback isn't part of the FreeType release yet */ - /* It is discarded for the moment.. */ - /* */ -#if 0 - if ( instance ) - { - /* is the glyph in an outline cache ? */ - cacheCb = instance->owner->engine->glCallback; - if ( cacheCb && 0 ) /* disabled */ - { - /* we have a callback */ - error = cacheCb( instance->generic, - index, &cached_outline, &x, &y ); - if ( !error ) - { - /* no error, then append the outline to the current subglyph */ - /* error = Append_Outline( subglyph, - &left_points, - &left_contours, - &cached_outline ); */ - phase = Load_End; - } - } - } -#endif break; @@ -821,18 +768,8 @@ FORGET_Frame(); - PTRACE6(( "Glyph %ld:\n", index )); - PTRACE6(( " # of contours: %d\n", num_contours )); - PTRACE6(( " xMin: %4d xMax: %4d\n", - subglyph->metrics.bbox.xMin, - subglyph->metrics.bbox.xMax )); - PTRACE6(( " yMin: %4d yMax: %4d\n", - subglyph->metrics.bbox.yMin, - subglyph->metrics.bbox.yMax )); - if ( num_contours > left_contours ) { - PTRACE0(( "ERROR: Too many contours for glyph %ld\n", index )); error = TT_Err_Too_Many_Contours; goto Fail; } diff --git a/Driver/Font/TrueType/FreeType/ttinterp.c b/Driver/Font/TrueType/FreeType/ttinterp.c index a8e8ff510..f5d8e3d8d 100644 --- a/Driver/Font/TrueType/FreeType/ttinterp.c +++ b/Driver/Font/TrueType/FreeType/ttinterp.c @@ -31,7 +31,6 @@ #include "freetype.h" #include "tttypes.h" -#include "ttdebug.h" #include "ttcalc.h" #include "ttmemory.h" #include "ttinterp.h" @@ -52,7 +51,6 @@ #ifdef DEBUG_INTERPRETER #include -#include "ttdebug.h" /* Define the `getch()' function. On Unix systems, it is an alias */ /* for `getchar()', and the debugger front end must ensure that the */ @@ -172,49 +170,49 @@ #define CUR_Func_project( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_project, EXEC_ARGS x, y ) #else #define CUR_Func_project( x, y ) CUR.func_project( EXEC_ARGS x, y ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_move( z, p, d ) ProcCallFixedOrMovable_cdecl( CUR.func_move, EXEC_ARGS z, p, d ) #else #define CUR_Func_move( z, p, d ) CUR.func_move( EXEC_ARGS z, p, d ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_dualproj( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_dualproj, EXEC_ARGS x, y ) #else #define CUR_Func_dualproj( x, y ) CUR.func_dualproj( EXEC_ARGS x, y ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_freeProj( x, y ) ProcCallFixedOrMovable_cdecl( CUR.func_freeProj, EXEC_ARGS x, y ) #else #define CUR_Func_freeProj( x, y ) CUR.func_freeProj( EXEC_ARGS x, y ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_round( d, c ) ProcCallFixedOrMovable_cdecl( CUR.func_round, EXEC_ARGS d, c ) #else #define CUR_Func_round( d, c ) CUR.func_round( EXEC_ARGS d, c ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_read_cvt( index ) ProcCallFixedOrMovable_cdecl( CUR.func_read_cvt, EXEC_ARGS index ) #else #define CUR_Func_read_cvt( index ) CUR.func_read_cvt( EXEC_ARGS index ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_write_cvt( index, val ) ProcCallFixedOrMovable_cdecl( CUR.func_write_cvt, EXEC_ARGS index, val ) #else #define CUR_Func_write_cvt( index, val ) CUR.func_write_cvt( EXEC_ARGS index, val ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #ifdef __GEOS__ #define CUR_Func_move_cvt( index, val ) ProcCallFixedOrMovable_cdecl( CUR.func_move_cvt, EXEC_ARGS index, val ) #else #define CUR_Func_move_cvt( index, val ) CUR.func_move_cvt( EXEC_ARGS index, val ) -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ #define CURRENT_Ratio() Current_Ratio( EXEC_ARG ) #define CURRENT_Ppem() Current_Ppem( EXEC_ARG ) diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 981386995..1dba36754 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -1,4 +1,3 @@ - /******************************************************************* * * ttload.c 1.0 @@ -17,7 +16,6 @@ ******************************************************************/ #include "tttypes.h" -#include "ttdebug.h" #include "ttcalc.h" #include "ttfile.h" @@ -57,18 +55,10 @@ UShort i; - PTRACE4(( "TT_LookUp_Table( %08lx, %c%c%c%c )\n", - (Long)face, - (Char)(tag >> 24), - (Char)(tag >> 16), - (Char)(tag >> 8), - (Char)(tag) )); - for ( i = 0; i < face->numTables; i++ ) if ( face->dirTables[i].Tag == tag ) return i; - PTRACE4(( " Could not find table!\n" )); return -1; } @@ -92,8 +82,6 @@ ULong n; - PTRACE3(( "Load_TrueType_Collection( %08lx )\n", (long)face )); - if ( FILE_Seek ( 0L ) || ACCESS_Frame( 12L ) ) return error; @@ -112,8 +100,6 @@ face->ttcHeader.TableDirectory = NULL; - PTRACE3(("skipped.\n")); - return TT_Err_File_Is_Not_Collection; } @@ -128,7 +114,6 @@ FORGET_Frame(); - PTRACE3(( "collections directory loaded.\n" )); return TT_Err_Ok; } @@ -159,8 +144,6 @@ PTableDirEntry entry; - PTRACE2(("Load_TT_Directory( %08lx, %ld )\n", (long)face, faceIndex)); - error = Load_TrueType_Collection( face ); if ( error ) @@ -200,16 +183,12 @@ FORGET_Frame(); - PTRACE2(( "-- Tables count : %12u\n", tableDir.numTables )); - PTRACE2(( "-- Format version : %08lx\n", tableDir.version )); - /* Check that we have a 'sfnt' format there */ if ( tableDir.version != 0x00010000 && /* MS fonts */ tableDir.version != 0x74727565 && /* Mac fonts */ tableDir.version != 0x00000000 ) /* some Korean fonts */ { - PERROR(( "!! invalid file format" )); return TT_Err_Invalid_File_Format; } @@ -233,19 +212,11 @@ entry->Offset = GET_Long(); entry->Length = GET_Long(); - PTRACE2(( " %c%c%c%c - %08lx - %08lx\n", - (Char)(entry->Tag >> 24), - (Char)(entry->Tag >> 16), - (Char)(entry->Tag >> 8 ), - (Char)(entry->Tag), - entry->Offset, - entry->Length )); entry++; } FORGET_Frame(); - PTRACE2(( "Directory loaded\n\n" )); return TT_Err_Ok; } @@ -271,8 +242,6 @@ PMaxProfile maxProfile = &face->maxProfile; - PTRACE2(( "Load_TT_MaxProfile( %08lx )\n", (long)face )); - if ( ( i = TT_LookUp_Table( face, TTAG_maxp ) ) < 0 ) return TT_Err_Max_Profile_Missing; @@ -333,7 +302,6 @@ face->maxPoints += 8; face->maxContours += 4; - PTRACE2(( "GASP loaded.\n" )); return TT_Err_Ok; } @@ -362,8 +330,6 @@ GaspRange* gaspranges; - PTRACE2(( "Load_TT_Gasp( %08lx )\n", (long)face )); - if ( ( i = TT_LookUp_Table( face, TTAG_gasp ) ) < 0 ) return TT_Err_Ok; /* gasp table is not required */ @@ -378,8 +344,6 @@ FORGET_Frame(); - PTRACE3(( "number of ranges = %d\n", gas->numRanges )); - if ( ALLOC_ARRAY( gaspranges, gas->numRanges, GaspRange ) || ACCESS_Frame( gas->numRanges * 4L ) ) goto Fail; @@ -390,16 +354,9 @@ { gaspranges[j].maxPPEM = GET_UShort(); gaspranges[j].gaspFlag = GET_UShort(); - - PTRACE3(( " [max:%d flag:%d]", - gaspranges[j].maxPPEM, - gaspranges[j].gaspFlag )); } - PTRACE3(("\n")); FORGET_Frame(); - - PTRACE2(( "GASP loaded\n" )); return TT_Err_Ok; Fail: @@ -431,13 +388,8 @@ TT_Header* header; - PTRACE2(( "Load_TT_Header( %08lx )\n", (long)face )); - if ( ( i = TT_LookUp_Table( face, TTAG_head ) ) < 0 ) - { - PTRACE0(( "Font Header is missing !!\n" )); return TT_Err_Header_Table_Missing; - } if ( FILE_Seek( face->dirTables[i].Offset ) || ACCESS_Frame( 54L ) ) @@ -473,9 +425,6 @@ FORGET_Frame(); - PTRACE2(( " Units per EM : %8u\n", header->Units_Per_EM )); - PTRACE2(( " IndexToLoc : %8d\n", header->Index_To_Loc_Format )); - PTRACE2(( "Font Header Loaded.\n" )); return TT_Err_Ok; } @@ -509,10 +458,6 @@ PLongMetrics long_metric; - PTRACE2(( "Load_TT_%s_Metrics( %08lx )\n", - vertical ? "Vertical" : "Horizontal", - (long)face )); - if ( vertical ) { /* The table is optional, quit silently if it wasn't found */ @@ -526,7 +471,6 @@ if ( n < 0 ) { /* Set the number_Of_VMetrics to 0! */ - PTRACE2(( " no vertical header in file.\n" )); face->verticalHeader.number_Of_VMetrics = 0; return TT_Err_Ok; } @@ -538,10 +482,7 @@ else { if ( ( n = TT_LookUp_Table( face, TTAG_hmtx ) ) < 0 ) - { - PERROR(( "!! No Horizontal metrics in file !!\n" )); return TT_Err_Hmtx_Table_Missing; - } num_longs = face->horizontalHeader.number_Of_HMetrics; longs = (PLongMetrics*)&face->horizontalHeader.long_metrics; @@ -555,7 +496,6 @@ if ( num_shorts < 0 ) /* sanity check */ { - PERROR(( "!! more metrics than glyphs!\n" )); if ( vertical ) return TT_Err_Invalid_Vert_Metrics; else @@ -600,7 +540,6 @@ FORGET_Frame(); - PTRACE2(( "loaded\n" )); return TT_Err_Ok; } @@ -634,8 +573,6 @@ TT_Horizontal_Header* header; - PTRACE2(( vertical ? "Vertical header" : "Horizontal header " )); - if ( vertical ) { face->verticalInfo = 0; @@ -690,8 +627,6 @@ header->long_metrics = NULL; header->short_metrics = NULL; - PTRACE2(( "loaded\n" )); - /* Now try to load the corresponding metrics */ return Load_TrueType_Metrics( face, vertical ); @@ -723,8 +658,6 @@ Short LongOffsets; - PTRACE2(( "Locations " )); - LongOffsets = face->fontHeader.Index_To_Loc_Format; if ( ( n = TT_LookUp_Table( face, TTAG_loca ) ) < 0 ) @@ -737,9 +670,6 @@ { face->numLocations = face->dirTables[n].Length >> 2; - PTRACE2(( "(32 bit offsets): %12lu ", - face->numLocations )); - if ( ALLOC_ARRAY( face->glyphLocations, face->numLocations, Long ) ) @@ -759,9 +689,6 @@ { face->numLocations = face->dirTables[n].Length >> 1; - PTRACE2(( "(16 bit offsets): %12lu ", - face->numLocations )); - if ( ALLOC_ARRAY( face->glyphLocations, face->numLocations, Long ) ) @@ -779,8 +706,6 @@ FORGET_Frame(); } - PTRACE2(( "loaded\n" )); - return TT_Err_Ok; } @@ -810,15 +735,8 @@ TNameRec* namerec; - PTRACE2(( "Names " )); - if ( ( n = TT_LookUp_Table( face, TTAG_name ) ) < 0 ) - { - /* The name table is required so indicate failure. */ - PTRACE2(( "is missing!\n" )); - return TT_Err_Name_Table_Missing; - } /* Seek to the beginning of the table and check the frame access. */ /* The names table has a 6 byte header. */ @@ -858,18 +776,10 @@ namerec->stringLength = GET_UShort(); namerec->stringOffset = GET_UShort(); -#if 0 - /* check the ids */ - if ( namerec->platformID <= 3 ) - { -#endif /* this test takes care of 'holes' in the names tables, as */ /* reported by Erwin */ if ( (namerec->stringOffset + namerec->stringLength) > bytes ) bytes = namerec->stringOffset + namerec->stringLength; -#if 0 - } -#endif } FORGET_Frame(); @@ -898,51 +808,9 @@ /* It is possible (but rather unlikely) that a new platform ID will be */ /* added by Apple, so we can't rule out IDs > 3. */ -#if 0 - if ( namerec->platformID <= 3 ) - namerec->string = storage + names->names[i].stringOffset; - else - { - namerec->string = NULL; - namerec->stringLength = 0; - } -#endif } } -#ifdef DEBUG_LEVEL_TRACE - - for ( i = 0; i < names->numNameRecords; i++ ) - { - int j; - - - PTRACE2(( "%d %d %x %d ", - names->names[i].platformID, - names->names[i].encodingID, - names->names[i].languageID, - names->names[i].nameID )); - - /* I know that M$ encoded strings are Unicode, */ - /* but this works reasonable well for debugging purposes. */ - for ( j = 0; j < names->names[i].stringLength; j++ ) - { - if (names->names[i].string) - { - Char c = *(names->names[i].string + j); - - - if ( (Byte)c < 128 ) - PTRACE2(( "%c", c )); - } - } - - PTRACE2(( "\n" )); - } - -#endif /* DEBUG_LEVEL_TRACE */ - - PTRACE2(( "loaded\n" )); return TT_Err_Ok; Fail_Storage: @@ -1006,12 +874,8 @@ Long n, limit; - PTRACE2(( "CVT " )); - if ( ( n = TT_LookUp_Table( face, TTAG_cvt ) ) < 0 ) { - PTRACE2(( "is missing!\n" )); - face->cvtSize = 0; face->cvt = NULL; return TT_Err_Ok; @@ -1035,8 +899,6 @@ FORGET_Frame(); - PTRACE2(( "loaded\n" )); - return TT_Err_Ok; } @@ -1067,8 +929,6 @@ PCMapTable cmap; - PTRACE2(( "CMaps " )); - if ( ( n = TT_LookUp_Table( face, TTAG_cmap ) ) < 0 ) return TT_Err_CMap_Table_Missing; @@ -1128,8 +988,6 @@ cmap++; } - PTRACE2(( "loaded\n" )); - return TT_Err_Ok; } @@ -1155,15 +1013,11 @@ Long n; - PTRACE2(( "Font program " )); - /* The font program is optional */ if ( ( n = TT_LookUp_Table( face, TTAG_fpgm ) ) < 0 ) { face->fontProgram = NULL; face->fontPgmSize = 0; - - PTRACE2(( "is missing!\n" )); } else { @@ -1175,18 +1029,12 @@ (void*)face->fontProgram, face->fontPgmSize ) ) return error; - - PTRACE2(( "loaded, %12d bytes\n", face->fontPgmSize )); } - PTRACE2(( "Prep program " )); - if ( ( n = TT_LookUp_Table( face, TTAG_prep ) ) < 0 ) { face->cvtProgram = NULL; face->cvtPgmSize = 0; - - PTRACE2(( "is missing!\n" )); } else { @@ -1198,8 +1046,6 @@ (void*)face->cvtProgram, face->cvtPgmSize ) ) return error; - - PTRACE2(( "loaded, %12d bytes\n", face->cvtPgmSize )); } return TT_Err_Ok; @@ -1227,14 +1073,11 @@ TT_OS2* os2; - PTRACE2(( "OS/2 Table " )); - /* We now support old Mac fonts where the OS/2 table doesn't */ /* exist. Simply put, we set the `version' field to 0xFFFF */ /* and test this value each time we need to access the table. */ if ( ( i = TT_LookUp_Table( face, TTAG_OS2 ) ) < 0 ) { - PTRACE2(( "is missing\n!" )); face->os2.version = 0xFFFF; error = TT_Err_Ok; return TT_Err_Ok; @@ -1303,8 +1146,6 @@ os2->ulCodePageRange2 = 0; } - PTRACE2(( "loaded\n" )); - return TT_Err_Ok; } @@ -1331,8 +1172,6 @@ TT_Postscript* post = &face->postscript; - PTRACE2(( "PostScript " )); - if ( ( i = TT_LookUp_Table( face, TTAG_post ) ) < 0 ) return TT_Err_Post_Table_Missing; @@ -1357,8 +1196,6 @@ /* we don't load the glyph names, we do that in a */ /* library extension (ftxpost). */ - PTRACE2(( "loaded\n" )); - return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c index 952d09ba7..db8602c04 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.c +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -21,12 +21,8 @@ * - introduced the FREE macro and the Free function for * future use in destructors. * - * - Init_FontPool() is now a macro to allow the compilation of - * 'legacy' applications (all four test programs have been updated). - * ******************************************************************/ -#include "ttdebug.h" #include "ttmemory.h" #include "ttengine.h" @@ -35,41 +31,15 @@ #define TT_COMPONENT trace_memory -#ifdef DEBUG_MEMORY - -#include - -#define MAX_TRACKED_BLOCKS 1024 - - struct TMemRec_ - { - void* base; - Long size; - }; - - typedef struct TMemRec_ TMemRec; - - static TMemRec pointers[MAX_TRACKED_BLOCKS + 1]; - - static Int num_alloc; - static Int num_free; - static Int num_realloc; /* counts only `real' reallocations - (i.e., an existing buffer will be resized - to a value larger than zero */ - - static Int fail_alloc; - static Int fail_realloc; - static Int fail_free; - -#endif /* DEBUG_MEMORY */ - - #ifndef TT_CONFIG_OPTION_THREAD_SAFE Long TTMemory_Allocated; Long TTMemory_MaxAllocated; #endif +#define MAX_BLOCK_SIZE 32000 + + /******************************************************************* * * Function : TT_Alloc @@ -90,190 +60,29 @@ EXPORT_FUNC TT_Error TT_Alloc( ULong Size, void** P ) { -#ifdef DEBUG_MEMORY - Int i; -#endif + MemHandle handle; if ( !P ) return TT_Err_Invalid_Argument; - if ( Size > (size_t)-1 ) + if ( Size > MAX_BLOCK_SIZE ) return TT_Err_Out_Of_Memory; - if ( Size > 0 ) - { - *P = (void*)malloc( Size ); - if ( !*P ) - return TT_Err_Out_Of_Memory; - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated += Size; - TTMemory_MaxAllocated += Size; -#endif - -#ifdef DEBUG_MEMORY - - num_alloc++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != NULL ) - i++; - if ( i >= MAX_TRACKED_BLOCKS ) - fail_alloc++; - else - { - pointers[i].base = *P; - pointers[i].size = Size; - } - -#endif /* DEBUG_MEMORY */ - - MEM_Set( *P, 0, Size ); - } - else - *P = NULL; - - return TT_Err_Ok; - } - - /* TODO: diese Funktion soll TT_Alloc ablösen */ - EXPORT_FUNC - TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ) - { - if ( !M || !C ) - return TT_Err_Invalid_Argument; - - if ( Size > (size_t)-1 ) - return TT_Err_Out_Of_Memory; if ( Size > 0 ) { - *C = LMemAlloc( M, Size ); - if ( !*C ) + handle = MemAlloc( Size, HF_SHARABLE | HF_SWAPABLE, HAF_ZERO_INIT | HAF_LOCK ); + if ( !handle ) return TT_Err_Out_Of_Memory; - - /* TODO: erstellten Chunkt mit 0 initialisieren */ - } - else - *C = NullChunk; - - return TT_Err_Ok; - } - - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - - -/******************************************************************* - * - * Function : TT_Realloc - * - * Description : Reallocates memory from the heap buffer. - * - * Input : Size new size of the memory to be allocated; - * if zero, TT_Free() will be called - * P pointer to a buffer pointer; if *P == NULL, - * TT_Alloc() will be called - * - * Output : Error code. - * - * NOTES : It's not necessary to zero the memory in case the - * reallocated buffer is larger than before -- the - * application has to take care of this. - * - * If the memory request fails, TT_Free() will be - * called on *P, and TT_Err_Out_Of_Memory returned. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Realloc( ULong Size, void** P ) - { - void* Q; - -#ifdef DEBUG_MEMORY - Int i; -#endif - - - if ( !P ) - return TT_Err_Invalid_Argument; - - if ( !*P ) - return TT_Alloc( Size, P ); - - if ( Size == 0 ) - return TT_Free( P ); - - if ( Size > (size_t)-1 ) - { - TT_Free( *P ); - return TT_Err_Out_Of_Memory; - } - - Q = (void*)realloc( *P, Size ); - if ( !Q ) - { - TT_Free( *P ); - return TT_Err_Out_Of_Memory; + + *P = MemDeref( handle ); } - -#ifdef DEBUG_MEMORY - - num_realloc++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_realloc++; else - { -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated += Size - pointers[i].size; - if ( Size > pointers[i].size ) - TTMemory_MaxAllocated += Size - pointers[i].size; -#endif - - pointers[i].base = Q; - pointers[i].size = size; - } -#endif /* DEBUG_MEMORY */ - - *P = Q; - - return TT_Err_Ok; - } - - /* TODO: diese Funktion soll TT_Realloc ablösen */ - EXPORT_FUNC - TT_Error GTT_Realloc( MemHandle M, ChunkHandle* C, unsigned int Size ) - { - if ( !M || !C ) - return TT_Err_Invalid_Argument; - - if ( !*C ) - return GTT_Alloc( M, C, Size ); - - if ( Size == 0 ) - return GTT_Free( M, C ); - - if ( Size > (size_t)-1 ) - { - GTT_Free( M, C ); - return TT_Err_Out_Of_Memory; - } - - *C = LMemReAllocHandles( M, *C, Size ); - if ( !*C ) - return TT_Err_Out_Of_Memory; + *P = NULL; return TT_Err_Ok; } -#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ - /******************************************************************* * @@ -292,36 +101,10 @@ EXPORT_FUNC TT_Error TT_Free( void** P ) { -#ifdef DEBUG_MEMORY - Int i; -#endif /* DEBUG_MEMORY */ - - if ( !P || !*P ) return TT_Err_Ok; -#ifdef DEBUG_MEMORY - - num_free++; - - i = 0; - while ( i < MAX_TRACKED_BLOCKS && pointers[i].base != *P ) - i++; - - if ( i >= MAX_TRACKED_BLOCKS ) - fail_free++; - else - { -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated -= pointers[i].size; -#endif - - pointers[i].base = NULL; - pointers[i].size = 0; - } -#endif /* DEBUG_MEMORY */ - - free( *P ); + MemFree( MemPtrToHandle( *P ) ); *P = NULL; @@ -329,21 +112,6 @@ } - /* TODO: diese Funktion soll TT_Free ablösen */ - EXPORT_FUNC - TT_Error GTT_Free( MemHandle M, ChunkHandle* C ) - { - if ( !M || !C || !*C ) - return TT_Err_Ok; - - LMemFreeHandles( M, *C ); - - *C = NullHandle; - - return TT_Err_Ok; - } - - /******************************************************************* * * Function : TTMemory_Init @@ -357,31 +125,6 @@ LOCAL_FUNC TT_Error TTMemory_Init( void ) { -#ifdef DEBUG_MEMORY - Int i; - - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - pointers[i].base = NULL; - pointers[i].size = 0; - } - - num_alloc = 0; - num_realloc = 0; - num_free = 0; - - fail_alloc = 0; - fail_realloc = 0; - fail_free = 0; -#endif - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - TTMemory_Allocated = 0; - TTMemory_MaxAllocated = 0; -#endif - return TT_Err_Ok; } @@ -399,60 +142,6 @@ LOCAL_FUNC TT_Error TTMemory_Done( void ) { -#ifdef DEBUG_MEMORY - Int i, num_leaked, tot_leaked; - - - num_leaked = 0; - tot_leaked = 0; - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - if ( pointers[i].base ) - { - num_leaked ++; - tot_leaked += pointers[i].size; - } - } - - fprintf( stderr, - "%d memory allocations, of which %d failed\n", - num_alloc, - fail_alloc ); - - fprintf( stderr, - "%d memory reallocations, of which %d failed\n", - num_realloc, - fail_realloc ); - - fprintf( stderr, - "%d memory frees, of which %d failed\n", - num_free, - fail_free ); - - if ( num_leaked > 0 ) - { - fprintf( stderr, - "There are %d leaked memory blocks, totalizing %d bytes\n", - num_leaked, tot_leaked ); - - for ( i = 0; i < MAX_TRACKED_BLOCKS; i++ ) - { - if ( pointers[i].base ) - { - fprintf( stderr, - "index: %4d (base: $%08lx, size: %08ld)\n", - i, - (long)pointers[i].base, - pointers[i].size ); - } - } - } - else - fprintf( stderr, "No memory leaks !\n" ); - -#endif /* DEBUG_MEMORY */ - return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h index 0e9d94e8c..914e6c3a7 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.h +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -21,9 +21,6 @@ * - introduced the FREE() macro and the Free() function for * future use in destructors. * - * - Init_FontPool() is now a macro to allow the compilation of - * 'legacy' applications (all four test programs have been updated). - * ******************************************************************/ #ifndef TTMEMORY_H @@ -42,7 +39,7 @@ #ifdef __GEOS__ #define MEM_Cmp( left, right, count ) memcmp( left, right, count ) -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ #ifdef HAVE_MEMCPY #define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) @@ -60,9 +57,6 @@ #define MEM_Alloc( _pointer_, _size_ ) \ TT_Alloc( _size_, (void**)&(_pointer_) ) -#define MEM_Realloc( _pointer_, _size_ ) \ - TT_Realloc( _size_, (void**)&(_pointer_) ) - #define ALLOC( _pointer_, _size_ ) \ ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok ) @@ -70,54 +64,9 @@ ( ( error = MEM_Alloc( _pointer_, \ (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) -#define REALLOC( _pointer_, _size_ ) \ - ( ( error = MEM_Realloc( _pointer_, _size_ ) ) != TT_Err_Ok ) - -#define REALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - ( (error = MEM_Realloc( _pointer_, \ - (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) - #define FREE( _pointer_ ) \ TT_Free( (void**)&(_pointer_) ) -/* TODO: diese Makros sollen die o.g. ablösen */ -#define MEM_USE_ENGINE MemHandle _memBlock = engineHandle - -#define MEM_LOCK MemLock( _memBlock ) - -#define MEM_UNLOCK MemUnlock( _memBlock ) - -#define GMEM_Alloc( _handle_, _size_ ) \ - GTT_Alloc( trueTypeHandle, (ChunkHandle*)&(_handle_), _size_ ) - -#define GMEM_Realloc( _handle_, _size_ ) \ - GTT_Realloc( _memBlock, (ChunkHandle*)&(_handle_), _size_ ) - -#define GALLOC( _handle_, _size_ ) \ - ( ( error = GMEM_Alloc( _handle_, _size_ ) ) != TT_Err_Ok ) - -#define GALLOC_ARRAY( _handle_, _count_, _type_ ) \ - ( ( error = GMEM_Alloc( _handle_, \ - (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) - -#define GREALLOC( _handle_, _size_ ) \ - ( ( error = GMEM_Realloc( _handle_, _size_ ) ) != TT_Err_Ok ) - -#define GREALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - ( (error = GMEM_Realloc( _handle_, \ - (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) - -#define GFREE( _handle_ ) \ - GTT_Free( trueTypeHandle, (ChunkHandle*)&(_handle_) ) - -#define DEREF( _handle_ ) LMemDerefHandles( trueTypeHandle, _handle_ ) - -#define FIELD( _type_, _chunk_, _field_) (((_type_*)DEREF(_chunk_))->_field_) - -#define ARRAY( _type_, _chunk_, _field_, _array_) ((_array_*)FIELD( _type_, _chunk_, _field_)) - -/* ENDE: diese Makros sollen die o.g. ablösen */ - /* Allocate a block of memory of 'Size' bytes from the heap, and */ /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ @@ -126,23 +75,6 @@ EXPORT_DEF TT_Error TT_Alloc( ULong Size, void** P ); - EXPORT_DEF - TT_Error GTT_Alloc( MemHandle M, ChunkHandle* C, unsigned int Size ); - -#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE - - /* Reallocates a block of memory pointed to by '*P' to 'Size' */ - /* bytes from the heap, possibly changing '*P'. If 'Size' is 0, */ - /* TT_Free() is called, if '*P' is NULL, TT_Alloc() is called. */ - /* '*P' is freed (if it's non-NULL) in case of error. */ - - EXPORT_DEF - TT_Error TT_Realloc( ULong Size, void** P ); - - EXPORT_DEF - TT_Error GTT_Realloc( MemHandle M, ChunkHandle* C, unsigned int Size ); - -#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ /* Releases a block that was previously allocated through Alloc. */ /* Note that the function returns successfully when P or *P are */ @@ -152,15 +84,6 @@ EXPORT_DEF TT_Error TT_Free( void** P ); - EXPORT_DEF - TT_Error GTT_Free( MemHandle M, ChunkHandle* C ); - - - /* For "legacy" applications, that should be re-coded. */ - /* Note that this won't release the previously allocated font pool. */ - -#define Init_FontPool( x, y ) while( 0 ) { } - LOCAL_DEF TT_Error TTMemory_Init( void ); LOCAL_DEF TT_Error TTMemory_Done( void ); diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index d51bd7f8c..11cf6b211 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -21,7 +21,6 @@ #include "ttmemory.h" #include "ttload.h" #include "ttinterp.h" -#include "ttdebug.h" /* Add extensions definition */ @@ -80,48 +79,6 @@ } -#if 0 - -/******************************************************************* - * - * Function : New_Instance - * - * Description : Creates a new instance for a given face object. - * - ******************************************************************/ - - LOCAL_FUNC - PInstance New_Instance( PFace face ) - { - PInstance ins; - - - if ( !face ) - return NULL; - - CACHE_New( &face->instances, ins, face ); - - return ins; - } - - -/******************************************************************* - * - * Function : Done_Instance - * - * Description : Discards an instance. - * - ******************************************************************/ - - LOCAL_FUNC - TT_Error Done_Instance( PInstance instance ) - { - return CACHE_Done( &instance->owner->instances, instance ); - } - -#endif - - /******************************************************************* * * * GLYPH ZONE FUNCTIONS * @@ -1178,7 +1135,7 @@ (error = Load_TrueType_##table (face)) != TT_Err_Ok - /* LOCAL_FUNC */ + LOCAL_FUNC TT_Error Face_Create( void* _face, void* _input ) { @@ -1408,7 +1365,7 @@ }; static - const TCache_Class objs_glyph_class = + const TCache_Class objs_glyph_class = { sizeof ( TGlyph ), -1, @@ -1418,12 +1375,14 @@ NULL }; + LOCAL_FUNC TT_Error TTObjs_Init( PEngine_Instance engine ) { PCache face_cache, exec_cache; TT_Error error; + face_cache = 0; exec_cache = 0; @@ -1431,10 +1390,9 @@ ALLOC( exec_cache, sizeof ( TCache ) ) ) goto Fail; - /* create face cache */ + /* create face cache */ error = Cache_Create( engine, (PCache_Class)&objs_face_class, face_cache, &engine->lock ); - if ( error ) goto Fail; diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 964f5a14b..ba673255a 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -39,7 +39,6 @@ ******************************************************************/ #include "ttraster.h" -#include "ttdebug.h" #include "tttypes.h" #include "ttengine.h" #include "ttcalc.h" /* for TT_MulDiv only */ @@ -248,7 +247,7 @@ TPoint* arc; /* current Bezier arc pointer */ - UShort bWidth; /* target buffer width */ + UShort bWidth; /* target bitmap width */ PByte bTarget; /* target bitmap buffer */ PByte gTarget; /* target pixmap buffer */ #ifdef __GEOS__ @@ -257,37 +256,37 @@ Long lastX, lastY, minY, maxY; - UShort num_Profs; /* current number of profiles */ + UShort num_Profs; /* current number of profiles */ - Bool fresh; /* signals a fresh new profile which */ - /* 'start' field must be completed */ - Bool joint; /* signals that the last arc ended */ - /* exactly on a scanline. Allows */ - /* removal of doublets */ - PProfile cProfile; /* current profile */ - PProfile fProfile; /* head of linked list of profiles */ - PProfile gProfile; /* contour's first profile in case */ - /* of impact */ - TStates state; /* rendering state */ + Bool fresh; /* signals a fresh new profile which */ + /* 'start' field must be completed */ + Bool joint; /* signals that the last arc ended */ + /* exactly on a scanline. Allows */ + /* removal of doublets */ + PProfile cProfile; /* current profile */ + PProfile fProfile; /* head of linked list of profiles */ + PProfile gProfile; /* contour's first profile in case */ + /* of impact */ + TStates state; /* rendering state */ - TT_Raster_Map target; /* description of target bit/pixmap */ + TT_Raster_Map target; /* description of target bit/pixmap */ - Long traceOfs; /* current offset in target bitmap or region */ - Long traceOfsLastLine; /* offset in traget region before line step */ - Long traceG; /* current offset in target pixmap */ + Long traceOfs; /* current offset in target bitmap */ + Long traceOfsLastLine; /* offset in traget region before line step */ + Long traceG; /* current offset in target pixmap */ - Short traceIncr; /* sweep's increment in target bitmap */ + Short traceIncr; /* sweep's increment in target bitmap */ - Short gray_min_x; /* current min x during gray rendering */ - Short gray_max_x; /* current max x during gray rendering */ + Short gray_min_x; /* current min x during gray rendering */ + Short gray_max_x; /* current max x during gray rendering */ /* dispatch variables */ - Function_Sweep_Init* Proc_Sweep_Init; - Function_Sweep_Span* Proc_Sweep_Span; - Function_Sweep_Span* Proc_Sweep_Drop; - Function_Sweep_Step* Proc_Sweep_Step; - Function_Sweep_Finish* Proc_Sweep_Finish; + Function_Sweep_Init* Proc_Sweep_Init; + Function_Sweep_Span* Proc_Sweep_Span; + Function_Sweep_Span* Proc_Sweep_Drop; + Function_Sweep_Step* Proc_Sweep_Step; + Function_Sweep_Finish* Proc_Sweep_Finish; TT_Vector* coords; @@ -302,9 +301,6 @@ TBand band_stack[16]; /* band stack used for sub-banding */ Int band_top; /* band stack top */ - - Int count_table[256]; /* Look-up table used to quickly count */ - /* set bits in a gray 2x2 cell */ }; @@ -320,68 +316,6 @@ #endif /* TT_STATIC_RASTER */ -#ifdef DEBUG_RASTER - - /************************************************/ - /* */ - /* Pset: */ - /* */ - /* Used for debugging only. Plots a point */ - /* in VRAM during rendering (not afterwards). */ - /* */ - /* NOTE: This procedure relies on the value */ - /* of cProfile->start, which may not */ - /* be set when Pset is called sometimes. */ - /* This will usually result in a dot */ - /* plotted on the first screen scanline */ - /* (far away its original position). */ - /* */ - /* This "bug" reflects nothing wrong */ - /* in the current implementation, and */ - /* the bitmap is rendered correctly, */ - /* so don't panic if you see 'flying' */ - /* dots in debugging mode. */ - /* */ - /* - David */ - /* */ - /************************************************/ - - static void Pset( RAS_ARG ) - { - Long o; - Long x; - - - x = ras.top[-1]; - - switch ( ras.cProfile->flow ) - { - case TT_Flow_Up: - o = Vio_ScanLineWidth * - ( ras.top-ras.cProfile->offset + ras.cProfile->start ) + - ( x / (ras.precision*8) ); - break; - - case TT_Flow_Down: - o = Vio_ScanLineWidth * - ( ras.cProfile->start-ras.top + ras.cProfile->offset ) + - ( x / (ras.precision*8) ); - break; - } - - if ( o > 0 ) - Vio[o] |= (unsigned)0x80 >> ( (x/ras.precision) & 7 ); - } - - - static void Clear_Band( RAS_ARGS Int y1, Int y2 ) - { - MEM_Set( Vio + y1*Vio_ScanLineWidth, (y2-y1+1)*Vio_ScanLineWidth, 0 ); - } - -#endif /* DEBUG_RASTER */ - - /************************************************************************/ /* */ /* Function: Set_High_Precision */ @@ -408,8 +342,6 @@ ras.precision_jitter = 2; } - PTRACE7(( "Set_High_Precision(%s)\n", High ? "true" : "false" )); - ras.precision = 1 << ras.precision_bits; ras.precision_half = ras.precision / 2; ras.precision_shift = ras.precision_bits - Pixel_Bits; @@ -449,16 +381,13 @@ { case Ascending: ras.cProfile->flow = TT_Flow_Up; - PTRACE7(( "New ascending profile = %lx\n", (long)ras.cProfile )); break; case Descending: ras.cProfile->flow = TT_Flow_Down; - PTRACE7(( "New descending profile = %lx\n", (long)ras.cProfile )); break; default: - PTRACE0(( "Invalid profile direction in Raster:New_Profile !!\n" )); ras.error = Raster_Err_Invalid; return FAILURE; } @@ -503,16 +432,12 @@ if ( h < 0 ) { - PTRACE0(( "Negative height encountered in End_Profile!\n" )); ras.error = Raster_Err_Neg_Height; return FAILURE; } if ( h > 0 ) { - PTRACE1(( "Ending profile %lx, start = %ld, height = %ld\n", - (long)ras.cProfile, ras.cProfile->start, h )); - oldProfile = ras.cProfile; ras.cProfile->height = h; ras.cProfile = (PProfile)ras.top; @@ -527,7 +452,6 @@ if ( ras.top >= ras.maxBuff ) { - PTRACE1(( "overflow in End_Profile\n" )); ras.error = Raster_Err_Overflow; return FAILURE; } @@ -1836,7 +1760,7 @@ PProfile right ) { /* nothing to do */ - } + } static void Vertical_Region_Sweep_Step( RAS_ARGS Short y ) { @@ -1890,7 +1814,7 @@ ras.target.size = ( ras.traceOfs + ras.traceIncr ) * sizeof( Short ); } -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ /***********************************************************************/ @@ -2052,7 +1976,7 @@ /* Nothing, really */ } - static void Horizontal_Sweep_Finish( RAS_ARG ) + static void Horizontal_Sweep_Finish( RAS_ARG ) { /* nothing to do */ } @@ -2101,7 +2025,7 @@ } - static void Vertical_Gray_Sweep_Step( RAS_ARG Short y ) + static void Vertical_Gray_Sweep_Step( RAS_ARG ) { Int c1, c2; PByte pix, bit, bit2; @@ -2317,7 +2241,7 @@ ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Init, RAS_VARS &min_Y, &max_Y ); #else ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ /* Then compute the distance of each profile from min_Y */ @@ -2417,7 +2341,7 @@ ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Span, RAS_VARS y, x1, x2, P_Left, P_Right ); #else ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right ); -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ Skip_To_Next: @@ -2437,7 +2361,7 @@ ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); #else ras.Proc_Sweep_Step( RAS_VARS y ); -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ y++; @@ -2482,7 +2406,7 @@ ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); #else ras.Proc_Sweep_Step( RAS_VARS y ); -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ y++; } @@ -2516,7 +2440,7 @@ Scan_DropOuts : P_Right->X, P_Left, P_Right ); -#endif /* ifdef __GEOS__ */ +#endif /* __GEOS__ */ } P_Left = P_Left->link; @@ -2686,115 +2610,6 @@ Scan_DropOuts : } -#ifdef TT_CONFIG_OPTION_GRAY_SCALING - -/****************************************************************************/ -/* */ -/* Function: Render_Gray_Glyph */ -/* */ -/* Description: Renders a glyph with grayscaling. Sub-banding if needed. */ -/* */ -/* Input: AGlyph Glyph record */ -/* */ -/* Returns: SUCCESS on success */ -/* FAILURE if any error was encountered during rendering. */ -/* */ -/****************************************************************************/ - - LOCAL_FUNC - TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, - TT_Raster_Map* target_map, - Byte* palette ) - { - Int i; - TT_Error error; - - if ( !ras.buff ) - { - ras.error = Raster_Err_Not_Ini; - return ras.error; - } - - if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) - return TT_Err_Ok; - - if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] ) - { - ras.error = TT_Err_Too_Many_Points; - return ras.error; - } - - if ( palette ) - { - for ( i = 0; i < 5; i++ ) - ras.grays[i] = palette[i]; - } - - if ( target_map ) - ras.target = *target_map; - - ras.outs = glyph->contours; - ras.flags = glyph->flags; - ras.nPoints = glyph->n_points; - ras.nContours = glyph->n_contours; - ras.coords = glyph->points; - - Set_High_Precision( RAS_VARS glyph->high_precision ); - ras.scale_shift = ras.precision_shift+1; - ras.dropOutControl = glyph->dropout_mode; - ras.second_pass = glyph->second_pass; - - - /* Vertical Sweep */ - - ras.band_top = 0; - ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = 2 * ras.target.rows - 1; - - ras.bWidth = ras.gray_width; - if ( ras.bWidth > ras.target.cols/4 ) - ras.bWidth = ras.target.cols/4; - - ras.bWidth = ras.bWidth * 8; - ras.bTarget = (Byte*)ras.gray_lines; - ras.gTarget = (Byte*)ras.target.bitmap; - - ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init; - ras.Proc_Sweep_Span = Vertical_Sweep_Span; - ras.Proc_Sweep_Drop = Vertical_Sweep_Drop; - ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step; - ras.Proc_Sweep_Finish = Vertical_Sweep_Finish; - - error = Render_Single_Pass( RAS_VARS 0 ); - if (error) - return error; - - /* Horizontal Sweep */ - - if ( ras.second_pass && ras.dropOutControl != 0 ) - { - ras.Proc_Sweep_Init = Horizontal_Sweep_Init; - ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span; - ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop; - ras.Proc_Sweep_Step = Horizontal_Sweep_Step; - ras.Proc_Sweep_Finish = Horizontal_Sweep_Finish; - - - ras.band_top = 0; - ras.band_stack[0].y_min = 0; - ras.band_stack[0].y_max = ras.target.width * 2 - 1; - - error = Render_Single_Pass( RAS_VARS 1 ); - if (error) - return error; - } - - return TT_Err_Ok; - } - -#endif /* TT_CONFIG_OPTION_GRAY_SCALING */ - - #ifdef __GEOS__ /****************************************************************************/ @@ -2869,7 +2684,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, return TT_Err_Ok; } -#endif /* __GEOS__ */ +#endif /* __GEOS__ */ /************************************************/ @@ -2906,8 +2721,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, LOCAL_FUNC TT_Error TTRaster_Init( PEngine_Instance engine ) { - TT_Error error; - + TT_Error error; TRaster_Instance* ras; @@ -2920,7 +2734,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras = (TRaster_Instance*)engine->raster_component; #endif - if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) + if ( ALLOC( ras->buff, RASTER_RENDER_POOL ) ) return error; ras->sizeBuff = ras->buff + ( RASTER_RENDER_POOL/sizeof(long) ); diff --git a/Driver/Font/TrueType/FreeType/ttraster.h b/Driver/Font/TrueType/FreeType/ttraster.h index 90d4192bf..8d1c78754 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.h +++ b/Driver/Font/TrueType/FreeType/ttraster.h @@ -115,15 +115,15 @@ extern "C" { TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, TT_Raster_Map* target ); -#endif +#endif /* __GEOS__ */ /* Initialize rasterizer */ LOCAL_DEF - TT_Error TTRaster_Init( TT_Engine engine ); + TT_Error TTRaster_Init( PEngine_Instance engine ); /* Finalize it */ LOCAL_DEF - TT_Error TTRaster_Done( TT_Engine engine ); + TT_Error TTRaster_Done( PEngine_Instance engine ); #ifdef __cplusplus diff --git a/Driver/Font/TrueType/Main/ansic_malloc.asm b/Driver/Font/TrueType/Main/ansic_malloc.asm deleted file mode 100644 index eb95d9c27..000000000 --- a/Driver/Font/TrueType/Main/ansic_malloc.asm +++ /dev/null @@ -1,790 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved - -PROJECT: PC/GEOS -MODULE: AnsiC library -FILE: malloc_asm.asm - -AUTHOR: Andrew Wilson, Sep 17, 1991 - -ROUTINES: - Name Description - ---- ----------- - _MALLOC allocs fixed memory - _REALLOC resizes fixed memory - _Free frees fixed memory - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/17/91 Initial revision - schoon 6/11/92 Revised for ANSI C standards - -DESCRIPTION: - This file contains the PC/GEOS implementations of the C routines - malloc(), calloc(), realloc(), cfree(), and free(). - -NOTES: - There are 2 allocation strategies used by this code. If the block size - is below MALLOC_LARGE_THRESHOLD, then it is allocated in one of the - fixed LMem heaps kept for this purpose. If the block size is above - the threshold, then the memory is allocated in a global memory block - by itself. Since the pointer to memory returned by the "large" strategy - is below any of the valid pointers returned by the "small" strategy - (due to the fact that the small blocks all lie beyond the - LMemBlockHeader at the start of the lmem blocks, while the large - blocks all lie at LARGE_BLOCK_OFFSET, which is less than the - LMemBlockHeader), we are able to tell which type of block it is just - by looking at the address. - - When we free these blocks, we have a different strategy for each. - When we free a large block, we just call MemFree on the block. If - it is a small block, we free the chunk, and then check to see if that - LMem block is now empty. If it isn't, we just exit. If it is, we scan - through the list of lmem blocks to see if it is the only lmem block. - if it isn't, we free it up (so we have at most one empty lmem block - hanging around per geode). - - In the GeodePrivData for each geode we keep 2 words - the first one - is the handle of a block containing a list of handles of lmem blocks - used for the small allocation scheme. The second one is the handle - of a block containing a list of handles of global memory blocks - containing blocks allocated via the large allocation scheme. - The format of these blocks is as follows: - - word numberOfEntriesInList ;This includes any empty slots - word entry1 - word entry2 - word entry3 - . - . - . - - $Id: malloc_asm.asm,v 1.1 97/04/04 17:42:12 newdeal Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -GEO_MALLOC_PASSED_SIZE_OF_ZERO enum FatalErrors -NULL_PTR_PASSED_TO_GEO_FREE enum FatalErrors -INVALID_PTR_PASSED_TO_GEO_REALLOC enum FatalErrors -COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT enum FatalErrors -LMEM_REALLOC_FAILED_WHEN_MAKING_CHUNK_SMALLER enum FatalErrors -MORE_THAN_ONE_FREE_MALLOC_BLOCK enum FatalErrors -FREE_CALLED_BEFORE_MALLOC enum FatalErrors -HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS enum FatalErrors - - -;RESIDENT segment word public 'CODE' -;MAINCODE segment word public 'CODE' -MAINCODE segment public 'CODE' - -.model medium, pascal - -GeodePrivReadOneWord proc near ;Returns value in CX - mov cx, 1 ;Read one word - push ax - segmov ds, ss - mov si, sp ;DS:SI <- ptr to word on stack - call GeodePrivRead - pop cx ; - ret -GeodePrivReadOneWord endp - -GeodePrivWriteOneWord proc near ;Pass value to write in CX - push cx - mov cx, 1 ;Write one word - segmov ds, ss - mov si, sp ;DS:SI <- ptr to word on stack - call GeodePrivWrite - pop cx ; - ret -GeodePrivWriteOneWord endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - AddHandleToMallocList -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Adds a handle to the associated list of handles. - -CALLED BY: GLOBAL -PASS: ds:[LMBH_handle] - handle to add - bx - geode whose privData we should use - di - offset to pass to GeodePrivRead/GeodePrivWrite -RETURN: carry set if error -DESTROYED: bx, cx, dx, di, si - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -SLOT_INCREMENT equ 8 -AddHandleToMallocList proc near uses ds, es, bp, ax - .enter - -; Read in the handle of the block containing the list of blocks - - mov dx, ds:[LMBH_handle] - call GeodePrivReadOneWord - jcxz doMalloc ;If no block, allocate a new one - -; Scan through the block looking for an empty slot to store the new -; handle. - - mov bx, cx - call MemLock - mov es, ax -scanTop: - mov di, 2 - mov cx, es:[0] ;CX <- # items in block - clr ax - repne scasw ;Look for an empty spot - jne reAlloc ;Branch if no empty slots found - - mov es:[di][-2], dx ;Save handle in empty slot - clc ;Signify no errors -unlockExit: - call MemUnlock ;Unlock the block -exit: - .leave - ret -reAlloc: - -; No empty slots found, so reallocate the block bigger (create some). - - mov ax, es:[0] - inc ax ;AX <- # words in block currently - shl ax, 1 ;AX <- # bytes in block - add ax, SLOT_INCREMENT*2 ;Add room for 8 more slots - mov ch, mask HAF_ZERO_INIT - call MemReAlloc - jc unlockExit ;If error reallocing, branch - mov es, ax - add {word} es:[0], SLOT_INCREMENT ; - jmp scanTop -doMalloc: - -; ALLOCATE A NEW BLOCK TO HOLD DATA - - mov bp, bx ;BP <- geode handle - mov ax, SLOT_INCREMENT*2 ; - mov cx, ALLOC_DYNAMIC_LOCK or mask HF_SHARABLE or (mask HAF_ZERO_INIT shl 8) - call MemAllocSetOwnerOrDefault - jc exit ;If we could not allocate the block, - ; branch. - mov es, ax ; - mov {word} es:[0], SLOT_INCREMENT-1; - mov cx, bx ; - mov bx, bp ;BX <- GeodeHandle - call GeodePrivWriteOneWord ;Store the handle in the GeodePrivData - mov bx, cx ; area. - jnc scanTop ;If no error, branch - call MemFree ;Else, free up this block and exit. - stc - jmp exit -AddHandleToMallocList endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - RemoveHandleFromMallocList -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Removes a handle from the associated list of handles. - -CALLED BY: GLOBAL -PASS: ds:[LMBH_handle] - handle to remove - bx - geode whose privData we should use - di - offset to pass to GeodePrivRead/GeodePrivWrite -RETURN: nothing -DESTROYED: ax, bx, cx, dx, di, si - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -RemoveHandleFromMallocList proc near uses es, ds - .enter - -; Read in the handle of the block containing the list of blocks - - mov dx, ds:[LMBH_handle] - call GeodePrivReadOneWord -EC < jcxz nullError ;If no block, allocate a new one > - -; Scan through the block looking for the passed handle. - - mov bx, cx - call MemLock - mov es, ax - mov di, 2 - mov cx, es:[0] ;CX <- # items in block - mov ax, dx - repne scasw ;Look for an empty spot -EC < ERROR_NZ HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS > - - mov {word} es:[di][-2], 0 ;Nuke handle - call MemUnlock - .leave - ret -EC -EC < ERROR FREE_CALLED_BEFORE_MALLOC > -RemoveHandleFromMallocList endp - - -if ERROR_CHECK -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ECCountFreeBlocksOnMallocList -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Counts total number of malloc heaps with no items - -CALLED BY: _Free -PASS: bx - geode whose privData we should use - di - offset to pass to GeodePrivRead/GeodePrivWrite -RETURN: dx - # free blocks -DESTROYED: ax, bx, cx, di, si, ds, es - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -ECCountFreeBlocksOnMallocList proc near - .enter - -; Read in the handle of the block containing the list of blocks - - call GeodePrivReadOneWord - jcxz nullError ;If no block, fail - -; Traverse the block counting the # empty blocks - - mov bx, cx - call MemLock - push bx - mov ds, ax - mov si, 2 - mov cx, ds:[0] ;CX <- # items in block - clr dx -findNext: - lodsw - tst ax - jz next - xchg ax, bx - call MemDerefES - cmp es:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader - jne next ;If not empty, branch - inc dx ;Else, increment count of empty blocks -next: - loop findNext - pop bx - call MemUnlock ; - .leave - ret -nullError: - ERROR FREE_CALLED_BEFORE_MALLOC -ECCountFreeBlocksOnMallocList endp -endif - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - AllocInSmallList -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Traverses the list of lmem blocks and tries to allocate - the passed # bytes in each one until it is successful - -CALLED BY: GLOBAL -PASS: bx - geode whose privData we should use - cx - # bytes to allocate -RETURN: ds:ax <- pointer to block allocated - carry set if unsuccessful -DESTROYED: ax, bx, cx, di, si, ds - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -AllocInSmallList proc near - .enter - -; Read in the handle of the block containing the list of blocks - - mov dx, cx ;DX <- size - push ds -NOFXIP< segmov ds, dgroup, di > -FXIP < push bx > -FXIP < mov bx, handle dgroup > -FXIP < call MemDerefDS ; ds = dgroup > -FXIP < pop bx > - mov di, ds:[mallocOffset] ; - pop ds - call GeodePrivReadOneWord - stc - jcxz exit ;If no blocks allocated, exit - -; Traverse the block and attempt to allocate in each one (ignoring -; empty slots). - - mov bx, cx - mov cx, dx ;CX <- # bytes to allocate - push bx - call MemLock - mov ds, ax - mov si, 2 - mov dx, ds:[0] ;CX <- # items in block -findNext: - lodsw - tst ax - jz next ;If handle is null, branch (empty slot) - mov di, ds ;. - xchg ax, bx ;BX <- handle of this lmem block - call MemDerefDS ;DS <- segment of this lmem block - call LMemAlloc ;Try to allocate here - jnc success ;Branch if no error allocating - mov ds, di ; -next: - dec dx ;Decrement # handles to try - jnz findNext ; - stc ;Unsuccessful, so unlock and exit w/carry set -success: - pop bx ;Unlock list of blocks - call MemUnlock ; -exit: - .leave - ret -AllocInSmallList endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - MemAllocFixed -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Just a front end to MemAlloc - -CALLED BY: GLOBAL -PASS: ax - size of block to alloc - bx - owner of block -RETURN: ds - segment of block - + rest of MemAlloc return values -DESTROYED: cx - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -MemAllocFixed proc near - mov cx, mask HF_FIXED or mask HF_SHARABLE - call MemAllocSetOwnerOrDefault - mov ds, ax - ret -MemAllocFixed endp - -MemAllocSetOwnerOrDefault proc near - tst bx ;If an owner is passed in, - jnz setOwner ; then set the owner. - call MemAlloc ;Else, use current process - jmp exit -setOwner: - call MemAllocSetOwner ;Try to allocate memory -exit: - ret -MemAllocSetOwnerOrDefault endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - _MALLOC -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: This routine allocates fixed memory for C programs to use. - -C DECLARATION: - -extern void _far _pascal - *_MALLOC(size_t blockSize, GeodeHandle geodeHan, word zeroInit) - -NOTES: geodeHan can be 0, if you just want to use the current process' - malloc heap. - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/17/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -MALLOC_LARGE_THRESHOLD equ 511 -MALLOC_SMALL_BLOCK_SIZE equ 1024 -LARGE_BLOCK_OFFSET equ size hptr -global _MALLOC:far -_MALLOC proc far blockSize:word, geodeHan:hptr, zinit:word - uses ds, di, si - .enter - mov cx, blockSize -EC < tst cx > -EC < ERROR_Z GEO_MALLOC_PASSED_SIZE_OF_ZERO > - -; Mallocs of over MALLOC_LARGE_THRESHOLD should be put in their own -; fixed block. - - cmp cx, MALLOC_LARGE_THRESHOLD - ja largeAlloc - -; Scan through the list of fixed lmem blocks to allocate this -; small block. - - mov bx, geodeHan - call AllocInSmallList ;Try to allocate in various blocks - ; in small list (returns pointer in - ; DS:AX). - jnc zinitAndExit ;Branch if successful - -; Could not allocate in already existing lmem block, so allocate a new -; lmem block and allocate in it. - - mov ax, MALLOC_SMALL_BLOCK_SIZE - mov bx, geodeHan - call MemAllocFixed ;Try to allocate new lmem block. - jc errRet ;If unsuccessful, branch to exit. - mov ax, LMEM_TYPE_GENERAL - mov dx, size LMemBlockHeader - mov di, mask LMF_NO_HANDLES or mask LMF_NO_ENLARGE or mask LMF_RETURN_ERRORS - push bp - clr bp - call LMemInitHeap - pop bp - -; Allocate a new chunk on the just-allocated lmem heap. - - mov cx, blockSize - call LMemAlloc -EC < ERROR_C COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT > - clr di - jmp mallocCommon ;Branch to add block to list, and - ; to return pointer to block - -largeAlloc: - -; Allocate a fixed block on the heap with the handle of the block at the -; start, and the remainder of the block to be returned for use by the -; caller. - - - add cx, LARGE_BLOCK_OFFSET ;These blocks have the handle of the - xchg ax, cx ; block at the start. Put size in AX. - mov bx, geodeHan - call MemAllocFixed ; - jc errRet ;If we couldn't, branch - mov dx, bx ;DX <- handle of new block - mov ds:[0], bx ;Save handle of block - - - mov di, 2 ;DI <- offset to handle of block - ; containing list of large data blocks - ; (in the GeodePrivData area reserved - ; for the malloc routines). - mov ax, LARGE_BLOCK_OFFSET ;DS:AX <- pointer to data just alloc'd - -mallocCommon: - -; Get the offset to the GeodePriv area reserved for the malloc routines. - - push ds -NOFXIP< segmov ds, , bx > -FXIP < mov bx, handle dgroup > -FXIP < call MemDerefDS ; ds = dgroup > - add di, ds:[mallocOffset] ; - pop ds - mov bx, geodeHan ; - call AddHandleToMallocList ;Add handle at DS:0 to malloc list - jc freeError ;If couldn't add to list, branch and - ; exit. -zinitAndExit: ; - mov dx, ds ;DX:AX <- pointer to data - tst zinit ;If no zero-init desired, just branch - jz exit - - push es, ax - mov es, dx ;ES:DI <- pointer to block - xchg di, ax - clr ax - mov cx, blockSize - shr cx, 1 - jnc 80$ - stosb -80$: - rep stosw - pop es, ax ;DX:AX <- pointer to block -exit: - .leave - ret - -freeError: - mov bx, dx ;Free up the block - call MemFree -errRet: - clr dx - clr ax - jmp exit -_MALLOC endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - _Free -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: Frees up a block previously returned from _Malloc. - -CALLED BY: GLOBAL -C DECLARATION: - extern void _far _pascal _Free(void *blockPtr, GeodeHandle geodeHan); - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global _FREE:far -_FREE proc far blockPtr:fptr, geodeHan:hptr - uses ds, di, si - .enter -EC < tst blockPtr.high > -EC < ERROR_Z NULL_PTR_PASSED_TO_GEO_FREE > - cmp blockPtr.low, LARGE_BLOCK_OFFSET - jne smallBlockFree - -; The free block was large (allocated as a single block on the global -; heap). Remove the block from the list, and free it up. - -NOFXIP< segmov ds, , di > -FXIP < mov bx, handle dgroup > -FXIP < call MemDerefDS ; ds = dgroup > - mov di, ds:[mallocOffset] ;DI <- ptr to handle of large - add di, 2 ; block list in GeodePrivData -freeAndRemoveBlock: - mov bx, geodeHan ; - mov ds, blockPtr.segment - call RemoveHandleFromMallocList ; - mov bx, ds:[0] - call MemFree ;Free up the handle - jmp exit -smallBlockFree: - lds ax, blockPtr ;If small block, just free - call LMemFree ; up the chunk. We never - ; return this memory to the - ; global heap. - -; If the block is now empty, free it. - - cmp ds:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader - jne exit ; Branch if block is non-empty - - push ds -NOFXIP< segmov ds, , di > -FXIP < mov bx, handle dgroup > -FXIP < call MemDerefDS ; ds = dgroup > - mov di, ds:[mallocOffset] ;DI <- ptr to handle of small - pop ds ; block list in GeodePrivData - -EC < mov bx, geodeHan ; > -EC < call ECCountFreeBlocksOnMallocList ; > -EC < cmp dx, 2 ; > -EC < ERROR_A MORE_THAN_ONE_FREE_MALLOC_BLOCK > - jmp freeAndRemoveBlock -exit: - .leave - ret -_FREE endp - - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - _REALLOC -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -SYNOPSIS: ReAllocates a previously _MALLOC'd block of memory. - -CALLED BY: GLOBAL - -C DECLARATION: extern void _far _pascal - *_REALLOC(void *blockPtr, size_t newSize, GeodeHandle geodeHan); - - -PSEUDO CODE/STRATEGY: - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - * - * 1) If the space is resized larger, new space is *not* zero-initialized. - * - * 2) If realloc() is called to resize the memory *smaller*, it will - * always succeed. - * - * 3) If realloc() does not succeed, it will return NULL, and the original - * memory block will be unaffected. - * - * 4) If the passed blockPtr is NULL, realloc() acts like malloc(). - * - * 5) If the passed newSize is 0, the passed blockPtr is freed, and - * NULL is returned. - * - * 6) The block *may* move. - * -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 9/18/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global _REALLOC:far -_REALLOC proc far blockPtr:fptr, newSize:word, geodeHan:hptr - uses ds - .enter - -; Handle special goofy cases (null size or block ptr passed in) - - mov cx, newSize - tst blockPtr.high ;If null block ptr, pass off to malloc() - jz doMalloc ; - jcxz doFree ;If zero new size, pass off to free() - mov ds, blockPtr.high - cmp blockPtr.low, LARGE_BLOCK_OFFSET;If large block, use - je largeBlockReAlloc ; appropriate realloc method - -; If this is a "small" block, then try to LMemReAlloc it. If that fails, -; then try malloc-ing a new block, and copying the data over. - - mov ax, blockPtr.low ;DS:AX <- ptr to block - call LMemReAlloc ; - mov dx, ds ;DX:AX <- ptr to block -if 0 - jc 20$ ;Error - -; Copy data from blockptr to new chunk and delete blockptr. -; LMemRealloc does not always resize blockptr, instead it may -; allocate a new chunk. -; - cmp ax, blockPtr.low - je exit ;No new chunk, so done - push es, di, si - jmp 30$ ;Copy and delete. -else -; -; For LMF_NO_HANDLES, if LMemReAlloc has to allocate a new chunk, it will -; copy over the data itself and delete the old chunk, so we don't need to -; do this -- brianc 11/17/98 (yes, '98) -; - jnc exit -endif - -; Simple allocation failed. malloc() new block and copy the data over. -20$: - push es, di, si - push newSize - push geodeHan - clr ax - push ax - call _MALLOC - tst dx ;If malloc failed, branch - jz mallocFailed - -; Copy the data from the old block into the newly alloc'd block. -30$: - mov si, blockPtr.low ;DS:SI <- ptr to original block - ChunkSizePtr ds, si, cx ;CX <- size of original block (data to - ; copy over). -EC < cmp cx, newSize > -EC < ERROR_AE LMEM_REALLOC_FAILED_WHEN_MAKING_CHUNK_SMALLER > - mov es, dx - mov di, ax - shr cx, 1 - jnc 10$ - movsb -10$: - rep movsw - -; Free the old block up. - - push dx, ax - push blockPtr.high - push blockPtr.low - push geodeHan - call _FREE - pop dx, ax -mallocFailed: - pop es, di, si -exit: - .leave - ret -doFree: - push blockPtr.high - push blockPtr.low - push geodeHan - call _FREE - jmp clrRet -doMalloc: -EC < tst blockPtr.low > -EC < ERROR_NZ INVALID_PTR_PASSED_TO_GEO_REALLOC > - push cx ; newSize - push geodeHan - clr ax ;Do not zero init - push ax - call _MALLOC - jmp exit - -; For large blocks, the data lies in a global memory block by itself. -; Just call MemReAlloc routine. -largeBlockReAlloc: - mov ds, blockPtr.high - mov_tr ax, cx - add ax, LARGE_BLOCK_OFFSET - clr ch - mov bx, ds:[0] ;ReAllocate the block - call MemReAlloc - xchg dx, ax ;DX <- segment of fixed block - mov ax, LARGE_BLOCK_OFFSET ;DX:AX <- ptr to large block - jnc exit ;If no error in the realloc, branch -clrRet: - clr ax, dx - jmp exit -_REALLOC endp - -;RESIDENT ends -MAINCODE ends diff --git a/Driver/Font/TrueType/Main/ansic_string.asm b/Driver/Font/TrueType/Main/ansic_string.asm deleted file mode 100644 index 07dc97546..000000000 --- a/Driver/Font/TrueType/Main/ansic_string.asm +++ /dev/null @@ -1,1936 +0,0 @@ -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved - -PROJECT: AnsiC -FILE: string_asm.asm - -AUTHOR: Andrew Wilson, Aug 23, 1991 - -ROUTINES: - Name Description - ---- ----------- - strlen Get the length of the passed string - strchr Return ptr to first occurrence of char in - passed string - strrchr Return ptr to last occurrence of char in - passed string - strpos Return offset in TCHARS to first occurrence of char in - passed string - strrpos Return offset in TCHARS to last occurrence of char in - passed string - strcpy Copy second string onto first string - strncpy Copy up to N characters from second string onto - first string - (output not necessarily null terminated) - strcmp Compare equality of strings - strncmp Compare equality of strings up to N chars - strcat Copy second string after first string - strncat Copy up to N bytes from second string onto - first string - strspn Get # chars from start of first string that - exist in second string - strcspn Get # chars from start of first string that - do not exist in second string - strpbrk Return ptr (into first string) to the first - char from second string that is found - in first string - strrpbrk Return ptr (into first string) to the last - char from second string that is found - in first string - strstr Return ptr (into first string) to the first - occurrence of the second string - (excluding its final null) in - the first string - - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 8/23/91 Initial version - jenny 30/9/91 Added strstr - schoon 6/3/92 Updated to near ANSI C standards - -DESCRIPTION: - Assembly versions of ANSI C string routines. - - $Id: string_asm.asm,v 1.1 97/04/04 17:42:28 newdeal Exp $ - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ - -STRINGCODE segment word public 'CODE' -.model medium, pascal -if ERROR_CHECK -ECCheckBoundsESDI proc near - segxchg es, ds - xchg si, di - call ECCheckBounds - xchg si, di - segxchg es, ds - ret -ECCheckBoundsESDI endp -ECCheckBoundsESDIMinusOne proc near - pushf - push di - dec di - call ECCheckBoundsESDI - pop di - popf - ret -ECCheckBoundsESDIMinusOne endp -ECCheckBoundsMinusOne proc near - pushf - push si - dec si - call ECCheckBounds - pop si - popf - ret -ECCheckBoundsMinusOne endp -endif - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strlen -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strlen - - -C DECLARATION word strlen(TCHAR far *str); - (For XIP system, *str can be pointing to the XIP movable - code resource.) - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global STRLEN:far -STRLEN proc far strPtr:fptr - uses es, di - .enter - les di, strPtr -EC < call ECCheckBoundsESDI > - mov cx, -1 -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > - not cx - dec cx ;Nuke count of null terminator - xchg ax, cx - .leave - ret -STRLEN endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strchr -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strchr - -C DECLARATION TCHAR far * strchr(TCHAR *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strchr:far -strchr proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 -EC < call ECCheckBoundsESDI > - mov cx, -1 -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > - not cx ;CX <- # chars including null - mov di, str1.offset - mov ax, theC -SBCS < repne scasb > ;Look for the character -DBCS < repne scasw > - jne notFound ;If not found, branch - dec di -DBCS < dec di > - mov dx, es ;DX:AX <- ptr to char found - xchg ax, di -exit: - .leave - ret -notFound: - clr dx ;If char not found, return NULL - clr ax - jmp exit -strchr endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strrchr -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strrchr - -C DECLARATION TCHAR far * strrchr(TCHAR *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strrchr:far -strrchr proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 - mov cx, -1 -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars including null - dec di ;DI <- ptr to null char -DBCS < dec di > - mov ax, theC - std -SBCS < repne scasb > ;Look for the character -DBCS < repne scasw > - cld - jne notFound ;If not found, branch - inc di -DBCS < inc di > - mov dx, es ;DX:AX <- ptr to char found - xchg ax, di -exit: - .leave - ret -notFound: - clr dx ;If char not found, return NULL - clr ax - jmp exit -strrchr endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strpos -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strpos - -C DECLARATION word strpos(TCHAR *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strpos:far -strpos proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 - mov cx, -1 -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars including null - mov di, str1.offset - mov ax, theC -SBCS < repne scasb > ;Look for the character -DBCS < repne scasw > - mov ax, -1 - jne exit ;If not found, branch - dec di -DBCS < dec di > - sub di, str1.offset - xchg ax, di ;AX <- offset to char in string -DBCS < shr ax > -exit: - .leave - ret -strpos endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strrpos -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strrpos - -C DECLARATION word strrpos(TCHAR *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strrpos:far -strrpos proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 - mov cx, -1 - clr ax -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars including null - dec di ;DI <- ptr to null char -DBCS < dec di > - mov ax, theC - std -SBCS < repne scasb > ;Look for the character -DBCS < repne scasw > - cld - mov ax, -1 - jne exit ;If not found, branch - inc di -DBCS < inc di > - sub di, str1.offset - xchg ax, di ;AX <- offset to char in string -DBCS < shr ax > -exit: - .leave - ret -strrpos endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcpy -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcpy - -C DECLARATION TCHAR far * strcpy(TCHAR far *dest, TCHAR far *source); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcpy:far -strcpy proc far destPtr:fptr, sourcePtr:fptr - uses ds, es, di, si - .enter - les di, sourcePtr ;ES:DI <- ptr to src string - mov ds, sourcePtr.segment - mov si, di ;DS:SI <- ptr to src string - - mov cx, -1 - clr ax -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars (+ null) in src string - - les di, destPtr ;ES:DI <- ptr to dest for string - mov dx, es ;DX:AX <- ptr to dest for string - mov ax, di - -SBCS < shr cx, 1 > -SBCS < jnc 10$ > -SBCS < movsb > -SBCS < 10$: > - rep movsw -EC < call ECCheckBoundsESDIMinusOne > - .leave - ret -strcpy endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - STRNCPY -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: STRNCPY - -C DECLARATION TCHAR far * strcpy(TCHAR far *dest, TCHAR far *source, word len); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global STRNCPY:far -STRNCPY proc far destPtr:fptr, sourcePtr:fptr, len:word - uses ds, es, di, si - .enter - - lds si, sourcePtr ;DS:SI <- ptr to src string - les di, destPtr ;ES:DI <- ptr to dest string - mov cx, len - jcxz exit -5$: -SBCS < lodsb > -DBCS < lodsw > -SBCS < tst al > -DBCS < tst ax > - jz 10$ -SBCS < stosb > -DBCS < stosw > - loop 5$ -exit: - .leave - ret -10$: -SBCS < rep stosb > ;Null pad the dest string -DBCS < rep stosw > -EC < call ECCheckBoundsMinusOne > -EC < call ECCheckBoundsESDIMinusOne > - jmp exit -STRNCPY endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcmp -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcmp - -C DECLARATION word strcmp(word far *str1, word far *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcmp:far -strcmp proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str1 ;ES:DI <- ptr to str1 - lds si, str2 ;DS:SI <- ptr to str 2 - mov cx, -1 - clr ax ; -SBCS < repne scasb > ; -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars in str 1 (w/null) - - mov di, str1.offset ;ES:DI <- ptr to str1 -SBCS < repe cmpsb > -DBCS < repe cmpsw > -EC < call ECCheckBoundsMinusOne > - jz exit ;If match, exit (with ax=0) -SBCS < mov al, es:[di][-1] > ;Else, return difference of chars> -DBCS < mov ax, es:[di][-2] > -SBCS < sub al, ds:[si][-1] > ; -DBCS < sub ax, ds:[si][-2] > -SBCS < cbw > ; -exit: - .leave - ret -strcmp endp - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strncmp -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strncmp - -C DECLARATION word strncmp(word far *str1, word far *str2, word len); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strncmp:far -strncmp proc far str1:fptr, str2:fptr, len:word - uses ds, es, di, si - .enter - clr ax ; - mov cx, len ; - jcxz exit ;If string is empty, return that they - ; are equal. - les di, str1 ;ES:DI <- ptr to str1 -SBCS < repne scasb > ;Get length of string -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - neg cx - add cx, len ;CX <- min (len, strlen(str1)+1); - lds si, str2 ;DS:SI <- ptr to str 2 - mov di, str1.offset ;ES:DI <- ptr to str1 -SBCS < repe cmpsb > -DBCS < repe cmpsw > -EC < call ECCheckBoundsMinusOne > -SBCS < mov al, es:[di][-1] > ;Return difference of chars -DBCS < mov ax, es:[di][-2] > -SBCS < sub al, ds:[si][-1] > ; -DBCS < sub ax, ds:[si][-2] > -SBCS < cbw > ; -exit: - .leave - ret -strncmp endp - - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcat -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcat - -C DECLARATION VOID * strcat(TCHAR far *str1, TCHAR far *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcat:far -strcat proc far str1:fptr, str2:fptr - uses es, ds, di, si - .enter - les di, str2 ; - lds si, str2 ; - -; GET LENGTH OF SECOND STRING - - clr ax - mov cx, -1 -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars in second string + null - -; SCAN TO END OF FIRST (DEST) STRING - - mov dx, cx ;DX <- size of second string - les di, str1 ;ES:DI <- ptr to str1 - mov cx, -1 ; -SBCS < repne scasb > ;ES:DI <- ptr past null -DBCS < repne scasw > - dec di ;ES:DI <- ptr to null byte of string -DBCS < dec di > -EC < call ECCheckBoundsESDI > - mov cx, dx ;CX <- size of second string - -; COPY SECOND STRING ONTO END OF FIRST STRING - -SBCS < shr cx, 1 > -SBCS < jnc 10$ > -SBCS < movsb > -SBCS <10$: > - rep movsw -EC < call ECCheckBoundsESDIMinusOne > -EC < call ECCheckBoundsMinusOne > - mov dx, es - mov ax, str1.offset - .leave - ret -strcat endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strncat -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strncat - -C DECLARATION VOID * strncat(TCHAR far *str1, TCHAR far *str2, word len); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - Name is in caps so routine can be published now that it's - fixed. - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strncat_old:far -; -; Exported as a place holder for the old, buggy strncat. -; -strncat_old proc far - REAL_FALL_THRU STRNCAT -endp - -global STRNCAT:far -STRNCAT proc far str1:fptr, str2:fptr, len:word - uses es, ds, di, si - .enter - les di, str1 ;ES:DI <- ptr to str1 - mov cx, -1 -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > - dec di ;ES:DI <- ptr to null-terminator for -DBCS < dec di > - ; str1 - mov cx, len ; - jcxz exit ;If string is empty, just exit - lds si, str2 -loopTop: -SBCS < lodsb > -DBCS < lodsw > -SBCS < tst al > -DBCS < tst ax > - jz 10$ -SBCS < stosb > -DBCS < stosw > - loop loopTop -SBCS < clr al> -DBCS < clr ax > -10$: -EC < call ECCheckBoundsMinusOne > -EC < call ECCheckBoundsESDI > -SBCS < stosb > -DBCS < stosw > -exit: - mov dx, es - mov ax, str1.offset - .leave - ret -STRNCAT endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcspn -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcspn - -C DECLARATION word strcspn(TCHAR *str1, TCHAR *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcspn:far -strcspn proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str2 ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov cx, -1 ;CX <- # chars in str2 not counting null -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx - dec cx - mov bx, cx - mov dx,-1 -loopTop: - inc dx ;DX <- # chars at start of str1 that aren't in - ; str2 -SBCS < lodsb > ;AL <- next char in str1 -DBCS < lodsw > -SBCS < tst al > -DBCS < tst ax > - jz exit - mov cx, bx ;CX <- # chars in string - mov di, str2.offset ;ES:DI <- ptr to str2 - jcxz loopTop -SBCS < repne scasb > -DBCS < repne scasw > - jnz loopTop ;If char not found, branch - - -exit: -EC < call ECCheckBoundsMinusOne > - xchg ax, dx ;AX <- # chars at start of str1 that do not lie - ; in str2 - .leave - ret -strcspn endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strspn -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strspn - -C DECLARATION word strspn(TCHAR *str1, TCHAR *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strspn:far -strspn proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str2 ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov cx, -1 ;CX <- # chars in str2 not counting null - clr ax -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx - dec cx - jcxz exit ;Exit if str2 is null - - mov bx, cx ;BX <- strlen(str2) - mov dx, -1 -loopTop: - inc dx ;DX <- # chars at start of str1 that are in - ; str2 -SBCS < lodsb > ;AL <- next char in str1 -DBCS < lodsw > -SBCS < tst al > ;Exit if at end of str1 -DBCS < tst ax > - jz 99$ ; - mov cx, bx ;CX <- # chars in string - mov di, str2.offset ;ES:DI <- ptr to str2 -SBCS < repne scasb > ; -DBCS < repne scasw > - jz loopTop ;If char found, branch - -99$: -EC < call ECCheckBoundsMinusOne > - xchg ax, dx ;AX <- # chars at start of str1 that lie - ; in str2 -exit: - .leave - ret -strspn endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strpbrk -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strpbrk - -C DECLARATION TCHAR *strpbrk(TCHAR *str1, TCHAR *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strpbrk:far -strpbrk proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str2 ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov cx, -1 ;CX <- # chars in str2 not counting null - clr ax -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx - dec cx - jcxz notFound ;Exit if str2 is null - - mov bx, cx ;BX <- strlen(str2) -loopTop: -SBCS < lodsb > ;AL <- next char in str1 -DBCS < lodsw > -SBCS < tst al > ;Exit if at end of str1 -DBCS < tst ax > - jz checkNotFound ; - mov cx, bx ;CX <- # chars in str2 - mov di, str2.offset ;ES:DI <- ptr to str2 -SBCS < repne scasb > ; -DBCS < repne scasw > - jnz loopTop ;If char not found, branch - dec si -DBCS < dec si > -EC < call ECCheckBounds > - movdw dxax, dssi ;DX:AX <- ptr to char in string1 -exit: - .leave - ret -checkNotFound: -EC < call ECCheckBoundsMinusOne > -notFound: - clrdw dxax - jmp exit -strpbrk endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strrpbrk -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strrpbrk - -C DECLARATION TCHAR *strrpbrk(TCHAR *str1, TCHAR *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strrpbrk:far -strrpbrk proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str1 - mov cx, -1 - clr ax -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx - dec cx - jcxz notFound ;if str1 is null, exit - mov dx, cx ;DX <- strlen(str1) - - mov ds, str1.segment - mov si, di -SBCS < sub si, 2 > ;DS:SI <- ptr to last char in str1 -DBCS < sub si, 4 > - - les di, str2 ;ES:DI <- ptr to str2 - mov cx, -1 ;CX <- strlen(str2) - clr ax ; -SBCS < repne scasb > ; -DBCS < repne scasw > - not cx ; -EC < call ECCheckBoundsESDIMinusOne > - dec cx ; - - jcxz notFound ;Exit if str2 is null - - mov bx, cx ;BX <- strlen(str2) -loopTop: -; -; DS:SI <- ptr to next char in str1 -; BX <- # chars in str2 -; DX <- # chars left to check in str1 -; - std -SBCS < lodsb > ;AL <- next char in str1 -DBCS < lodsw > - cld - mov cx, bx ;CX <- # chars in str2 - mov di, str2.offset ;ES:DI <- ptr to str2 -SBCS < repne scasb > ; -DBCS < repne scasw > - jz found ;If char found, branch - - dec dx ;Dec # chars to check in str1 - jnz loopTop - -notFound: - clr dx ;Return NULL - mov ax, dx - jmp exit -found: - inc si -DBCS < inc si > - movdw dxax, dssi ;DX:AX <- ptr to char in string1 -exit: - .leave - ret -strrpbrk endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strstr -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strstr - -C DECLARATION TCHAR far * strstr(TCHAR *str1, TCHAR *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - jenny 30/9/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strstr:far -strstr proc far str1:fptr, str2:fptr - uses ds, es, di, si - - .enter - les di, str1 ;ES:DI <- ptr to str1 - mov cx, -1 -SBCS < clr al> -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx - mov bx, cx ;BX <- # chars in str1 (w/ null) - - les di, str2 ;ES:DI <- ptr to str2 - mov cx, -1 -SBCS < clr al > -DBCS < clr ax > -SBCS < repne scasb > -DBCS < repne scasw > -EC < call ECCheckBoundsESDIMinusOne > - not cx ;CX <- # chars in str2 (w/ null) - sub bx, cx ;BX <- length diff. betw. str1 & str2 - jl notFound ;If str1 is shorter than str2, branch - dec cx - mov ax, cx ;AX <- # chars in str2 (without null) - - mov dx, str2.offset ;DX <- str2.offset - mov di, dx ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov bp, si ;BP <- str1.offset -cmpStrings: -SBCS < repe cmpsb > -DBCS < repe cmpsw > - jne notSameChar ;If not same char, branch - mov dx, ds ;DX:AX <- ptr to string found - mov ax, bp ; - jmp exit -notSameChar: - inc bp ;Increment offset into str1 -DBCS < inc bp > - mov si, bp ;DS:SI <- next str1 char to start with - mov di, dx ;ES:DI <- ptr to str2 - mov cx, ax ;CX <- # of chars in str2 - dec bx ;Decrement length diff. betw. str2 - ; and what remains of str1 - jge cmpStrings ;If str2 is not longer, branch -notFound: - clrdw dxax ;If string not found, return NULL -exit: - .leave - ret -strstr endp - -STRINGCODE ends - - -; -; For DBCS, SBCS versions -; -ifdef DO_DBCS - -STRINGCODESBCS segment byte public 'CODE' -.model medium, pascal - -if ERROR_CHECK -ECCheckBoundsESDISBCS proc near - segxchg es, ds - xchg si, di - call ECCheckBounds - xchg si, di - segxchg es, ds - ret -ECCheckBoundsESDISBCS endp -ECCheckBoundsESDIMinusOneSBCS proc near - pushf - push di - dec di - call ECCheckBoundsESDISBCS - pop di - popf - ret -ECCheckBoundsESDIMinusOneSBCS endp -ECCheckBoundsMinusOneSBCS proc near - pushf - push si - dec si - call ECCheckBounds - pop si - popf - ret -ECCheckBoundsMinusOneSBCS endp -endif - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strlensbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strlensbcs - - -C DECLARATION word strlensbcs(char far *str); - (For XIP system, *str can be pointing to the XIP movable - code resource.) - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global STRLENSBCS:far -STRLENSBCS proc far strPtr:fptr - uses es, di - .enter - les di, strPtr -EC < call ECCheckBoundsESDISBCS > - mov cx, -1 - clr al - repne scasb - not cx - dec cx ;Nuke count of null terminator - xchg ax, cx - .leave - ret -STRLENSBCS endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strchrsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strchrsbcs - -C DECLARATION char far * strchrsbcs(char *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strchrsbcs:far -strchrsbcs proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 -EC < call ECCheckBoundsESDISBCS > - mov cx, -1 - clr al - repne scasb - not cx ;CX <- # chars including null - mov di, str1.offset - mov ax, theC - repne scasb ;Look for the character - jne notFound ;If not found, branch - dec di - mov dx, es ;DX:AX <- ptr to char found - xchg ax, di -exit: - .leave - ret -notFound: - clr dx ;If char not found, return NULL - clr ax - jmp exit -strchrsbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strrchrsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strrchrsbcs - -C DECLARATION char far * strrchrsbcs(char *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strrchrsbcs:far -strrchrsbcs proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 - mov cx, -1 - clr al - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars including null - dec di ;DI <- ptr to null char - mov ax, theC - std - repne scasb ;Look for the character - cld - jne notFound ;If not found, branch - inc di - mov dx, es ;DX:AX <- ptr to char found - xchg ax, di -exit: - .leave - ret -notFound: - clr dx ;If char not found, return NULL - clr ax - jmp exit -strrchrsbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strpos -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strpos - -C DECLARATION word strpos(char *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strpossbcs:far -strpossbcs proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 - mov cx, -1 - clr al - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars including null - mov di, str1.offset - mov ax, theC - repne scasb ;Look for the character - mov ax, -1 - jne exit ;If not found, branch - dec di - sub di, str1.offset - xchg ax, di ;AX <- offset to char in string -exit: - .leave - ret -strpossbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strrpossbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strrpossbcs - -C DECLARATION word strrpossbcs(char *str1, word c); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strrpossbcs:far -strrpossbcs proc far str1:fptr, theC:word - uses es, di - .enter - les di, str1 - mov cx, -1 - clr ax - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars including null - dec di ;DI <- ptr to null char - mov ax, theC - std - repne scasb ;Look for the character - cld - mov ax, -1 - jne exit ;If not found, branch - inc di - sub di, str1.offset - xchg ax, di ;AX <- offset to char in string -exit: - .leave - ret -strrpossbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcpysbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcpysbcs - -C DECLARATION char far * strcpysbcs(char far *dest, char far *source); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcpysbcs:far -strcpysbcs proc far destPtr:fptr, sourcePtr:fptr - uses ds, es, di, si - .enter - les di, sourcePtr ;ES:DI <- ptr to src string - mov ds, sourcePtr.segment - mov si, di ;DS:SI <- ptr to src string - - mov cx, -1 - clr ax - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars (+ null) in src string - - les di, destPtr ;ES:DI <- ptr to dest for string - mov dx, es ;DX:AX <- ptr to dest for string - mov ax, di - - shr cx, 1 - jnc 10$ - movsb -10$: - rep movsw -EC < call ECCheckBoundsESDIMinusOneSBCS > - .leave - ret -strcpysbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strncpysbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strncpysbcs - -C DECLARATION char far * strcpysbcs(char far *dest, char far *source, word len); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strncpysbcs:far -strncpysbcs proc far destPtr:fptr, sourcePtr:fptr, len:word - uses ds, es, di, si - .enter - - lds si, sourcePtr ;DS:SI <- ptr to src string - les di, destPtr ;ES:DI <- ptr to dest string - mov cx, len - jcxz exit -5$: - lodsb - tst al - jz 10$ - stosb - loop 5$ -exit: - .leave - ret -10$: - rep stosb ;Null pad the dest string -EC < call ECCheckBoundsMinusOneSBCS > -EC < call ECCheckBoundsESDIMinusOneSBCS > - jmp exit -strncpysbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcmpsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcmpsbcs - -C DECLARATION word strcmpsbcs(word far *str1, word far *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcmpsbcs:far -strcmpsbcs proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str1 ;ES:DI <- ptr to str1 - lds si, str2 ;DS:SI <- ptr to str 2 - mov cx, -1 - clr ax ; - repne scasb ; -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars in str 1 (w/null) - - mov di, str1.offset ;ES:DI <- ptr to str1 - repe cmpsb -EC < call ECCheckBoundsMinusOneSBCS > - jz exit ;If match, exit (with ax=0) - mov al, es:[di][-1] ;Else, return difference of chars> - sub al, ds:[si][-1] ; - cbw ; -exit: - .leave - ret -strcmpsbcs endp - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strncmpsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strncmpsbcs - -C DECLARATION word strncmpsbcs(word far *str1, word far *str2, word len); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strncmpsbcs:far -strncmpsbcs proc far str1:fptr, str2:fptr, len:word - uses ds, es, di, si - .enter - clr ax ; - mov cx, len ; - jcxz exit ;If string is empty, return that they - ; are equal. - les di, str1 ;ES:DI <- ptr to str1 - repne scasb ;Get length of string -EC < call ECCheckBoundsESDIMinusOneSBCS > - neg cx - add cx, len ;CX <- min (len, strlen(str1)+1); - lds si, str2 ;DS:SI <- ptr to str 2 - mov di, str1.offset ;ES:DI <- ptr to str1 - repe cmpsb -EC < call ECCheckBoundsMinusOneSBCS > - mov al, es:[di][-1] ;Return difference of chars - sub al, ds:[si][-1] ; - cbw ; -exit: - .leave - ret -strncmpsbcs endp - - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcatsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcatsbcs - -C DECLARATION VOID * strcatsbcs(char far *str1, char far *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcatsbcs:far -strcatsbcs proc far str1:fptr, str2:fptr - uses es, ds, di, si - .enter - les di, str2 ; - lds si, str2 ; - -; GET LENGTH OF SECOND STRING - - clr ax - mov cx, -1 - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars in second string + null - -; SCAN TO END OF FIRST (DEST) STRING - - mov dx, cx ;DX <- size of second string - les di, str1 ;ES:DI <- ptr to str1 - mov cx, -1 ; - repne scasb ;ES:DI <- ptr past null - dec di ;ES:DI <- ptr to null byte of string -EC < call ECCheckBoundsESDISBCS > - mov cx, dx ;CX <- size of second string - -; COPY SECOND STRING ONTO END OF FIRST STRING - - shr cx, 1 - jnc 10$ - movsb -10$: - rep movsw -EC < call ECCheckBoundsESDIMinusOneSBCS > -EC < call ECCheckBoundsMinusOneSBCS > - mov dx, es - mov ax, str1.offset - .leave - ret -strcatsbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strncatsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strncatsbcs - -C DECLARATION VOID * strncatsbcs(char far *str1, char far *str2, word len); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - Name is in caps so routine can be published now that it's - fixed. - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global STRNCATSBCS:far -STRNCATSBCS proc far str1:fptr, str2:fptr, len:word - uses es, ds, di, si - .enter - les di, str1 ;ES:DI <- ptr to str1 - mov cx, -1 - clr al - repne scasb - dec di ;ES:DI <- ptr to null-terminator for - ; str1 - mov cx, len ; - jcxz exit ;If string is empty, just exit - lds si, str2 -loopTop: - lodsb - tst al - jz 10$ - stosb - loop loopTop - clr al -10$: -EC < call ECCheckBoundsMinusOneSBCS > -EC < call ECCheckBoundsESDISBCS > - stosb -exit: - mov dx, es - mov ax, str1.offset - .leave - ret -STRNCATSBCS endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strcspnsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strcspnsbcs - -C DECLARATION word strcspnsbcs(char *str1, char *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strcspnsbcs:far -strcspnsbcs proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str2 ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov cx, -1 ;CX <- # chars in str2 not counting null - clr al - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx - dec cx - mov bx, cx - mov dx,-1 -loopTop: - inc dx ;DX <- # chars at start of str1 that aren't in - ; str2 - lodsb ;AL <- next char in str1 - tst al - jz exit - mov cx, bx ;CX <- # chars in string - mov di, str2.offset ;ES:DI <- ptr to str2 - jcxz loopTop - repne scasb - jnz loopTop ;If char not found, branch - - -exit: -EC < call ECCheckBoundsMinusOneSBCS > - xchg ax, dx ;AX <- # chars at start of str1 that do not lie - ; in str2 - .leave - ret -strcspnsbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strspnsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strspnsbcs - -C DECLARATION word strspn(char *str1, char *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strspnsbcs:far -strspnsbcs proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str2 ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov cx, -1 ;CX <- # chars in str2 not counting null - clr ax - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx - dec cx - jcxz exit ;Exit if str2 is null - - mov bx, cx ;BX <- strlen(str2) - mov dx, -1 -loopTop: - inc dx ;DX <- # chars at start of str1 that are in - ; str2 - lodsb ;AL <- next char in str1 - tst al ;Exit if at end of str1 - jz 99$ ; - mov cx, bx ;CX <- # chars in string - mov di, str2.offset ;ES:DI <- ptr to str2 - repne scasb ; - jz loopTop ;If char found, branch - -99$: -EC < call ECCheckBoundsMinusOneSBCS > - xchg ax, dx ;AX <- # chars at start of str1 that lie - ; in str2 -exit: - .leave - ret -strspnsbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strpbrksbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strpbrk - -C DECLARATION char *strpbrksbcs(char *str1, char *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strpbrksbcs:far -strpbrksbcs proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str2 ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov cx, -1 ;CX <- # chars in str2 not counting null - clr ax - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx - dec cx - jcxz notFound ;Exit if str2 is null - - mov bx, cx ;BX <- strlen(str2) -loopTop: - lodsb ;AL <- next char in str1 - tst al ;Exit if at end of str1 - jz checkNotFound ; - mov cx, bx ;CX <- # chars in str2 - mov di, str2.offset ;ES:DI <- ptr to str2 - repne scasb ; - jnz loopTop ;If char not found, branch - dec si -EC < call ECCheckBounds > - movdw dxax, dssi ;DX:AX <- ptr to char in string1 -exit: - .leave - ret -checkNotFound: -EC < call ECCheckBoundsMinusOneSBCS > -notFound: - clrdw dxax - jmp exit -strpbrksbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strrpbrksbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strrpbrksbcs - -C DECLARATION char *strrpbrksbcs(char *str1, char *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - atw 3/ 8/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strrpbrksbcs:far -strrpbrksbcs proc far str1:fptr, str2:fptr - uses ds, es, di, si - .enter - les di, str1 - mov cx, -1 - clr ax - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx - dec cx - jcxz notFound ;if str1 is null, exit - mov dx, cx ;DX <- strlen(str1) - - mov ds, str1.segment - mov si, di - sub si, 2 ;DS:SI <- ptr to last char in str1 - - les di, str2 ;ES:DI <- ptr to str2 - mov cx, -1 ;CX <- strlen(str2) - clr ax ; - repne scasb ; - not cx ; -EC < call ECCheckBoundsESDIMinusOneSBCS > - dec cx ; - - jcxz notFound ;Exit if str2 is null - - mov bx, cx ;BX <- strlen(str2) -loopTop: -; -; DS:SI <- ptr to next char in str1 -; BX <- # chars in str2 -; DX <- # chars left to check in str1 -; - std - lodsb ;AL <- next char in str1 - cld - mov cx, bx ;CX <- # chars in str2 - mov di, str2.offset ;ES:DI <- ptr to str2 - repne scasb ; - jz found ;If char found, branch - - dec dx ;Dec # chars to check in str1 - jnz loopTop - -notFound: - clr dx ;Return NULL - mov ax, dx - jmp exit -found: - inc si - inc si - movdw dxax, dssi ;DX:AX <- ptr to char in string1 -exit: - .leave - ret -strrpbrksbcs endp - - -COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - strstrsbcs -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -C FUNCTION: strstrsbcs - -C DECLARATION char far * strstrsbcs(char *str1, char *str2); - -DESTROYED: various important but undocumented things - -PSEUDO CODE/STRATEGY: - This page intentionally left blank - -KNOWN BUGS/SIDE EFFECTS/IDEAS: - -REVISION HISTORY: - Name Date Description - ---- ---- ----------- - jenny 30/9/91 Initial version - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ -global strstrsbcs:far -strstrsbcs proc far str1:fptr, str2:fptr - uses ds, es, di, si - - .enter - les di, str1 ;ES:DI <- ptr to str1 - mov cx, -1 - clr al - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx - mov bx, cx ;BX <- # chars in str1 (w/ null) - - les di, str2 ;ES:DI <- ptr to str2 - mov cx, -1 - clr al - repne scasb -EC < call ECCheckBoundsESDIMinusOneSBCS > - not cx ;CX <- # chars in str2 (w/ null) - sub bx, cx ;BX <- length diff. betw. str1 & str2 - jl notFound ;If str1 is shorter than str2, branch - dec cx - mov ax, cx ;AX <- # chars in str2 (without null) - - mov dx, str2.offset ;DX <- str2.offset - mov di, dx ;ES:DI <- ptr to str2 - lds si, str1 ;DS:SI <- ptr to str1 - mov bp, si ;BP <- str1.offset -cmpStrings: - repe cmpsb - jne notSameChar ;If not same char, branch - mov dx, ds ;DX:AX <- ptr to string found - mov ax, bp ; - jmp exit -notSameChar: - inc bp ;Increment offset into str1 - mov si, bp ;DS:SI <- next str1 char to start with - mov di, dx ;ES:DI <- ptr to str2 - mov cx, ax ;CX <- # of chars in str2 - dec bx ;Decrement length diff. betw. str2 - ; and what remains of str1 - jge cmpStrings ;If str2 is not longer, branch -notFound: - clrdw dxax ;If string not found, return NULL -exit: - .leave - ret -strstrsbcs endp - -STRINGCODESBCS ends - -endif diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index f98b55219..d9d8c5af4 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -115,8 +115,7 @@ CharMod ends global INIT_FREETYPE:far global EXIT_FREETYPE:far -global engineHandle:lptr; -global trueTypeHandle:hptr; +global engineInstance:TrueTypeEngineInstance MetricsMod segment resource include truetypeMetrics.asm @@ -132,8 +131,6 @@ InitMod ends include truetypeEC.asm include ansic_runtime.asm include ansic_memory.asm -include ansic_malloc.asm -include ansic_string.asm Resident segment resource ;MODULE_FIXED diff --git a/Driver/Font/TrueType/Main/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def index 2b08c8b9f..b18e41e92 100644 --- a/Driver/Font/TrueType/Main/truetypeVariable.def +++ b/Driver/Font/TrueType/Main/truetypeVariable.def @@ -68,6 +68,26 @@ TrueTypeOutlineEntry struct TTOE_fontFileName DosDotFileName TrueTypeOutlineEntry ends +; +; TrueTypeEngineInstance corresponds to TEngine_Instance of the FreeType +; library. With the adaptation of the memory management, further static +; components of the FreeType structures are integrated into this structure. +; +TrueTypeEngineInstance struct + TTEI_lock fptr ;engine lock + list_free_elements fptr + objs_face_class fptr ;the face cache class + objs_instance_class fptr ;the instance cache class + objs_execution_class fptr ;the context cache class + objs_glyph_classfptr fptr ;the glyph cache class + objs_face_cache fptr ;these caches are used to track + objs_exec_cache fptr ;the current face and execution + ;context objects + raster_lock fptr ;mutex for this engine's render pool + raster_component fptr ;ttraster implementation depedent + extension_component fptr ;extensions dependent +TrueTypeEngineInstance ends + ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ @@ -93,10 +113,12 @@ udata segment bitmapHandle hptr ;handle of our bitmap block bitmapSize word ;size of our bitmap block (in bytes) +;After refactoring the memory management, the TrueTypeEngineInstance struct is +;stored in this block. variableHandle hptr ;handle of our variable block -trueTypeHandle hptr ;MemHandle to hold all FreeType structures -engineHandle lptr ;ChunkHandle to TT_EngineInstance +;This structure is later moved to the variable block. +engineInstance TrueTypeEngineInstance <> udata ends diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 2d54dc051..e841865f7 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,26 +4,25 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -MAIN = truetypeEscape.asm ansic_malloc.asm ansic_runtime.asm\ - mainManager.asm ansic_string.asm truetypeWidths.asm\ - ansic_memory.asm truetypeMetrics.asm truetypeInit.asm\ - truetypeEC.asm truetypeChars.asm truetypePath.asm\ - truetypeMacros.def truetypeVariable.def\ +MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ + truetypeWidths.asm ansic_memory.asm truetypeMetrics.asm\ + truetypeInit.asm truetypeEC.asm truetypeChars.asm\ + truetypePath.asm truetypeMacros.def truetypeVariable.def\ truetypeConstant.def ADAPTER = ttadapter.c ttadapter.h FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ttdebug.c ftxkern.c ttinterp.c ttload.c\ - ttfile.c ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h ttdebug.h\ + ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ + ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttconfig.h freetype.h ttgload.h ttfile.h header.h\ ttinterp.h ttload.h tttables.h ttobjs.h fterrid.h\ ttraster.h ttengine.h tttypes.h ttmutex.h ft_conf.h\ ttextend.h ftnameid.h ttcalc.h ftxkern.h ttmemory.h\ tttags.h UI_TO_RDFS = OBJS = ttadapter.obj ttcache.obj ttraster.obj ttmutex.obj\ - ttgload.obj ttextend.obj ttcalc.obj ttapi.obj ttdebug.obj\ - ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ - ttobjs.obj ttmemory.obj + ttgload.obj ttextend.obj ttcalc.obj ttapi.obj ftxkern.obj\ + ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ + ttmemory.obj COMMON = MODULES = Main CMODULES = Adapter FreeType diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index 3dc0081a4..55fed9502 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -12,137 +12,136 @@ Main.eobj: Main/mainManager.asm \ ../FontCom/fontcomUtils.asm truetypeChars.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ - truetypeEC.asm ansic_runtime.asm ansic_memory.asm \ - ansic_malloc.asm ansic_string.asm + truetypeEC.asm ansic_runtime.asm ansic_memory.asm ttadapter.obj \ -ttadapter.eobj: Adapter/ttadapter.h geos.h Adapter/../FreeType/freetype.h \ +ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h Ansi/stdlib.h \ + Adapter/../FreeType/freetype.h \ Adapter/../FreeType/fterrid.h \ - Adapter/../FreeType/ftnameid.h + Adapter/../FreeType/ftnameid.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h file.h resource.h \ + graphics.h fontID.h font.h color.h heap.h lmem.h \ + Adapter/../FreeType/ttmutex.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ - fontID.h font.h color.h heap.h ec.h Ansi/stdlib.h \ + fontID.h font.h color.h heap.h lmem.h ec.h Ansi/stdlib.h \ FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h \ FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ - FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h \ - FreeType/ttdebug.h + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h ttraster.obj \ ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ - FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ - Ansi/string.h + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ + FreeType/ttmemory.h Ansi/string.h ttmutex.obj \ ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h + color.h heap.h lmem.h ec.h Ansi/stdlib.h ttgload.obj \ ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ - FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttgload.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/tttags.h \ - FreeType/ttload.h + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttcalc.h FreeType/ttfile.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h ttextend.obj \ ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h ttcalc.obj \ ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ - FreeType/tttypes.h FreeType/tttables.h + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttables.h \ + FreeType/tttypes.h ttapi.obj \ ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h graphics.h fontID.h font.h color.h heap.h ec.h \ - Ansi/stdlib.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ - FreeType/ttfile.h FreeType/ttdebug.h FreeType/ttobjs.h \ + resource.h graphics.h fontID.h font.h color.h heap.h \ + lmem.h ec.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttcache.h FreeType/ttfile.h FreeType/ttobjs.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttload.h \ FreeType/ttgload.h FreeType/ttraster.h \ FreeType/ttextend.h -ttdebug.obj \ -ttdebug.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/tttables.h FreeType/ttobjs.h \ - FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/ttcmap.h ftxkern.obj \ ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h geos.h FreeType/ttextend.h \ FreeType/ttconfig.h FreeType/ft_conf.h file.h resource.h \ - graphics.h fontID.h font.h color.h heap.h ec.h \ + graphics.h fontID.h font.h color.h heap.h lmem.h ec.h \ Ansi/stdlib.h FreeType/tttypes.h FreeType/ttobjs.h \ FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/ttfile.h \ - FreeType/ttload.h FreeType/tttags.h + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/ttfile.h FreeType/ttload.h \ + FreeType/tttags.h ttinterp.obj \ ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ geos.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ft_conf.h file.h resource.h graphics.h fontID.h \ - font.h color.h heap.h ec.h Ansi/stdlib.h \ - FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/ttinterp.h FreeType/ttobjs.h \ - FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h + font.h color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h ttload.obj \ ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h FreeType/ttdebug.h \ - FreeType/ttcalc.h FreeType/ttfile.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/tttables.h FreeType/ttobjs.h \ - FreeType/ttcache.h FreeType/ttcmap.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/tttags.h FreeType/ttload.h + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttcalc.h FreeType/ttfile.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/tttags.h FreeType/ttload.h ttfile.obj \ ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h graphics.h fontID.h font.h color.h heap.h ec.h \ - Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + resource.h graphics.h fontID.h font.h color.h heap.h \ + lmem.h ec.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/tttypes.h FreeType/ttdebug.h \ + FreeType/ftnameid.h FreeType/tttypes.h \ FreeType/ttengine.h FreeType/ttmutex.h \ FreeType/ttmemory.h FreeType/ttfile.h ttcmap.obj \ ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttdebug.h \ - FreeType/ttfile.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttload.h + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttload.h ttobjs.obj \ ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ - FreeType/ttdebug.h FreeType/ttcalc.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/ttload.h FreeType/ttinterp.h \ - FreeType/ttextend.h + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttload.h FreeType/ttinterp.h FreeType/ttextend.h ttmemory.obj \ -ttmemory.eobj: FreeType/ttdebug.h FreeType/ttconfig.h FreeType/ft_conf.h \ +ttmemory.eobj: FreeType/ttmemory.h FreeType/ttconfig.h FreeType/ft_conf.h \ geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h ec.h Ansi/stdlib.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttengine.h FreeType/ttmutex.h + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h Ansi/string.h FreeType/ttengine.h \ + FreeType/ttmutex.h truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file From 2656f0848554d0bd4642b5b29553549a13ac4d0e Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 17 Oct 2022 22:41:24 +0200 Subject: [PATCH 077/246] add FreeType license file --- Driver/Font/TrueType/Adapter/ttadapter.c | 64 ++++++++- Driver/Font/TrueType/Adapter/ttadapter.h | 1 - Driver/Font/TrueType/FreeType/license.txt | 158 ++++++++++++++++++++++ Driver/Font/TrueType/backlog.md | 130 ------------------ 4 files changed, 219 insertions(+), 134 deletions(-) create mode 100644 Driver/Font/TrueType/FreeType/license.txt delete mode 100644 Driver/Font/TrueType/backlog.md diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index b7d49d3b9..dccd5bbf8 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -87,9 +87,66 @@ TT_Error _pascal Exit_FreeType() /******************************************************************** - * Char_Metrics + * Get_Font_Info ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Returns the FontID, FontWeight and FontStyle of the + * font with the given FileHandle. + * + * PARAMETERS: FileHandle Handle of the font. + * FontID* Pointer in which the ID of the + * font returned. + * FontWeight* Pointer in which the weight of the + * font returned. + * TextStyle* Pointer in which the style of the + * font returned. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * / /22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, + FontID* fontID, + FontWeight* fontWeight, + TextStyle* textStyle ) +{ + TT_Error error; + TT_Face face; + + + ECCheckFileHandle( fileHandle ); + + error = TT_Open_Face( fileHandle, &face ); + if ( error != TT_Err_Ok ) + return error; + + /* load font family name for ID generation */ + //TODO + + /* load font weight */ + //TODO + + /* load text style */ + //TODO + + + TT_Flush_Face( face ); + + return TT_Err_Ok; +} + + +/******************************************************************** + * Get_Char_Metrics + ******************************************************************** + * SYNOPSIS: Returns the metrics of the passed glyph of the font. * * PARAMETERS: * @@ -104,6 +161,7 @@ TT_Error _pascal Exit_FreeType() * ---- ---- ----------- * / /22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Char_Metrics() { +TT_Error _pascal Get_Char_Metrics( const FileHandle fileHandle ) +{ return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index dcf262cb0..c54d9ebfd 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -22,7 +22,6 @@ #include #include -#include #include "../FreeType/freetype.h" #include "../FreeType/ttengine.h" diff --git a/Driver/Font/TrueType/FreeType/license.txt b/Driver/Font/TrueType/FreeType/license.txt new file mode 100644 index 000000000..f0f96c75c --- /dev/null +++ b/Driver/Font/TrueType/FreeType/license.txt @@ -0,0 +1,158 @@ + The FreeType Project LICENSE + ---------------------------- + + Copyright 1996-1999 by + David Turner, Robert Wilhelm, and Werner Lemberg + + + +Introduction +============ + + The FreeType Project is distributed in several archive packages; + some of them may contain, in addition to the FreeType font engine, + various tools and contributions which rely on, or relate to, the + FreeType Project. + + This license applies to all files found in such packages, and + which do not fall under their own explicit license. The license + affects thus the FreeType font engine, the test programs, + documentation and makefiles, at the very least. + + This license was inspired by the BSD, Artistic, and IJG + (Independent JPEG Group) licenses, which all encourage inclusion + and use of free software in commercial and freeware products + alike. As a consequence, its main points are that: + + o We don't promise that this software works. However, we are be + interested in any kind of bug reports. (`as is' distribution) + + o You can use this software for whatever you want, in parts or + full form, without having to pay us. (`royalty-free' usage) + + o You may not pretend that you wrote this software. If you use + it, or only parts of it, in a program, you must acknowledge + somewhere in your documentation that you've used the FreeType + code. (`credits') + + We specifically permit and encourage the inclusion of this + software, with or without modifications, in commercial products, + provided that all warranty or liability claims are assumed by the + product vendor. + + +Legal Terms +=========== + +0. Definitions +-------------- + + Throughout this license, the terms `package', `FreeType Project', + and `FreeType archive' refer to the set of files originally + distributed by the authors (David Turner, Robert Wilhelm, and + Werner Lemberg) as the `FreeType project', be they named as alpha, + beta or final release. + + `You' refers to the licensee, or person using the project, where + `using' is a generic term including compiling the project's source + code as well as linking it to form a `program' or `executable'. + This program is referred to as `a program using the FreeType + engine'. + + This license applies to all files distributed in the original + FreeType archive, including all source code, binaries and + documentation, unless otherwise stated in the file in its + original, unmodified form as distributed in the original archive. + If you are unsure whether or not a particular file is covered by + this license, you must contact us to verify this. + + The FreeType project is copyright (C) 1996-1999 by David Turner, + Robert Wilhelm, and Werner Lemberg. All rights reserved except as + specified below. + +1. No Warranty +-------------- + + THE FREETYPE ARCHIVE IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO + USE, OF THE FREETYPE PROJECT. + + As you have not signed this license, you are not required to + accept it. However, as the FreeType project is copyrighted + material, only this license, or another one contracted with the + authors, grants you the right to use, distribute, and modify it. + Therefore, by using, distributing, or modifying the FreeType + project, you indicate that you understand and accept all the terms + of this license. + +2. Redistribution +----------------- + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + o Redistribution of source code must retain this license file + (`licence.txt') unaltered; any additions, deletions or changes + to the original files must be clearly indicated in + accompanying documentation. The copyright notices of the + unaltered, original files must be preserved in all copies of + source files. + + o Redistribution in binary form must provide a disclaimer that + states that the software is based in part of the work of the + FreeType Team, in the distribution documentation. We also + encourage you to put an URL to the FreeType web page in your + documentation, though this isn't mandatory. + + These conditions apply to any software derived from or based on + the FreeType code, not just the unmodified files. If you use our + work, you must acknowledge us. However, no fee need be paid to + us. + +3. Advertising +-------------- + + The names of FreeType's authors and contributors may not be used + to endorse or promote products derived from this software without + specific prior written permission. + + We suggest, but do not require, that you use one or more of the + following phrases to refer to this software in your documentation + or advertising materials: `FreeType Project', `FreeType Engine', + `FreeType library', or `FreeType Distribution'. + +4. Contacts +----------- + + There are two mailing lists related to FreeType: + + o freetype@freetype.org + + Discusses general use and applications of FreeType, as well as + future and wanted additions to the library and distribution. + If you are looking for support, start in this list if you + haven't found anything to help you in the documentation. + + o devel@freetype.org + + Discusses bugs, as well as engine internals, design issues, + specific licenses, porting, etc. + + o http://www.freetype.org + + Holds the current FreeType web page, which will allow you to + download our latest development version and read online + documentation. + + You can also contact us individually at: + + David Turner + Robert Wilhelm + Werner Lemberg + + +--- end of license.txt --- diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md deleted file mode 100644 index 140f1e7ac..000000000 --- a/Driver/Font/TrueType/backlog.md +++ /dev/null @@ -1,130 +0,0 @@ -## Integration des FreeType Frameworks in den FreeGEOS TrueType Font-Treiber - -Der Treiber wird in 3 Schichten realisiert: -- die Treiberschicht - + ist in Assembler geschrieben - + implementiert die Strategiefunktionen des Treibers - + delegiert an die Funktionen der Adapterschicht - + der Code liegt unter /Main -- die Adapterschicht - + ist in c geschrieben - + implementiert eine Funktion je Strategiefunktion - + eigene Logik und delegieren an die FreeType Engine - + der Code liegt unter /Adapter -- die FreeType Schicht - + die angepasste Implementierung der FreeType Engine - + der Code liegt unter /FreeType - -### Speicherverwaltung -- auf MemHandle/ChunkHandle umstellen - - TT_Engine - - TT_Stream - - TT_Face - - TT_Instance - - TT_Glyph - - TT_CharMap -- ~~Hilfsfunktionen TT_Alloc, TT_ReAlloc und TT_Free auf MemHandles/ChunkHandles umstellen~~ -- ~~Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen~~ -- Nutzer der Speicherverwaltungsmakros auf MemHandles/ChunkHandles umstellen - -**Wie soll die Speicherverwaltung aussehen?** - -~~**Variante a)**~~ -- ~~alle Pointer werden zu MemHandles~~ -- ~~vor/nach dem Zugriff muss gelock/geunlockt werden~~ - -**Variante b)** -- die Pointer werden zu ChunkHandles -- unklar ob ein LMemBlock genügt oder eine Aufteillung notwendig/sinnvoll ist --> währen der gesamten Lebenszeit des Treibers ist nur TT_Engine im Speicher notwendig --> die anderen FreeType Objekte (TT_Face, TT_Glyph ...) können durch die Adapterfunktionen angelegt und abgeräumt werden (das ist ev. eine sinnvolle Trennung) - -***Entscheidung:*** -- es wird 2 LMem Blöcke geben (Variante b): - - ein Block für die Engine (benötigt nach Analyse ca. 10kb) - - bleibt die ganze Laufzeit des Treibers erhalten - - enthält genau 8 Chunks - - wird durch die Adapterfunktion aufgebaut/abgebaut - - ein zweiter Block ist für die TrueTypeVars (Face, Instance, Glyph usw.) - - kann, je nach Font, bis zu 54kb anwachsen - - enthält bis zu 100 Chunks - - wird nur für das Rendern eines Glyphs aufgebaut und danach abgebaut - - wird durch die Adapterfunktionen aufgebaut/abgebaut - -~~**Klären:**~~ - - ~~wieviel Speicher und wieviele Blocks werden beim Rendervorgang belegt?~~ - - ~~gibt es bei der Speicherbelegung große Unterschieden bei versch. Fonts?~~ - -### DR_INIT -- ~~Adapterfunktion für DR_INIT schreiben~~ -- ~~Aufruf in truetypeInit.asm~~ -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### DR_EXIT -- ~~Adapter für DR_EXIT schreiben~~ -- ~~Aufruf in truetypeInit.asm~~ -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### DR_FONT_GEN_CHAR -- Adapterfunktion für DR_FONT_GEN_CHAR schreiben -- Kerning implementieren -- Aufruf in truetypeChars.asm -- prüfen ob die Adapterfunktion sauber durchlaufen wird -- das gerenderte Glyph wird in die GEOS Datenstrukturen einsortiert - -### DR_FONT_GEN_WIDTHS -- Adapterfunktion für DR_FONT_GEN_WIDTHS schreiben -- Aufruf in truetypeWidts.asm -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### DR_FONT_CHAR_METRICS -- Adapterfunktion für DR_FONT_CHAR_METRICS schreiben -- Aufruf in truetypeMetrics.asm -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### DR_FONT_INIT_FONTS (geringe Priorität) -Die bisherigen Implementierung in Assembler kann auf die FreeType Engine umgestellt werden, somit vermeiden wir Redundanzen. Die akt. Implementierung scheint nicht korrekt zu funktionieren, das wird gleich mit behoben. -- Adapterfunktion für DR_FONT_INIT_FONTS schreiben -- Aufruf in truetypeInit.asm -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### DR_FONT_GEN_PATH -- Adapterfunktion für DR_FONT_GEN_PATH schreiben -- Aufruf in truetypePath.asm -- hier ist die Behandlung der Transformationsmatrizen noch unklar -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### DR_FONT_GEN_IN_REGION -- Adapterfunktion für DR_FONT_GEN_REGION schreiben -- Aufruf in truetypePath.asm -- hier ist die Behandlung der Transformationsmatrizen noch unklar -- prüfen ob die Adapterfunktion sauber durchlaufen wird - -### sonstiges -- laden eines Fonts auf FileHandle umstellen -- diverse Segmente sind noch sehr groß (ttraster und ttinterp) -> prüfen wie diese verkleinert werden können -- diverse Strukturen prüfen ob diese noch verkleinert werden können - -### Aufräumarbeiten -- Abhängigkeit von Ansic auflösen (**sehr wichtig da jetzt im Sourcetree Codefragmente aus ansic liegen**) -- nicht genutzte Funktionen ausklammern -- Initalisierung des Graustufenarrays in TT_Init_FreeType entfernen -- das Graustufenarray kann aus TT_Engine entfernt werden -- Warnungen entfernen -- Makros vereinen: - - HANDLE_Engine und GHANDLE_Engine - - UNHANDLE_Engine und -/- -- Strukturen vereinen: - - GTT_Engine und TT_Engine - - GTT_Stream und TT_Stream - - GTT_Face und TT_Face - - GTT_Instance und TT_Instance - - GTT_Glyph und TT_Glyph - - GTT_CharMap und TT_CharMap - -### Funktionen die ausgeklammert werden können -- TT_Open_Collection() -- TT_Set_Face_Pointer() -- TT_Get_Face_Pointer() -- TT_Set_Instance_Pointer() -- TT_Get_Instance_Pointer() From 453b167bc716cb020e89b80399e04c563bff7fd3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 19 Oct 2022 20:07:20 +0200 Subject: [PATCH 078/246] Add skeleton for Get_Char_Metrics in adapter. --- Driver/Font/TrueType/Adapter/ttadapter.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index dccd5bbf8..58b389735 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -148,9 +148,14 @@ TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, ******************************************************************** * SYNOPSIS: Returns the metrics of the passed glyph of the font. * - * PARAMETERS: + * PARAMETERS: FileHandle Handle of the font. + * word Character to get metrics of. + * WBFixed* Pointer in wich the minimum of x returned. + * WBFixed* Pointer in wich the minimum of y returned. + * WBFixed* Pointer in wich the maximum of x returned. + * WBFixed* Pointer in wich the maximum of y returned. * - * RETURNS: + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) * * SIDE EFFECTS: none * @@ -161,7 +166,12 @@ TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, * ---- ---- ----------- * / /22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Get_Char_Metrics( const FileHandle fileHandle ) +TT_Error _pascal Get_Char_Metrics( const FileHandle fileHandle, + const word character, + WBFixed* minX, + WBFixed* minY, + WBFixed* maxX, + WBFixed* maxY ) { return TT_Err_Ok; } From 0ac8fa22d1726dac92d3d796db94d8814292efc0 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 30 Oct 2022 11:32:04 +0100 Subject: [PATCH 079/246] ttc support removed because we do not need it for the FreeGEOS driver. --- Driver/Font/TrueType/Adapter/ttadapter.c | 108 ++++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttadapter.h | 7 ++ Driver/Font/TrueType/FreeType/freetype.h | 4 - Driver/Font/TrueType/FreeType/ttapi.c | 5 -- Driver/Font/TrueType/FreeType/ttload.c | 82 ----------------- Driver/Font/TrueType/FreeType/ttobjs.c | 4 - Driver/Font/TrueType/FreeType/ttobjs.h | 3 - Driver/Font/TrueType/FreeType/tttables.h | 14 --- 8 files changed, 103 insertions(+), 124 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 58b389735..96ea806af 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -21,6 +21,8 @@ #include "ttadapter.h" #include +#include +#include /******************************************************************** @@ -95,6 +97,7 @@ TT_Error _pascal Exit_FreeType() * PARAMETERS: FileHandle Handle of the font. * FontID* Pointer in which the ID of the * font returned. + * char* Pointer to name of font family. * FontWeight* Pointer in which the weight of the * font returned. * TextStyle* Pointer in which the style of the @@ -113,12 +116,19 @@ TT_Error _pascal Exit_FreeType() *******************************************************************/ TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, - FontID* fontID, - FontWeight* fontWeight, - TextStyle* textStyle ) + FontID* fontID, + char* fontFamilyName, + FontWeight* fontWeight, + TextStyle* textStyle ) { - TT_Error error; - TT_Face face; + TT_Error error; + TT_Face face; + TT_Face_Properties props; + TT_UShort nameIndexFamily; + TT_UShort nameIndexStyle; + TT_UShort nameIndex; + TT_String* stringPtr; + TT_UShort* length; ECCheckFileHandle( fileHandle ); @@ -127,18 +137,60 @@ TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, if ( error != TT_Err_Ok ) return error; - /* load font family name for ID generation */ - //TODO + error = TT_Get_Face_Properties( face, &props ); + if ( error != TT_Err_Ok ) + return error; - /* load font weight */ - //TODO + /* process fontweight */ + *fontWeight = mapFontWeight( props.os2->usWeightClass ); - /* load text style */ - //TODO + /* find index for name and family in name table */ + for( nameIndex = 0; nameIndex < props.num_Names; ++nameIndex ) + { + TT_UShort platformID; + TT_UShort encodingID; + TT_UShort languageID; + TT_UShort nameID; + error = TT_Get_Name_ID( face, + nameIndex, + &platformID, + &encodingID, + &languageID, + &nameID ); + if ( error != TT_Err_Ok ) + return error; - TT_Flush_Face( face ); + if ( nameID == NAME_ID_FAMILY ) + nameIndexFamily = nameIndex; + + if ( nameID == NAME_ID_STYLE ) + nameIndexStyle = nameIndex; + } + + /* process font family name */ + error = TT_Get_Name_String( face, + nameIndexFamily, + &stringPtr, + &length ); + if ( error != TT_Err_Ok ) + return error; + + //*fontID = calculateFontID( stringPtr ); + copyFamilyName( stringPtr, fontFamilyName ); + /* process text style */ + error = TT_Get_Name_String( face, + nameIndexStyle, + &stringPtr, + &length ); + if ( error != TT_Err_Ok ) + return error; + + *textStyle = mapTextStyle( stringPtr ); + + /* free resouces and exit */ + TT_Flush_Face( face ); return TT_Err_Ok; } @@ -150,6 +202,7 @@ TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, * * PARAMETERS: FileHandle Handle of the font. * word Character to get metrics of. + * boolean Indicates that the rounded results are expected. * WBFixed* Pointer in wich the minimum of x returned. * WBFixed* Pointer in wich the minimum of y returned. * WBFixed* Pointer in wich the maximum of x returned. @@ -168,6 +221,7 @@ TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, *******************************************************************/ TT_Error _pascal Get_Char_Metrics( const FileHandle fileHandle, const word character, + Boolean rounded, WBFixed* minX, WBFixed* minY, WBFixed* maxX, @@ -175,3 +229,33 @@ TT_Error _pascal Get_Char_Metrics( const FileHandle fileHandle, { return TT_Err_Ok; } + + +static +int /* TextStyle */ +mapTextStyle( TT_String* style ) +{ + return TS_BOLD; +} + +static +int /* FontWeight */ +mapFontWeight( TT_UShort weight ) +{ + //TODO: definition of FontWeight in font.h is incomplete + return FW_NORMAL; +} + +/*static +FontID +calculateFontID( TT_String* familyName ) +{ + return 0; +}*/ + +static +void +copyFamilyName( TT_String* familyNameFromFile, char* fontFamilyName ) +{ + +} diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index c54d9ebfd..282c1109a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -31,4 +31,11 @@ extern TEngine_Instance engineInstance; +/*********************************************************************** + * parameters for search in name table + ***********************************************************************/ +#define NAME_ID_FAMILY 1 // font family name +#define NAME_ID_STYLE 2 // font style + + #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 4933faf6b..4b0abfcd2 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -576,10 +576,6 @@ TT_UShort num_CharMaps; /* number of charmaps in the face */ TT_UShort num_Names; /* number of name records in the face */ - TT_ULong num_Faces; /* 1 for normal TrueType files, and the */ - /* number of embedded faces for TrueType */ - /* collections */ - TT_Header* header; /* TrueType header table */ TT_Horizontal_Header* horizontal; /* TrueType horizontal header */ TT_OS2* os2; /* TrueType OS/2 table */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 74d67a1ce..819b59feb 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -258,11 +258,6 @@ extern TEngine_Instance engineInstance; properties->num_CharMaps = _face->numCMaps; properties->num_Names = _face->nameTable.numNameRecords; - if ( _face->ttcHeader.DirCount == 0 ) - properties->num_Faces = 1; - else - properties->num_Faces = _face->ttcHeader.DirCount; - properties->header = &_face->fontHeader; properties->horizontal = &_face->horizontalHeader; diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 1dba36754..c5eb0e38f 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -63,61 +63,6 @@ } -/******************************************************************* - * - * Function : Load_TrueType_Collection - * - * Description : Loads the TTC table directory into face table. - * - * Input : face face record to look for - * - * Output : Error code. - * - ******************************************************************/ - - static TT_Error Load_TrueType_Collection( PFace face ) - { - DEFINE_LOCALS; - - ULong n; - - - if ( FILE_Seek ( 0L ) || - ACCESS_Frame( 12L ) ) - return error; - - face->ttcHeader.Tag = GET_Tag4(); - face->ttcHeader.version = GET_Long(); - face->ttcHeader.DirCount = GET_Long(); - - FORGET_Frame(); - - if ( face->ttcHeader.Tag != TTAG_ttcf ) - { - face->ttcHeader.Tag = 0; - face->ttcHeader.version = 0; - face->ttcHeader.DirCount = 0; - - face->ttcHeader.TableDirectory = NULL; - - return TT_Err_File_Is_Not_Collection; - } - - if ( ALLOC_ARRAY( face->ttcHeader.TableDirectory, - face->ttcHeader.DirCount, - ULong ) || - ACCESS_Frame( face->ttcHeader.DirCount * 4L ) ) - return error; - - for ( n = 0; n < face->ttcHeader.DirCount; n++ ) - face->ttcHeader.TableDirectory[n] = GET_ULong(); - - FORGET_Frame(); - - return TT_Err_Ok; - } - - /******************************************************************* * * Function : Load_TrueType_Directory @@ -144,33 +89,6 @@ PTableDirEntry entry; - error = Load_TrueType_Collection( face ); - - if ( error ) - { - if ( error != TT_Err_File_Is_Not_Collection ) - return error; - - /* the file isn't a collection, exit if we're asking */ - /* for a collected font */ - if ( faceIndex != 0 ) - return error; - - /* Now skip to the beginning of the file */ - if ( FILE_Seek( 0L ) ) - return error; - } - else - { - /* The file is a collection. Check the font index */ - if ( faceIndex >= face->ttcHeader.DirCount ) - return TT_Err_Invalid_Argument; - - /* select a TrueType font in the ttc file */ - if ( FILE_Seek( face->ttcHeader.TableDirectory[faceIndex] ) ) - return error; - } - if ( ACCESS_Frame( 12L ) ) return error; diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index 11cf6b211..e4fda537a 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -1054,10 +1054,6 @@ Extension_Destroy( face ); #endif - /* freeing the collection table */ - FREE( face->ttcHeader.TableDirectory ); - face->ttcHeader.DirCount = 0; - /* freeing table directory */ FREE( face->dirTables ); face->numTables = 0; diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h index 2414c9fcf..71c46613d 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.h +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -486,9 +486,6 @@ /* used only by the threaded builds of the library */ TMutex lock; - /* TrueType collection header, if any was found */ - TTTCHeader ttcHeader; - /* maximum profile table, as found in the TrueType file */ TMaxProfile maxProfile; diff --git a/Driver/Font/TrueType/FreeType/tttables.h b/Driver/Font/TrueType/FreeType/tttables.h index 0ea5fffe8..cdc00a7d4 100644 --- a/Driver/Font/TrueType/FreeType/tttables.h +++ b/Driver/Font/TrueType/FreeType/tttables.h @@ -31,20 +31,6 @@ /* */ /***********************************************************************/ - /* TrueType Collection Header */ - - struct TTTCHeader_ - { - ULong Tag; - TT_Fixed version; - ULong DirCount; - PULong TableDirectory; - }; - - typedef struct TTTCHeader_ TTTCHeader; - typedef TTTCHeader* PTTCHeader; - - /* TrueType Table Directory type */ struct TTableDir_ From a2ac77e17cd331ffde2d1d9b8423c952d09bcd07 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 9 Nov 2022 21:21:50 +0100 Subject: [PATCH 080/246] Vorbereitung Font-Hackathon --- Driver/Font/TrueType/Adapter/ttadapter.c | 277 +++++++++-------------- 1 file changed, 106 insertions(+), 171 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 96ea806af..6a0f753ff 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -22,6 +22,7 @@ #include "ttadapter.h" #include #include +#include #include @@ -88,174 +89,108 @@ TT_Error _pascal Exit_FreeType() } -/******************************************************************** - * Get_Font_Info - ******************************************************************** - * SYNOPSIS: Returns the FontID, FontWeight and FontStyle of the - * font with the given FileHandle. - * - * PARAMETERS: FileHandle Handle of the font. - * FontID* Pointer in which the ID of the - * font returned. - * char* Pointer to name of font family. - * FontWeight* Pointer in which the weight of the - * font returned. - * TextStyle* Pointer in which the style of the - * font returned. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * / /22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Get_Font_Info( const FileHandle fileHandle, - FontID* fontID, - char* fontFamilyName, - FontWeight* fontWeight, - TextStyle* textStyle ) -{ - TT_Error error; - TT_Face face; - TT_Face_Properties props; - TT_UShort nameIndexFamily; - TT_UShort nameIndexStyle; - TT_UShort nameIndex; - TT_String* stringPtr; - TT_UShort* length; - - - ECCheckFileHandle( fileHandle ); - - error = TT_Open_Face( fileHandle, &face ); - if ( error != TT_Err_Ok ) - return error; - - error = TT_Get_Face_Properties( face, &props ); - if ( error != TT_Err_Ok ) - return error; - - /* process fontweight */ - *fontWeight = mapFontWeight( props.os2->usWeightClass ); - - /* find index for name and family in name table */ - for( nameIndex = 0; nameIndex < props.num_Names; ++nameIndex ) - { - TT_UShort platformID; - TT_UShort encodingID; - TT_UShort languageID; - TT_UShort nameID; - - error = TT_Get_Name_ID( face, - nameIndex, - &platformID, - &encodingID, - &languageID, - &nameID ); - if ( error != TT_Err_Ok ) - return error; - - if ( nameID == NAME_ID_FAMILY ) - nameIndexFamily = nameIndex; - - if ( nameID == NAME_ID_STYLE ) - nameIndexStyle = nameIndex; - } - - /* process font family name */ - error = TT_Get_Name_String( face, - nameIndexFamily, - &stringPtr, - &length ); - if ( error != TT_Err_Ok ) - return error; - - //*fontID = calculateFontID( stringPtr ); - copyFamilyName( stringPtr, fontFamilyName ); - - /* process text style */ - error = TT_Get_Name_String( face, - nameIndexStyle, - &stringPtr, - &length ); - if ( error != TT_Err_Ok ) - return error; - - *textStyle = mapTextStyle( stringPtr ); - - /* free resouces and exit */ - TT_Flush_Face( face ); - return TT_Err_Ok; -} - - -/******************************************************************** - * Get_Char_Metrics - ******************************************************************** - * SYNOPSIS: Returns the metrics of the passed glyph of the font. - * - * PARAMETERS: FileHandle Handle of the font. - * word Character to get metrics of. - * boolean Indicates that the rounded results are expected. - * WBFixed* Pointer in wich the minimum of x returned. - * WBFixed* Pointer in wich the minimum of y returned. - * WBFixed* Pointer in wich the maximum of x returned. - * WBFixed* Pointer in wich the maximum of y returned. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * / /22 JK Initial Revision - *******************************************************************/ -TT_Error _pascal Get_Char_Metrics( const FileHandle fileHandle, - const word character, - Boolean rounded, - WBFixed* minX, - WBFixed* minY, - WBFixed* maxX, - WBFixed* maxY ) -{ - return TT_Err_Ok; -} - - -static -int /* TextStyle */ -mapTextStyle( TT_String* style ) -{ - return TS_BOLD; -} - -static -int /* FontWeight */ -mapFontWeight( TT_UShort weight ) -{ - //TODO: definition of FontWeight in font.h is incomplete - return FW_NORMAL; -} - -/*static -FontID -calculateFontID( TT_String* familyName ) -{ - return 0; -}*/ - -static -void -copyFamilyName( TT_String* familyNameFromFile, char* fontFamilyName ) -{ - -} +//füllen der fontsAvialEntry Struktur: +// FAE_fontID (FontID) := wird berechnet aus Fontfamily +// Fontfamily := NameTable ID 1 (Font Family) +// Wie ist der Bildungsalgorithmus? +// FAE_fileName (char/wchar) := Dateiname des Fonts (Prüfung auf max. 36 Zeichen; sbcs/dbcs beachten) +// FAE_infoHandle (ChunkHandle) := Handle auf u.g. fontInfo + + +//füllen der fontInfo Struktur +// FI_fileHandle (word) := FileOpen( fileName ... ) +// FI_RESIDENT label(word) := ??? +// FI_fontID (FontID) := siehe oben FAE_fontID +// FI_maker (FontMaker) := FontMaker.FM_TRUETYPE +// FI_family (FontAttrs) := +// FA_USEFUL (FontUseful:1) := FU_USEFUL/FU_NOT_USEFUL? +// FA_FIXED_WIDTH (FontPitch:1) := FP_PROPORTIONAL +// FA_ORIENT (FontOrientation:1) := FO_NORMAL +// FA_OUTLINE (FontSource:1) := FS_OUTLINE +// FA_FAMILY (FontFamily:4) := gemappt aus FontProperties -> OS2 -> sWeightClass +// (high byte = class; low byte = subclass) +// class 0 (no classification) -> FF_NON_PORTABLE? +// class 1 (old style serifs) -> FF_SERIF +// class 2 (transitional serifs) -> FF_SERIF +// class 3 (modern serifs) -> FF_SERIF +// class 4 (clarendon serifs) +// subclass 6 (monotone) -> FF_MONO sonst FF_SERIF +// class 5 (slab serifs) -> FF_SERIF +// subclass 1 (monotone) -> FF_MONO sonst FF_SERIF +// class 6 (reserved) +// class 7 (freeform serifs) -> FF_SERIF +// class 8 (sans serif) -> FF_SANS_SERIF +// class 9 (ornamentals) -> FF_ORNAMENT +// class 10 (scrips) -> FF_SCRIPT +// class 11 (reserved) +// class 12 (symbolic) -> FF_SYMBOL +// Achtung: für FF_SPECIAL gibt es keine Zuordnung +// FI_faceName (char/wchar) := NameTable ID 1 (Font Family) (Prüfung auf max. 20 Zeichen) +// FI_pointSizeTab (word?) := 0 (keine Unterstützung für Bitmaps) +// FI_pointSizeEnd (word?) := 0 ( -"- ) +// FI_outlineTab (word?) := wird nicht verändert; muss in der asm-Schicht gefüllt werden +// FI_outlineEnd (word?) := ( -"- ) + +//füllen des OutlineDataEntry (im TTF Treiber gibt es nur einen Entry je Fontfile) +// ODE_style (TextStyle) := gemappt aus NameTable ID 2 (Subfamily) +// "Regular" := 0 +// "Bold" := TS_BOLD +// "Italic" := TS_ITALIC +// "Bold Italic" := TS_BOLD | TS_ITALIC +// "Oblique" := TS_ITALIC +// "Bold Oblique" := TS_BOLD | TS_ITALIC +// ODE_weight (FontWeight) := gemappt aus gemappt aus FontProperties -> OS2 -> usWeightClass +// 1 (Ultra-light) := FWE_ULTRA_LIGHT +// 2 (Extra-light) := FWE_EXTRA_LIGHT +// 3 (Light) := FWE_LIGHT +// 4 (Semi-light) := FWE_BOOK +// 5 (Medium (normal)) := FWE_NORMAL +// 6 (Semi-bold) := FWE_DEMI +// 7 (Bold) := FWE_BOLD +// 8 (Extra-Bold) := FWE_EXTRA_BOLD +// 9 (Ultra-bold) := FWE_ULTRA_BOLD +// ODE_header (OutlineEntry) := 0? +// ODE_first (OutlineEntry) := 0? +// ODE_second (OutlineEntry) := 0? + +//füllen der FontBuf Struktur +// FB_dataSize (word) := berechnet +// FB_maker (FontMaker) := FontMaker.FM_TRUETYPE +// FB_avgwidth (WBFixed) := +// FB_maxwidth (WBFixed) ; width of widest character +// FB_heightAdjust (WBFixed) ; offset to top of font box +// FB_height (WBFixed) ; height of characters +// FB_accent (WBFixed) ; height of accent portion. +// FB_mean (WBFixed) ; top of lower case character boxes. +// FB_baseAdjust (WBFixed) ; offset to top of ascent +// FB_baselinePos (WBFixed) ; position of baseline from top of font +// FB_descent (WBFixed) ; maximum descent (from baseline) +// FB_extLeading (WBFixed) ; recommended external leading +// FB_kernCount (word) := TT_Get_Kerning_Directory() +// directory->nTables +// FB_kernPairPtr nptr.KernPair := Ptr zur KernpairTabelle +// FB_kernValuePtr nptr.BBFixed := Ptr zur KernvalueTabelle +// FB_firstChar byte/Chars ; first char in section +// FB_lastChar byte/Chars ; last char in section +// FB_defaultChar byte/Chars ; default character +// FB_underPos WBFixed ; underline position (from baseline) +// FB_underThickness WBFixed ; underline thickness +// FB_strikePos WBFixed ; position of the strike-thru +// FB_aboveBox WBFixed ; maximum above font box +// FB_belowBox WBFixed ; maximum below font box +// FB_minLSB sword ; minimum left side bearing +// FB_minTSB sword ; minimum top side bound +// FB_maxBSB* sword ; maximum bottom side bound +// FB_maxRSB* sword ; maximum right side bound +// FB_pixHeight word ; height of font (invalid for rotation) +// FB_flags FontBufFlags ; special flags +// FB_heapCount word ; usage counter for this font +// FB_charTable CharTableEntry <> +// *nicht DBCS + +//füllen eines CharTableEntries +// CTE_dataOffset nptr.CharData ;Offset to data +// CTE_width WBFixed ;character width +// CTE_flags CharTableFlags ;flags +// CTE_usage* word ;LRU count +// *nicht DBCS From 8c6a058217842ebfffd4c2d3484b3de8d3a7edd6 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Fri, 11 Nov 2022 23:32:35 +0100 Subject: [PATCH 081/246] =?UTF-8?q?erster=20Vorschlag=20f=C3=BCr=20das=20C?= =?UTF-8?q?-API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Driver/Font/TrueType/Adapter/ttadapter.c | 119 +++++++++++++++++++---- 1 file changed, 100 insertions(+), 19 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 6a0f753ff..bdbd5fbfa 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -88,6 +88,87 @@ TT_Error _pascal Exit_FreeType() return TT_Done_FreeType(); } +/* Vorschlag C-API für den TTF-Treiber*/ + +/* Teil I relevante Strukturen füllen */ +TT_Error Fill_FontsAvialEntry( const char* file, fontsAvialEntry* fontsAvialEntry ) +{ + /* das ChunkHandle auf die FontInfo Struktur wird nicht gefüllt*/ + return TT_Err_Ok; +} + +TT_Error Fill_FontInfo( const FontAvailEntry* fontAvailEntry, FontInfo* fontInfo ) +{ + return TT_Err_Ok; +} + +TT_Error Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEntry* outlineDataEntry) +{ + /* unklar: OutlineDataEntry, OutlineData */ + return TT_Err_Ok +} + +TT_Error Fill_FontBuf( const FontInfo* fontInfo, FontBuf* fontBuf ) +{ + /* Hier ist für einige Felder der FontBuf Struktur nicht klar was erwartet wird. */ + /* Vielleicht hilft hier ein Blick in die Bitstream Sourcen. Ggf. müssen wir hier */ + /* mit via try and error die richtgen Werte herausfinden. */ + /* Beschreibung der TrueType Tabellen: */ + /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html */ + return TT_Err_Ok; +} + +/* offen: Kerning */ + +/* Teil II Metriken */ +TT_Error Get_Char_Metrics( const FontInfo* fontInfo, word character, GCM_info info, dword* result ) +{ + /* Api-Funktion für DR_FONT_GET_METRICS */ + /* Transformationen werden nicht beachtet!!! */ + /* The information is in document coordinates, which is to say it is not affected by */ + /* scaling, rotation, etc. that modifies the way the document is viewed, but simply */ + /* by the pointsize and font attributes requested. */ + /* siehe GrCharMetrics() */ + return TT_Err_Ok; +} + +/*****************************/ +/* Teil III Glyph rendern */ +/*****************************/ + +TT_Error Gen_Char( const FontInfo* fontInfo, GState gstate, word character ) +{ + /* Das Zeichen wird als Bitmap/Region gerendert. Die Transformationsmatix und */ + /* PointSize wird aus den GState geholt. Die gerenderte Bitmap wird in den */ + /* bitmapBlock und die belegte Größe in bitmapSize abgelegt. Das Format entspricht */ + /* CharData bzw. RegionCharData. */ + + /* offen: Was machen wir mit dem CharTableEntry? */ + /* Da das Flag welches anzeigt ob ein Glyph als Bitmap oder Region abgelegt wird */ + /* in FontInfo liegt, gilt: alle Zeichen als Bitmap oder als Region, Auf welcher */ + /* Basis wollen wir entscheiden ob wir ein Glyph als Bitmap oder als Region rendern?*/ + + return TT_Err_Ok; +} + +TT_Error Gen_In_Region( const FontInfo* fontInfo, GState gstate, RegionPathHandle regionPath, word character ) +{ + /* Das Zeichen wird als RegionPath gerendert. Die Transformationsmatix und */ + /* PointSize wird aus den GState geholt. Das gerenderte Glyph wird in den */ + /* übergebenen RegionPath gelegt. */ + + return TT_Err_Ok; +} + +TT_Error Gen_Path( const FontInfo* fontInfo, GState gstate, FontGenPathFlags flags, word character ) +{ + /* Das Zeichen wird als Path gerendert. Die Transformationsmatix und PointSize wird */ + /* aus den GState geholt. Das gerenderte Glyph wird in den übergebenen GState gelegt.*/ */ + + return TT_Err_Ok; +} + + //füllen der fontsAvialEntry Struktur: // FAE_fontID (FontID) := wird berechnet aus Fontfamily @@ -104,10 +185,10 @@ TT_Error _pascal Exit_FreeType() // FI_maker (FontMaker) := FontMaker.FM_TRUETYPE // FI_family (FontAttrs) := // FA_USEFUL (FontUseful:1) := FU_USEFUL/FU_NOT_USEFUL? -// FA_FIXED_WIDTH (FontPitch:1) := FP_PROPORTIONAL +// FA_FIXED_WIDTH (FontPitch:1) := FP_PROPORTIONAL // FA_ORIENT (FontOrientation:1) := FO_NORMAL // FA_OUTLINE (FontSource:1) := FS_OUTLINE -// FA_FAMILY (FontFamily:4) := gemappt aus FontProperties -> OS2 -> sWeightClass +// FA_FAMILY (FontFamily:4) := gemappt aus FaceProperties -> OS2 -> sWeightClass // (high byte = class; low byte = subclass) // class 0 (no classification) -> FF_NON_PORTABLE? // class 1 (old style serifs) -> FF_SERIF @@ -126,9 +207,9 @@ TT_Error _pascal Exit_FreeType() // class 12 (symbolic) -> FF_SYMBOL // Achtung: für FF_SPECIAL gibt es keine Zuordnung // FI_faceName (char/wchar) := NameTable ID 1 (Font Family) (Prüfung auf max. 20 Zeichen) -// FI_pointSizeTab (word?) := 0 (keine Unterstützung für Bitmaps) +// FI_pointSizeTab (word?) := 0 (keine Unterstützung für Bitmaps) // FI_pointSizeEnd (word?) := 0 ( -"- ) -// FI_outlineTab (word?) := wird nicht verändert; muss in der asm-Schicht gefüllt werden +// FI_outlineTab (word?) := wird nicht verändert; muss in der asm-Schicht gefüllt werden // FI_outlineEnd (word?) := ( -"- ) //füllen des OutlineDataEntry (im TTF Treiber gibt es nur einen Entry je Fontfile) @@ -139,7 +220,7 @@ TT_Error _pascal Exit_FreeType() // "Bold Italic" := TS_BOLD | TS_ITALIC // "Oblique" := TS_ITALIC // "Bold Oblique" := TS_BOLD | TS_ITALIC -// ODE_weight (FontWeight) := gemappt aus gemappt aus FontProperties -> OS2 -> usWeightClass +// ODE_weight (FontWeight) := gemappt aus gemappt aus FaceProperties -> OS2 -> usWeightClass // 1 (Ultra-light) := FWE_ULTRA_LIGHT // 2 (Extra-light) := FWE_EXTRA_LIGHT // 3 (Light) := FWE_LIGHT @@ -156,10 +237,10 @@ TT_Error _pascal Exit_FreeType() //füllen der FontBuf Struktur // FB_dataSize (word) := berechnet // FB_maker (FontMaker) := FontMaker.FM_TRUETYPE -// FB_avgwidth (WBFixed) := -// FB_maxwidth (WBFixed) ; width of widest character -// FB_heightAdjust (WBFixed) ; offset to top of font box -// FB_height (WBFixed) ; height of characters +// FB_avgwidth (WBFixed) := FaceProperties -> OS2 -> xAvgCharWidth +// FB_maxwidth (WBFixed) := muss berechnet werden; wird im BS Teiber nicht gefüllt +// FB_heightAdjust (WBFixed) := BS-Treiber: pointsize +// FB_height (WBFixed) := ; height of characters // FB_accent (WBFixed) ; height of accent portion. // FB_mean (WBFixed) ; top of lower case character boxes. // FB_baseAdjust (WBFixed) ; offset to top of ascent @@ -170,16 +251,16 @@ TT_Error _pascal Exit_FreeType() // directory->nTables // FB_kernPairPtr nptr.KernPair := Ptr zur KernpairTabelle // FB_kernValuePtr nptr.BBFixed := Ptr zur KernvalueTabelle -// FB_firstChar byte/Chars ; first char in section -// FB_lastChar byte/Chars ; last char in section -// FB_defaultChar byte/Chars ; default character -// FB_underPos WBFixed ; underline position (from baseline) -// FB_underThickness WBFixed ; underline thickness -// FB_strikePos WBFixed ; position of the strike-thru -// FB_aboveBox WBFixed ; maximum above font box -// FB_belowBox WBFixed ; maximum below font box -// FB_minLSB sword ; minimum left side bearing -// FB_minTSB sword ; minimum top side bound +// FB_firstChar (byte/Chars) ; first char in section +// FB_lastChar (byte/Chars) ; last char in section +// FB_defaultChar (byte/Chars) ; default character +// FB_underPos (WBFixed) ; underline position (from baseline) +// FB_underThickness (WBFixed) ; underline thickness +// FB_strikePos (WBFixed) ; position of the strike-thru +// FB_aboveBox (WBFixed) ; maximum above font box +// FB_belowBox (WBFixed) ; maximum below font box +// FB_minLSB (sword) ; minimum left side bearing +// FB_minTSB (sword) ; minimum top side bound // FB_maxBSB* sword ; maximum bottom side bound // FB_maxRSB* sword ; maximum right side bound // FB_pixHeight word ; height of font (invalid for rotation) From 68be907e54a673ef8d41bd13cb7f73d5d89a0f64 Mon Sep 17 00:00:00 2001 From: jirkakunze Date: Sat, 12 Nov 2022 16:40:35 +0100 Subject: [PATCH 082/246] Prototypes for C-API added --- Driver/Font/TrueType/Adapter/ttadapter.c | 240 +++++++++++++++++++++-- Driver/Font/TrueType/Adapter/ttadapter.h | 127 ++++++++++++ 2 files changed, 348 insertions(+), 19 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index bdbd5fbfa..31811f683 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -88,27 +88,122 @@ TT_Error _pascal Exit_FreeType() return TT_Done_FreeType(); } -/* Vorschlag C-API für den TTF-Treiber*/ -/* Teil I relevante Strukturen füllen */ -TT_Error Fill_FontsAvialEntry( const char* file, fontsAvialEntry* fontsAvialEntry ) +/******************************************************************** + * Fill_FontsAvialEntry + ******************************************************************** + * SYNOPSIS: Fills the FontsAvialEntry structure with infomations + * of the passed font file. + * + * PARAMETERS: file Name of font file + * fontsAvailEntry Pointer to FontsAvialEntry + * structure to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Fill_FontsAvailEntry( const char* file, FontsAvailEntry* fontsAvailEntry ) { - /* das ChunkHandle auf die FontInfo Struktur wird nicht gefüllt*/ + //FAE_fontID + //FAE_fileName + //ChunkHandle --> wird nicht gefüllt return TT_Err_Ok; } -TT_Error Fill_FontInfo( const FontAvailEntry* fontAvailEntry, FontInfo* fontInfo ) + +/******************************************************************** + * Fill_FontInfo + ******************************************************************** + * SYNOPSIS: Fills the FontsInfo structure with infomations + * of the passed in FontsAvailEntry. + * + * PARAMETERS: fontAvailEntry Entry of font file + * fontInfo Pointer to FontInfo structure + * to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Fill_FontInfo( const FontsAvailEntry* fontAvailEntry, FontInfo* fontInfo ) { + //TBD return TT_Err_Ok; } -TT_Error Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEntry* outlineDataEntry) + +/******************************************************************** + * Fill_OutlineDataEntry + ******************************************************************** + * SYNOPSIS: Fills the OutlineDataEntry structure with infomations + * of the passed in FontInfo. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * OutlineDataEntry Pointer to OutlineDataEntry + * structure to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEntry* outlineDataEntry) { /* unklar: OutlineDataEntry, OutlineData */ - return TT_Err_Ok + + /* Warum wird im TrueTypeOutlineEntry der Filename gehalten? + Wäre nicht das FileHandle sinvoller? + In der FontInfo steckt auch ein Filehandle! */ + return TT_Err_Ok; } -TT_Error Fill_FontBuf( const FontInfo* fontInfo, FontBuf* fontBuf ) + +/******************************************************************** + * Fill_FontBuf + ******************************************************************** + * SYNOPSIS: Fills the FontBuf structure with infomations + * of the passed in FontInfo. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * fontBuf Pointer to FontBuf structure + * to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ +TT_Error _pascal Fill_FontBuf( const FontInfo* fontInfo, FontBuf* fontBuf ) { /* Hier ist für einige Felder der FontBuf Struktur nicht klar was erwartet wird. */ /* Vielleicht hilft hier ein Blick in die Bitstream Sourcen. Ggf. müssen wir hier */ @@ -118,9 +213,56 @@ TT_Error Fill_FontBuf( const FontInfo* fontInfo, FontBuf* fontBuf ) return TT_Err_Ok; } +/******************************************************************** + * Fill_CharTableEntry + ******************************************************************** + * SYNOPSIS: Fills the FontBuf structure with infomations + * of the passed in FontInfo. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * gstate Handle to current gstate. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Pointsize, scale and rotation will read from gstate. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ +TT_Error _pascal Fill_CharTableEntry( const FontInfo* fontInfo, GStateHandle gstate, word character ) +{ + + return TT_Err_Ok; +} + /* offen: Kerning */ -/* Teil II Metriken */ +/******************************************************************** + * Fill_CharTableEntry + ******************************************************************** + * SYNOPSIS: Fills the FontBuf structure with infomations + * of the passed in FontInfo. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * gstate Handle to current gstate. + * result Pointer in wicht the result will + * stored. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Pointsize, scale and rotation will read from gstate. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ TT_Error Get_Char_Metrics( const FontInfo* fontInfo, word character, GCM_info info, dword* result ) { /* Api-Funktion für DR_FONT_GET_METRICS */ @@ -132,11 +274,28 @@ TT_Error Get_Char_Metrics( const FontInfo* fontInfo, word character, GCM_info i return TT_Err_Ok; } -/*****************************/ -/* Teil III Glyph rendern */ -/*****************************/ - -TT_Error Gen_Char( const FontInfo* fontInfo, GState gstate, word character ) +/******************************************************************** + * Gen_Char + ******************************************************************** + * SYNOPSIS: Renders the given character as bitmap or region to + * bitmap block. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * gstate Handle to current gstate. + * word Character to render. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Pointsize, scale and rotation will read from gstate. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ +TT_Error _pascal Gen_Char( const FontInfo* fontInfo, GStateHandle gstate, word character ) { /* Das Zeichen wird als Bitmap/Region gerendert. Die Transformationsmatix und */ /* PointSize wird aus den GState geholt. Die gerenderte Bitmap wird in den */ @@ -147,11 +306,33 @@ TT_Error Gen_Char( const FontInfo* fontInfo, GState gstate, word character ) /* Da das Flag welches anzeigt ob ein Glyph als Bitmap oder Region abgelegt wird */ /* in FontInfo liegt, gilt: alle Zeichen als Bitmap oder als Region, Auf welcher */ /* Basis wollen wir entscheiden ob wir ein Glyph als Bitmap oder als Region rendern?*/ + // --> im NibusTreiber prüfen return TT_Err_Ok; } -TT_Error Gen_In_Region( const FontInfo* fontInfo, GState gstate, RegionPathHandle regionPath, word character ) +/******************************************************************** + * Gen_InRegion + ******************************************************************** + * SYNOPSIS: Renders the given character into the RegionPath. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * gstate Handle to current gstate. + * regionPath Handle in wich the character + * will rendered. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Pointsize, scale and rotation will read from gstate. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ +TT_Error _pascal Gen_In_Region( const FontInfo* fontInfo, GStateHandle gstate, Handle regionPath, word character ) { /* Das Zeichen wird als RegionPath gerendert. Die Transformationsmatix und */ /* PointSize wird aus den GState geholt. Das gerenderte Glyph wird in den */ @@ -160,17 +341,38 @@ TT_Error Gen_In_Region( const FontInfo* fontInfo, GState gstate, RegionPathHandl return TT_Err_Ok; } -TT_Error Gen_Path( const FontInfo* fontInfo, GState gstate, FontGenPathFlags flags, word character ) +/******************************************************************** + * Gen_Path + ******************************************************************** + * SYNOPSIS: Renders the given character into the GStateHandle. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * gstate Handle to current gstate. + * flags Transformation flags. + * word Character to render. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Pointsize, scale and rotation will read from gstate. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ +TT_Error _pascal Gen_Path( const FontInfo* fontInfo, GStateHandle gstate, FontGenPathFlags flags, word character ) { /* Das Zeichen wird als Path gerendert. Die Transformationsmatix und PointSize wird */ - /* aus den GState geholt. Das gerenderte Glyph wird in den übergebenen GState gelegt.*/ */ - + /* aus den GState geholt. Das gerenderte Glyph wird in den übergebenen GState gelegt.*/ + return TT_Err_Ok; } -//füllen der fontsAvialEntry Struktur: +//füllen der fontsAvailEntry Struktur: // FAE_fontID (FontID) := wird berechnet aus Fontfamily // Fontfamily := NameTable ID 1 (Font Family) // Wie ist der Bildungsalgorithmus? diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 282c1109a..43a1aa2d3 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -22,6 +22,8 @@ #include #include +#include +#include #include "../FreeType/freetype.h" #include "../FreeType/ttengine.h" @@ -38,4 +40,129 @@ extern TEngine_Instance engineInstance; #define NAME_ID_STYLE 2 // font style +#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE + +/*********************************************************************** + * structures + ***********************************************************************/ + +typedef struct +{ + FontID FAE_fontID; +#ifdef DBCS_PCGEOS + wchar FAE_fileName[FONT_FILE_LENGTH]; +#else + char FAE_fileName[FONT_FILE_LENGTH]; +#endif + ChunkHandle FAE_infoHandle; +} FontsAvailEntry; + + +typedef struct +{ + word FI_fileHandle; + word FI_RESIDENT; + word FI_fontID; + FontMaker FI_maker; + FontAttrs FI_family; +#ifdef DBCS_PCGEOS + wchar FI_faceName[FID_NAME_LEN]; +#else + char FI_faceName[FID_NAME_LEN]; +#endif + word FI_pointSizeTab; //nptr to PointSizeEntry + word FI_pointSizeEnd; //nptr to PointSizeEntry + word FI_outlineTab; //nptr to OutlineEntry + word FI_outlineEnd; //nptr to outlineEntry +#ifdef DBCS_PCGEOS + wchar FI_firstChar; + wchar FI_lastChar; +#endif +} FontInfo; + +typedef struct +{ + char x; //TBD +} TrueTypeOutlineEntry; + +typedef struct +{ + char x; //TBD +} CharTableEntry; + + +typedef enum +{ + //TBD + FGPF_SAVE_STATE = 0x00, + FGPF_POSTSCRIPT = 0x00, +} FontGenPathFlags; + + + +typedef struct +{ + word FB_dataSize; + FontMaker FB_maker; +/* FB_avgwidth WBFixed ; average character width + FB_maxwidth WBFixed ; width of widest character + FB_heightAdjust WBFixed ; offset to top of font box + FB_height WBFixed ; height of characters + FB_accent WBFixed ; height of accent portion. + FB_mean WBFixed ; top of lower case character boxes. + FB_baseAdjust WBFixed ; offset to top of ascent + FB_baselinePos WBFixed ; position of baseline from top of font + FB_descent WBFixed ; maximum descent (from baseline) + FB_extLeading WBFixed ; recommended external leading + ; line spacing = FB_height + + ; FB_extLeading + + ; FB_heightAdjust + FB_kernCount word ; number of kerning pairs + FB_kernPairPtr nptr.KernPair ; offset to kerning pair table + FB_kernValuePtr nptr.BBFixed ; offset to kerning value table +if DBCS_PCGEOS + FB_firstChar Chars ; first char in section + FB_lastChar Chars ; last char in section + FB_defaultChar Chars ; default character +else + FB_firstChar byte ; first char defined + FB_lastChar byte ; last char defined + FB_defaultChar byte ; default character +endif + FB_underPos WBFixed ; underline position (from baseline) + FB_underThickness WBFixed ; underline thickness + FB_strikePos WBFixed ; position of the strike-thru + FB_aboveBox WBFixed ; maximum above font box + FB_belowBox WBFixed ; maximum below font box + ; Bounds are signed integers, in device coords, and are + ; measured from the upper left of the font box where + ; character drawing starts from. + FB_minLSB sword ; minimum left side bearing + FB_minTSB sword ; minimum top side bound +if not DBCS_PCGEOS + FB_maxBSB sword ; maximum bottom side bound + FB_maxRSB sword ; maximum right side bound +endif + FB_pixHeight word ; height of font (invalid for rotation) + FB_flags FontBufFlags ; special flags + FB_heapCount word ; usage counter for this font + FB_charTable CharTableEntry <> + */ +} FontBuf; + + +typedef struct +{ + TextStyle ODE_style; + FontWeight ODE_weight; +#ifdef DBCS_PCGEOS + word ODE_extraData; +#else + TrueTypeOutlineEntry ODE_header; + TrueTypeOutlineEntry ODE_first; + TrueTypeOutlineEntry ODE_second; +#endif +} OutlineDataEntry; + + #endif /* _TTADAPTER_H_ */ From 484270513fa3c71d3ddb90c551744b7e5e6f4c4b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 14 Nov 2022 18:22:18 +0100 Subject: [PATCH 083/246] Adapterfunction Fill_FontsAvailEntry implemented --- Driver/Font/TrueType/Adapter/ttadapter.c | 99 +++++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttadapter.h | 31 +++++--- 2 files changed, 108 insertions(+), 22 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 31811f683..a351ff63b 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -20,10 +20,6 @@ ***********************************************************************/ #include "ttadapter.h" -#include -#include -#include -#include /******************************************************************** @@ -95,7 +91,7 @@ TT_Error _pascal Exit_FreeType() * SYNOPSIS: Fills the FontsAvialEntry structure with infomations * of the passed font file. * - * PARAMETERS: file Name of font file + * PARAMETERS: fileName Name of font file * fontsAvailEntry Pointer to FontsAvialEntry * structure to fill. * @@ -103,7 +99,9 @@ TT_Error _pascal Exit_FreeType() * * SIDE EFFECTS: none * - * STRATEGY: + * STRATEGY: + * + * TODO: Prepare it for dbcs. * * REVISION HISTORY: * Date Name Description @@ -111,12 +109,45 @@ TT_Error _pascal Exit_FreeType() * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Fill_FontsAvailEntry( const char* file, FontsAvailEntry* fontsAvailEntry ) +TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, + FontsAvailEntry* fontsAvailEntry ) { - //FAE_fontID - //FAE_fileName - //ChunkHandle --> wird nicht gefüllt - return TT_Err_Ok; + FileHandle fileHandle; + TT_Error error; + TT_Face face; + char familyName[FAMILY_NAME_LENGTH]; + word familyNameLength; + + ECCheckBounds( fileName ); + ECCheckBounds( fontsAvailEntry ); + + if ( strlen( fileName ) >= FONT_FILE_LENGTH ) + return TT_Err_Invalid_Argument; + + fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); + ECCheckFileHandle( fileHandle ); + + error = TT_Open_Face( fileHandle, &face ); + if ( error != TT_Err_Ok ) + goto Fail; + + error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, familyName, &familyNameLength ); + if ( error != TT_Err_Ok ) + goto Fin; + + if ( isMappedFont( familyName ) ) + fontsAvailEntry->FAE_fontID = getMappedFontID( familyName ); + else + fontsAvailEntry->FAE_fontID = FM_TRUETYPE | ( 0x0fff & toHash ( familyName )); + + strcpy ( fontsAvailEntry->FAE_fileName, fileName ); + error = TT_Err_Ok; + +Fin: + TT_Close_Face( face ); +Fail: + FileClose( fileHandle, FALSE ); + return error; } @@ -370,6 +401,52 @@ TT_Error _pascal Gen_Path( const FontInfo* fontInfo, GStateHandle gstate, FontGe return TT_Err_Ok; } +/*******************************************************************/ +/* Implemetation of helperfunctions */ +/*******************************************************************/ + +static int toHash( const char* str ) +{ + word i; + dword hash = strlen( str ); + + for ( i = 0; i < strlen( str ) ; i++ ) + hash = ( hash * 7 ) % ( 2^16 ) + str[i]; + + return (int) hash; +} + +static Boolean isMappedFont( const char* familiyName ) +{ + //TODO: implement it + return FALSE; +} + +static FontID getMappedFontID( const char* familyName ) +{ + //TODO: implement it + //TODO: FontMaker austauschen + return (FontID) FID_DTC_URW_SANS; +} + +/*******************************************************************/ +/* We cannot use functions from the Ansic library, which causes a */ +/* cycle. Therefore, the required functions are reimplemented here.*/ +/*******************************************************************/ + +static int strlen( const char* str ) +{ + const char *s; + + for ( s = str; *s; ++s ) + ; + return( s - str ); +} + +static void strcpy( char* dest, const char* source ) +{ + while ((*dest++ = *source++) != '\0'); +} //füllen der fontsAvailEntry Struktur: diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 43a1aa2d3..d65b14b78 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -36,11 +36,12 @@ extern TEngine_Instance engineInstance; /*********************************************************************** * parameters for search in name table ***********************************************************************/ -#define NAME_ID_FAMILY 1 // font family name -#define NAME_ID_STYLE 2 // font style +#define NAME_INDEX_FAMILY 1 // font family name +#define NAME_INDEX_STYLE 2 // font style +#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE -#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE +#define FAMILY_NAME_LENGTH 20 /*********************************************************************** * structures @@ -104,19 +105,16 @@ typedef struct { word FB_dataSize; FontMaker FB_maker; -/* FB_avgwidth WBFixed ; average character width - FB_maxwidth WBFixed ; width of widest character - FB_heightAdjust WBFixed ; offset to top of font box - FB_height WBFixed ; height of characters - FB_accent WBFixed ; height of accent portion. + WBFixed FB_avgwidth; + WBFixed FB_maxwidth; + WBFixed FB_heightAdjust; + WBFixed FB_height; +/* FB_accent WBFixed ; height of accent portion. FB_mean WBFixed ; top of lower case character boxes. FB_baseAdjust WBFixed ; offset to top of ascent FB_baselinePos WBFixed ; position of baseline from top of font FB_descent WBFixed ; maximum descent (from baseline) FB_extLeading WBFixed ; recommended external leading - ; line spacing = FB_height + - ; FB_extLeading + - ; FB_heightAdjust FB_kernCount word ; number of kerning pairs FB_kernPairPtr nptr.KernPair ; offset to kerning pair table FB_kernValuePtr nptr.BBFixed ; offset to kerning value table @@ -164,5 +162,16 @@ typedef struct #endif } OutlineDataEntry; +/*********************************************************************** + * helperfunctions + ***********************************************************************/ + +static Boolean isMappedFont( const char* familiyName ); +static FontID getMappedFontID( const char* familyName ); +static int toHash( const char* str ); + +static int strlen( const char* str ); +static void strcpy( char* dest, const char* source ); #endif /* _TTADAPTER_H_ */ + From 08f0826c28a729da8c2858698bb25c8f1c3277d7 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 16 Nov 2022 20:58:37 +0100 Subject: [PATCH 084/246] first implementation of Fill_FontInfo() --- Driver/Font/TrueType/Adapter/ttadapter.c | 70 ++++++++++++++++++++++-- Driver/Font/TrueType/Adapter/ttadapter.h | 20 +++++-- 2 files changed, 80 insertions(+), 10 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index a351ff63b..e03053089 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -135,10 +135,16 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, if ( error != TT_Err_Ok ) goto Fin; + if ( familyNameLength >= FAMILY_NAME_LENGTH ) + { + error = TT_Err_Invalid_Argument; + goto Fin; + } + if ( isMappedFont( familyName ) ) fontsAvailEntry->FAE_fontID = getMappedFontID( familyName ); else - fontsAvailEntry->FAE_fontID = FM_TRUETYPE | ( 0x0fff & toHash ( familyName )); + fontsAvailEntry->FAE_fontID = MAKE_FONTID( familyName ); strcpy ( fontsAvailEntry->FAE_fileName, fileName ); error = TT_Err_Ok; @@ -157,7 +163,7 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, * SYNOPSIS: Fills the FontsInfo structure with infomations * of the passed in FontsAvailEntry. * - * PARAMETERS: fontAvailEntry Entry of font file + * PARAMETERS: fileName Name of font file * fontInfo Pointer to FontInfo structure * to fill. * @@ -173,10 +179,59 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Fill_FontInfo( const FontsAvailEntry* fontAvailEntry, FontInfo* fontInfo ) +TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) { - //TBD - return TT_Err_Ok; + FileHandle fileHandle; + TT_Error error; + TT_Face face; + TT_Face_Properties faceProperties; + char familyName[FAMILY_NAME_LENGTH]; + word familyNameLength; + + ECCheckBounds( fileName ); + ECCheckBounds( fontInfo ); + + fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); + ECCheckFileHandle( fileHandle ); + + error = TT_Open_Face( fileHandle, &face ); + if ( error != TT_Err_Ok ) + goto Fail; + + error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, familyName, &familyNameLength ); + if ( error != TT_Err_Ok ) + goto Fin; + + if ( familyNameLength >= FAMILY_NAME_LENGTH ) + { + error = TT_Err_Invalid_Argument; + goto Fin; + } + + error = TT_Get_Face_Properties( face, &faceProperties ); + if ( error != TT_Err_Ok ) + goto Fin; + + fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); + + if ( isMappedFont( familyName ) ) + fontInfo->FI_fontID = getMappedFontID( familyName ); + else + fontInfo->FI_fontID = MAKE_FONTID( familyName ); + + fontInfo->FI_maker = FM_TRUETYPE; + fontInfo->FI_pointSizeTab = 0; + fontInfo->FI_pointSizeEnd = 0; + fontInfo->FI_outlineTab = 0; + fontInfo->FI_outlineEnd = 0; + + error = TT_Err_Ok; + +Fin: + TT_Close_Face( face ); +Fail: + FileClose( fileHandle, FALSE ); + return error; } @@ -429,6 +484,11 @@ static FontID getMappedFontID( const char* familyName ) return (FontID) FID_DTC_URW_SANS; } +static FontAttrs mapFamilyClass( TT_Short familyClass ) +{ + return FA_OUTLINE; +} + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ /* cycle. Therefore, the required functions are reimplemented here.*/ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index d65b14b78..e472e3ec5 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -43,6 +43,9 @@ extern TEngine_Instance engineInstance; #define FAMILY_NAME_LENGTH 20 + +#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) + /*********************************************************************** * structures ***********************************************************************/ @@ -166,12 +169,19 @@ typedef struct * helperfunctions ***********************************************************************/ -static Boolean isMappedFont( const char* familiyName ); -static FontID getMappedFontID( const char* familyName ); -static int toHash( const char* str ); +static Boolean isMappedFont( const char* familiyName ); + +static FontID getMappedFontID( const char* familyName ); + +static int toHash( const char* str ); + +static FontAttrs mapFamilyClass( TT_Short familyClass ); + + + +static int strlen( const char* str ); -static int strlen( const char* str ); -static void strcpy( char* dest, const char* source ); +static void strcpy( char* dest, const char* source ); #endif /* _TTADAPTER_H_ */ From ca41b113dc5e638d3e49e712fd0d7749c09a53c5 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 17 Nov 2022 21:49:55 +0100 Subject: [PATCH 085/246] Fontfamily mapping implemented --- Driver/Font/TrueType/Adapter/ttadapter.c | 91 ++++++++++++++++++++---- Driver/Font/TrueType/Adapter/ttadapter.h | 6 +- 2 files changed, 79 insertions(+), 18 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index e03053089..5f472ad03 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -241,7 +241,7 @@ TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) * SYNOPSIS: Fills the OutlineDataEntry structure with infomations * of the passed in FontInfo. * - * PARAMETERS: fontInfo Pointer to FontInfo structure. + * PARAMETERS: fontInfo Name of font file. * OutlineDataEntry Pointer to OutlineDataEntry * structure to fill. * @@ -259,12 +259,19 @@ TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEntry* outlineDataEntry) { - /* unklar: OutlineDataEntry, OutlineData */ + FileHandle fileHandle; + TT_Face face; + TT_Error error; - /* Warum wird im TrueTypeOutlineEntry der Filename gehalten? - Wäre nicht das FileHandle sinvoller? - In der FontInfo steckt auch ein Filehandle! */ - return TT_Err_Ok; + + + error = TT_Err_Ok; + +Fin: + TT_Close_Face( face ); +Fail: + FileClose( fileHandle, FALSE ); + return error; } @@ -274,7 +281,7 @@ TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEnt * SYNOPSIS: Fills the FontBuf structure with infomations * of the passed in FontInfo. * - * PARAMETERS: fontInfo Pointer to FontInfo structure. + * PARAMETERS: fontName Name of font file. * fontBuf Pointer to FontBuf structure * to fill. * @@ -289,14 +296,30 @@ TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEnt * ---- ---- ----------- * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Fill_FontBuf( const FontInfo* fontInfo, FontBuf* fontBuf ) +TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) { - /* Hier ist für einige Felder der FontBuf Struktur nicht klar was erwartet wird. */ - /* Vielleicht hilft hier ein Blick in die Bitstream Sourcen. Ggf. müssen wir hier */ - /* mit via try and error die richtgen Werte herausfinden. */ - /* Beschreibung der TrueType Tabellen: */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html */ - return TT_Err_Ok; + FileHandle fileHandle; + TT_Error error; + TT_Face face; + TT_Face_Properties faceProperties; + + ECCheckBounds( fileName ); + ECCheckBounds( fontBuf ); + + fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); + ECCheckFileHandle( fileHandle ); + + error = TT_Open_Face( fileHandle, &face ); + if ( error != TT_Err_Ok ) + goto Fail; + + error = TT_Err_Ok; + +Fin: + TT_Close_Face( face ); +Fail: + FileClose( fileHandle, FALSE ); + return error; } /******************************************************************** @@ -486,7 +509,45 @@ static FontID getMappedFontID( const char* familyName ) static FontAttrs mapFamilyClass( TT_Short familyClass ) { - return FA_OUTLINE; + byte class = familyClass >> 8; + byte subclass = (byte) familyClass & 0x00ff; + FontFamily family; + + switch ( class ) + { + case 1: //old style serifs + case 2: //transitional serifs + case 3: //modern serifs + family = FF_SERIF; + break; + case 4: //clarendon serifs + family = subclass == 6 ? FF_MONO : FF_SERIF; + break; + case 5: //slab serifs + family = subclass == 1 ? FF_MONO : FF_SERIF; + break; + //6 = reserved + case 7: //freeform serfis + family = FF_SERIF; + break; + case 8: //sans serif + family = FF_SANS_SERIF; + break; + case 9: //ornamentals + family = FF_ORNAMENT; + break; + case 10: //scripts + family = FF_SCRIPT; + break; + //11 = reserved + case 12: //symbolic + family = FF_SYMBOL; + break; + default: + family = FF_NON_PORTABLE; + } + + return FA_USEFUL | FA_OUTLINE | family; } /*******************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index e472e3ec5..ed20fcee7 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -112,9 +112,9 @@ typedef struct WBFixed FB_maxwidth; WBFixed FB_heightAdjust; WBFixed FB_height; -/* FB_accent WBFixed ; height of accent portion. - FB_mean WBFixed ; top of lower case character boxes. - FB_baseAdjust WBFixed ; offset to top of ascent + WBFixed FB_accent; + WBFixed FB_mean; +/* FB_baseAdjust WBFixed ; offset to top of ascent FB_baselinePos WBFixed ; position of baseline from top of font FB_descent WBFixed ; maximum descent (from baseline) FB_extLeading WBFixed ; recommended external leading From fc7b16364132a30eff4bd70818c7385d86ac9099 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 18 Nov 2022 21:12:20 +0100 Subject: [PATCH 086/246] add font driver c structures --- Driver/Font/TrueType/Adapter/ttadapter.h | 154 +++++++++++++++-------- 1 file changed, 101 insertions(+), 53 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index ed20fcee7..614a5a711 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -15,7 +15,7 @@ * * DESCRIPTION: * Declaration of global objects which are defined in assembler - * and are also needed in c functions. + * and are also needed in c functions. ***********************************************************************/ #ifndef _TTADAPTER_H_ #define _TTADAPTER_H_ @@ -50,6 +50,9 @@ extern TEngine_Instance engineInstance; * structures ***********************************************************************/ +/* + * drivers FontsAvialEntry structure (see fontDr.def) + */ typedef struct { FontID FAE_fontID; @@ -62,6 +65,9 @@ typedef struct } FontsAvailEntry; +/* + * drivers FontInfo structure (see fontDr.def) + */ typedef struct { word FI_fileHandle; @@ -84,26 +90,70 @@ typedef struct #endif } FontInfo; + +/* + * drivers TrueTypeOutlineEntry structure (see truetypeVariable.def) + */ typedef struct { - char x; //TBD +#if DBCS_PCGEOS + wchar TTOE_fontFileName[FONT_FILE_LENGTH] +#else + char TTOE_fontFileName[FONT_FILE_LENGTH]; +#endif } TrueTypeOutlineEntry; + +/* + * flags for describing rendered char (see fontDr.def) + */ +typedef ByteFlags CharTableFlags; +#define CTF_NEGATIVE_LSB 0x40 +#define CTF_ABOVE_ASCENT 0x20 +#define CTF_BELOW_DESCENT 0x10 +#define CTF_NO_DATA 0x08 +#define CTF_IS_FIRST_KERN 0x04 +#define CTF_IS_SECOND_KERN 0x02 +#define CTF_NOT_VISIBLE 0x01 + + +/* + * driver CharTableEntry structure (see fontDr.def) + */ typedef struct { - char x; //TBD + word CTE_dataOffset; //nptr to data + WBFixed CTE_width; + CharTableFlags CTE_flags; +#ifndef DBCS_PCGEOS + word CTE_usage; +#endif } CharTableEntry; -typedef enum -{ - //TBD - FGPF_SAVE_STATE = 0x00, - FGPF_POSTSCRIPT = 0x00, -} FontGenPathFlags; +/* + * flags for font transforming (see fontDr.def) + */ +typedef ByteFlags FontGenPathFlags; +#define FGPF_SAVE_STATE 0x02 +#define FGPF_POSTSCRIPT 0x01 + +/* + * flags for font information (see fontDr.def) + */ +typedef ByteFlags FontBufFlags; +#define FBF_DEFAULT_FONT 0x80 +#define FBF_MAPPED_FONT 0x40 +#define FBF_IS_OUTLINE 0x10 +#define FBF_IS_REGION 0x08 +#define FBF_IS_COMPLEX 0x04 +#define FBF_IS_INVALID 0x02 +/* + * drivers FontBuf structure (see frontDr.def) + */ typedef struct { word FB_dataSize; @@ -114,44 +164,42 @@ typedef struct WBFixed FB_height; WBFixed FB_accent; WBFixed FB_mean; -/* FB_baseAdjust WBFixed ; offset to top of ascent - FB_baselinePos WBFixed ; position of baseline from top of font - FB_descent WBFixed ; maximum descent (from baseline) - FB_extLeading WBFixed ; recommended external leading - FB_kernCount word ; number of kerning pairs - FB_kernPairPtr nptr.KernPair ; offset to kerning pair table - FB_kernValuePtr nptr.BBFixed ; offset to kerning value table -if DBCS_PCGEOS - FB_firstChar Chars ; first char in section - FB_lastChar Chars ; last char in section - FB_defaultChar Chars ; default character -else - FB_firstChar byte ; first char defined - FB_lastChar byte ; last char defined - FB_defaultChar byte ; default character -endif - FB_underPos WBFixed ; underline position (from baseline) - FB_underThickness WBFixed ; underline thickness - FB_strikePos WBFixed ; position of the strike-thru - FB_aboveBox WBFixed ; maximum above font box - FB_belowBox WBFixed ; maximum below font box - ; Bounds are signed integers, in device coords, and are - ; measured from the upper left of the font box where - ; character drawing starts from. - FB_minLSB sword ; minimum left side bearing - FB_minTSB sword ; minimum top side bound -if not DBCS_PCGEOS - FB_maxBSB sword ; maximum bottom side bound - FB_maxRSB sword ; maximum right side bound -endif - FB_pixHeight word ; height of font (invalid for rotation) - FB_flags FontBufFlags ; special flags - FB_heapCount word ; usage counter for this font - FB_charTable CharTableEntry <> - */ + WBFixed FB_baseAdjust; + WBFixed FB_baselinePos; + WBFixed FB_descent; + WBFixed FB_extLeading; + word FB_kernCount; + word FB_kernPairPtr; //offset to kerning pair table + word FB_kernValuePtr; //offset to kerning value table +#ifdef DBCS_PCGEOS + wchar FB_firstChar; + wchar FB_lastChar; + wchar FB_defaultChar; +#else + char FB_firstChar; + char FB_lastChar; + char FB_defaultChar; +#endif + WBFixed FB_underPos; + WBFixed FB_underThickness; + WBFixed FB_strikePos; + WBFixed FB_aboveBox; + WBFixed FB_belowBox; + sword FB_minLSB; + sword FB_minTSB; +#ifndef DBCS_PCGEOS + sword FB_maxBSB; + sword FB_maxRSB; +#endif + word FB_pixHeight; + FontBufFlags FB_flags; + word FB_heapCount; } FontBuf; +/* + * drivers OutlineDataEntry structure (see fontDr.def) + */ typedef struct { TextStyle ODE_style; @@ -159,9 +207,9 @@ typedef struct #ifdef DBCS_PCGEOS word ODE_extraData; #else - TrueTypeOutlineEntry ODE_header; - TrueTypeOutlineEntry ODE_first; - TrueTypeOutlineEntry ODE_second; + TrueTypeOutlineEntry ODE_header; + TrueTypeOutlineEntry ODE_first; + TrueTypeOutlineEntry ODE_second; #endif } OutlineDataEntry; @@ -169,19 +217,19 @@ typedef struct * helperfunctions ***********************************************************************/ -static Boolean isMappedFont( const char* familiyName ); +static Boolean isMappedFont( const char* familiyName ); -static FontID getMappedFontID( const char* familyName ); +static FontID getMappedFontID( const char* familyName ); -static int toHash( const char* str ); +static int toHash( const char* str ); -static FontAttrs mapFamilyClass( TT_Short familyClass ); +static FontAttrs mapFamilyClass( TT_Short familyClass ); -static int strlen( const char* str ); +static int strlen( const char* str ); -static void strcpy( char* dest, const char* source ); +static void strcpy( char* dest, const char* source ); #endif /* _TTADAPTER_H_ */ From 0cc245e11fbed548a175b9ed07852d63cbfba9ba Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 19 Nov 2022 18:58:39 +0100 Subject: [PATCH 087/246] Fill_OutlineData implemented --- Driver/Font/TrueType/Adapter/ttadapter.c | 115 +++++++++++++++++++---- Driver/Font/TrueType/Adapter/ttadapter.h | 11 ++- 2 files changed, 107 insertions(+), 19 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 5f472ad03..8f4c4009e 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -99,6 +99,8 @@ TT_Error _pascal Exit_FreeType() * * SIDE EFFECTS: none * + * CONDITION: The current directory must be the ttf font directory. + * * STRATEGY: * * TODO: Prepare it for dbcs. @@ -146,7 +148,12 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, else fontsAvailEntry->FAE_fontID = MAKE_FONTID( familyName ); + /* We probably don't need this because we keep the file name in the */ + /* TrueTypeOutlineEntry for each style. */ strcpy ( fontsAvailEntry->FAE_fileName, fileName ); + + fontsAvailEntry->FAE_infoHandle = NullChunk; + error = TT_Err_Ok; Fin: @@ -171,6 +178,8 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, * * SIDE EFFECTS: none * + * CONDITION: The current directory must be the ttf font directory. + * * STRATEGY: * * REVISION HISTORY: @@ -236,19 +245,23 @@ TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) /******************************************************************** - * Fill_OutlineDataEntry + * Fill_OutlineData ******************************************************************** - * SYNOPSIS: Fills the OutlineDataEntry structure with infomations - * of the passed in FontInfo. + * SYNOPSIS: Fills OutlineDataEntry and TrueTypeOutlineEntry + * structure with infomations of the passed file. * - * PARAMETERS: fontInfo Name of font file. - * OutlineDataEntry Pointer to OutlineDataEntry + * PARAMETERS: fileName Name of font file. + * outlineDataEntry Pointer to OutlineDataEntry + * structure to fill. + * trueTypeOutlineEntry Pointer to TrueTypeOutlineEntry * structure to fill. * * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) * * SIDE EFFECTS: none * + * CONDITION: The current directory must be the ttf font directory. + * * STRATEGY: * * REVISION HISTORY: @@ -257,13 +270,48 @@ TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEntry* outlineDataEntry) +TT_Error _pascal Fill_OutlineData( const char* fileName, + OutlineDataEntry* outlineDataEntry, + TrueTypeOutlineEntry* trueTypeOutlineEntry ) { FileHandle fileHandle; TT_Face face; + TT_Face_Properties faceProperties; + char styleName[STYLE_NAME_LENGTH]; + word styleNameLength; TT_Error error; + ECCheckBounds( fileName ); + ECCheckBounds( outlineDataEntry ); + ECCheckBounds( trueTypeOutlineEntry ); + + fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); + ECCheckFileHandle( fileHandle ); + + error = TT_Open_Face( fileHandle, &face ); + if ( error != TT_Err_Ok ) + goto Fail; + + error = TT_Get_Name_String( face, NAME_INDEX_STYLE, styleName, &styleNameLength ); + if ( error != TT_Err_Ok ) + goto Fin; + + if ( styleNameLength >= STYLE_NAME_LENGTH ) + { + error = TT_Err_Invalid_Argument; + goto Fin; + } + + error = TT_Get_Face_Properties( face, &faceProperties ); + if ( error != TT_Err_Ok ) + goto Fin; + + /* fill outlineDataEntry */ + outlineDataEntry->ODE_style = mapTextStyle( styleName ); + outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); + /* fill trueTypeOutlineEntry */ + strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); error = TT_Err_Ok; @@ -278,10 +326,10 @@ TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEnt /******************************************************************** * Fill_FontBuf ******************************************************************** - * SYNOPSIS: Fills the FontBuf structure with infomations - * of the passed in FontInfo. + * SYNOPSIS: Fills the FontBuf structure with informations + * of the passed in ttf fileo. * - * PARAMETERS: fontName Name of font file. + * PARAMETERS: fileName Name of font file. * fontBuf Pointer to FontBuf structure * to fill. * @@ -289,6 +337,8 @@ TT_Error _pascal Fill_OutlineDataEntry( const FontInfo* fontInfo, OutlineDataEnt * * SIDE EFFECTS: none * + * CONDITION: The current directory must be the ttf font directory. + * * STRATEGY: * * REVISION HISTORY: @@ -313,6 +363,13 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) if ( error != TT_Err_Ok ) goto Fail; + fontBuf->FB_dataSize = sizeof( FontBuf ); + fontBuf->FB_maker = FM_TRUETYPE; + + /* + * TBD + */ + error = TT_Err_Ok; Fin: @@ -351,28 +408,42 @@ TT_Error _pascal Fill_CharTableEntry( const FontInfo* fontInfo, GStateHandle gst /* offen: Kerning */ /******************************************************************** - * Fill_CharTableEntry + * Get_Char_Metrics ******************************************************************** - * SYNOPSIS: Fills the FontBuf structure with infomations - * of the passed in FontInfo. + * SYNOPSIS: Returns the metics of the given char. * * PARAMETERS: fontInfo Pointer to FontInfo structure. * gstate Handle to current gstate. - * result Pointer in wicht the result will - * stored. + * character Character from which the metrics + * are requested. + * info Information to return. + * result Pointer in wich the result will + * stored. The result is not affected + * by scaling, rotation, etc. * * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) * * SIDE EFFECTS: none * - * STRATEGY: Pointsize, scale and rotation will read from gstate. + * CONDITION: The current directory must be the ttf font directory. + * + * STRATEGY: - find font-file for the requested style from fontInfo + * - open outline of character in founded font-file + * - calculate requested metrics and return it + * + * TODO: If we want to support fake styles, this must also + * be implemented here. * * REVISION HISTORY: * Date Name Description * ---- ---- ----------- * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error Get_Char_Metrics( const FontInfo* fontInfo, word character, GCM_info info, dword* result ) +TT_Error Get_Char_Metrics( const FontInfo* fontInfo, + GStateHandle gstate, + word character, + GCM_info info, + dword* result ) { /* Api-Funktion für DR_FONT_GET_METRICS */ /* Transformationen werden nicht beachtet!!! */ @@ -550,6 +621,18 @@ static FontAttrs mapFamilyClass( TT_Short familyClass ) return FA_USEFUL | FA_OUTLINE | family; } +static FontWeight mapFontWeight( TT_Short weightClass ) +{ + //TBD + return FW_NORMAL; +} + +static TextStyle mapTextStyle( const char* subfamily ) +{ + //TBD + return TS_BOLD; +} + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ /* cycle. Therefore, the required functions are reimplemented here.*/ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 614a5a711..dc072e5af 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -42,6 +42,7 @@ extern TEngine_Instance engineInstance; #define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE #define FAMILY_NAME_LENGTH 20 +#define STYLE_NAME_LENGTH 16 #define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) @@ -70,7 +71,7 @@ typedef struct */ typedef struct { - word FI_fileHandle; + FileHandle FI_fileHandle; word FI_RESIDENT; word FI_fontID; FontMaker FI_maker; @@ -169,8 +170,8 @@ typedef struct WBFixed FB_descent; WBFixed FB_extLeading; word FB_kernCount; - word FB_kernPairPtr; //offset to kerning pair table - word FB_kernValuePtr; //offset to kerning value table + word FB_kernPairPtr; //offset to kerning pair table + word FB_kernValuePtr; //offset to kerning value table #ifdef DBCS_PCGEOS wchar FB_firstChar; wchar FB_lastChar; @@ -225,6 +226,10 @@ static int toHash( const char* str ); static FontAttrs mapFamilyClass( TT_Short familyClass ); +static FontWeight mapFontWeight( TT_Short weightClass ); + +static TextStyle mapTextStyle( const char* subfamily ); + static int strlen( const char* str ); From 675502e5c617c5031ecc8e21d2f11f8bc6ffad3c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 20 Nov 2022 18:53:09 +0100 Subject: [PATCH 088/246] mapFontWeight implemented --- Driver/Font/TrueType/Adapter/ttadapter.c | 63 ++++++++++++++++++++++-- Driver/Font/TrueType/Adapter/ttadapter.h | 17 ++++++- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 8f4c4009e..2370e0d27 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -368,6 +368,44 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) /* * TBD + + fontBuf->FB_avgwidth = FaceProperties -> OS2 -> xAvgCharWidth + fontBuf->FB_maxwidth = Kann wie folgt berechnet werden? + FaceProperties -> header -> + ((xMax - xMin)/Units_Per_EM) * PointSize + (Wenn der Wert in Dokumentkoordinaten erwartet wird) + fontBuf->FB_heightAdjust = offset to top of font box -> ??? + fontBuf->FB_height = height of characters -> ??? Die Pointsize? + fontBuf->FB_accent = height of accent point -> ??? + fontBuf->FB_mean = top of lower case character boxes -> ??? + fontBuf->FB_baseAdjust = offset to top of ascent -> ??? + fontBuf->FB_baselinePos = position of baseline from top of font -> ??? + fontBuf->FB_descent = maximum descent from baseline -> ??? + fontBuf->FB_extLeading = recommended external leading -> ??? + fontBuf->FB_kernCount = TT_Get_Kerning_Directory -> nTables + fontBuf->FB_kernPairPtr = Pointer zu den KerningPairs + fontBuf->FB_kernValuePtr = Pointer zu den KerningValues + + fontBuf->FB_firstChar = FaceProperties -> OS2 -> usFirstCharIndex (TT_UShort) + (SBCS: Müssen wir die Anzahl der Zeichen im Font begrenzen?) + fontBuf->FB_lastChar = FaceProperties -> OS2 -> usLastCharIndex (TT_UShort) + (SBCS: Müssen wir die Anzahl der Zeichen im Font begrenzen?) + fontBuf->FB_defaultChar = default character -> ??? + Hier können wir ein festes Zeichen vorgeben. + + fontBuf->FB_underPos = FacePorperties -> postscript -> underlinePosition (TT_FWord) + fontBuf->FB_underThickness = FaceProperties -> postscript -> underlineThickness (TT_FWord) + fontBuf->FB_strikePos = FaceProperties -> OS2 -> yStrikeoutPosition (TT_Word) + fontBuf->FB_aboveBox = maximum above box -> ??? + fontBuf->FB_belowBox = maximum below box -> ??? + fontBuf->FB_minLSB = FaceProperties -> horizontal -> min_Left_Side_Bearing (TT_FWord) + fontBuf->FB_minTSB = FaceProperties -> vertical -> min_Top_Side_Bearing (TT_FWord) + + fontBuf->FB_pixHeight = height of font (invalid for rotation) -> ??? + Vergleichbar wie FB_maxWidth berechnen? + fontBuf->FB_flags = FBF_IS_OUTLINE | (je nach Bedarf FBF_IS_REGION) Weitere? + fontBuf->FB_heapCount = ??? + */ error = TT_Err_Ok; @@ -621,10 +659,29 @@ static FontAttrs mapFamilyClass( TT_Short familyClass ) return FA_USEFUL | FA_OUTLINE | family; } -static FontWeight mapFontWeight( TT_Short weightClass ) +static AdjustedWeight mapFontWeight( TT_Short weightClass ) { - //TBD - return FW_NORMAL; + switch (weightClass) + { + case 1: + return AW_ULTRA_LIGHT; + case 2: + return AW_EXTRA_LIGHT; + case 3: + return AW_LIGHT; + case 4: + return AW_SEMI_LIGHT; + case 5: + return AW_MEDIUM; + case 6: + return AW_SEMI_BOLD; + case 7: + return AW_BOLD; + case 8: + return AW_EXTRA_BOLD; + default: + return AW_ULTRA_BOLD; + } } static TextStyle mapTextStyle( const char* subfamily ) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index dc072e5af..63bf5a203 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -198,13 +198,28 @@ typedef struct } FontBuf; +/* + * drivers AdjustedWeight structure + */ +typedef ByteEnum AdjustedWeight; +#define AW_ULTRA_LIGHT 80 +#define AW_EXTRA_LIGHT 85 +#define AW_LIGHT 90 +#define AW_SEMI_LIGHT 95 +#define AW_MEDIUM 100 +#define AW_SEMI_BOLD 105 +#define AW_BOLD 110 +#define AW_EXTRA_BOLD 115 +#define AW_ULTRA_BOLD 120 + + /* * drivers OutlineDataEntry structure (see fontDr.def) */ typedef struct { TextStyle ODE_style; - FontWeight ODE_weight; + AdjustedWeight ODE_weight; #ifdef DBCS_PCGEOS word ODE_extraData; #else From 337c9855e30545d0806350e4d3d2057aa25ed99d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 21 Nov 2022 21:48:31 +0100 Subject: [PATCH 089/246] mapTextStyle implemented --- Driver/Font/TrueType/Adapter/ttadapter.c | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 2370e0d27..d39527b3a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -374,7 +374,7 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) FaceProperties -> header -> ((xMax - xMin)/Units_Per_EM) * PointSize (Wenn der Wert in Dokumentkoordinaten erwartet wird) - fontBuf->FB_heightAdjust = offset to top of font box -> ??? + fontBuf->FB_heightAdjust = Pointsize (siehe nimbusWidths.asm line 156) fontBuf->FB_height = height of characters -> ??? Die Pointsize? fontBuf->FB_accent = height of accent point -> ??? fontBuf->FB_mean = top of lower case character boxes -> ??? @@ -443,6 +443,7 @@ TT_Error _pascal Fill_CharTableEntry( const FontInfo* fontInfo, GStateHandle gst return TT_Err_Ok; } + /* offen: Kerning */ /******************************************************************** @@ -686,8 +687,19 @@ static AdjustedWeight mapFontWeight( TT_Short weightClass ) static TextStyle mapTextStyle( const char* subfamily ) { - //TBD - return TS_BOLD; + if ( strcmp( subfamily, "Regular" ) == 0 ) + return 0x00; + if ( strcmp( subfamily, "Bold" ) == 0 ) + return TS_BOLD; + if ( strcmp( subfamily, "Italic" ) == 0 ) + return TS_ITALIC; + if ( strcmp( subfamily, "Bold Italic" ) == 0 ) + return TS_BOLD | TS_ITALIC; + if ( strcmp( subfamily, "Oblique" ) == 0 ) + return TS_ITALIC; + + /* only Bold Oblique remains */ + return TS_BOLD | TS_ITALIC; } /*******************************************************************/ @@ -709,6 +721,16 @@ static void strcpy( char* dest, const char* source ) while ((*dest++ = *source++) != '\0'); } +static int strcmp( const char* s1, const char* s2 ) +{ + while ( *s1 && ( *s1 == *s2 ) ) + { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} + //füllen der fontsAvailEntry Struktur: // FAE_fontID (FontID) := wird berechnet aus Fontfamily From 34c75c1ed843bf51797360b7981b0492c0bfcedc Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 26 Nov 2022 22:17:51 +0100 Subject: [PATCH 090/246] Start filling FontBuf structure. --- Driver/Font/TrueType/Adapter/ttadapter.c | 76 +++++++++++++++++++----- Driver/Font/TrueType/Adapter/ttadapter.h | 17 +++++- 2 files changed, 77 insertions(+), 16 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index d39527b3a..495ec23af 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -327,9 +327,10 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, * Fill_FontBuf ******************************************************************** * SYNOPSIS: Fills the FontBuf structure with informations - * of the passed in ttf fileo. + * of the passed in ttf file. * * PARAMETERS: fileName Name of font file. + * pointSize Current Pointsize. * fontBuf Pointer to FontBuf structure * to fill. * @@ -346,12 +347,16 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, * ---- ---- ----------- * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) +TT_Error _pascal Fill_FontBuf( const char* fileName, + WBFixed pointSize, + FontBuf* fontBuf ) { FileHandle fileHandle; TT_Error error; TT_Face face; + TT_Instance instance; TT_Face_Properties faceProperties; + TT_Instance_Metrics instanceMetrics; ECCheckBounds( fileName ); ECCheckBounds( fontBuf ); @@ -363,28 +368,52 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) if ( error != TT_Err_Ok ) goto Fail; - fontBuf->FB_dataSize = sizeof( FontBuf ); - fontBuf->FB_maker = FM_TRUETYPE; + //TODO: load instance and get scalefactor + error = TT_New_Instance( face, &instance ); + if ( error ) + goto Fail; + + error = TT_Set_Instance_CharSize( instance, wBFixedToF26Dot6( pointSize ) ); + if ( error ) + goto Fail; + + error = TT_Get_Instance_Metrics( instance, &instanceMetrics ); + if ( error ) + goto Fail; + + /* Fill elements in FontBuf structure. */ + + fontBuf->FB_maker = FM_TRUETYPE; + fontBuf->FB_kernPairPtr = 0; + fontBuf->FB_kernValuePtr = 0; + fontBuf->FB_kernCount = 0; + fontBuf->FB_heapCount = 0; + + //TODO: mov es:FB_flags, mask FBF_IS_OUTLINE + /* heightAdjust := size_per_em - fontSize */ + + /* height := height of characters aka current pointsize */ + fontBuf->FB_height.WBF_int = pointSize.WBF_int; + fontBuf->FB_height.WBF_frac = pointSize.WBF_frac; + + /* pixHeight := rounded pointsize to nearest word */ + fontBuf->FB_pixHeight = roundWBFixedToNearestWord( pointSize ); + /* * TBD - - fontBuf->FB_avgwidth = FaceProperties -> OS2 -> xAvgCharWidth + fontBuf->FB_avgwidth = scale ( FaceProperties -> OS2 -> xAvgCharWidth ) fontBuf->FB_maxwidth = Kann wie folgt berechnet werden? FaceProperties -> header -> ((xMax - xMin)/Units_Per_EM) * PointSize (Wenn der Wert in Dokumentkoordinaten erwartet wird) fontBuf->FB_heightAdjust = Pointsize (siehe nimbusWidths.asm line 156) - fontBuf->FB_height = height of characters -> ??? Die Pointsize? fontBuf->FB_accent = height of accent point -> ??? fontBuf->FB_mean = top of lower case character boxes -> ??? fontBuf->FB_baseAdjust = offset to top of ascent -> ??? fontBuf->FB_baselinePos = position of baseline from top of font -> ??? fontBuf->FB_descent = maximum descent from baseline -> ??? fontBuf->FB_extLeading = recommended external leading -> ??? - fontBuf->FB_kernCount = TT_Get_Kerning_Directory -> nTables - fontBuf->FB_kernPairPtr = Pointer zu den KerningPairs - fontBuf->FB_kernValuePtr = Pointer zu den KerningValues fontBuf->FB_firstChar = FaceProperties -> OS2 -> usFirstCharIndex (TT_UShort) (SBCS: Müssen wir die Anzahl der Zeichen im Font begrenzen?) @@ -400,12 +429,7 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) fontBuf->FB_belowBox = maximum below box -> ??? fontBuf->FB_minLSB = FaceProperties -> horizontal -> min_Left_Side_Bearing (TT_FWord) fontBuf->FB_minTSB = FaceProperties -> vertical -> min_Top_Side_Bearing (TT_FWord) - - fontBuf->FB_pixHeight = height of font (invalid for rotation) -> ??? - Vergleichbar wie FB_maxWidth berechnen? fontBuf->FB_flags = FBF_IS_OUTLINE | (je nach Bedarf FBF_IS_REGION) Weitere? - fontBuf->FB_heapCount = ??? - */ error = TT_Err_Ok; @@ -685,6 +709,28 @@ static AdjustedWeight mapFontWeight( TT_Short weightClass ) } } +static void f26dot6ToWBFixed( TT_F26Dot6 f26Dot6, WBFixed* wbFixed ) +{ + wbFixed->WBF_frac = f26Dot6 << 2; + wbFixed->WBF_int = f26Dot6 >> 6; +} + +static TT_F26Dot6 wBFixedToF26Dot6( WBFixed wbFixed ) +{ + return ( ( (long)wbFixed.WBF_int ) * 1024 ) | wbFixed.WBF_frac >> 2; +} + +static TT_F26Dot6 scaleShort( TT_Short value, TT_F26Dot6 scale ) +{ + return TT_MulFix( INT_TO_F26DOT6( value ), scale ); +} + +static word roundWBFixedToNearestWord( WBFixed wbFixed ) +{ + return wbFixed.WBF_frac >= 0x10 ? wbFixed.WBF_int + 1 : wbFixed.WBF_int; +} + + static TextStyle mapTextStyle( const char* subfamily ) { if ( strcmp( subfamily, "Regular" ) == 0 ) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 63bf5a203..d84986c69 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -26,6 +26,7 @@ #include #include "../FreeType/freetype.h" #include "../FreeType/ttengine.h" +#include "../FreeType/ttcalc.h" /*********************************************************************** * global dgoup objects @@ -229,6 +230,12 @@ typedef struct #endif } OutlineDataEntry; + +/*********************************************************************** + * macros + ***********************************************************************/ + + /*********************************************************************** * helperfunctions ***********************************************************************/ @@ -246,10 +253,18 @@ static FontWeight mapFontWeight( TT_Short weightClass ); static TextStyle mapTextStyle( const char* subfamily ); - static int strlen( const char* str ); static void strcpy( char* dest, const char* source ); + +static void f26dot6ToWBFixed( TT_F26Dot6 f26Dot6, WBFixed* wbFixed ); + +static TT_F26Dot6 wBFixedToF26Dot6( WBFixed wbFixed ); + +static TT_F26Dot6 scaleShort( TT_Short value, TT_F26Dot6 scale ); + +static word roundWBFixedToNearestWord( WBFixed wbFixed ); + #endif /* _TTADAPTER_H_ */ From 813408f715c4a07bdc982bf3aabf262e88a3b594 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 26 Nov 2022 22:23:16 +0100 Subject: [PATCH 091/246] calculation adjustHeight corrected --- Driver/Font/TrueType/Adapter/ttadapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 495ec23af..634abc329 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -391,7 +391,7 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, //TODO: mov es:FB_flags, mask FBF_IS_OUTLINE - /* heightAdjust := size_per_em - fontSize */ + /* heightAdjust := pointsize - hightSize */ /* height := height of characters aka current pointsize */ fontBuf->FB_height.WBF_int = pointSize.WBF_int; From eaed2b9d61172e403b15c81434737a7b5a7041a7 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 28 Nov 2022 19:42:40 +0100 Subject: [PATCH 092/246] fill FB_extLeading in FontBuf --- Driver/Font/TrueType/Adapter/ttadapter.c | 132 ++++++++--------------- Driver/Font/TrueType/Adapter/ttadapter.h | 2 +- 2 files changed, 48 insertions(+), 86 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 634abc329..2d718c6b9 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -368,7 +368,6 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, if ( error != TT_Err_Ok ) goto Fail; - //TODO: load instance and get scalefactor error = TT_New_Instance( face, &instance ); if ( error ) goto Fail; @@ -381,6 +380,10 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, if ( error ) goto Fail; + error = TT_Get_Face_Properties( face, &faceProperties ); + if ( error ) + goto Fail; + /* Fill elements in FontBuf structure. */ fontBuf->FB_maker = FM_TRUETYPE; @@ -391,49 +394,52 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, //TODO: mov es:FB_flags, mask FBF_IS_OUTLINE - /* heightAdjust := pointsize - hightSize */ + /* FB_minLSB := scale( TT_Face_Properties->horizontal->min_Left_Side_Bearing )*/ - /* height := height of characters aka current pointsize */ - fontBuf->FB_height.WBF_int = pointSize.WBF_int; - fontBuf->FB_height.WBF_frac = pointSize.WBF_frac; + /* FB_avgWidth := scale( TT_Face_Properties->OS2->aAvgCharWidth ) */ - /* pixHeight := rounded pointsize to nearest word */ - fontBuf->FB_pixHeight = roundWBFixedToNearestWord( pointSize ); - - /* - * TBD - fontBuf->FB_avgwidth = scale ( FaceProperties -> OS2 -> xAvgCharWidth ) - fontBuf->FB_maxwidth = Kann wie folgt berechnet werden? - FaceProperties -> header -> - ((xMax - xMin)/Units_Per_EM) * PointSize - (Wenn der Wert in Dokumentkoordinaten erwartet wird) - fontBuf->FB_heightAdjust = Pointsize (siehe nimbusWidths.asm line 156) - fontBuf->FB_accent = height of accent point -> ??? - fontBuf->FB_mean = top of lower case character boxes -> ??? - fontBuf->FB_baseAdjust = offset to top of ascent -> ??? - fontBuf->FB_baselinePos = position of baseline from top of font -> ??? - fontBuf->FB_descent = maximum descent from baseline -> ??? - fontBuf->FB_extLeading = recommended external leading -> ??? - - fontBuf->FB_firstChar = FaceProperties -> OS2 -> usFirstCharIndex (TT_UShort) - (SBCS: Müssen wir die Anzahl der Zeichen im Font begrenzen?) - fontBuf->FB_lastChar = FaceProperties -> OS2 -> usLastCharIndex (TT_UShort) - (SBCS: Müssen wir die Anzahl der Zeichen im Font begrenzen?) - fontBuf->FB_defaultChar = default character -> ??? - Hier können wir ein festes Zeichen vorgeben. - - fontBuf->FB_underPos = FacePorperties -> postscript -> underlinePosition (TT_FWord) - fontBuf->FB_underThickness = FaceProperties -> postscript -> underlineThickness (TT_FWord) - fontBuf->FB_strikePos = FaceProperties -> OS2 -> yStrikeoutPosition (TT_Word) - fontBuf->FB_aboveBox = maximum above box -> ??? - fontBuf->FB_belowBox = maximum below box -> ??? - fontBuf->FB_minLSB = FaceProperties -> horizontal -> min_Left_Side_Bearing (TT_FWord) - fontBuf->FB_minTSB = FaceProperties -> vertical -> min_Top_Side_Bearing (TT_FWord) - fontBuf->FB_flags = FBF_IS_OUTLINE | (je nach Bedarf FBF_IS_REGION) Weitere? - */ + /* FB_maxWidth := scale( TT_Face_Properties->header->yMax - yMin ) */ - error = TT_Err_Ok; + /* FB_maxRSB ??? gibt es in TT_Vertical_Header nicht */ + + /* FB_height := scale( TT_Face_Properties->header->yMax ) */ + + /* FB_pixHeight := round( pointsize ) */ + /* + scale( TT_Face_Properties->vertical->min_Top_Side_Bearing ) */ + + /* FB_heightAdjust := pointsize - FB_height */ + + /* FB_baseAdjust ??? gibt es in den TrueType Strukturen nicht */ + + /* FB_baselinePos := scale( TT_Face_Properties->OS2->sTypoAscender ) */ + /* + scale( TT_Face_Properties->OS2->usWinDescend ) */ + + /* FB_minTSB := scale( TT_Face_Properties->vertical->min_Top_Side_Bearing ) */ + + /* FB_maxBSB ??? gibt es in den TrueType Strukturen nicht */ + + /* FB_underPos := scale( TT_Face_Properties->postscript->underlinePosition ) */ + /* FB_underThick := scale( TT_Face_Properties->postscript->underlineThickness ) */ + + /* FB_strikePos := scale( TT_Face_Properties->OS2->yStrikeoutPosition ) */ + + /* FB_mean := scale( TT_Face_Properties->OS2->sCapHeight ) */ + + /* FB_descent := scale( TT_Face_Properties->OS2->usWinDescent ) */ + + /* FB_accent := FB_height - FB_baseline - FB_descent */ + + /* FB_aboveBox ??? gibt es in den TrueType Strukturen nicht */ + + /* FB_belowBox ??? gibt es in den TrueType Strukturen nicht */ + + /* Nimbus and TrueType has no external leading */ + fontBuf->FB_extLeading.WBF_int = 0; + fontBuf->FB_extLeading.WBF_frac = 0; + + TT_Done_Instance( instance ); + error = TT_Err_Ok; Fin: TT_Close_Face( face ); Fail: @@ -725,7 +731,7 @@ static TT_F26Dot6 scaleShort( TT_Short value, TT_F26Dot6 scale ) return TT_MulFix( INT_TO_F26DOT6( value ), scale ); } -static word roundWBFixedToNearestWord( WBFixed wbFixed ) +static word roundWBFixedToWord( WBFixed wbFixed ) { return wbFixed.WBF_frac >= 0x10 ? wbFixed.WBF_int + 1 : wbFixed.WBF_int; } @@ -777,15 +783,6 @@ static int strcmp( const char* s1, const char* s2 ) return *(const unsigned char*)s1 - *(const unsigned char*)s2; } - -//füllen der fontsAvailEntry Struktur: -// FAE_fontID (FontID) := wird berechnet aus Fontfamily -// Fontfamily := NameTable ID 1 (Font Family) -// Wie ist der Bildungsalgorithmus? -// FAE_fileName (char/wchar) := Dateiname des Fonts (Prüfung auf max. 36 Zeichen; sbcs/dbcs beachten) -// FAE_infoHandle (ChunkHandle) := Handle auf u.g. fontInfo - - //füllen der fontInfo Struktur // FI_fileHandle (word) := FileOpen( fileName ... ) // FI_RESIDENT label(word) := ??? @@ -842,41 +839,6 @@ static int strcmp( const char* s1, const char* s2 ) // ODE_first (OutlineEntry) := 0? // ODE_second (OutlineEntry) := 0? -//füllen der FontBuf Struktur -// FB_dataSize (word) := berechnet -// FB_maker (FontMaker) := FontMaker.FM_TRUETYPE -// FB_avgwidth (WBFixed) := FaceProperties -> OS2 -> xAvgCharWidth -// FB_maxwidth (WBFixed) := muss berechnet werden; wird im BS Teiber nicht gefüllt -// FB_heightAdjust (WBFixed) := BS-Treiber: pointsize -// FB_height (WBFixed) := ; height of characters -// FB_accent (WBFixed) ; height of accent portion. -// FB_mean (WBFixed) ; top of lower case character boxes. -// FB_baseAdjust (WBFixed) ; offset to top of ascent -// FB_baselinePos (WBFixed) ; position of baseline from top of font -// FB_descent (WBFixed) ; maximum descent (from baseline) -// FB_extLeading (WBFixed) ; recommended external leading -// FB_kernCount (word) := TT_Get_Kerning_Directory() -// directory->nTables -// FB_kernPairPtr nptr.KernPair := Ptr zur KernpairTabelle -// FB_kernValuePtr nptr.BBFixed := Ptr zur KernvalueTabelle -// FB_firstChar (byte/Chars) ; first char in section -// FB_lastChar (byte/Chars) ; last char in section -// FB_defaultChar (byte/Chars) ; default character -// FB_underPos (WBFixed) ; underline position (from baseline) -// FB_underThickness (WBFixed) ; underline thickness -// FB_strikePos (WBFixed) ; position of the strike-thru -// FB_aboveBox (WBFixed) ; maximum above font box -// FB_belowBox (WBFixed) ; maximum below font box -// FB_minLSB (sword) ; minimum left side bearing -// FB_minTSB (sword) ; minimum top side bound -// FB_maxBSB* sword ; maximum bottom side bound -// FB_maxRSB* sword ; maximum right side bound -// FB_pixHeight word ; height of font (invalid for rotation) -// FB_flags FontBufFlags ; special flags -// FB_heapCount word ; usage counter for this font -// FB_charTable CharTableEntry <> -// *nicht DBCS - //füllen eines CharTableEntries // CTE_dataOffset nptr.CharData ;Offset to data // CTE_width WBFixed ;character width diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index d84986c69..d4832e3e9 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -264,7 +264,7 @@ static TT_F26Dot6 wBFixedToF26Dot6( WBFixed wbFixed ); static TT_F26Dot6 scaleShort( TT_Short value, TT_F26Dot6 scale ); -static word roundWBFixedToNearestWord( WBFixed wbFixed ); +static word roundWBFixedToWord( WBFixed wbFixed ); #endif /* _TTADAPTER_H_ */ From 6db61f7c4d863d8b8f4c51011bd4c92f371831fe Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 30 Nov 2022 19:40:21 +0100 Subject: [PATCH 093/246] add macros for scaling and converting --- Driver/Font/TrueType/Adapter/ttadapter.c | 24 +-------------- Driver/Font/TrueType/Adapter/ttadapter.h | 38 +++++++++++++++++++----- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 2d718c6b9..753a869e3 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -372,7 +372,7 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, if ( error ) goto Fail; - error = TT_Set_Instance_CharSize( instance, wBFixedToF26Dot6( pointSize ) ); + error = TT_Set_Instance_CharSize( instance, WBFIXED_TO_FIXED26DOT6( pointSize ) ); if ( error ) goto Fail; @@ -715,28 +715,6 @@ static AdjustedWeight mapFontWeight( TT_Short weightClass ) } } -static void f26dot6ToWBFixed( TT_F26Dot6 f26Dot6, WBFixed* wbFixed ) -{ - wbFixed->WBF_frac = f26Dot6 << 2; - wbFixed->WBF_int = f26Dot6 >> 6; -} - -static TT_F26Dot6 wBFixedToF26Dot6( WBFixed wbFixed ) -{ - return ( ( (long)wbFixed.WBF_int ) * 1024 ) | wbFixed.WBF_frac >> 2; -} - -static TT_F26Dot6 scaleShort( TT_Short value, TT_F26Dot6 scale ) -{ - return TT_MulFix( INT_TO_F26DOT6( value ), scale ); -} - -static word roundWBFixedToWord( WBFixed wbFixed ) -{ - return wbFixed.WBF_frac >= 0x10 ? wbFixed.WBF_int + 1 : wbFixed.WBF_int; -} - - static TextStyle mapTextStyle( const char* subfamily ) { if ( strcmp( subfamily, "Regular" ) == 0 ) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index d4832e3e9..44b43d445 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -235,6 +235,36 @@ typedef struct * macros ***********************************************************************/ +/* + * convert value (word) to WWFixedAsDWord + */ +#define WORD_TO_WWFIXEDASDWORD( value ) \ + ( (WWFixedAsDWord)value << 16 ) + +/* + * convert value (TT_F26DOT6) to WWFixedAsDWord + */ +#define FIXED26DOT6_TO_WWFIXEDASDWORD( value ) \ + ( (WWFixedAsDWord)value << 10 ) + +/* + * copy from (WWFixedAsDWord) into to (WBFixed) + */ +#define FILL_WBFIXED( to, from ) \ + ( to.WBF_int = (sword)(from >> 16); \ + to.WBF_frac = (byte)(from >> 8); ) + +/* + * scale value (word) by factor (WWFixedAsDWord) + */ +#define SCALE( value, factor ) \ + ( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( value ), factor ) ) + +/* + * convert value (WBFixed) to TT_F26DOT6 + */ +#define WBFIXED_TO_FIXED26DOT6( value ) \ + ( ( ( (long)value.WBF_int ) * 1024 ) | value.WBF_frac >> 2 ) /*********************************************************************** * helperfunctions @@ -258,13 +288,5 @@ static int strlen( const char* str ); static void strcpy( char* dest, const char* source ); -static void f26dot6ToWBFixed( TT_F26Dot6 f26Dot6, WBFixed* wbFixed ); - -static TT_F26Dot6 wBFixedToF26Dot6( WBFixed wbFixed ); - -static TT_F26Dot6 scaleShort( TT_Short value, TT_F26Dot6 scale ); - -static word roundWBFixedToWord( WBFixed wbFixed ); - #endif /* _TTADAPTER_H_ */ From 88f26ae4bcac62a4b536f2aeec065c7a3b9e1b2c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 30 Nov 2022 20:53:17 +0100 Subject: [PATCH 094/246] fill FontBuf.FB_minLSB --- Driver/Font/TrueType/Adapter/ttadapter.c | 7 ++++++- Driver/Font/TrueType/Adapter/ttadapter.h | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 753a869e3..6f113eb74 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -357,6 +357,8 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, TT_Instance instance; TT_Face_Properties faceProperties; TT_Instance_Metrics instanceMetrics; + WWFixedAsDWord scaleFactor; + WWFixedAsDWord ttfElement; ECCheckBounds( fileName ); ECCheckBounds( fontBuf ); @@ -384,6 +386,8 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, if ( error ) goto Fail; + scaleFactor = instanceMetrics.x_scale; + /* Fill elements in FontBuf structure. */ fontBuf->FB_maker = FM_TRUETYPE; @@ -394,7 +398,8 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, //TODO: mov es:FB_flags, mask FBF_IS_OUTLINE - /* FB_minLSB := scale( TT_Face_Properties->horizontal->min_Left_Side_Bearing )*/ + ttfElement = SCALE_WORD( faceProperties.horizontal->min_Left_Side_Bearing, scaleFactor ); + fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); /* FB_avgWidth := scale( TT_Face_Properties->OS2->aAvgCharWidth ) */ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 44b43d445..bb30712a2 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -257,8 +257,16 @@ typedef struct /* * scale value (word) by factor (WWFixedAsDWord) */ -#define SCALE( value, factor ) \ - ( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( value ), factor ) ) +#define SCALE_WORD( value, factor ) \ + ( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( value ), factor ) ) + +/* + * round value (WWFixedAsDWord) to nearest word + */ +#define ROUND_WWFIXEDASDWORD( value ) \ + ( value & 0x8000 ? \ + ( value & 0x0080 ? (((word)value >> 16) - 1 ) : ((word)value >> 16 )) : \ + ( value & 0x0080 ? (((word)value >> 16) + 1 ) : ((word)value >> 16 )) ) /* * convert value (WBFixed) to TT_F26DOT6 From 0bc69167514ae0f89a0e3be7ae7ea08cdafa61f7 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 1 Dec 2022 20:40:34 +0100 Subject: [PATCH 095/246] Further fields of FontBuf are filled. --- Driver/Font/TrueType/Adapter/ttadapter.c | 20 ++++++++++++++++---- Driver/Font/TrueType/Adapter/ttadapter.h | 23 ++++++++++++++--------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 6f113eb74..dfcb10d04 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -398,16 +398,28 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, //TODO: mov es:FB_flags, mask FBF_IS_OUTLINE - ttfElement = SCALE_WORD( faceProperties.horizontal->min_Left_Side_Bearing, scaleFactor ); + ttfElement = SCALE_WORD( faceProperties.horizontal->min_Left_Side_Bearing, + scaleFactor ); fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); - /* FB_avgWidth := scale( TT_Face_Properties->OS2->aAvgCharWidth ) */ + ttfElement = SCALE_WORD( faceProperties.os2->xAvgCharWidth, scaleFactor ); + fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - /* FB_maxWidth := scale( TT_Face_Properties->header->yMax - yMin ) */ + ttfElement = SCALE_WORD( faceProperties.header->xMax - + faceProperties.header->xMin, + scaleFactor ); + fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); /* FB_maxRSB ??? gibt es in TT_Vertical_Header nicht */ - /* FB_height := scale( TT_Face_Properties->header->yMax ) */ + ttfElement = SCALE_WORD( faceProperties.header->yMax - + faceProperties.header->yMin, + scaleFactor ); + fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + /* FB_pixHeight := round( pointsize ) */ /* + scale( TT_Face_Properties->vertical->min_Top_Side_Bearing ) */ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index bb30712a2..49f3cba16 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -247,13 +247,6 @@ typedef struct #define FIXED26DOT6_TO_WWFIXEDASDWORD( value ) \ ( (WWFixedAsDWord)value << 10 ) -/* - * copy from (WWFixedAsDWord) into to (WBFixed) - */ -#define FILL_WBFIXED( to, from ) \ - ( to.WBF_int = (sword)(from >> 16); \ - to.WBF_frac = (byte)(from >> 8); ) - /* * scale value (word) by factor (WWFixedAsDWord) */ @@ -265,8 +258,20 @@ typedef struct */ #define ROUND_WWFIXEDASDWORD( value ) \ ( value & 0x8000 ? \ - ( value & 0x0080 ? (((word)value >> 16) - 1 ) : ((word)value >> 16 )) : \ - ( value & 0x0080 ? (((word)value >> 16) + 1 ) : ((word)value >> 16 )) ) + ( value & 0x0080 ? ( ( (word)value >> 16 ) - 1 ) : ( (word)value >> 16 )) : \ + ( value & 0x0080 ? ( ( (word)value >> 16 ) + 1 ) : ( (word)value >> 16 )) ) + +/* + * get integral part of value (WWFixedAsDWord) + */ +#define INTEGER_OF_WWFIXEDASDWORD( value ) \ + ( (word) ( (WWFixedAsDWord)value >> 16 ) ) + +/* + * get fractional part (reduced to 8 bit) of value (WWFixedAsDWord) + */ +#define FRACTION_OF_WWFIXEDASDWORD( value ) \ + ( (byte) ( (WWFixedAsDWord)value >> 8 ) ) /* * convert value (WBFixed) to TT_F26DOT6 From dea1cea524ac1b15da184483a82949aee437f9b0 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 3 Dec 2022 19:18:39 +0100 Subject: [PATCH 096/246] add support for os/2 table version 3 --- Driver/Font/TrueType/Adapter/ttadapter.c | 3 +++ Driver/Font/TrueType/FreeType/freetype.h | 8 ++++++++ Driver/Font/TrueType/FreeType/ttload.c | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index dfcb10d04..8dabad84b 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -442,6 +442,9 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, /* FB_strikePos := scale( TT_Face_Properties->OS2->yStrikeoutPosition ) */ /* FB_mean := scale( TT_Face_Properties->OS2->sCapHeight ) */ + ttfElement = SCALE_WORD( faceProperties.os2->sCapHeight, scaleFactor ); + fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); /* FB_descent := scale( TT_Face_Properties->OS2->usWinDescent ) */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 4b0abfcd2..4bda3b3e2 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -517,6 +517,14 @@ TT_ULong ulCodePageRange1; /* Bits 0-31 */ TT_ULong ulCodePageRange2; /* Bits 32-63 */ + + /* only version 3 tables: */ + + TT_Short sxHeight; + TT_Short sCapHeight; + TT_UShort usDefaultChar; + TT_UShort usBreakChar; + }; typedef struct TT_OS2_ TT_OS2; diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index c5eb0e38f..0f85849fd 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -1064,6 +1064,28 @@ os2->ulCodePageRange2 = 0; } + if ( os2->version >= 0x0003 ) + { + /* only version 3 tables */ + + if ( ACCESS_Frame( 8L ) ) + return error; + + os2->sxHeight = GET_Short(); + os2->sCapHeight = GET_Short(); + os2->usDefaultChar = GET_UShort(); + os2->usBreakChar = GET_UShort(); + + FORGET_Frame(); + } + else + { + os2->sxHeight = 0; + os2->sCapHeight = 0; + os2->usDefaultChar = 0; + os2->usBreakChar = 0; + } + return TT_Err_Ok; } From 8a1e139c2a569640b6c2548d331cb001f6b20cb9 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 10 Dec 2022 22:08:11 +0100 Subject: [PATCH 097/246] Fill_FontBuf() implemented --- Driver/Font/TrueType/Adapter/ttadapter.c | 113 +++++++----- Driver/Font/TrueType/Adapter/ttadapter.h | 50 +++++- Driver/Font/TrueType/Adapter/ttcharmapper.c | 166 ++++++++++++++++++ Driver/Font/TrueType/Adapter/ttcharmapper.h | 36 ++++ Driver/Font/TrueType/FreeType/freetype.h | 8 - Driver/Font/TrueType/FreeType/ttload.c | 22 --- Installed/Driver/Font/TrueType/Makefile | 19 +- .../Driver/Font/TrueType/dependencies.mk | 12 +- 8 files changed, 336 insertions(+), 90 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttcharmapper.c create mode 100644 Driver/Font/TrueType/Adapter/ttcharmapper.h diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 8dabad84b..4e7d08576 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -352,10 +352,10 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, FontBuf* fontBuf ) { FileHandle fileHandle; + FontHeader fontHeader; TT_Error error; TT_Face face; TT_Instance instance; - TT_Face_Properties faceProperties; TT_Instance_Metrics instanceMetrics; WWFixedAsDWord scaleFactor; WWFixedAsDWord ttfElement; @@ -382,7 +382,7 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, if ( error ) goto Fail; - error = TT_Get_Face_Properties( face, &faceProperties ); + error = fillFontHeader( face, &fontHeader ); if ( error ) goto Fail; @@ -395,69 +395,91 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, fontBuf->FB_kernValuePtr = 0; fontBuf->FB_kernCount = 0; fontBuf->FB_heapCount = 0; - - //TODO: mov es:FB_flags, mask FBF_IS_OUTLINE + fontBuf->FB_flags = FBF_IS_OUTLINE; - ttfElement = SCALE_WORD( faceProperties.horizontal->min_Left_Side_Bearing, - scaleFactor ); + ttfElement = SCALE_WORD( fontHeader.FH_minLSB, scaleFactor ); fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( faceProperties.os2->xAvgCharWidth, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader.FH_avgwidth, scaleFactor ); fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( faceProperties.header->xMax - - faceProperties.header->xMin, - scaleFactor ); + ttfElement = SCALE_WORD( fontHeader.FH_maxwidth, scaleFactor ); fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - /* FB_maxRSB ??? gibt es in TT_Vertical_Header nicht */ +#ifndef DBCS_PCGEOS + ttfElement = SCALE_WORD( fontHeader.FH_maxRSB, scaleFactor ); + fontBuf->FB_maxRSB = ROUND_WWFIXEDASDWORD( ttfElement ); +#endif /* DBCS_PCGEOS */ + + scaleFactor = instanceMetrics.y_scale; - ttfElement = SCALE_WORD( faceProperties.header->yMax - - faceProperties.header->yMin, - scaleFactor ); + ttfElement = SCALE_WORD( fontHeader.FH_height, scaleFactor ); fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - /* FB_pixHeight := round( pointsize ) */ - /* + scale( TT_Face_Properties->vertical->min_Top_Side_Bearing ) */ - - /* FB_heightAdjust := pointsize - FB_height */ - - /* FB_baseAdjust ??? gibt es in den TrueType Strukturen nicht */ - - /* FB_baselinePos := scale( TT_Face_Properties->OS2->sTypoAscender ) */ - /* + scale( TT_Face_Properties->OS2->usWinDescend ) */ - - /* FB_minTSB := scale( TT_Face_Properties->vertical->min_Top_Side_Bearing ) */ - - /* FB_maxBSB ??? gibt es in den TrueType Strukturen nicht */ - - /* FB_underPos := scale( TT_Face_Properties->postscript->underlinePosition ) */ - - /* FB_underThick := scale( TT_Face_Properties->postscript->underlineThickness ) */ - - /* FB_strikePos := scale( TT_Face_Properties->OS2->yStrikeoutPosition ) */ - - /* FB_mean := scale( TT_Face_Properties->OS2->sCapHeight ) */ - ttfElement = SCALE_WORD( faceProperties.os2->sCapHeight, scaleFactor ); + /* FB_heightAdjust = pointSize - FH_height */ + ttfElement = WBFIXED_TO_WWFIXEDASDWORD( pointSize ) - + WORD_TO_WWFIXEDASDWORD( fontHeader.FH_height ); + fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_pixHeight = ROUND_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_baseAdjust, scaleFactor ); + fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ROUND_WWFIXEDASDWORD( ttfElement ) ); + fontBuf->FB_baseAdjust.WBF_frac = 0; + + ttfElement = SCALE_WORD( fontHeader.FH_minTSB, scaleFactor ); + fontBuf->FB_aboveBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_aboveBox.WBF_frac = 0; + fontBuf->FB_minTSB = CEIL_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_pixHeight += CEIL_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_maxBSB, scaleFactor ); + fontBuf->FB_belowBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_belowBox.WBF_frac = 0; +#ifdef SBCS_PCGEOS + fontBuf->FB_maxBSB = CEIL_WWFIXEDASDWORD( ttfElement ); +#endif /* SBCS_PCGEOS */ + + ttfElement = SCALE_WORD( fontHeader.FH_underPos, scaleFactor ); + fontBuf->FB_underPos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_underPos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_underThick, scaleFactor ); + fontBuf->FB_underThickness.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_underThickness.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_strikePos, scaleFactor ); + fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_x_height, scaleFactor ); fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - /* FB_descent := scale( TT_Face_Properties->OS2->usWinDescent ) */ + ttfElement = SCALE_WORD( fontHeader.FH_descent, scaleFactor ); + fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - /* FB_accent := FB_height - FB_baseline - FB_descent */ + ttfElement = SCALE_WORD( fontHeader.FH_accent, scaleFactor ); + fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - /* FB_aboveBox ??? gibt es in den TrueType Strukturen nicht */ + /* baslinepos = accent + ascent */ + ttfElement = SCALE_WORD( fontHeader.FH_ascent + fontHeader.FH_accent, scaleFactor ); + fontBuf->FB_baselinePos.WBF_int = ROUND_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_baselinePos.WBF_frac = 0; - /* FB_belowBox ??? gibt es in den TrueType Strukturen nicht */ - - /* Nimbus and TrueType has no external leading */ + /* Nimbus fonts and TrueType fonts has no external leading */ fontBuf->FB_extLeading.WBF_int = 0; fontBuf->FB_extLeading.WBF_frac = 0; + fontBuf->FB_firstChar = fontHeader.FH_firstChar; + fontBuf->FB_lastChar = fontHeader.FH_lastChar; + fontBuf->FB_defaultChar = fontHeader.FH_defaultChar; + TT_Done_Instance( instance ); error = TT_Err_Ok; Fin: @@ -752,6 +774,11 @@ static TextStyle mapTextStyle( const char* subfamily ) return TS_BOLD | TS_ITALIC; } +static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ) +{ + return TT_Err_Ok; +} + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ /* cycle. Therefore, the required functions are reimplemented here.*/ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 49f3cba16..c1fd69858 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -231,6 +231,37 @@ typedef struct } OutlineDataEntry; +/* + * structure to hold information necessary to fill FontBuf structure + */ +typedef struct +{ + word FH_h_height; //top of 'H' + word FH_x_height; //top of 'x' + word FH_ascender; //top of 'd' + word FH_descender; //bottom of 'p' + word FH_avgwidth; //average character width + word FH_maxwidth; //widest character width + word FH_height; //height of font box + word FH_accent; //height of accents + word FH_ascent; //height of caps + word FH_descent; //descent (from baseline) + word FH_baseAdjust; //adjustment for baseline + word FH_firstChar; //first char defined + word FH_lastChar; //last char defined + word FH_defaultChar; //default character + word FH_underPos; //position of underline + word FH_underThick; //thickness of underline + word FH_strikePos; //position of strikethrough + word FH_numChars; //number of characters + sword FH_minLSB; //minimum left side bearing + sword FH_minTSB; //minimum top side bound + sword FH_maxBSB; //maximum bottom side bound + sword FH_maxRSB; //maximum right side bound + sword FH_continuitySize; //continuity cutoff +} FontHeader; + + /*********************************************************************** * macros ***********************************************************************/ @@ -258,14 +289,22 @@ typedef struct */ #define ROUND_WWFIXEDASDWORD( value ) \ ( value & 0x8000 ? \ - ( value & 0x0080 ? ( ( (word)value >> 16 ) - 1 ) : ( (word)value >> 16 )) : \ - ( value & 0x0080 ? ( ( (word)value >> 16 ) + 1 ) : ( (word)value >> 16 )) ) + ( value & 0x0080 ? ( ( (sword)(value >> 16) ) - 1 ) : ( (sword)(value >> 16) ) ) : \ + ( value & 0x0080 ? ( ( (sword)(value >> 16) ) + 1 ) : ( (sword)(value >> 16) ) ) ) + +/* + * round value (WWFixedAsDWord) to negativ infinity (word) + */ +#define CEIL_WWFIXEDASDWORD( value ) \ + ( value & 0x8000 ? \ + ( value & 0x00ff ? ( ( (sword)value >> 16 - 1 ) ) : ( (sword)value >> 16 ) ) : \ + ( (sword)value >> 16 ) ) /* * get integral part of value (WWFixedAsDWord) */ #define INTEGER_OF_WWFIXEDASDWORD( value ) \ - ( (word) ( (WWFixedAsDWord)value >> 16 ) ) + ( (sword) ( (WWFixedAsDWord)value >> 16 ) ) /* * get fractional part (reduced to 8 bit) of value (WWFixedAsDWord) @@ -279,6 +318,9 @@ typedef struct #define WBFIXED_TO_FIXED26DOT6( value ) \ ( ( ( (long)value.WBF_int ) * 1024 ) | value.WBF_frac >> 2 ) +#define WBFIXED_TO_WWFIXEDASDWORD( value ) \ + ( ( (long)(value.WBF_int << 16 ) ) | value.WBF_frac << 8 ) + /*********************************************************************** * helperfunctions ***********************************************************************/ @@ -295,6 +337,8 @@ static FontWeight mapFontWeight( TT_Short weightClass ); static TextStyle mapTextStyle( const char* subfamily ); +static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ); + static int strlen( const char* str ); diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c new file mode 100644 index 000000000..fdf3ce1a0 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -0,0 +1,166 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttcharmapper.c + * + * AUTHOR: Jirka Kunze: December 5 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/5/22 JK Initial version + * + * DESCRIPTION: + * Functions for mapping character from FreeGEOS charset zu Unicode + * charset. + ***********************************************************************/ + +#include +#include +#include + +#define NUM_CHARMAPENTRIES ( sizeof(geosCharMap) / sizeof(CharMapEntry) ) +#define MIN_GEOS_CHAR ( C_SPACE ) +#define MAX_GEOS_CHAR ( NUM_CHARMAPENTRIES + MIN_GEOS_CHAR ) +#define GEOS_CHAR_INDEX( i ) ( i - MIN_GEOS_CHAR ) + + +CharMapEntry geosCharMap[] = +{ +/* unicode weight flags */ + C_SPACE, 0, 0, + C_EXCLAMATION_MARK, 0, 0, + C_QUOTATION_MARK, 0, 0, + C_NUMBER_SIGN, 0, 0, + C_DOLLAR_SIGN, 0, 0, + C_PERCENT_SIGN, 0, 0, + C_AMPERSAND, 0, 0, + C_APOSTROPHE_QUOTE, 0, 0, + C_OPENING_PARENTHESIS, 0, 0, + C_CLOSING_PARENTHESIS, 0, 0, + C_ASTERISK, 0, 0, + C_PLUS_SIGN, 0, 0, + C_COMMA, 0, 0, + C_HYPHEN_MINUS, 0, 0, + C_PERIOD, 0, 0, + C_SLASH, 0, 0, + C_DIGIT_ZERO, 0, 0, + C_DIGIT_ONE, 0, 0, + C_DIGIT_TWO, 0, 0, + C_DIGIT_THREE, 0, 0, + C_DIGIT_FOUR, 0, 0, + C_DIGIT_FIVE, 0, 0, + C_DIGIT_SIX, 0, 0, + C_DIGIT_SEVEN, 0, 0, + C_DIGIT_EIGHT, 0, 0, + C_DIGIT_NINE, 0, 0, + C_COLON, 0, 0, + C_SEMICOLON, 0, 0, + C_LESS_THAN_SIGN, 0, 0, + C_EQUALS_SIGN, 0, 0, + C_GREATER_THAN_SIGN, 0, 0, + C_QUESTION_MARK, 0, 0, + C_COMMERCIAL_AT, 0, 0, + C_LATIN_CAPITAL_LETTER_A, 0, 0, + C_LATIN_CAPITAL_LETTER_B, 0, 0, + C_LATIN_CAPITAL_LETTER_C, 0, 0, + C_LATIN_CAPITAL_LETTER_D, 0, 0, + C_LATIN_CAPITAL_LETTER_E, 0, 0, + C_LATIN_CAPITAL_LETTER_F, 0, 0, + C_LATIN_CAPITAL_LETTER_G, 0, 0, + C_LATIN_CAPITAL_LETTER_H, 0, 0, + C_LATIN_CAPITAL_LETTER_I, 0, 0, + C_LATIN_CAPITAL_LETTER_J, 0, 0, + C_LATIN_CAPITAL_LETTER_K, 0, 0, + C_LATIN_CAPITAL_LETTER_L, 0, 0, + C_LATIN_CAPITAL_LETTER_M, 0, 0, + C_LATIN_CAPITAL_LETTER_N, 0, 0, + C_LATIN_CAPITAL_LETTER_O, 0, 0, + C_LATIN_CAPITAL_LETTER_P, 0, 0, + C_LATIN_CAPITAL_LETTER_Q, 0, 0, + C_LATIN_CAPITAL_LETTER_R, 0, 0, + C_LATIN_CAPITAL_LETTER_S, 0, 0, + C_LATIN_CAPITAL_LETTER_T, 0, 0, + C_LATIN_CAPITAL_LETTER_U, 0, 0, + C_LATIN_CAPITAL_LETTER_V, 0, 0, + C_LATIN_CAPITAL_LETTER_W, 0, 0, + C_LATIN_CAPITAL_LETTER_X, 0, 0, + C_LATIN_CAPITAL_LETTER_Y, 0, 0, + C_LATIN_CAPITAL_LETTER_Z, 0, 0, + C_OPENING_SQUARE_BRACKET, 0, 0, + C_BACKSLASH, 0, 0, + C_CLOSING_SQUARE_BRACKET, 0, 0, + C_SPACING_CIRCUMFLEX, 0, 0, + C_SPACING_UNDERSCORE, 0, 0, + C_SPACING_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_A, 0, 0, + C_LATIN_SMALL_LETTER_B, 0, 0, + C_LATIN_SMALL_LETTER_C, 0, 0, + C_LATIN_SMALL_LETTER_D, 0, 0, + C_LATIN_SMALL_LETTER_E, 0, 0, + C_LATIN_SMALL_LETTER_F, 0, 0, + C_LATIN_SMALL_LETTER_G, 0, 0, + C_LATIN_SMALL_LETTER_H, 0, 0, + C_LATIN_SMALL_LETTER_I, 0, 0, + C_LATIN_SMALL_LETTER_J, 0, 0, + C_LATIN_SMALL_LETTER_K, 0, 0, + C_LATIN_SMALL_LETTER_L, 0, 0, + C_LATIN_SMALL_LETTER_M, 0, 0, + C_LATIN_SMALL_LETTER_N, 0, 0, + C_LATIN_SMALL_LETTER_O, 0, 0, + C_LATIN_SMALL_LETTER_P, 0, 0, + C_LATIN_SMALL_LETTER_Q, 0, 0, + C_LATIN_SMALL_LETTER_R, 0, 0, + C_LATIN_SMALL_LETTER_S, 0, 0, + C_LATIN_SMALL_LETTER_T, 0, 0, + C_LATIN_SMALL_LETTER_U, 0, 0, + C_LATIN_SMALL_LETTER_V, 0, 0, + C_LATIN_SMALL_LETTER_W, 0, 0, + C_LATIN_SMALL_LETTER_X, 0, 0, + C_LATIN_SMALL_LETTER_Y, 0, 0, + C_LATIN_SMALL_LETTER_Z, 0, 0, + C_OPENING_CURLY_BRACKET, 0, 0, + C_VERTICAL_BAR, 0, 0, + C_CLOSING_CURLY_BRACKET, 0, 0, + C_TILDE, 0, 0, + C_DELETE, 0, 0, + C_LATIN_CAPITAL_LETTER_A_DIAERESIS, 0, 0, + C_LATIN_CAPITAL_LETTER_A_RING, 0, 0, + C_LATIN_CAPITAL_LETTER_C_CEDILLA, 0, 0, + C_LATIN_CAPITAL_LETTER_E_ACUTE, 0, 0 +}; + + +sword GeosCharToUnicode( word geosChar ) +{ + if( geosChar < MIN_GEOS_CHAR || geosChar > MAX_GEOS_CHAR ) + return -1; + + return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].unicode; +} + + +word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) +{ + word charIndex; + word charCount = 0; + + + *firstChar = 9999; + *lastChar = 0; + + for( charIndex = 0; charIndex < NUM_CHARMAPENTRIES; ++charIndex ) + { + if( TT_Char_Index( map, geosCharMap[ charIndex ].unicode ) ) + { + ++charCount; + if ( *firstChar > ( charIndex + C_SPACE ) ) *firstChar = charIndex + C_SPACE; + if ( *lastChar < ( charIndex + C_SPACE ) ) *lastChar = charIndex + C_SPACE; + } + } + + return charCount; +} diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h new file mode 100644 index 000000000..e12a45688 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -0,0 +1,36 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttcharmapper.h + * + * AUTHOR: Jirka Kunze: December 5 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/5/22 JK Initial version + * + * DESCRIPTION: + * Structures and definitions for mapping character from FreeGEOS + * charset zu Unicode charset. + ***********************************************************************/ +#ifndef _TTCHARMAPPER_H_ +#define _TTCHARMAPPER_H_ + +#include + +typedef ByteFlags CharMapFlags; +#define CMF_ 0x40 + +typedef struct +{ + word unicode; + byte weight; + CharMapFlags flags; +} CharMapEntry; + + +#endif /* _TTCHARMAPPER_H_ */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 4bda3b3e2..4b0abfcd2 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -517,14 +517,6 @@ TT_ULong ulCodePageRange1; /* Bits 0-31 */ TT_ULong ulCodePageRange2; /* Bits 32-63 */ - - /* only version 3 tables: */ - - TT_Short sxHeight; - TT_Short sCapHeight; - TT_UShort usDefaultChar; - TT_UShort usBreakChar; - }; typedef struct TT_OS2_ TT_OS2; diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 0f85849fd..63dfbc0d7 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -1063,28 +1063,6 @@ os2->ulCodePageRange1 = 0; os2->ulCodePageRange2 = 0; } - - if ( os2->version >= 0x0003 ) - { - /* only version 3 tables */ - - if ( ACCESS_Frame( 8L ) ) - return error; - - os2->sxHeight = GET_Short(); - os2->sCapHeight = GET_Short(); - os2->usDefaultChar = GET_UShort(); - os2->usBreakChar = GET_UShort(); - - FORGET_Frame(); - } - else - { - os2->sxHeight = 0; - os2->sCapHeight = 0; - os2->usDefaultChar = 0; - os2->usBreakChar = 0; - } return TT_Err_Ok; } diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index e841865f7..7b2a9ff8a 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -9,20 +9,19 @@ MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ truetypeInit.asm truetypeEC.asm truetypeChars.asm\ truetypePath.asm truetypeMacros.def truetypeVariable.def\ truetypeConstant.def -ADAPTER = ttadapter.c ttadapter.h +ADAPTER = ttcharmapper.c ttadapter.c ttcharmapper.h ttadapter.h FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h header.h\ - ttinterp.h ttload.h tttables.h ttobjs.h fterrid.h\ - ttraster.h ttengine.h tttypes.h ttmutex.h ft_conf.h\ - ttextend.h ftnameid.h ttcalc.h ftxkern.h ttmemory.h\ - tttags.h + ttconfig.h freetype.h ttgload.h ttfile.h ttinterp.h\ + ttload.h tttables.h ttobjs.h fterrid.h ttraster.h\ + ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ + ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h UI_TO_RDFS = -OBJS = ttadapter.obj ttcache.obj ttraster.obj ttmutex.obj\ - ttgload.obj ttextend.obj ttcalc.obj ttapi.obj ftxkern.obj\ - ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ - ttmemory.obj +OBJS = ttcharmapper.obj ttadapter.obj ttcache.obj ttraster.obj\ + ttmutex.obj ttgload.obj ttextend.obj ttcalc.obj ttapi.obj\ + ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ + ttobjs.obj ttmemory.obj COMMON = MODULES = Main CMODULES = Adapter FreeType diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index 55fed9502..c73b83ba8 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -13,17 +13,21 @@ Main.eobj: Main/mainManager.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm +ttcharmapper.obj \ +ttcharmapper.eobj: Adapter/ttcharmapper.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h geos.h unicode.h ttadapter.obj \ -ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h Ansi/stdlib.h \ +ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/freetype.h \ Adapter/../FreeType/fterrid.h \ Adapter/../FreeType/ftnameid.h \ Adapter/../FreeType/ttengine.h \ Adapter/../FreeType/tttypes.h \ Adapter/../FreeType/ttconfig.h \ - Adapter/../FreeType/ft_conf.h file.h resource.h \ - graphics.h fontID.h font.h color.h heap.h lmem.h \ - Adapter/../FreeType/ttmutex.h + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ From 80b78da5b62eeac60e272a3ab572dcb5a2bcb339 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 11 Dec 2022 12:47:00 +0100 Subject: [PATCH 098/246] Mapping table completed. --- Driver/Font/TrueType/Adapter/ttadapter.c | 12 + Driver/Font/TrueType/Adapter/ttcharmapper.c | 238 +++++++++++++++----- Driver/Font/TrueType/Adapter/ttcharmapper.h | 8 +- 3 files changed, 200 insertions(+), 58 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 4e7d08576..0beb76b0f 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -776,6 +776,18 @@ static TextStyle mapTextStyle( const char* subfamily ) static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ) { + //Chartable holen + + //numChars, fistChar, lastChar füllen + + //iteriere über die Zeichen des Zeichensatzes + //Zeichen vorhanden? + //Whidth + //xMin + //xMax + //yMin + //yMax + return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index fdf3ce1a0..748b8b080 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -31,7 +31,7 @@ CharMapEntry geosCharMap[] = { /* unicode weight flags */ - C_SPACE, 0, 0, + C_SPACE, 166, 0, C_EXCLAMATION_MARK, 0, 0, C_QUOTATION_MARK, 0, 0, C_NUMBER_SIGN, 0, 0, @@ -64,73 +64,197 @@ CharMapEntry geosCharMap[] = C_GREATER_THAN_SIGN, 0, 0, C_QUESTION_MARK, 0, 0, C_COMMERCIAL_AT, 0, 0, - C_LATIN_CAPITAL_LETTER_A, 0, 0, - C_LATIN_CAPITAL_LETTER_B, 0, 0, - C_LATIN_CAPITAL_LETTER_C, 0, 0, - C_LATIN_CAPITAL_LETTER_D, 0, 0, - C_LATIN_CAPITAL_LETTER_E, 0, 0, - C_LATIN_CAPITAL_LETTER_F, 0, 0, - C_LATIN_CAPITAL_LETTER_G, 0, 0, - C_LATIN_CAPITAL_LETTER_H, 0, 0, - C_LATIN_CAPITAL_LETTER_I, 0, 0, - C_LATIN_CAPITAL_LETTER_J, 0, 0, - C_LATIN_CAPITAL_LETTER_K, 0, 0, - C_LATIN_CAPITAL_LETTER_L, 0, 0, - C_LATIN_CAPITAL_LETTER_M, 0, 0, - C_LATIN_CAPITAL_LETTER_N, 0, 0, - C_LATIN_CAPITAL_LETTER_O, 0, 0, - C_LATIN_CAPITAL_LETTER_P, 0, 0, - C_LATIN_CAPITAL_LETTER_Q, 0, 0, - C_LATIN_CAPITAL_LETTER_R, 0, 0, - C_LATIN_CAPITAL_LETTER_S, 0, 0, - C_LATIN_CAPITAL_LETTER_T, 0, 0, - C_LATIN_CAPITAL_LETTER_U, 0, 0, - C_LATIN_CAPITAL_LETTER_V, 0, 0, - C_LATIN_CAPITAL_LETTER_W, 0, 0, - C_LATIN_CAPITAL_LETTER_X, 0, 0, - C_LATIN_CAPITAL_LETTER_Y, 0, 0, - C_LATIN_CAPITAL_LETTER_Z, 0, 0, + C_LATIN_CAPITAL_LETTER_A, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_B, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_C, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_D, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_E, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_F, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_G, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_H, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_I, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_J, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_K, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_L, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_M, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_N, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_O, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_P, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_Q, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_R, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_S, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_T, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_U, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_V, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_W, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_X, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_Y, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_Z, 0, CMF_CAP, C_OPENING_SQUARE_BRACKET, 0, 0, C_BACKSLASH, 0, 0, C_CLOSING_SQUARE_BRACKET, 0, 0, C_SPACING_CIRCUMFLEX, 0, 0, C_SPACING_UNDERSCORE, 0, 0, C_SPACING_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_A, 0, 0, - C_LATIN_SMALL_LETTER_B, 0, 0, - C_LATIN_SMALL_LETTER_C, 0, 0, - C_LATIN_SMALL_LETTER_D, 0, 0, - C_LATIN_SMALL_LETTER_E, 0, 0, - C_LATIN_SMALL_LETTER_F, 0, 0, - C_LATIN_SMALL_LETTER_G, 0, 0, - C_LATIN_SMALL_LETTER_H, 0, 0, - C_LATIN_SMALL_LETTER_I, 0, 0, - C_LATIN_SMALL_LETTER_J, 0, 0, - C_LATIN_SMALL_LETTER_K, 0, 0, - C_LATIN_SMALL_LETTER_L, 0, 0, - C_LATIN_SMALL_LETTER_M, 0, 0, - C_LATIN_SMALL_LETTER_N, 0, 0, - C_LATIN_SMALL_LETTER_O, 0, 0, - C_LATIN_SMALL_LETTER_P, 0, 0, - C_LATIN_SMALL_LETTER_Q, 0, 0, - C_LATIN_SMALL_LETTER_R, 0, 0, - C_LATIN_SMALL_LETTER_S, 0, 0, - C_LATIN_SMALL_LETTER_T, 0, 0, - C_LATIN_SMALL_LETTER_U, 0, 0, - C_LATIN_SMALL_LETTER_V, 0, 0, - C_LATIN_SMALL_LETTER_W, 0, 0, - C_LATIN_SMALL_LETTER_X, 0, 0, - C_LATIN_SMALL_LETTER_Y, 0, 0, - C_LATIN_SMALL_LETTER_Z, 0, 0, + C_LATIN_SMALL_LETTER_A, 64, CMF_MEAN, + C_LATIN_SMALL_LETTER_B, 14, CMF_ASCENT, + C_LATIN_SMALL_LETTER_C, 27, CMF_MEAN, + C_LATIN_SMALL_LETTER_D, 35, CMF_ASCENT, + C_LATIN_SMALL_LETTER_E, 100, CMF_MEAN, + C_LATIN_SMALL_LETTER_F, 20, CMF_ASCENT, + C_LATIN_SMALL_LETTER_G, 14, CMF_DESCENT, + C_LATIN_SMALL_LETTER_H, 42, CMF_ASCENT, + C_LATIN_SMALL_LETTER_I, 63, CMF_ASCENT, + C_LATIN_SMALL_LETTER_J, 3, CMF_DESCENT, + C_LATIN_SMALL_LETTER_K, 6, CMF_ASCENT, + C_LATIN_SMALL_LETTER_L, 35, CMF_ASCENT, + C_LATIN_SMALL_LETTER_M, 20, CMF_MEAN, + C_LATIN_SMALL_LETTER_N, 56, CMF_MEAN, + C_LATIN_SMALL_LETTER_O, 56, CMF_MEAN, + C_LATIN_SMALL_LETTER_P, 17, CMF_DESCENT, + C_LATIN_SMALL_LETTER_Q, 4, CMF_DESCENT, + C_LATIN_SMALL_LETTER_R, 49, CMF_MEAN, + C_LATIN_SMALL_LETTER_S, 56, CMF_MEAN, + C_LATIN_SMALL_LETTER_T, 71, CMF_ASCENT, + C_LATIN_SMALL_LETTER_U, 31, CMF_MEAN, + C_LATIN_SMALL_LETTER_V, 10, CMF_MEAN, + C_LATIN_SMALL_LETTER_W, 18, CMF_MEAN, + C_LATIN_SMALL_LETTER_X, 3, CMF_MEAN, + C_LATIN_SMALL_LETTER_Y, 18, CMF_DESCENT, + C_LATIN_SMALL_LETTER_Z, 2, CMF_MEAN, C_OPENING_CURLY_BRACKET, 0, 0, C_VERTICAL_BAR, 0, 0, C_CLOSING_CURLY_BRACKET, 0, 0, C_TILDE, 0, 0, C_DELETE, 0, 0, - C_LATIN_CAPITAL_LETTER_A_DIAERESIS, 0, 0, - C_LATIN_CAPITAL_LETTER_A_RING, 0, 0, - C_LATIN_CAPITAL_LETTER_C_CEDILLA, 0, 0, - C_LATIN_CAPITAL_LETTER_E_ACUTE, 0, 0 + C_LATIN_CAPITAL_LETTER_A_DIAERESIS, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_RING, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_C_CEDILLA, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_ACUTE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_N_TILDE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_DIAERESIS, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_DIAERESIS, 0, CMF_ACCENT, + C_LATIN_SMALL_LETTER_A_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_A_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_A_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_A_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_A_TILDE, 0, 0, + C_LATIN_SMALL_LETTER_A_RING, 0, 0, + C_LATIN_SMALL_LETTER_C_CEDILLA, 0, 0, + C_LATIN_SMALL_LETTER_E_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_E_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_E_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_E_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_I_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_I_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_I_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_I_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_N_TILDE, 0, 0, + C_LATIN_SMALL_LETTER_O_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_O_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_O_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_O_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_O_TILDE, 0, 0, + C_LATIN_SMALL_LETTER_U_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_U_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_U_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_U_DIAERESIS, 0, 0, + C_DAGGER, 0, 0, + C_DEGREE_SIGN, 0, 0, + C_CENT_SIGN, 0, 0, + C_POUND_SIGN, 0, 0, + C_SECTION_SIGN, 0, 0, + C_BULLET_OPERATOR, 0, 0, + C_PARAGRAPH_SIGN, 0, 0, + C_LATIN_SMALL_LETTER_SHARP_S, 0, 0, + C_REGISTERED_TRADE_MARK_SIGN, 0, 0, + C_COPYRIGHT_SIGN, 0, 0, + C_TRADEMARK, 0, 0, + C_SPACING_ACUTE, 0, 0, + C_SPACING_DIAERESIS, 0, 0, + C_NOT_EQUAL_TO, 0, 0, + C_LATIN_CAPITAL_LETTER_A_E, 0, CMF_CAP, + C_LATIN_CAPITAL_LETTER_O_SLASH, 0, CMF_CAP, + C_INFINITY, 0, 0, + C_PLUS_OR_MINUS_SIGN, 0, 0, + C_LESS_THAN_OR_EQUAL_TO, 0, 0, + C_GREATER_THAN_OR_EQUAL_TO, 0, 0, + C_YEN_SIGN, 0, 0, + C_MICRO_SIGN, 0, 0, + C_PARTIAL_DIFFERENTIAL, 0, 0, + C_N_ARY_SUMMATION, 0, 0, + C_N_ARY_PRODUCT, 0, 0, + C_GREEK_SMALL_LETTER_PI, 0, 0, + C_INTEGRAL, 0, 0, + C_FEMININE_ORDINAL_INDICATOR, 0, 0, + C_MASCULINE_ORDINAL_INDICATOR, 0, 0, + C_GREEK_CAPITAL_LETTER_OMEGA, 0, 0, + C_LATIN_SMALL_LETTER_A_E, 0, 0, + C_LATIN_SMALL_LETTER_O_SLASH, 0, 0, + C_INVERTED_QUESTION_MARK, 0, 0, + C_INVERTED_EXCLAMATION_MARK, 0, 0, + C_NOT_SIGN, 0, 0, + C_SQUARE_ROOT, 0, 0, + C_LATIN_SMALL_LETTER_SCRIPT_F, 0, 0, + C_ALMOST_EQUAL_TO 0, 0, + C_GREEK_CAPITAL_LETTER_DELTA, 0, 0, + C_LEFT_POINTING_GUILLEMET, 0, 0, + C_RIGHT_POINTING_GUILLEMET, 0, 0, + C_MIDLINE_HORIZONTAL_ELLIPSIS, 0, 0, + C_NON_BREAKING_SPACE, 0, 0, + C_LATIN_CAPITAL_LETTER_A_GRAVE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_TILDE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_TILDE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_E, 0, CMF_ACCENT, + C_LATIN_SMALL_LETTER_O_E, 0, 0, + C_EM_DASH, 0, 0, + C_EN_DASH, 0, 0, + C_DOUBLE_TURNED_COMMA_QUOTATION_MARK, 0, 0, + C_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, + C_SINGLE_TURNED_COMMA_QUOTATION_MARK, 0, 0, + C_SINGLE_COMMA_QUOTATION_MARK, 0, 0, + C_DIVISION_SIGN, 0, 0, + C_BLACK_DIAMOND, 0, 0, + C_LATIN_SMALL_LETTER_Y_DIAERESIS, 0, 0, + C_LATIN_CAPITAL_LETTER_Y_DIAERESIS, 0, CMF_ACCENT, + C_FRACTION_SLASH, 0, 0, + C_EURO_CURRENCY_SIGN, 0, 0, + C_LEFT_POINTING_SINGLE_GUILLEMET, 0, 0, + C_RIGHT_POINTING_SINGLE_GUILLEMET, 0, 0, + C_LATIN_SMALL_LETTER_Y_ACUTE, 0, 0, + C_LATIN_CAPITAL_LETTER_Y_ACUTE, 0, 0, + C_DOUBLE_DAGGER, 0, 0, + C_MIDDLE_DOT, 0, 0, + C_LOW_SINGLE_COMMA_QUOTATION_MARK, 0, 0, + C_LOW_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, + C_PER_MILLE_SIGN, 0, 0, + C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_CIRCUMFLEX, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_ACUTE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_DIAERESIS, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_GRAVE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_ACUTE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_CIRCUMFLEX, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_DIAERESIS, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_GRAVE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_ACUTE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_CIRCUMFLEX, 0, CMF_ACCENT, + 0, 0, 0, //no character + C_LATIN_CAPITAL_LETTER_O_GRAVE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_ACUTE, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_CIRCUMFLEX, 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_GRAVE, 0, CMF_ACCENT, + C_LATIN_SMALL_LETTER_DOTLESS_I, 0, 0, + C_NON_SPACING_CIRCUMFLEX, 0, 0, + C_NON_SPACING_TILDE, 0, 0, + C_SPACING_MACRON, 0, 0, + C_SPACING_BREVE, 0, 0, + C_SPACING_DOT_ABOVE, 0, 0, + C_SPACING_RING_ABOVE, 0, 0, + C_SPACING_CEDILLA, 0, 0, + C_SPACING_DOUBLE_ACUTE, 0, 0, + C_SPACING_OGONEK, 0, 0, + C_MODIFIER_LETTER_HACEK, 0, 0 }; diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index e12a45688..039f28c2b 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -22,8 +22,14 @@ #include + typedef ByteFlags CharMapFlags; -#define CMF_ 0x40 +#define CMF_CAP 0x10 +#define CMF_ASCENT 0x08 +#define CMF_DESCENT 0x04 +#define CMF_MEAN 0x02 +#define CMF_ACCENT 0x01 + typedef struct { From 42501627d235f53223745eb0424c65c800e7232d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 11 Dec 2022 12:49:19 +0100 Subject: [PATCH 099/246] Missing semicolon added --- Driver/Font/TrueType/Adapter/ttcharmapper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 748b8b080..58237e94b 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -196,7 +196,7 @@ CharMapEntry geosCharMap[] = C_NOT_SIGN, 0, 0, C_SQUARE_ROOT, 0, 0, C_LATIN_SMALL_LETTER_SCRIPT_F, 0, 0, - C_ALMOST_EQUAL_TO 0, 0, + C_ALMOST_EQUAL_TO, 0, 0, C_GREEK_CAPITAL_LETTER_DELTA, 0, 0, C_LEFT_POINTING_GUILLEMET, 0, 0, C_RIGHT_POINTING_GUILLEMET, 0, 0, @@ -228,7 +228,7 @@ CharMapEntry geosCharMap[] = C_LOW_SINGLE_COMMA_QUOTATION_MARK, 0, 0, C_LOW_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, C_PER_MILLE_SIGN, 0, 0, - C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX 0, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_E_CIRCUMFLEX, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_A_ACUTE, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_E_DIAERESIS, 0, CMF_ACCENT, From aa9008d1774560e4697a9929bb2c6f60ed1dbbff Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 11 Dec 2022 17:14:46 +0100 Subject: [PATCH 100/246] Begin to fill FontHeader. --- Driver/Font/TrueType/Adapter/ttadapter.c | 82 +++++++++++++++------ Driver/Font/TrueType/Adapter/ttadapter.h | 8 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 4 +- Driver/Font/TrueType/Adapter/ttcharmapper.h | 4 + 4 files changed, 71 insertions(+), 27 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 0beb76b0f..a0c68303d 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -20,6 +20,7 @@ ***********************************************************************/ #include "ttadapter.h" +#include "ttcharmapper.h" /******************************************************************** @@ -117,11 +118,11 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, FileHandle fileHandle; TT_Error error; TT_Face face; - char familyName[FAMILY_NAME_LENGTH]; + TT_String* familyName; word familyNameLength; - ECCheckBounds( fileName ); - ECCheckBounds( fontsAvailEntry ); + ECCheckBounds( (void*)fileName ); + ECCheckBounds( (void*)fontsAvailEntry ); if ( strlen( fileName ) >= FONT_FILE_LENGTH ) return TT_Err_Invalid_Argument; @@ -133,7 +134,7 @@ TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, if ( error != TT_Err_Ok ) goto Fail; - error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, familyName, &familyNameLength ); + error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, &familyName, &familyNameLength ); if ( error != TT_Err_Ok ) goto Fin; @@ -194,11 +195,11 @@ TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) TT_Error error; TT_Face face; TT_Face_Properties faceProperties; - char familyName[FAMILY_NAME_LENGTH]; + TT_String* familyName; word familyNameLength; - ECCheckBounds( fileName ); - ECCheckBounds( fontInfo ); + ECCheckBounds( (void*)fileName ); + ECCheckBounds( (void*)fontInfo ); fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( fileHandle ); @@ -207,7 +208,7 @@ TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) if ( error != TT_Err_Ok ) goto Fail; - error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, familyName, &familyNameLength ); + error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, &familyName, &familyNameLength ); if ( error != TT_Err_Ok ) goto Fin; @@ -277,13 +278,13 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, FileHandle fileHandle; TT_Face face; TT_Face_Properties faceProperties; - char styleName[STYLE_NAME_LENGTH]; + TT_String* styleName; word styleNameLength; TT_Error error; - ECCheckBounds( fileName ); - ECCheckBounds( outlineDataEntry ); - ECCheckBounds( trueTypeOutlineEntry ); + ECCheckBounds( (void*)fileName ); + ECCheckBounds( (void*)outlineDataEntry ); + ECCheckBounds( (void*)trueTypeOutlineEntry ); fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( fileHandle ); @@ -292,7 +293,7 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, if ( error != TT_Err_Ok ) goto Fail; - error = TT_Get_Name_String( face, NAME_INDEX_STYLE, styleName, &styleNameLength ); + error = TT_Get_Name_String( face, NAME_INDEX_STYLE, &styleName, &styleNameLength ); if ( error != TT_Err_Ok ) goto Fin; @@ -360,8 +361,8 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, WWFixedAsDWord scaleFactor; WWFixedAsDWord ttfElement; - ECCheckBounds( fileName ); - ECCheckBounds( fontBuf ); + ECCheckBounds( (void*)fileName ); + ECCheckBounds( (void*)fontBuf ); fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( fileHandle ); @@ -372,19 +373,19 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, error = TT_New_Instance( face, &instance ); if ( error ) - goto Fail; + goto Fin; error = TT_Set_Instance_CharSize( instance, WBFIXED_TO_FIXED26DOT6( pointSize ) ); if ( error ) - goto Fail; + goto Fin; error = TT_Get_Instance_Metrics( instance, &instanceMetrics ); if ( error ) - goto Fail; + goto Fin; error = fillFontHeader( face, &fontHeader ); if ( error ) - goto Fail; + goto Fin; scaleFactor = instanceMetrics.x_scale; @@ -774,23 +775,60 @@ static TextStyle mapTextStyle( const char* subfamily ) return TS_BOLD | TS_ITALIC; } +//TODO: better in ttcharmapper.c ? static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ) { - //Chartable holen + TT_CharMap charMap; + TT_Error error; + word i; + + + error = getCharMap( face, &charMap ); + if ( error != TT_Err_Ok ) + return error; - //numChars, fistChar, lastChar füllen + fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, + &fontHeader->FH_firstChar, + &fontHeader->FH_lastChar ); - //iteriere über die Zeichen des Zeichensatzes + for ( i = fontHeader->FH_firstChar; i < fontHeader->FH_lastChar; ++i ) + { //Zeichen vorhanden? //Whidth //xMin //xMax //yMin //yMax + } return TT_Err_Ok; } +static TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) +{ + TT_Face_Properties face_Properties; + TT_UShort platform; + TT_UShort encoding; + int i; + + + TT_Get_Face_Properties( face, &face_Properties ); + + for ( i = 0; i < face_Properties.num_CharMaps; ++i ) + { + TT_Get_CharMap_ID( face, i, &platform, &encoding ); + if ( platform == TT_PLATFORM_MICROSOFT && encoding == TT_MS_ID_UNICODE_CS ) + { + TT_Get_CharMap(face, i, charMap); + break; + } + } + + if ( i == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; + else return TT_Err_Ok; +} + + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ /* cycle. Therefore, the required functions are reimplemented here.*/ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index c1fd69858..2ffcc3545 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -270,7 +270,7 @@ typedef struct * convert value (word) to WWFixedAsDWord */ #define WORD_TO_WWFIXEDASDWORD( value ) \ - ( (WWFixedAsDWord)value << 16 ) + ( (WWFixedAsDWord) ( (long)value ) << 16 ) /* * convert value (TT_F26DOT6) to WWFixedAsDWord @@ -297,8 +297,8 @@ typedef struct */ #define CEIL_WWFIXEDASDWORD( value ) \ ( value & 0x8000 ? \ - ( value & 0x00ff ? ( ( (sword)value >> 16 - 1 ) ) : ( (sword)value >> 16 ) ) : \ - ( (sword)value >> 16 ) ) + ( value & 0x00ff ? ( ( value >> 16 ) - 1 ) : ( ( value >> 16 ) ) ) : \ + ( value >> 16 ) ) /* * get integral part of value (WWFixedAsDWord) @@ -339,6 +339,8 @@ static TextStyle mapTextStyle( const char* subfamily ); static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ); +static TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); + static int strlen( const char* str ); diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 58237e94b..ec2b5a939 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -258,10 +258,10 @@ CharMapEntry geosCharMap[] = }; -sword GeosCharToUnicode( word geosChar ) +word GeosCharToUnicode( word geosChar ) { if( geosChar < MIN_GEOS_CHAR || geosChar > MAX_GEOS_CHAR ) - return -1; + return 0; return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].unicode; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 039f28c2b..7e51a74f1 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -21,6 +21,7 @@ #define _TTCHARMAPPER_H_ #include +#include typedef ByteFlags CharMapFlags; @@ -39,4 +40,7 @@ typedef struct } CharMapEntry; +word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ); + + #endif /* _TTCHARMAPPER_H_ */ From 5d34dfa50cdb14b0886c3db67245d4037516663b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 11 Dec 2022 21:07:13 +0100 Subject: [PATCH 101/246] Refactor adapter and charmapper --- Driver/Font/TrueType/Adapter/ttadapter.c | 53 ----------------- Driver/Font/TrueType/Adapter/ttadapter.h | 35 ------------ Driver/Font/TrueType/Adapter/ttcharmapper.c | 63 ++++++++++++++++++++- Driver/Font/TrueType/Adapter/ttcharmapper.h | 38 +++++++++++++ 4 files changed, 100 insertions(+), 89 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index a0c68303d..3c59d9161 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -775,59 +775,6 @@ static TextStyle mapTextStyle( const char* subfamily ) return TS_BOLD | TS_ITALIC; } -//TODO: better in ttcharmapper.c ? -static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ) -{ - TT_CharMap charMap; - TT_Error error; - word i; - - - error = getCharMap( face, &charMap ); - if ( error != TT_Err_Ok ) - return error; - - fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, - &fontHeader->FH_firstChar, - &fontHeader->FH_lastChar ); - - for ( i = fontHeader->FH_firstChar; i < fontHeader->FH_lastChar; ++i ) - { - //Zeichen vorhanden? - //Whidth - //xMin - //xMax - //yMin - //yMax - } - - return TT_Err_Ok; -} - -static TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) -{ - TT_Face_Properties face_Properties; - TT_UShort platform; - TT_UShort encoding; - int i; - - - TT_Get_Face_Properties( face, &face_Properties ); - - for ( i = 0; i < face_Properties.num_CharMaps; ++i ) - { - TT_Get_CharMap_ID( face, i, &platform, &encoding ); - if ( platform == TT_PLATFORM_MICROSOFT && encoding == TT_MS_ID_UNICODE_CS ) - { - TT_Get_CharMap(face, i, charMap); - break; - } - } - - if ( i == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; - else return TT_Err_Ok; -} - /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 2ffcc3545..07d1ecb66 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -231,37 +231,6 @@ typedef struct } OutlineDataEntry; -/* - * structure to hold information necessary to fill FontBuf structure - */ -typedef struct -{ - word FH_h_height; //top of 'H' - word FH_x_height; //top of 'x' - word FH_ascender; //top of 'd' - word FH_descender; //bottom of 'p' - word FH_avgwidth; //average character width - word FH_maxwidth; //widest character width - word FH_height; //height of font box - word FH_accent; //height of accents - word FH_ascent; //height of caps - word FH_descent; //descent (from baseline) - word FH_baseAdjust; //adjustment for baseline - word FH_firstChar; //first char defined - word FH_lastChar; //last char defined - word FH_defaultChar; //default character - word FH_underPos; //position of underline - word FH_underThick; //thickness of underline - word FH_strikePos; //position of strikethrough - word FH_numChars; //number of characters - sword FH_minLSB; //minimum left side bearing - sword FH_minTSB; //minimum top side bound - sword FH_maxBSB; //maximum bottom side bound - sword FH_maxRSB; //maximum right side bound - sword FH_continuitySize; //continuity cutoff -} FontHeader; - - /*********************************************************************** * macros ***********************************************************************/ @@ -337,10 +306,6 @@ static FontWeight mapFontWeight( TT_Short weightClass ); static TextStyle mapTextStyle( const char* subfamily ); -static TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ); - -static TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); - static int strlen( const char* str ); diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index ec2b5a939..b8affefac 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -20,6 +20,7 @@ #include #include +#include #include #define NUM_CHARMAPENTRIES ( sizeof(geosCharMap) / sizeof(CharMapEntry) ) @@ -239,7 +240,7 @@ CharMapEntry geosCharMap[] = C_LATIN_CAPITAL_LETTER_I_GRAVE, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_O_ACUTE, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_O_CIRCUMFLEX, 0, CMF_ACCENT, - 0, 0, 0, //no character + 0, 0, 0, //no character C_LATIN_CAPITAL_LETTER_O_GRAVE, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_U_ACUTE, 0, CMF_ACCENT, C_LATIN_CAPITAL_LETTER_U_CIRCUMFLEX, 0, CMF_ACCENT, @@ -267,6 +268,66 @@ word GeosCharToUnicode( word geosChar ) } +TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ) +{ + TT_CharMap charMap; + TT_Error error; + TT_UShort charIndex; + word geosChar; + + + error = getCharMap( face, &charMap ); + if ( error != TT_Err_Ok ) + return error; + + fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, + &fontHeader->FH_firstChar, + &fontHeader->FH_lastChar ); + + for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) + { + charIndex = TT_Char_Index( charMap, GeosCharToUnicode( geosChar ) ); + if ( charIndex == 0 ) + break; + + //Whidth + //xMin + //xMax + //yMin + //yMax + } + + return TT_Err_Ok; +} + + +static +TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) +{ + TT_Face_Properties face_Properties; + TT_UShort platform; + TT_UShort encoding; + int i; + + + TT_Get_Face_Properties( face, &face_Properties ); + + for ( i = 0; i < face_Properties.num_CharMaps; ++i ) + { + TT_Get_CharMap_ID( face, i, &platform, &encoding ); + if ( platform == TT_PLATFORM_MICROSOFT && encoding == TT_MS_ID_UNICODE_CS ) + { + TT_Get_CharMap(face, i, charMap); + break; + } + } + + if ( i == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; + else return TT_Err_Ok; +} + + +static word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) { word charIndex; diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 7e51a74f1..eb03b693e 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -32,6 +32,9 @@ typedef ByteFlags CharMapFlags; #define CMF_ACCENT 0x01 +/* + * Entry for converting FreeGEOS chars to unicode. + */ typedef struct { word unicode; @@ -40,7 +43,42 @@ typedef struct } CharMapEntry; +/* + * Structure to hold information necessary to fill FontBuf structure. + */ +typedef struct +{ + word FH_h_height; //top of 'H' + word FH_x_height; //top of 'x' + word FH_ascender; //top of 'd' + word FH_descender; //bottom of 'p' + word FH_avgwidth; //average character width + word FH_maxwidth; //widest character width + word FH_height; //height of font box + word FH_accent; //height of accents + word FH_ascent; //height of caps + word FH_descent; //descent (from baseline) + word FH_baseAdjust; //adjustment for baseline + word FH_firstChar; //first char defined + word FH_lastChar; //last char defined + word FH_defaultChar; //default character + word FH_underPos; //position of underline + word FH_underThick; //thickness of underline + word FH_strikePos; //position of strikethrough + word FH_numChars; //number of characters + sword FH_minLSB; //minimum left side bearing + sword FH_minTSB; //minimum top side bound + sword FH_maxBSB; //maximum bottom side bound + sword FH_maxRSB; //maximum right side bound + sword FH_continuitySize; //continuity cutoff +} FontHeader; + + word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ); +TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); + +TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ); + #endif /* _TTCHARMAPPER_H_ */ From 2fec2d41e3bce26a68e3531ee481377ee1e05cca Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 16 Dec 2022 21:27:54 +0100 Subject: [PATCH 102/246] fillFontHeader() added --- Driver/Font/TrueType/Adapter/ttadapter.c | 2 +- Driver/Font/TrueType/Adapter/ttadapter.h | 4 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 96 +++++++++++++++++---- Driver/Font/TrueType/Adapter/ttcharmapper.h | 15 +++- 4 files changed, 98 insertions(+), 19 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 3c59d9161..326131885 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -383,7 +383,7 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, if ( error ) goto Fin; - error = fillFontHeader( face, &fontHeader ); + error = fillFontHeader( face, instance, &fontHeader ); if ( error ) goto Fin; diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 07d1ecb66..817f2dd1a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -239,7 +239,7 @@ typedef struct * convert value (word) to WWFixedAsDWord */ #define WORD_TO_WWFIXEDASDWORD( value ) \ - ( (WWFixedAsDWord) ( (long)value ) << 16 ) + ( (WWFixedAsDWord) MakeWWFixed( value ) ) /* * convert value (TT_F26DOT6) to WWFixedAsDWord @@ -288,7 +288,7 @@ typedef struct ( ( ( (long)value.WBF_int ) * 1024 ) | value.WBF_frac >> 2 ) #define WBFIXED_TO_WWFIXEDASDWORD( value ) \ - ( ( (long)(value.WBF_int << 16 ) ) | value.WBF_frac << 8 ) + ( ( (long)value.WBF_int << 16 ) | ( value.WBF_frac << 8 ) ) /*********************************************************************** * helperfunctions diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index b8affefac..5ec121538 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -29,6 +29,7 @@ #define GEOS_CHAR_INDEX( i ) ( i - MIN_GEOS_CHAR ) +//TODO: put geosCharMap into movable ressource CharMapEntry geosCharMap[] = { /* unicode weight flags */ @@ -268,35 +269,100 @@ word GeosCharToUnicode( word geosChar ) } -TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ) +CharMapFlags GeosCharMapFlag( word geosChar ) { - TT_CharMap charMap; - TT_Error error; - TT_UShort charIndex; - word geosChar; + if( geosChar < MIN_GEOS_CHAR || geosChar > MAX_GEOS_CHAR ) + return 0; + + return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].flags; +} + + +TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) +{ + TT_CharMap charMap; + TT_Error error; + TT_UShort charIndex; + TT_Glyph glyph; + TT_Glyph_Metrics metrics; + TT_Face_Properties faceProperties; + word geosChar; + word unitsPerEM; error = getCharMap( face, &charMap ); if ( error != TT_Err_Ok ) return error; + /* initialize max and min values in fontHeader */ + fontHeader->FH_minLSB = 9999; + fontHeader->FH_maxBSB = -9999; + fontHeader->FH_minTSB = -9999; + fontHeader->FH_maxRSB = -9999; + fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, &fontHeader->FH_firstChar, &fontHeader->FH_lastChar ); for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) { - charIndex = TT_Char_Index( charMap, GeosCharToUnicode( geosChar ) ); + word unicode = GeosCharToUnicode( geosChar ); + + charIndex = TT_Char_Index( charMap, unicode ); if ( charIndex == 0 ) break; + /* load glyph without scaling or hinting */ + TT_New_Glyph( face, &glyph ); + TT_Load_Glyph( instance, glyph, charIndex, 0 ); + TT_Get_Glyph_Metrics( glyph, &metrics ); + + //h_height + if( unicode == C_LATIN_CAPITAL_LETTER_H ) + fontHeader->FH_h_height = metrics.bbox.yMax; + + //x_height + if ( unicode == C_LATIN_SMALL_LETTER_X ) + fontHeader->FH_x_height = metrics.bbox.yMax; + + //ascender + if ( unicode == C_LATIN_SMALL_LETTER_D ) + fontHeader->FH_ascender = metrics.bbox.yMax; + + //descender + if ( unicode == C_LATIN_SMALL_LETTER_P ) + fontHeader->FH_descender = metrics.bbox.yMax; + //Whidth - //xMin - //xMax - //yMin + if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) + fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; + + /* scan xMin */ + if( fontHeader->FH_minLSB > metrics.bbox.xMin ) + fontHeader->FH_minLSB = (sword) metrics.bbox.xMin; + + /* scan xMax */ + if ( fontHeader->FH_maxRSB < metrics.bbox.xMax ) + fontHeader->FH_maxRSB = metrics.bbox.xMax; + /* scan yMin */ + if ( fontHeader->FH_maxBSB < metrics.bbox.yMin ) + fontHeader->FH_maxBSB = metrics.bbox.yMin; + //yMax + if ( fontHeader->FH_minTSB < metrics.bbox.yMax ) + { + fontHeader->FH_minTSB = metrics.bbox.yMax; + if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT && + fontHeader->FH_accent < metrics.bbox.yMax ) + fontHeader->FH_accent = metrics.bbox.yMax; + } } + TT_Get_Face_Properties( face, &faceProperties ); + unitsPerEM = faceProperties.header->Units_Per_EM; + + //basline + return TT_Err_Ok; } @@ -307,23 +373,23 @@ TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) TT_Face_Properties face_Properties; TT_UShort platform; TT_UShort encoding; - int i; + int map; TT_Get_Face_Properties( face, &face_Properties ); - for ( i = 0; i < face_Properties.num_CharMaps; ++i ) + for ( map = 0; map < face_Properties.num_CharMaps; ++map ) { - TT_Get_CharMap_ID( face, i, &platform, &encoding ); + TT_Get_CharMap_ID( face, map, &platform, &encoding ); if ( platform == TT_PLATFORM_MICROSOFT && encoding == TT_MS_ID_UNICODE_CS ) { - TT_Get_CharMap(face, i, charMap); + TT_Get_CharMap(face, map, charMap); break; } } - if ( i == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; - else return TT_Err_Ok; + if ( map == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; + else return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index eb03b693e..3d2973d40 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -74,11 +74,24 @@ typedef struct } FontHeader; +/* + * constants for calculating values in FontHeader + */ +#define DEFAULT_CONTINUITY_CUTOFF( value ) ( value / 40 ) // 2.5% of size +#define DEFAULT_DEFAULT_CHAR '.' +#define BASELINE( value ) ( 3 * value / 4 ) // 75% of size +#define DESCENT( value ) ( value / 4 ) // 25% of size +#define DEFAULT_UNDER_THICK( value ) ( value / 10 ) // 10% of size +#define DEFAULT_UNDER_POSITION( value ) ( value / -10 ) // -10% of size +#define SAFETY( value ) ( value / 40 ) // 2.5% of size + + word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ); TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); -TT_Error fillFontHeader( TT_Face face, FontHeader* fontHeader ); +TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); +void ScanCharXMin( TT_Glyph glyph, FontHeader* fontHeader ); #endif /* _TTCHARMAPPER_H_ */ From 46868ff4cfa86bb68d1c9314485890702c090504 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 18 Dec 2022 11:20:36 +0100 Subject: [PATCH 103/246] Fill_FontBuf() completed --- Driver/Font/TrueType/Adapter/ttcharmapper.c | 67 ++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttcharmapper.h | 12 ++-- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 5ec121538..7468ac384 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -277,6 +277,14 @@ CharMapFlags GeosCharMapFlag( word geosChar ) return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].flags; } +byte GeosAvgWidth( word geosChar ) +{ + if( geosChar < MIN_GEOS_CHAR || geosChar > MAX_GEOS_CHAR ) + return 0; + + return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].weight; +} + TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) { @@ -288,17 +296,19 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea TT_Face_Properties faceProperties; word geosChar; word unitsPerEM; + sword maxAccentOrAscent; error = getCharMap( face, &charMap ); if ( error != TT_Err_Ok ) return error; - /* initialize max and min values in fontHeader */ - fontHeader->FH_minLSB = 9999; - fontHeader->FH_maxBSB = -9999; - fontHeader->FH_minTSB = -9999; - fontHeader->FH_maxRSB = -9999; + /* initialize min, max and avg values in fontHeader */ + fontHeader->FH_minLSB = 9999; + fontHeader->FH_maxBSB = -9999; + fontHeader->FH_minTSB = -9999; + fontHeader->FH_maxRSB = -9999; + fontHeader->FH_avgwidth = 0; fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, &fontHeader->FH_firstChar, @@ -331,11 +341,18 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea //descender if ( unicode == C_LATIN_SMALL_LETTER_P ) - fontHeader->FH_descender = metrics.bbox.yMax; + fontHeader->FH_descender = metrics.bbox.yMin; - //Whidth + //width if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; + + //avg width + if ( GeosAvgWidth( geosChar ) ) + { + fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( + ( metrics.bbox.xMax - metrics.bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); + } /* scan xMin */ if( fontHeader->FH_minLSB > metrics.bbox.xMin ) @@ -361,7 +378,41 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea TT_Get_Face_Properties( face, &faceProperties ); unitsPerEM = faceProperties.header->Units_Per_EM; - //basline + //baseline + if ( fontHeader->FH_accent <= 0 ) + { + fontHeader->FH_accent = 0; + maxAccentOrAscent = fontHeader->FH_ascent; + } + else + { + maxAccentOrAscent = fontHeader->FH_accent; + fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; + } + + fontHeader->FH_baseAdjust = BASELINE( unitsPerEM )- maxAccentOrAscent; + fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; + fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( unitsPerEM ); + fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( unitsPerEM ) - + SAFETY( unitsPerEM ) ); + + fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; + if( fontHeader->FH_underPos == 0 ) + fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( unitsPerEM ); + + fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; + + fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; + if( fontHeader->FH_underThick == 0 ) + fontHeader->FH_underThick = DEFAULT_UNDER_THICK( unitsPerEM ); + + if( fontHeader->FH_x_height > 0 ) + fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; + else + fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; + + fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( unitsPerEM ); + return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 3d2973d40..b8d0dec3a 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -51,19 +51,19 @@ typedef struct word FH_h_height; //top of 'H' word FH_x_height; //top of 'x' word FH_ascender; //top of 'd' - word FH_descender; //bottom of 'p' + sword FH_descender; //bottom of 'p' word FH_avgwidth; //average character width word FH_maxwidth; //widest character width word FH_height; //height of font box - word FH_accent; //height of accents + sword FH_accent; //height of accents word FH_ascent; //height of caps - word FH_descent; //descent (from baseline) - word FH_baseAdjust; //adjustment for baseline + sword FH_descent; //descent (from baseline) + sword FH_baseAdjust; //adjustment for baseline word FH_firstChar; //first char defined word FH_lastChar; //last char defined word FH_defaultChar; //default character - word FH_underPos; //position of underline - word FH_underThick; //thickness of underline + sword FH_underPos; //position of underline + sword FH_underThick; //thickness of underline word FH_strikePos; //position of strikethrough word FH_numChars; //number of characters sword FH_minLSB; //minimum left side bearing From ba278629df9b38a31b1c6dd36cab47e33f2980e3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 21 Dec 2022 21:53:01 +0100 Subject: [PATCH 104/246] First step to integrate the FreeType engine into the INIT and GEN_WIDTHS driver functions. --- Driver/Font/TrueType/Adapter/ttadapter.c | 24 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 1 - Driver/Font/TrueType/Adapter/ttinit.c | 117 ++++++++ Driver/Font/TrueType/Adapter/ttinit.h | 56 ++++ Driver/Font/TrueType/Adapter/ttwidths.c | 266 ++++++++++++++++++ Driver/Font/TrueType/Adapter/ttwidths.h | 49 ++++ Installed/Driver/Font/TrueType/Makefile | 12 +- .../Driver/Font/TrueType/dependencies.mk | 17 +- 8 files changed, 531 insertions(+), 11 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttinit.c create mode 100644 Driver/Font/TrueType/Adapter/ttinit.h create mode 100644 Driver/Font/TrueType/Adapter/ttwidths.c create mode 100644 Driver/Font/TrueType/Adapter/ttwidths.h diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 326131885..12a16f985 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -497,7 +497,9 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, * of the passed in FontInfo. * * PARAMETERS: fontInfo Pointer to FontInfo structure. - * gstate Handle to current gstate. + * word Character to which the entry + * is to be filled. + * charTableEntry Pointer to entry to be filled. * * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) * @@ -510,9 +512,27 @@ TT_Error _pascal Fill_FontBuf( const char* fileName, * ---- ---- ----------- * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error _pascal Fill_CharTableEntry( const FontInfo* fontInfo, GStateHandle gstate, word character ) +TT_Error _pascal Fill_CharTableEntry( const FontInfo* fontInfo, + word character, + CharTableEntry* charTableEntry ) { + TT_CharMap charMap; + word geosChar; + + ECCheckBounds( (void*)fontInfo ); + ECCheckBounds( (void*)charTableEntry ); + + geosChar = GeosCharToUnicode( character ); + if ( geosChar == 0 ) + { + charTableEntry->CTE_width.WBF_int = 0; + charTableEntry->CTE_width.WBF_frac = 0; + charTableEntry->CTE_flags = CTF_NO_DATA; + } + + +Fin: return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 7468ac384..312c2cbb5 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -418,7 +418,6 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea } -static TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) { TT_Face_Properties face_Properties; diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c new file mode 100644 index 000000000..765263ec0 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -0,0 +1,117 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttinit.c + * + * AUTHOR: Jirka Kunze: December 20 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial version + * + * DESCRIPTION: + * Definition of driver function DR_INIT. + ***********************************************************************/ + +#include "ttinit.h" +#include +#include +#include +#include + + +void _pascal TrueType_Init() +{ + //Speicherblöcke allocieren + //FreeType Engine initialisiern +} + +void _pascal TrueType_Exit() +{ + //FreeType Engine deinitialisieren + //Speicherblöcke freen +} + + +void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) +{ + FileEnumParams ttfEnumParams; + word numOtherFiles; + word numFiles; + word file; + FileLongName* ptrFileName; + MemHandle fileEnumBlock = NullHandle; + FileExtAttrDesc ttfExtAttrDesc[] = + { { FEA_NAME, 0, sizeof( FileLongName ), NULL }, + { FEA_END_OF_LIST, 0, 0, NULL } }; + + + FilePushDir(); + + /* go to font/ttf directory */ + if( FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ) == NullHandle ) + goto Fin; + + /* get all filenames contained in current directory */ + ttfEnumParams.FEP_searchFlags = FESF_NON_GEOS; + ttfEnumParams.FEP_returnAttrs = &ttfExtAttrDesc; + ttfEnumParams.FEP_returnSize = sizeof( FileLongName ); + ttfEnumParams.FEP_matchAttrs = NullHandle; + ttfEnumParams.FEP_bufSize = FE_BUFSIZE_UNLIMITED; + ttfEnumParams.FEP_skipCount = 0; + ttfEnumParams.FEP_callback = NullHandle; + ttfEnumParams.FEP_callbackAttrs = NullHandle; + ttfEnumParams.FEP_headerSize = 0; + + numFiles = FileEnum( &ttfEnumParams, &fileEnumBlock, &numOtherFiles ); + + if( numFiles == 0 ) + goto Fin; + + ECCheckMemHandle( fileEnumBlock ); + + /* iterate over all filenames and try to register a font.*/ + ptrFileName = MemLock( fileEnumBlock ); + for( file = 0; file < numFiles; ++file ) + TrueType_ProcessFont( ptrFileName++, fontInfoBlock ); + + MemFree( fileEnumBlock ); + +Fin: + FilePopDir(); +} + + +TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ) +{ + FileHandle truetypeFile; + TT_Face face; + TT_Error error; + + + /* open truetype file */ + truetypeFile = FileOpen( file, FILE_ACCESS_R | FILE_DENY_W ); + + ECCheckFileHandle( truetypeFile ); + + error = TT_Open_Face( truetypeFile, &face ); + if( error ) + goto Fail; + + //Font ID erzeugen + //Font ID noch nicht bekannt? + //FontsAvailEntry erzeugen und füllen + //FontInfo erzeugen und füllen + //Referenz auf FontInfo in FAE füllen + //Outline anhängen und füllen + //Gibt es schon noch keine Outline für den Style? + //Outline anhängen und füllen + +Fail: + FileClose( truetypeFile, FALSE ); + return error; +} diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h new file mode 100644 index 000000000..5fbb408af --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -0,0 +1,56 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttinit.h + * + * AUTHOR: Jirka Kunze: December 20 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial version + * + * DESCRIPTION: + * Declarations of types and functions for the driver function + * DR_INIT. + ***********************************************************************/ + +#ifndef _TTINIT_H_ +#define _TTINIT_H_ + +#include +#include "../FreeType/freetype.h" + + +/*********************************************************************** + * constants + ***********************************************************************/ + +#define TTF_DIRECTORY "TTF" + + +/*********************************************************************** + * functions called by driver + ***********************************************************************/ + +void _pascal TrueType_Init(); + + +void _pascal TrueType_Exit(); + + +void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); + + +TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ); + + +/*********************************************************************** + * internal functions + ***********************************************************************/ + + +#endif /* _TTINT_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c new file mode 100644 index 000000000..66660e579 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -0,0 +1,266 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttwidths.h + * + * AUTHOR: Jirka Kunze: December 20 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial version + * + * DESCRIPTION: + * Definition of driver function DR_FONT_GEN_WIDTHS. + ***********************************************************************/ + +#include "ttwidths.h" +#include "../FreeType/ftxkern.h" + + +/******************************************************************** + * TrueType_Gen_Widths + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void _pascal TrueType_Gen_Widths( ) +{ + word numKernPairs; + word numCharacters; + + //Anzahl KernPairs ermitteln + //Anzahl der Zeichen ermitteln + + +} + + +/******************************************************************** + * GenNumKernPairs + ******************************************************************** + * SYNOPSIS: Gets number of kerning pairs. + * + * PARAMETERS: TT_Face Face from which the number of kerning + * pairs is to be determined. + * + * RETURNS: word number of kerning pairs + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: A TrueType font usually has a larger number of + * characters than are used in FreeGEOS. Therefore, the + * kerning pairs must be filtered so that only pairs + * containing characters from the FreeGEOS character + * set are delivered. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +word GetNumKernPairs( TT_Face face ) +{ + TT_Kerning directory; + + //TODO: implement + + return 0; +} + + +/******************************************************************** + * ConvertHeader + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void ConvertHeader() +{ + +} + + +/******************************************************************** + * ConvertKernPairs + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void ConvertKernPairs() +{ + +} + + +/******************************************************************** + * CalcTransform + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void CalcTransform() +{ + +} + + +/******************************************************************** + * CalcRoutines + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void CalcRoutines() +{ + +} + + + +void AllocFontBlock( word additionSpaceInBlock, + word numOfCharacters, + word numOf) +{ + + /* Geamtgröße berechnen */ + + + /* wenn alter Block ReAlloc sonst Alloc */ + + + /**** + ontAllocFontBlock proc near + uses ax, cx, dx + .enter + + shl ax, 1 + shl ax, 1 ;ax <- # kern pairs * 4 + add ax, bx ;ax <- added additional space + --> ax = kernpairs * 4 --> 4 Byte je Kernpair + + mov bx, di ;bx <- handle or 0 + ; + ; NOTE: the following is not really an index, but the + ; calculation is identical. + ; + FDIndexCharTable cx, dx ;cx == # chars * 8 (or *6) + --> cx = characters * 6 or 8 + add ax, cx ;ax <- bytes for ptrs+driver + add ax, size FontBuf - size CharTableEntry + + size = sizeOf(FontBuf) + + #kernPais * 4 + + #chars * 6 or 8 + + additinal space + mov cx, mask HF_SWAPABLE \ + or mask HF_SHARABLE \ + or mask HF_DISCARDABLE \ + or ((mask HAF_NO_ERR) \ + or (mask HAF_LOCK)) shl 8 + push ax ;save size + tst bx ;test for handle passed + jne oldBlock ;branch handle passed + mov bx, FONT_MAN_ID ;cx <- make font manager owner + call MemAllocSetOwner ;allocate for new pointsize + ; + ; P the new block handle, as fonts require exclusive access + ; + call HandleP +afterAlloc: + + mov es, ax ;es <- seg addr of font + pop es:FB_dataSize ;save size in bytes + + .leave + ret + +oldBlock: + call MemReAlloc ;reallocate font block + jmp afterAlloc +FontAllocFontBlock endp + ****/ +} + + diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h new file mode 100644 index 000000000..2363a7cd8 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -0,0 +1,49 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttwidths.h + * + * AUTHOR: Jirka Kunze: December 20 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial version + * + * DESCRIPTION: + * Declarations of types and functions for the driver function + * DR_FONT_GEN_WIDTHS. + ***********************************************************************/ + +#ifndef _TTWIDTHS_H_ +#define _TTWIDTHS_H_ + +#include "../FreeType/freetype.h" + + +/*********************************************************************** + * functions called by driver + ***********************************************************************/ + +void _pascal TrueType_Gen_Widths(); + + +/*********************************************************************** + * internal functions + ***********************************************************************/ + +word GetNumKernPairs( TT_Face face); + +void ConvertHeader(); + +void ConvertKernPairs(); + +void CalcTransform(); + +void CalcRoutines(); + + +#endif /* _TTWIDTHS_H_ */ diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 7b2a9ff8a..f6b1a81af 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -9,7 +9,8 @@ MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ truetypeInit.asm truetypeEC.asm truetypeChars.asm\ truetypePath.asm truetypeMacros.def truetypeVariable.def\ truetypeConstant.def -ADAPTER = ttcharmapper.c ttadapter.c ttcharmapper.h ttadapter.h +ADAPTER = ttinit.c ttcharmapper.c ttadapter.c ttwidths.c\ + ttcharmapper.h ttwidths.h ttinit.h ttadapter.h FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ @@ -18,10 +19,11 @@ FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h UI_TO_RDFS = -OBJS = ttcharmapper.obj ttadapter.obj ttcache.obj ttraster.obj\ - ttmutex.obj ttgload.obj ttextend.obj ttcalc.obj ttapi.obj\ - ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ - ttobjs.obj ttmemory.obj +OBJS = ttinit.obj ttcharmapper.obj ttadapter.obj ttwidths.obj\ + ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ + ttextend.obj ttcalc.obj ttapi.obj ftxkern.obj\ + ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ + ttmemory.obj COMMON = MODULES = Main CMODULES = Adapter FreeType diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index c73b83ba8..f3fe2f3e3 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -13,9 +13,14 @@ Main.eobj: Main/mainManager.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm +ttinit.obj \ +ttinit.eobj: Adapter/ttinit.h geos.h Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h fileEnum.h file.h heap.h \ + ec.h ttcharmapper.obj \ -ttcharmapper.eobj: Adapter/ttcharmapper.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h geos.h unicode.h +ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h unicode.h ttadapter.obj \ ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/freetype.h \ @@ -27,7 +32,13 @@ ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/ft_conf.h resource.h graphics.h \ font.h color.h heap.h lmem.h Ansi/stdlib.h \ Adapter/../FreeType/ttmutex.h \ - Adapter/../FreeType/ttcalc.h + Adapter/../FreeType/ttcalc.h Adapter/ttcharmapper.h \ + FreeType/freetype.h +ttwidths.obj \ +ttwidths.eobj: Adapter/ttwidths.h Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h geos.h \ + Adapter/../FreeType/ftxkern.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ From d806d81c6a1c3ab609a78161d395769d08b6947b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 23 Dec 2022 19:19:37 +0100 Subject: [PATCH 105/246] split ttAdapter.c into separat files --- Driver/Font/TrueType/Adapter/ttadapter.c | 889 ------------------ Driver/Font/TrueType/Adapter/ttadapter.h | 44 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 139 +-- Driver/Font/TrueType/Adapter/ttcharmapper.h | 52 +- Driver/Font/TrueType/Adapter/ttinit.c | 479 +++++++++- Driver/Font/TrueType/Adapter/ttinit.h | 35 +- Driver/Font/TrueType/Adapter/ttmetrics.c | 69 ++ Driver/Font/TrueType/Adapter/ttmetrics.h | 30 + Driver/Font/TrueType/Adapter/ttwidths.c | 383 +++++++- Driver/Font/TrueType/Adapter/ttwidths.h | 57 +- Installed/Driver/Font/TrueType/Makefile | 7 +- .../Driver/Font/TrueType/dependencies.mk | 39 +- 12 files changed, 1019 insertions(+), 1204 deletions(-) delete mode 100644 Driver/Font/TrueType/Adapter/ttadapter.c create mode 100644 Driver/Font/TrueType/Adapter/ttmetrics.c create mode 100644 Driver/Font/TrueType/Adapter/ttmetrics.h diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c deleted file mode 100644 index 12a16f985..000000000 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ /dev/null @@ -1,889 +0,0 @@ -/*********************************************************************** - * - * Copyright FreeGEOS-Project - * - * PROJECT: FreeGEOS - * MODULE: TrueType font driver - * FILE: ttadapter.c - * - * AUTHOR: Jirka Kunze: July 5 2022 - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 7/5/22 JK Initial version - * - * DESCRIPTION: - * Functions to adapt the FreeGEOS font driver interface to the - * FreeType library interface. - * - ***********************************************************************/ - -#include "ttadapter.h" -#include "ttcharmapper.h" - - -/******************************************************************** - * Init_FreeType - ******************************************************************** - * SYNOPSIS: Initialises the FreeType Engine with the kerning - * extension. This is the adapter function for DR_INIT. - * - * PARAMETERS: void - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Initialises the FreeType engine by delegating to - * TT_Init_FreeType() and TT_Init_Kerning(). - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 7/15/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Init_FreeType() -{ - TT_Error error; - - - error = TT_Init_FreeType(); - if ( error != TT_Err_Ok ) - return error; - - //TT_Init_Kerning() - - return TT_Err_Ok; -} - - -/******************************************************************** - * Exit_FreeType - ******************************************************************** - * SYNOPSIS: Deinitialises the FreeType Engine. This is the - * adapter function for DR_EXIT. - * - * PARAMETERS: void - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Deinitialises the FreeType engine by delegating to - * TT_Done_FreeType(). - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 7/15/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Exit_FreeType() -{ - return TT_Done_FreeType(); -} - - -/******************************************************************** - * Fill_FontsAvialEntry - ******************************************************************** - * SYNOPSIS: Fills the FontsAvialEntry structure with infomations - * of the passed font file. - * - * PARAMETERS: fileName Name of font file - * fontsAvailEntry Pointer to FontsAvialEntry - * structure to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - * - * TODO: Prepare it for dbcs. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Fill_FontsAvailEntry( const char* fileName, - FontsAvailEntry* fontsAvailEntry ) -{ - FileHandle fileHandle; - TT_Error error; - TT_Face face; - TT_String* familyName; - word familyNameLength; - - ECCheckBounds( (void*)fileName ); - ECCheckBounds( (void*)fontsAvailEntry ); - - if ( strlen( fileName ) >= FONT_FILE_LENGTH ) - return TT_Err_Invalid_Argument; - - fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( fileHandle ); - - error = TT_Open_Face( fileHandle, &face ); - if ( error != TT_Err_Ok ) - goto Fail; - - error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, &familyName, &familyNameLength ); - if ( error != TT_Err_Ok ) - goto Fin; - - if ( familyNameLength >= FAMILY_NAME_LENGTH ) - { - error = TT_Err_Invalid_Argument; - goto Fin; - } - - if ( isMappedFont( familyName ) ) - fontsAvailEntry->FAE_fontID = getMappedFontID( familyName ); - else - fontsAvailEntry->FAE_fontID = MAKE_FONTID( familyName ); - - /* We probably don't need this because we keep the file name in the */ - /* TrueTypeOutlineEntry for each style. */ - strcpy ( fontsAvailEntry->FAE_fileName, fileName ); - - fontsAvailEntry->FAE_infoHandle = NullChunk; - - error = TT_Err_Ok; - -Fin: - TT_Close_Face( face ); -Fail: - FileClose( fileHandle, FALSE ); - return error; -} - - -/******************************************************************** - * Fill_FontInfo - ******************************************************************** - * SYNOPSIS: Fills the FontsInfo structure with infomations - * of the passed in FontsAvailEntry. - * - * PARAMETERS: fileName Name of font file - * fontInfo Pointer to FontInfo structure - * to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Fill_FontInfo( const char* fileName, FontInfo* fontInfo ) -{ - FileHandle fileHandle; - TT_Error error; - TT_Face face; - TT_Face_Properties faceProperties; - TT_String* familyName; - word familyNameLength; - - ECCheckBounds( (void*)fileName ); - ECCheckBounds( (void*)fontInfo ); - - fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( fileHandle ); - - error = TT_Open_Face( fileHandle, &face ); - if ( error != TT_Err_Ok ) - goto Fail; - - error = TT_Get_Name_String( face, NAME_INDEX_FAMILY, &familyName, &familyNameLength ); - if ( error != TT_Err_Ok ) - goto Fin; - - if ( familyNameLength >= FAMILY_NAME_LENGTH ) - { - error = TT_Err_Invalid_Argument; - goto Fin; - } - - error = TT_Get_Face_Properties( face, &faceProperties ); - if ( error != TT_Err_Ok ) - goto Fin; - - fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); - - if ( isMappedFont( familyName ) ) - fontInfo->FI_fontID = getMappedFontID( familyName ); - else - fontInfo->FI_fontID = MAKE_FONTID( familyName ); - - fontInfo->FI_maker = FM_TRUETYPE; - fontInfo->FI_pointSizeTab = 0; - fontInfo->FI_pointSizeEnd = 0; - fontInfo->FI_outlineTab = 0; - fontInfo->FI_outlineEnd = 0; - - error = TT_Err_Ok; - -Fin: - TT_Close_Face( face ); -Fail: - FileClose( fileHandle, FALSE ); - return error; -} - - -/******************************************************************** - * Fill_OutlineData - ******************************************************************** - * SYNOPSIS: Fills OutlineDataEntry and TrueTypeOutlineEntry - * structure with infomations of the passed file. - * - * PARAMETERS: fileName Name of font file. - * outlineDataEntry Pointer to OutlineDataEntry - * structure to fill. - * trueTypeOutlineEntry Pointer to TrueTypeOutlineEntry - * structure to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Fill_OutlineData( const char* fileName, - OutlineDataEntry* outlineDataEntry, - TrueTypeOutlineEntry* trueTypeOutlineEntry ) -{ - FileHandle fileHandle; - TT_Face face; - TT_Face_Properties faceProperties; - TT_String* styleName; - word styleNameLength; - TT_Error error; - - ECCheckBounds( (void*)fileName ); - ECCheckBounds( (void*)outlineDataEntry ); - ECCheckBounds( (void*)trueTypeOutlineEntry ); - - fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( fileHandle ); - - error = TT_Open_Face( fileHandle, &face ); - if ( error != TT_Err_Ok ) - goto Fail; - - error = TT_Get_Name_String( face, NAME_INDEX_STYLE, &styleName, &styleNameLength ); - if ( error != TT_Err_Ok ) - goto Fin; - - if ( styleNameLength >= STYLE_NAME_LENGTH ) - { - error = TT_Err_Invalid_Argument; - goto Fin; - } - - error = TT_Get_Face_Properties( face, &faceProperties ); - if ( error != TT_Err_Ok ) - goto Fin; - - /* fill outlineDataEntry */ - outlineDataEntry->ODE_style = mapTextStyle( styleName ); - outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); - - /* fill trueTypeOutlineEntry */ - strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); - - error = TT_Err_Ok; - -Fin: - TT_Close_Face( face ); -Fail: - FileClose( fileHandle, FALSE ); - return error; -} - - -/******************************************************************** - * Fill_FontBuf - ******************************************************************** - * SYNOPSIS: Fills the FontBuf structure with informations - * of the passed in ttf file. - * - * PARAMETERS: fileName Name of font file. - * pointSize Current Pointsize. - * fontBuf Pointer to FontBuf structure - * to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error _pascal Fill_FontBuf( const char* fileName, - WBFixed pointSize, - FontBuf* fontBuf ) -{ - FileHandle fileHandle; - FontHeader fontHeader; - TT_Error error; - TT_Face face; - TT_Instance instance; - TT_Instance_Metrics instanceMetrics; - WWFixedAsDWord scaleFactor; - WWFixedAsDWord ttfElement; - - ECCheckBounds( (void*)fileName ); - ECCheckBounds( (void*)fontBuf ); - - fileHandle = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( fileHandle ); - - error = TT_Open_Face( fileHandle, &face ); - if ( error != TT_Err_Ok ) - goto Fail; - - error = TT_New_Instance( face, &instance ); - if ( error ) - goto Fin; - - error = TT_Set_Instance_CharSize( instance, WBFIXED_TO_FIXED26DOT6( pointSize ) ); - if ( error ) - goto Fin; - - error = TT_Get_Instance_Metrics( instance, &instanceMetrics ); - if ( error ) - goto Fin; - - error = fillFontHeader( face, instance, &fontHeader ); - if ( error ) - goto Fin; - - scaleFactor = instanceMetrics.x_scale; - - /* Fill elements in FontBuf structure. */ - - fontBuf->FB_maker = FM_TRUETYPE; - fontBuf->FB_kernPairPtr = 0; - fontBuf->FB_kernValuePtr = 0; - fontBuf->FB_kernCount = 0; - fontBuf->FB_heapCount = 0; - fontBuf->FB_flags = FBF_IS_OUTLINE; - - ttfElement = SCALE_WORD( fontHeader.FH_minLSB, scaleFactor ); - fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_avgwidth, scaleFactor ); - fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_maxwidth, scaleFactor ); - fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - -#ifndef DBCS_PCGEOS - ttfElement = SCALE_WORD( fontHeader.FH_maxRSB, scaleFactor ); - fontBuf->FB_maxRSB = ROUND_WWFIXEDASDWORD( ttfElement ); -#endif /* DBCS_PCGEOS */ - - scaleFactor = instanceMetrics.y_scale; - - ttfElement = SCALE_WORD( fontHeader.FH_height, scaleFactor ); - fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - /* FB_heightAdjust = pointSize - FH_height */ - ttfElement = WBFIXED_TO_WWFIXEDASDWORD( pointSize ) - - WORD_TO_WWFIXEDASDWORD( fontHeader.FH_height ); - fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_pixHeight = ROUND_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_baseAdjust, scaleFactor ); - fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ROUND_WWFIXEDASDWORD( ttfElement ) ); - fontBuf->FB_baseAdjust.WBF_frac = 0; - - ttfElement = SCALE_WORD( fontHeader.FH_minTSB, scaleFactor ); - fontBuf->FB_aboveBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_aboveBox.WBF_frac = 0; - fontBuf->FB_minTSB = CEIL_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_pixHeight += CEIL_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_maxBSB, scaleFactor ); - fontBuf->FB_belowBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_belowBox.WBF_frac = 0; -#ifdef SBCS_PCGEOS - fontBuf->FB_maxBSB = CEIL_WWFIXEDASDWORD( ttfElement ); -#endif /* SBCS_PCGEOS */ - - ttfElement = SCALE_WORD( fontHeader.FH_underPos, scaleFactor ); - fontBuf->FB_underPos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_underPos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_underThick, scaleFactor ); - fontBuf->FB_underThickness.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_underThickness.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_strikePos, scaleFactor ); - fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_x_height, scaleFactor ); - fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_descent, scaleFactor ); - fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader.FH_accent, scaleFactor ); - fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - /* baslinepos = accent + ascent */ - ttfElement = SCALE_WORD( fontHeader.FH_ascent + fontHeader.FH_accent, scaleFactor ); - fontBuf->FB_baselinePos.WBF_int = ROUND_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_baselinePos.WBF_frac = 0; - - /* Nimbus fonts and TrueType fonts has no external leading */ - fontBuf->FB_extLeading.WBF_int = 0; - fontBuf->FB_extLeading.WBF_frac = 0; - - fontBuf->FB_firstChar = fontHeader.FH_firstChar; - fontBuf->FB_lastChar = fontHeader.FH_lastChar; - fontBuf->FB_defaultChar = fontHeader.FH_defaultChar; - - TT_Done_Instance( instance ); - error = TT_Err_Ok; -Fin: - TT_Close_Face( face ); -Fail: - FileClose( fileHandle, FALSE ); - return error; -} - -/******************************************************************** - * Fill_CharTableEntry - ******************************************************************** - * SYNOPSIS: Fills the FontBuf structure with infomations - * of the passed in FontInfo. - * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * word Character to which the entry - * is to be filled. - * charTableEntry Pointer to entry to be filled. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Pointsize, scale and rotation will read from gstate. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error _pascal Fill_CharTableEntry( const FontInfo* fontInfo, - word character, - CharTableEntry* charTableEntry ) -{ - TT_CharMap charMap; - word geosChar; - - - ECCheckBounds( (void*)fontInfo ); - ECCheckBounds( (void*)charTableEntry ); - - geosChar = GeosCharToUnicode( character ); - if ( geosChar == 0 ) - { - charTableEntry->CTE_width.WBF_int = 0; - charTableEntry->CTE_width.WBF_frac = 0; - charTableEntry->CTE_flags = CTF_NO_DATA; - } - - -Fin: - return TT_Err_Ok; -} - - -/* offen: Kerning */ - -/******************************************************************** - * Get_Char_Metrics - ******************************************************************** - * SYNOPSIS: Returns the metics of the given char. - * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * gstate Handle to current gstate. - * character Character from which the metrics - * are requested. - * info Information to return. - * result Pointer in wich the result will - * stored. The result is not affected - * by scaling, rotation, etc. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - find font-file for the requested style from fontInfo - * - open outline of character in founded font-file - * - calculate requested metrics and return it - * - * TODO: If we want to support fake styles, this must also - * be implemented here. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error Get_Char_Metrics( const FontInfo* fontInfo, - GStateHandle gstate, - word character, - GCM_info info, - dword* result ) -{ - /* Api-Funktion für DR_FONT_GET_METRICS */ - /* Transformationen werden nicht beachtet!!! */ - /* The information is in document coordinates, which is to say it is not affected by */ - /* scaling, rotation, etc. that modifies the way the document is viewed, but simply */ - /* by the pointsize and font attributes requested. */ - /* siehe GrCharMetrics() */ - return TT_Err_Ok; -} - -/******************************************************************** - * Gen_Char - ******************************************************************** - * SYNOPSIS: Renders the given character as bitmap or region to - * bitmap block. - * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * gstate Handle to current gstate. - * word Character to render. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Pointsize, scale and rotation will read from gstate. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error _pascal Gen_Char( const FontInfo* fontInfo, GStateHandle gstate, word character ) -{ - /* Das Zeichen wird als Bitmap/Region gerendert. Die Transformationsmatix und */ - /* PointSize wird aus den GState geholt. Die gerenderte Bitmap wird in den */ - /* bitmapBlock und die belegte Größe in bitmapSize abgelegt. Das Format entspricht */ - /* CharData bzw. RegionCharData. */ - - /* offen: Was machen wir mit dem CharTableEntry? */ - /* Da das Flag welches anzeigt ob ein Glyph als Bitmap oder Region abgelegt wird */ - /* in FontInfo liegt, gilt: alle Zeichen als Bitmap oder als Region, Auf welcher */ - /* Basis wollen wir entscheiden ob wir ein Glyph als Bitmap oder als Region rendern?*/ - // --> im NibusTreiber prüfen - - return TT_Err_Ok; -} - -/******************************************************************** - * Gen_InRegion - ******************************************************************** - * SYNOPSIS: Renders the given character into the RegionPath. - * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * gstate Handle to current gstate. - * regionPath Handle in wich the character - * will rendered. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Pointsize, scale and rotation will read from gstate. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error _pascal Gen_In_Region( const FontInfo* fontInfo, GStateHandle gstate, Handle regionPath, word character ) -{ - /* Das Zeichen wird als RegionPath gerendert. Die Transformationsmatix und */ - /* PointSize wird aus den GState geholt. Das gerenderte Glyph wird in den */ - /* übergebenen RegionPath gelegt. */ - - return TT_Err_Ok; -} - -/******************************************************************** - * Gen_Path - ******************************************************************** - * SYNOPSIS: Renders the given character into the GStateHandle. - * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * gstate Handle to current gstate. - * flags Transformation flags. - * word Character to render. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Pointsize, scale and rotation will read from gstate. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error _pascal Gen_Path( const FontInfo* fontInfo, GStateHandle gstate, FontGenPathFlags flags, word character ) -{ - /* Das Zeichen wird als Path gerendert. Die Transformationsmatix und PointSize wird */ - /* aus den GState geholt. Das gerenderte Glyph wird in den übergebenen GState gelegt.*/ - - return TT_Err_Ok; -} - -/*******************************************************************/ -/* Implemetation of helperfunctions */ -/*******************************************************************/ - -static int toHash( const char* str ) -{ - word i; - dword hash = strlen( str ); - - for ( i = 0; i < strlen( str ) ; i++ ) - hash = ( hash * 7 ) % ( 2^16 ) + str[i]; - - return (int) hash; -} - -static Boolean isMappedFont( const char* familiyName ) -{ - //TODO: implement it - return FALSE; -} - -static FontID getMappedFontID( const char* familyName ) -{ - //TODO: implement it - //TODO: FontMaker austauschen - return (FontID) FID_DTC_URW_SANS; -} - -static FontAttrs mapFamilyClass( TT_Short familyClass ) -{ - byte class = familyClass >> 8; - byte subclass = (byte) familyClass & 0x00ff; - FontFamily family; - - switch ( class ) - { - case 1: //old style serifs - case 2: //transitional serifs - case 3: //modern serifs - family = FF_SERIF; - break; - case 4: //clarendon serifs - family = subclass == 6 ? FF_MONO : FF_SERIF; - break; - case 5: //slab serifs - family = subclass == 1 ? FF_MONO : FF_SERIF; - break; - //6 = reserved - case 7: //freeform serfis - family = FF_SERIF; - break; - case 8: //sans serif - family = FF_SANS_SERIF; - break; - case 9: //ornamentals - family = FF_ORNAMENT; - break; - case 10: //scripts - family = FF_SCRIPT; - break; - //11 = reserved - case 12: //symbolic - family = FF_SYMBOL; - break; - default: - family = FF_NON_PORTABLE; - } - - return FA_USEFUL | FA_OUTLINE | family; -} - -static AdjustedWeight mapFontWeight( TT_Short weightClass ) -{ - switch (weightClass) - { - case 1: - return AW_ULTRA_LIGHT; - case 2: - return AW_EXTRA_LIGHT; - case 3: - return AW_LIGHT; - case 4: - return AW_SEMI_LIGHT; - case 5: - return AW_MEDIUM; - case 6: - return AW_SEMI_BOLD; - case 7: - return AW_BOLD; - case 8: - return AW_EXTRA_BOLD; - default: - return AW_ULTRA_BOLD; - } -} - -static TextStyle mapTextStyle( const char* subfamily ) -{ - if ( strcmp( subfamily, "Regular" ) == 0 ) - return 0x00; - if ( strcmp( subfamily, "Bold" ) == 0 ) - return TS_BOLD; - if ( strcmp( subfamily, "Italic" ) == 0 ) - return TS_ITALIC; - if ( strcmp( subfamily, "Bold Italic" ) == 0 ) - return TS_BOLD | TS_ITALIC; - if ( strcmp( subfamily, "Oblique" ) == 0 ) - return TS_ITALIC; - - /* only Bold Oblique remains */ - return TS_BOLD | TS_ITALIC; -} - - -/*******************************************************************/ -/* We cannot use functions from the Ansic library, which causes a */ -/* cycle. Therefore, the required functions are reimplemented here.*/ -/*******************************************************************/ - -static int strlen( const char* str ) -{ - const char *s; - - for ( s = str; *s; ++s ) - ; - return( s - str ); -} - -static void strcpy( char* dest, const char* source ) -{ - while ((*dest++ = *source++) != '\0'); -} - -static int strcmp( const char* s1, const char* s2 ) -{ - while ( *s1 && ( *s1 == *s2 ) ) - { - s1++; - s2++; - } - return *(const unsigned char*)s1 - *(const unsigned char*)s2; -} - -//füllen der fontInfo Struktur -// FI_fileHandle (word) := FileOpen( fileName ... ) -// FI_RESIDENT label(word) := ??? -// FI_fontID (FontID) := siehe oben FAE_fontID -// FI_maker (FontMaker) := FontMaker.FM_TRUETYPE -// FI_family (FontAttrs) := -// FA_USEFUL (FontUseful:1) := FU_USEFUL/FU_NOT_USEFUL? -// FA_FIXED_WIDTH (FontPitch:1) := FP_PROPORTIONAL -// FA_ORIENT (FontOrientation:1) := FO_NORMAL -// FA_OUTLINE (FontSource:1) := FS_OUTLINE -// FA_FAMILY (FontFamily:4) := gemappt aus FaceProperties -> OS2 -> sWeightClass -// (high byte = class; low byte = subclass) -// class 0 (no classification) -> FF_NON_PORTABLE? -// class 1 (old style serifs) -> FF_SERIF -// class 2 (transitional serifs) -> FF_SERIF -// class 3 (modern serifs) -> FF_SERIF -// class 4 (clarendon serifs) -// subclass 6 (monotone) -> FF_MONO sonst FF_SERIF -// class 5 (slab serifs) -> FF_SERIF -// subclass 1 (monotone) -> FF_MONO sonst FF_SERIF -// class 6 (reserved) -// class 7 (freeform serifs) -> FF_SERIF -// class 8 (sans serif) -> FF_SANS_SERIF -// class 9 (ornamentals) -> FF_ORNAMENT -// class 10 (scrips) -> FF_SCRIPT -// class 11 (reserved) -// class 12 (symbolic) -> FF_SYMBOL -// Achtung: für FF_SPECIAL gibt es keine Zuordnung -// FI_faceName (char/wchar) := NameTable ID 1 (Font Family) (Prüfung auf max. 20 Zeichen) -// FI_pointSizeTab (word?) := 0 (keine Unterstützung für Bitmaps) -// FI_pointSizeEnd (word?) := 0 ( -"- ) -// FI_outlineTab (word?) := wird nicht verändert; muss in der asm-Schicht gefüllt werden -// FI_outlineEnd (word?) := ( -"- ) - -//füllen des OutlineDataEntry (im TTF Treiber gibt es nur einen Entry je Fontfile) -// ODE_style (TextStyle) := gemappt aus NameTable ID 2 (Subfamily) -// "Regular" := 0 -// "Bold" := TS_BOLD -// "Italic" := TS_ITALIC -// "Bold Italic" := TS_BOLD | TS_ITALIC -// "Oblique" := TS_ITALIC -// "Bold Oblique" := TS_BOLD | TS_ITALIC -// ODE_weight (FontWeight) := gemappt aus gemappt aus FaceProperties -> OS2 -> usWeightClass -// 1 (Ultra-light) := FWE_ULTRA_LIGHT -// 2 (Extra-light) := FWE_EXTRA_LIGHT -// 3 (Light) := FWE_LIGHT -// 4 (Semi-light) := FWE_BOOK -// 5 (Medium (normal)) := FWE_NORMAL -// 6 (Semi-bold) := FWE_DEMI -// 7 (Bold) := FWE_BOLD -// 8 (Extra-Bold) := FWE_EXTRA_BOLD -// 9 (Ultra-bold) := FWE_ULTRA_BOLD -// ODE_header (OutlineEntry) := 0? -// ODE_first (OutlineEntry) := 0? -// ODE_second (OutlineEntry) := 0? - -//füllen eines CharTableEntries -// CTE_dataOffset nptr.CharData ;Offset to data -// CTE_width WBFixed ;character width -// CTE_flags CharTableFlags ;flags -// CTE_usage* word ;LRU count -// *nicht DBCS diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 817f2dd1a..c6d37fd37 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -34,20 +34,6 @@ extern TEngine_Instance engineInstance; -/*********************************************************************** - * parameters for search in name table - ***********************************************************************/ -#define NAME_INDEX_FAMILY 1 // font family name -#define NAME_INDEX_STYLE 2 // font style - -#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE - -#define FAMILY_NAME_LENGTH 20 -#define STYLE_NAME_LENGTH 16 - - -#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) - /*********************************************************************** * structures ***********************************************************************/ @@ -59,9 +45,9 @@ typedef struct { FontID FAE_fontID; #ifdef DBCS_PCGEOS - wchar FAE_fileName[FONT_FILE_LENGTH]; + wchar FAE_fileName[FILE_LONGNAME_BUFFER_SIZE]; #else - char FAE_fileName[FONT_FILE_LENGTH]; + char FAE_fileName[FILE_LONGNAME_BUFFER_SIZE]; #endif ChunkHandle FAE_infoHandle; } FontsAvailEntry; @@ -99,9 +85,9 @@ typedef struct typedef struct { #if DBCS_PCGEOS - wchar TTOE_fontFileName[FONT_FILE_LENGTH] + wchar TTOE_fontFileName[FILE_LONGNAME_BUFFER_SIZE] #else - char TTOE_fontFileName[FONT_FILE_LENGTH]; + char TTOE_fontFileName[FILE_LONGNAME_BUFFER_SIZE]; #endif } TrueTypeOutlineEntry; @@ -290,27 +276,5 @@ typedef struct #define WBFIXED_TO_WWFIXEDASDWORD( value ) \ ( ( (long)value.WBF_int << 16 ) | ( value.WBF_frac << 8 ) ) -/*********************************************************************** - * helperfunctions - ***********************************************************************/ - -static Boolean isMappedFont( const char* familiyName ); - -static FontID getMappedFontID( const char* familyName ); - -static int toHash( const char* str ); - -static FontAttrs mapFamilyClass( TT_Short familyClass ); - -static FontWeight mapFontWeight( TT_Short weightClass ); - -static TextStyle mapTextStyle( const char* subfamily ); - - -static int strlen( const char* str ); - -static void strcpy( char* dest, const char* source ); - #endif /* _TTADAPTER_H_ */ - diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 312c2cbb5..fe11e547a 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -286,138 +286,9 @@ byte GeosAvgWidth( word geosChar ) } -TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) -{ - TT_CharMap charMap; - TT_Error error; - TT_UShort charIndex; - TT_Glyph glyph; - TT_Glyph_Metrics metrics; - TT_Face_Properties faceProperties; - word geosChar; - word unitsPerEM; - sword maxAccentOrAscent; - - - error = getCharMap( face, &charMap ); - if ( error != TT_Err_Ok ) - return error; - - /* initialize min, max and avg values in fontHeader */ - fontHeader->FH_minLSB = 9999; - fontHeader->FH_maxBSB = -9999; - fontHeader->FH_minTSB = -9999; - fontHeader->FH_maxRSB = -9999; - fontHeader->FH_avgwidth = 0; - - fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, - &fontHeader->FH_firstChar, - &fontHeader->FH_lastChar ); - - for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) - { - word unicode = GeosCharToUnicode( geosChar ); - - charIndex = TT_Char_Index( charMap, unicode ); - if ( charIndex == 0 ) - break; - - /* load glyph without scaling or hinting */ - TT_New_Glyph( face, &glyph ); - TT_Load_Glyph( instance, glyph, charIndex, 0 ); - TT_Get_Glyph_Metrics( glyph, &metrics ); - - //h_height - if( unicode == C_LATIN_CAPITAL_LETTER_H ) - fontHeader->FH_h_height = metrics.bbox.yMax; - - //x_height - if ( unicode == C_LATIN_SMALL_LETTER_X ) - fontHeader->FH_x_height = metrics.bbox.yMax; - - //ascender - if ( unicode == C_LATIN_SMALL_LETTER_D ) - fontHeader->FH_ascender = metrics.bbox.yMax; - - //descender - if ( unicode == C_LATIN_SMALL_LETTER_P ) - fontHeader->FH_descender = metrics.bbox.yMin; - - //width - if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) - fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; - - //avg width - if ( GeosAvgWidth( geosChar ) ) - { - fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( - ( metrics.bbox.xMax - metrics.bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); - } - - /* scan xMin */ - if( fontHeader->FH_minLSB > metrics.bbox.xMin ) - fontHeader->FH_minLSB = (sword) metrics.bbox.xMin; - - /* scan xMax */ - if ( fontHeader->FH_maxRSB < metrics.bbox.xMax ) - fontHeader->FH_maxRSB = metrics.bbox.xMax; - /* scan yMin */ - if ( fontHeader->FH_maxBSB < metrics.bbox.yMin ) - fontHeader->FH_maxBSB = metrics.bbox.yMin; - - //yMax - if ( fontHeader->FH_minTSB < metrics.bbox.yMax ) - { - fontHeader->FH_minTSB = metrics.bbox.yMax; - if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT && - fontHeader->FH_accent < metrics.bbox.yMax ) - fontHeader->FH_accent = metrics.bbox.yMax; - } - } - - TT_Get_Face_Properties( face, &faceProperties ); - unitsPerEM = faceProperties.header->Units_Per_EM; - - //baseline - if ( fontHeader->FH_accent <= 0 ) - { - fontHeader->FH_accent = 0; - maxAccentOrAscent = fontHeader->FH_ascent; - } - else - { - maxAccentOrAscent = fontHeader->FH_accent; - fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; - } - - fontHeader->FH_baseAdjust = BASELINE( unitsPerEM )- maxAccentOrAscent; - fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; - fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( unitsPerEM ); - fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( unitsPerEM ) - - SAFETY( unitsPerEM ) ); - - fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; - if( fontHeader->FH_underPos == 0 ) - fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( unitsPerEM ); - - fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; - - fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; - if( fontHeader->FH_underThick == 0 ) - fontHeader->FH_underThick = DEFAULT_UNDER_THICK( unitsPerEM ); - - if( fontHeader->FH_x_height > 0 ) - fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; - else - fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; - - fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( unitsPerEM ); - - - return TT_Err_Ok; -} - - +/* + * Get microsoft unicode charmap in face. + */ TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) { TT_Face_Properties face_Properties; @@ -443,7 +314,9 @@ TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) } -static +/* + * Counts the GEOS characters that are present in the font. + */ word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) { word charIndex; diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index b8d0dec3a..d2dbfe92e 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -14,7 +14,7 @@ * 12/5/22 JK Initial version * * DESCRIPTION: - * Structures and definitions for mapping character from FreeGEOS + * Structures and definitions for mapping character from FreeGEOS * charset zu Unicode charset. ***********************************************************************/ #ifndef _TTCHARMAPPER_H_ @@ -43,55 +43,13 @@ typedef struct } CharMapEntry; -/* - * Structure to hold information necessary to fill FontBuf structure. - */ -typedef struct -{ - word FH_h_height; //top of 'H' - word FH_x_height; //top of 'x' - word FH_ascender; //top of 'd' - sword FH_descender; //bottom of 'p' - word FH_avgwidth; //average character width - word FH_maxwidth; //widest character width - word FH_height; //height of font box - sword FH_accent; //height of accents - word FH_ascent; //height of caps - sword FH_descent; //descent (from baseline) - sword FH_baseAdjust; //adjustment for baseline - word FH_firstChar; //first char defined - word FH_lastChar; //last char defined - word FH_defaultChar; //default character - sword FH_underPos; //position of underline - sword FH_underThick; //thickness of underline - word FH_strikePos; //position of strikethrough - word FH_numChars; //number of characters - sword FH_minLSB; //minimum left side bearing - sword FH_minTSB; //minimum top side bound - sword FH_maxBSB; //maximum bottom side bound - sword FH_maxRSB; //maximum right side bound - sword FH_continuitySize; //continuity cutoff -} FontHeader; - - -/* - * constants for calculating values in FontHeader - */ -#define DEFAULT_CONTINUITY_CUTOFF( value ) ( value / 40 ) // 2.5% of size -#define DEFAULT_DEFAULT_CHAR '.' -#define BASELINE( value ) ( 3 * value / 4 ) // 75% of size -#define DESCENT( value ) ( value / 4 ) // 25% of size -#define DEFAULT_UNDER_THICK( value ) ( value / 10 ) // 10% of size -#define DEFAULT_UNDER_POSITION( value ) ( value / -10 ) // -10% of size -#define SAFETY( value ) ( value / 40 ) // 2.5% of size - +/*********************************************************************** + * internal functions + ***********************************************************************/ -word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ); +word CountGeosCharsInCharMap( TT_CharMap map, word* firstChar, word* lastChar ); TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); -TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); - -void ScanCharXMin( TT_Glyph glyph, FontHeader* fontHeader ); #endif /* _TTCHARMAPPER_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 765263ec0..d5f7bf993 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -18,25 +18,98 @@ ***********************************************************************/ #include "ttinit.h" +#include "ttadapter.h" #include #include #include +#include #include -void _pascal TrueType_Init() -{ - //Speicherblöcke allocieren - //FreeType Engine initialisiern +/******************************************************************** + * Init_FreeType + ******************************************************************** + * SYNOPSIS: Initialises the FreeType Engine with the kerning + * extension. This is the adapter function for DR_INIT. + * + * PARAMETERS: void + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Initialises the FreeType engine by delegating to + * TT_Init_FreeType() and TT_Init_Kerning(). + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 7/15/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Init_FreeType() +{ + TT_Error error; + + + error = TT_Init_FreeType(); + if ( error != TT_Err_Ok ) + return error; + + //commented out because it freezes swat + //TT_Init_Kerning() + + return TT_Err_Ok; } -void _pascal TrueType_Exit() + +/******************************************************************** + * Exit_FreeType + ******************************************************************** + * SYNOPSIS: Deinitialises the FreeType Engine. This is the + * adapter function for DR_EXIT. + * + * PARAMETERS: void + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Deinitialises the FreeType engine by delegating to + * TT_Done_FreeType(). + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 7/15/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Exit_FreeType() { - //FreeType Engine deinitialisieren - //Speicherblöcke freen + return TT_Done_FreeType(); } +/******************************************************************** + * TrueType_InitFonts + ******************************************************************** + * SYNOPSIS: Deinitialises the FreeType Engine. This is the + * adapter function for DR_EXIT. + * + * PARAMETERS: void + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Deinitialises the FreeType engine by delegating to + * TT_Done_FreeType(). + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 7/15/22 JK Initial Revision + *******************************************************************/ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) { FileEnumParams ttfEnumParams; @@ -68,15 +141,14 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) ttfEnumParams.FEP_headerSize = 0; numFiles = FileEnum( &ttfEnumParams, &fileEnumBlock, &numOtherFiles ); + ECCheckMemHandle( fileEnumBlock ); if( numFiles == 0 ) goto Fin; - ECCheckMemHandle( fileEnumBlock ); - /* iterate over all filenames and try to register a font.*/ ptrFileName = MemLock( fileEnumBlock ); - for( file = 0; file < numFiles; ++file ) + for( file = 0; file < numFiles; file++ ) TrueType_ProcessFont( ptrFileName++, fontInfoBlock ); MemFree( fileEnumBlock ); @@ -86,32 +158,399 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) } -TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ) +TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { FileHandle truetypeFile; TT_Face face; TT_Error error; + TT_String* familyName; + word familyNameLength; + FontID fontID; + + ECCheckBounds( (void*)fileName ); + ECCheckMemHandle( fontInfoBlock ); - /* open truetype file */ - truetypeFile = FileOpen( file, FILE_ACCESS_R | FILE_DENY_W ); + + truetypeFile = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( truetypeFile ); error = TT_Open_Face( truetypeFile, &face ); if( error ) - goto Fail; + goto Fin; + + //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein + // die Implementierung muss damit umgehen können + error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); + if ( error != TT_Err_Ok ) + goto Fin; - //Font ID erzeugen - //Font ID noch nicht bekannt? + if ( isMappedFont( familyName ) ) + fontID = getMappedFontID( familyName ); + else + fontID = MAKE_FONTID( familyName ); + + if ( !isRegistredFontID( fontID, fontInfoBlock ) ) + { //FontsAvailEntry erzeugen und füllen //FontInfo erzeugen und füllen - //Referenz auf FontInfo in FAE füllen - //Outline anhängen und füllen - //Gibt es schon noch keine Outline für den Style? + //Referenz auf FontInfo in FontsAvailEntry füllen //Outline anhängen und füllen + } + else + { + //Gibt es schon noch keine Outline für den Style? + //Outline anhängen und füllen + + } -Fail: +Fin: FileClose( truetypeFile, FALSE ); return error; } + + +/******************************************************************** + * Fill_FontsAvialEntry + ******************************************************************** + * SYNOPSIS: Fills the FontsAvialEntry structure with infomations + * of the passed font file. + * + * PARAMETERS: fileName Name of font file. + * face Face from font file. + * fontID Calcualted FontID. + * fontsAvailEntry Pointer to FontsAvialEntry + * structure to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * TODO: Prepare it for dbcs. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error Fill_FontsAvailEntry( const char * fileName, + TT_Face face, + FontID fontID, + FontsAvailEntry* fontsAvailEntry ) +{ + TT_Error error; + TT_String* familyName; + word familyNameLength; + + + ECCheckBounds( (void*)fontsAvailEntry ); + + + error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); + if ( error ) + return error; + + if ( familyNameLength >= FAMILY_NAME_LENGTH ) + return TT_Err_Invalid_Argument; + + fontsAvailEntry->FAE_fontID = fontID; + + /* We probably don't need this because we keep the file name in the */ + /* TrueTypeOutlineEntry for each style. */ + strcpy ( fontsAvailEntry->FAE_fileName, fileName ); + + /* Will be filled later with the ChunkHandle to the FontInfo. */ + fontsAvailEntry->FAE_infoHandle = NullChunk; + + return TT_Err_Ok; +} + + +/******************************************************************** + * Fill_FontInfo + ******************************************************************** + * SYNOPSIS: Fills the FontsInfo structure with infomations + * of the passed in FontsAvailEntry. + * + * PARAMETERS: face Face from font file. + * fontID Calculated FontID. + * fontInfo Pointer to FontInfo structure + * to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Fill_FontInfo( TT_Face face, + FontID fontID, + FontInfo* fontInfo ) +{ + TT_Error error; + TT_Face_Properties faceProperties; + TT_String* familyName; + word familyNameLength; + + + ECCheckBounds( (void*)fontInfo ); + + + error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); + if ( error ) + return error; + + if ( familyNameLength >= FAMILY_NAME_LENGTH ) + return TT_Err_Invalid_Argument; + + error = TT_Get_Face_Properties( face, &faceProperties ); + if ( error ) + return error; + + strcpy( fontInfo->FI_faceName, familyName ); + + fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); + fontInfo->FI_fontID = fontID; + fontInfo->FI_maker = FM_TRUETYPE; + fontInfo->FI_pointSizeTab = 0; + fontInfo->FI_pointSizeEnd = 0; + fontInfo->FI_outlineTab = 0; + fontInfo->FI_outlineEnd = 0; + + return TT_Err_Ok; +} + + +/******************************************************************** + * Fill_OutlineData + ******************************************************************** + * SYNOPSIS: Fills OutlineDataEntry and TrueTypeOutlineEntry + * structure with infomations of the passed file. + * + * PARAMETERS: fileName Name of font file. + * face Face from font file. + * outlineDataEntry Pointer to OutlineDataEntry + * structure to fill. + * trueTypeOutlineEntry Pointer to TrueTypeOutlineEntry + * structure to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * CONDITION: The current directory must be the ttf font directory. + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error _pascal Fill_OutlineData( const char* fileName, + TT_Face face, + OutlineDataEntry* outlineDataEntry, + TrueTypeOutlineEntry* trueTypeOutlineEntry ) +{ + TT_Face_Properties faceProperties; + TT_String* styleName; + word styleNameLength; + TT_Error error; + + + ECCheckBounds( (void*)fileName ); + ECCheckBounds( (void*)outlineDataEntry ); + ECCheckBounds( (void*)trueTypeOutlineEntry ); + + + error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); + if ( error != TT_Err_Ok ) + return error; + + if ( styleNameLength >= STYLE_NAME_LENGTH ) + return TT_Err_Invalid_Argument; + + + error = TT_Get_Face_Properties( face, &faceProperties ); + if ( error != TT_Err_Ok ) + return error; + + /* fill outlineDataEntry */ + outlineDataEntry->ODE_style = mapTextStyle( styleName ); + outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); + + /* fill trueTypeOutlineEntry */ + strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); + + return TT_Err_Ok; +} + + +/*******************************************************************/ +/* Implemetation of helperfunctions */ +/*******************************************************************/ + +static int toHash( const char* str ) +{ + word i; + dword hash = strlen( str ); + + for ( i = 0; i < strlen( str ) ; i++ ) + hash = ( hash * 7 ) % ( 2^16 ) + str[i]; + + return (int) hash; +} + +static FontAttrs mapFamilyClass( TT_Short familyClass ) +{ + byte class = familyClass >> 8; + byte subclass = (byte) familyClass & 0x00ff; + FontFamily family; + + switch ( class ) + { + case 1: //old style serifs + case 2: //transitional serifs + case 3: //modern serifs + family = FF_SERIF; + break; + case 4: //clarendon serifs + family = subclass == 6 ? FF_MONO : FF_SERIF; + break; + case 5: //slab serifs + family = subclass == 1 ? FF_MONO : FF_SERIF; + break; + //6 = reserved + case 7: //freeform serfis + family = FF_SERIF; + break; + case 8: //sans serif + family = FF_SANS_SERIF; + break; + case 9: //ornamentals + family = FF_ORNAMENT; + break; + case 10: //scripts + family = FF_SCRIPT; + break; + //11 = reserved + case 12: //symbolic + family = FF_SYMBOL; + break; + default: + family = FF_NON_PORTABLE; + } + + return FA_USEFUL | FA_OUTLINE | family; +} + +static AdjustedWeight mapFontWeight( TT_Short weightClass ) +{ + switch (weightClass) + { + case 1: + return AW_ULTRA_LIGHT; + case 2: + return AW_EXTRA_LIGHT; + case 3: + return AW_LIGHT; + case 4: + return AW_SEMI_LIGHT; + case 5: + return AW_MEDIUM; + case 6: + return AW_SEMI_BOLD; + case 7: + return AW_BOLD; + case 8: + return AW_EXTRA_BOLD; + default: + return AW_ULTRA_BOLD; + } +} + +static TextStyle mapTextStyle( const char* subfamily ) +{ + if ( strcmp( subfamily, "Regular" ) == 0 ) + return 0x00; + if ( strcmp( subfamily, "Bold" ) == 0 ) + return TS_BOLD; + if ( strcmp( subfamily, "Italic" ) == 0 ) + return TS_ITALIC; + if ( strcmp( subfamily, "Bold Italic" ) == 0 ) + return TS_BOLD | TS_ITALIC; + if ( strcmp( subfamily, "Oblique" ) == 0 ) + return TS_ITALIC; + + /* only Bold Oblique remains */ + return TS_BOLD | TS_ITALIC; +} + +static Boolean isMappedFont( const char* familiyName ) +{ + //TODO: implement it + return FALSE; +} + +static FontID getMappedFontID( const char* familyName ) +{ + //TODO: implement it + //TODO: FontMaker austauschen + return (FontID) FID_DTC_URW_SANS; +} + +static Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ) +{ + byte* fontsAvailEntry; + + /* set fontsAvailEntry to first Element */ + fontsAvailEntry = MemDeref( fontInfoBlock ); + return FALSE; +} + + +/*******************************************************************/ +/* We cannot use functions from the Ansic library, which causes a */ +/* cycle. Therefore, the required functions are reimplemented here.*/ +/*******************************************************************/ + +static int strlen( const char* str ) +{ + const char *s; + + for ( s = str; *s; ++s ) + ; + return( s - str ); +} + + +static void strcpy( char* dest, const char* source ) +{ + while ((*dest++ = *source++) != '\0'); +} + + +static int strcmp( const char* s1, const char* s2 ) +{ + while ( *s1 && ( *s1 == *s2 ) ) + { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 5fbb408af..21db817b0 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -22,6 +22,9 @@ #define _TTINIT_H_ #include +#include +#include +#include #include "../FreeType/freetype.h" @@ -30,27 +33,47 @@ ***********************************************************************/ #define TTF_DIRECTORY "TTF" +#define FAMILY_NAME_INDEX 1 // font family name +#define STYLE_NAME_INDEX 2 // font style + +#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE + +#define FAMILY_NAME_LENGTH 20 +#define STYLE_NAME_LENGTH 16 + +#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) /*********************************************************************** * functions called by driver ***********************************************************************/ -void _pascal TrueType_Init(); +void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); +TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ); -void _pascal TrueType_Exit(); +Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ); +Boolean isMappedFont( const char* familiyName ); -void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); - - -TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ); +FontID getMappedFontID( const char* familyName ); /*********************************************************************** * internal functions ***********************************************************************/ +static FontAttrs mapFamilyClass( TT_Short familyClass ); + +static FontWeight mapFontWeight( TT_Short weightClass ); + +static TextStyle mapTextStyle( const char* subfamily ); + +static int toHash( const char* str ); + +static int strlen( const char* str ); + +static void strcpy( char* dest, const char* source ); + #endif /* _TTINT_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c new file mode 100644 index 000000000..5c3355576 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -0,0 +1,69 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttadapter.c + * + * AUTHOR: Jirka Kunze: December 23 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial version + * + * DESCRIPTION: + * Definition of driver function DR_FONT_CHAR_METRICS. + ***********************************************************************/ + +#include "ttadapter.h" +#include "ttmetrics.h" + +/******************************************************************** + * Get_Char_Metrics + ******************************************************************** + * SYNOPSIS: Returns the metics of the given char. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * gstate Handle to current gstate. + * character Character from which the metrics + * are requested. + * info Information to return. + * result Pointer in wich the result will + * stored. The result is not affected + * by scaling, rotation, etc. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * CONDITION: The current directory must be the ttf font directory. + * + * STRATEGY: - find font-file for the requested style from fontInfo + * - open outline of character in founded font-file + * - calculate requested metrics and return it + * + * TODO: If we want to support fake styles, this must also + * be implemented here. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 23/12/22 JK Initial Revision + * + *******************************************************************/ +TT_Error _pascal Get_Char_Metrics( const FontInfo* fontInfo, + GStateHandle gstate, + word character, + GCM_info info, + dword* result ) +{ + /* Api-Funktion für DR_FONT_GET_METRICS */ + /* Transformationen werden nicht beachtet!!! */ + /* The information is in document coordinates, which is to say it is not affected by */ + /* scaling, rotation, etc. that modifies the way the document is viewed, but simply */ + /* by the pointsize and font attributes requested. */ + /* siehe GrCharMetrics() */ + return TT_Err_Ok; +} \ No newline at end of file diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.h b/Driver/Font/TrueType/Adapter/ttmetrics.h new file mode 100644 index 000000000..35a15aa58 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttmetrics.h @@ -0,0 +1,30 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttadapter.c + * + * AUTHOR: Jirka Kunze: December 23 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial version + * + * DESCRIPTION: + * Declarations of driver function DR_FONT_CHAR_METRICS. + ***********************************************************************/ + +#ifndef _TTMETRICS_H_ +#define _TTMETRICS_H_ + + +TT_Error _pascal Get_Char_Metrics( const FontInfo* fontInfo, + GStateHandle gstate, + word character, + GCM_info info, + dword* result ); + +#endif _TTMETRICS_H_ \ No newline at end of file diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 66660e579..54e7e91b9 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -17,7 +17,10 @@ * Definition of driver function DR_FONT_GEN_WIDTHS. ***********************************************************************/ +#include +#include #include "ttwidths.h" +#include "ttcharmapper.h" #include "../FreeType/ftxkern.h" @@ -47,6 +50,7 @@ void _pascal TrueType_Gen_Widths( ) word numKernPairs; word numCharacters; + //Font öffenen und Face laden //Anzahl KernPairs ermitteln //Anzahl der Zeichen ermitteln @@ -203,64 +207,339 @@ void AllocFontBlock( word additionSpaceInBlock, word numOfCharacters, word numOf) { - /* Geamtgröße berechnen */ /* wenn alter Block ReAlloc sonst Alloc */ +} + +/******************************************************************** + * Fill_CharTableEntry + ******************************************************************** + * SYNOPSIS: Fills the FontBuf structure with infomations + * of the passed in FontInfo. + * + * PARAMETERS: fontInfo Pointer to FontInfo structure. + * word Character to which the entry + * is to be filled. + * charTableEntry Pointer to entry to be filled. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * STRATEGY: Pointsize, scale and rotation will read from gstate. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ +TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, + word character, + CharTableEntry* charTableEntry ) +{ + TT_CharMap charMap; + word geosChar; - /**** - ontAllocFontBlock proc near - uses ax, cx, dx - .enter - - shl ax, 1 - shl ax, 1 ;ax <- # kern pairs * 4 - add ax, bx ;ax <- added additional space - --> ax = kernpairs * 4 --> 4 Byte je Kernpair - - mov bx, di ;bx <- handle or 0 - ; - ; NOTE: the following is not really an index, but the - ; calculation is identical. - ; - FDIndexCharTable cx, dx ;cx == # chars * 8 (or *6) - --> cx = characters * 6 or 8 - add ax, cx ;ax <- bytes for ptrs+driver - add ax, size FontBuf - size CharTableEntry - - size = sizeOf(FontBuf) + - #kernPais * 4 + - #chars * 6 or 8 + - additinal space - mov cx, mask HF_SWAPABLE \ - or mask HF_SHARABLE \ - or mask HF_DISCARDABLE \ - or ((mask HAF_NO_ERR) \ - or (mask HAF_LOCK)) shl 8 - push ax ;save size - tst bx ;test for handle passed - jne oldBlock ;branch handle passed - mov bx, FONT_MAN_ID ;cx <- make font manager owner - call MemAllocSetOwner ;allocate for new pointsize - ; - ; P the new block handle, as fonts require exclusive access - ; - call HandleP -afterAlloc: - - mov es, ax ;es <- seg addr of font - pop es:FB_dataSize ;save size in bytes - - .leave - ret - -oldBlock: - call MemReAlloc ;reallocate font block - jmp afterAlloc -FontAllocFontBlock endp - ****/ + ECCheckBounds( (void*)fontInfo ); + ECCheckBounds( (void*)charTableEntry ); + + geosChar = GeosCharToUnicode( character ); + if ( geosChar == 0 ) + { + charTableEntry->CTE_width.WBF_int = 0; + charTableEntry->CTE_width.WBF_frac = 0; + charTableEntry->CTE_flags = CTF_NO_DATA; + } + + +Fin: + return TT_Err_Ok; } +/******************************************************************** + * Fill_FontBuf + ******************************************************************** + * SYNOPSIS: Fills the FontBuf structure with informations + * of the passed in ttf file. + * + * PARAMETERS: fileName Name of font file. + * pointSize Current Pointsize. + * fontBuf Pointer to FontBuf structure + * to fill. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * CONDITION: The current directory must be the ttf font directory. + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/12/22 JK Initial Revision + *******************************************************************/ + +TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) +{ + FontHeader fontHeader; + TT_Error error; + TT_Instance instance; + TT_Instance_Metrics instanceMetrics; + WWFixedAsDWord scaleFactor; + WWFixedAsDWord ttfElement; + + + ECCheckBounds( (void*)fontBuf ); + + + error = TT_New_Instance( face, &instance ); + if ( error ) + return error; + + error = TT_Set_Instance_CharSize( instance, WBFIXED_TO_FIXED26DOT6( pointSize ) ); + if ( error ) + return error; + + error = TT_Get_Instance_Metrics( instance, &instanceMetrics ); + if ( error ) + return error; + + error = fillFontHeader( face, instance, &fontHeader ); + if ( error ) + return error; + + scaleFactor = instanceMetrics.x_scale; + + /* Fill elements in FontBuf structure. */ + + fontBuf->FB_maker = FM_TRUETYPE; + fontBuf->FB_kernPairPtr = 0; + fontBuf->FB_kernValuePtr = 0; + fontBuf->FB_kernCount = 0; + fontBuf->FB_heapCount = 0; + fontBuf->FB_flags = FBF_IS_OUTLINE; + + ttfElement = SCALE_WORD( fontHeader.FH_minLSB, scaleFactor ); + fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_avgwidth, scaleFactor ); + fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_maxwidth, scaleFactor ); + fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + +#ifndef DBCS_PCGEOS + ttfElement = SCALE_WORD( fontHeader.FH_maxRSB, scaleFactor ); + fontBuf->FB_maxRSB = ROUND_WWFIXEDASDWORD( ttfElement ); +#endif /* DBCS_PCGEOS */ + + scaleFactor = instanceMetrics.y_scale; + + ttfElement = SCALE_WORD( fontHeader.FH_height, scaleFactor ); + fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + /* FB_heightAdjust = pointSize - FH_height */ + ttfElement = WBFIXED_TO_WWFIXEDASDWORD( pointSize ) - + WORD_TO_WWFIXEDASDWORD( fontHeader.FH_height ); + fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_pixHeight = ROUND_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_baseAdjust, scaleFactor ); + fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ROUND_WWFIXEDASDWORD( ttfElement ) ); + fontBuf->FB_baseAdjust.WBF_frac = 0; + + ttfElement = SCALE_WORD( fontHeader.FH_minTSB, scaleFactor ); + fontBuf->FB_aboveBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_aboveBox.WBF_frac = 0; + fontBuf->FB_minTSB = CEIL_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_pixHeight += CEIL_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_maxBSB, scaleFactor ); + fontBuf->FB_belowBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_belowBox.WBF_frac = 0; +#ifdef SBCS_PCGEOS + fontBuf->FB_maxBSB = CEIL_WWFIXEDASDWORD( ttfElement ); +#endif /* SBCS_PCGEOS */ + + ttfElement = SCALE_WORD( fontHeader.FH_underPos, scaleFactor ); + fontBuf->FB_underPos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_underPos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_underThick, scaleFactor ); + fontBuf->FB_underThickness.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_underThickness.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_strikePos, scaleFactor ); + fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_x_height, scaleFactor ); + fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_descent, scaleFactor ); + fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader.FH_accent, scaleFactor ); + fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + /* baslinepos = accent + ascent */ + ttfElement = SCALE_WORD( fontHeader.FH_ascent + fontHeader.FH_accent, scaleFactor ); + fontBuf->FB_baselinePos.WBF_int = ROUND_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_baselinePos.WBF_frac = 0; + + /* Nimbus fonts and TrueType fonts has no external leading */ + fontBuf->FB_extLeading.WBF_int = 0; + fontBuf->FB_extLeading.WBF_frac = 0; + + fontBuf->FB_firstChar = fontHeader.FH_firstChar; + fontBuf->FB_lastChar = fontHeader.FH_lastChar; + fontBuf->FB_defaultChar = fontHeader.FH_defaultChar; + + TT_Done_Instance( instance ); + + return TT_Err_Ok; +} + +TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) +{ + TT_CharMap charMap; + TT_Error error; + TT_UShort charIndex; + TT_Glyph glyph; + TT_Glyph_Metrics metrics; + TT_Face_Properties faceProperties; + word geosChar; + word unitsPerEM; + sword maxAccentOrAscent; + + + error = getCharMap( face, &charMap ); + if ( error != TT_Err_Ok ) + return error; + + /* initialize min, max and avg values in fontHeader */ + fontHeader->FH_minLSB = 9999; + fontHeader->FH_maxBSB = -9999; + fontHeader->FH_minTSB = -9999; + fontHeader->FH_maxRSB = -9999; + fontHeader->FH_avgwidth = 0; + + fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, + &fontHeader->FH_firstChar, + &fontHeader->FH_lastChar ); + + for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) + { + word unicode = GeosCharToUnicode( geosChar ); + + charIndex = TT_Char_Index( charMap, unicode ); + if ( charIndex == 0 ) + break; + + /* load glyph without scaling or hinting */ + TT_New_Glyph( face, &glyph ); + TT_Load_Glyph( instance, glyph, charIndex, 0 ); + TT_Get_Glyph_Metrics( glyph, &metrics ); + + //h_height + if( unicode == C_LATIN_CAPITAL_LETTER_H ) + fontHeader->FH_h_height = metrics.bbox.yMax; + + //x_height + if ( unicode == C_LATIN_SMALL_LETTER_X ) + fontHeader->FH_x_height = metrics.bbox.yMax; + + //ascender + if ( unicode == C_LATIN_SMALL_LETTER_D ) + fontHeader->FH_ascender = metrics.bbox.yMax; + + //descender + if ( unicode == C_LATIN_SMALL_LETTER_P ) + fontHeader->FH_descender = metrics.bbox.yMin; + + //width + if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) + fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; + + //avg width + if ( GeosAvgWidth( geosChar ) ) + { + fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( + ( metrics.bbox.xMax - metrics.bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); + } + + /* scan xMin */ + if( fontHeader->FH_minLSB > metrics.bbox.xMin ) + fontHeader->FH_minLSB = (sword) metrics.bbox.xMin; + + /* scan xMax */ + if ( fontHeader->FH_maxRSB < metrics.bbox.xMax ) + fontHeader->FH_maxRSB = metrics.bbox.xMax; + /* scan yMin */ + if ( fontHeader->FH_maxBSB < metrics.bbox.yMin ) + fontHeader->FH_maxBSB = metrics.bbox.yMin; + + //yMax + if ( fontHeader->FH_minTSB < metrics.bbox.yMax ) + { + fontHeader->FH_minTSB = metrics.bbox.yMax; + if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT && + fontHeader->FH_accent < metrics.bbox.yMax ) + fontHeader->FH_accent = metrics.bbox.yMax; + } + } + + TT_Get_Face_Properties( face, &faceProperties ); + unitsPerEM = faceProperties.header->Units_Per_EM; + + //baseline + if ( fontHeader->FH_accent <= 0 ) + { + fontHeader->FH_accent = 0; + maxAccentOrAscent = fontHeader->FH_ascent; + } + else + { + maxAccentOrAscent = fontHeader->FH_accent; + fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; + } + + fontHeader->FH_baseAdjust = BASELINE( unitsPerEM )- maxAccentOrAscent; + fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; + fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( unitsPerEM ); + fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( unitsPerEM ) - + SAFETY( unitsPerEM ) ); + + fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; + if( fontHeader->FH_underPos == 0 ) + fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( unitsPerEM ); + + fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; + + fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; + if( fontHeader->FH_underThick == 0 ) + fontHeader->FH_underThick = DEFAULT_UNDER_THICK( unitsPerEM ); + + if( fontHeader->FH_x_height > 0 ) + fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; + else + fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; + + fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( unitsPerEM ); + + + return TT_Err_Ok; +} \ No newline at end of file diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 2363a7cd8..4ebb68381 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -14,7 +14,7 @@ * 20/12/22 JK Initial version * * DESCRIPTION: - * Declarations of types and functions for the driver function + * Declarations of types and functions for the driver function * DR_FONT_GEN_WIDTHS. ***********************************************************************/ @@ -22,6 +22,53 @@ #define _TTWIDTHS_H_ #include "../FreeType/freetype.h" +#include "ttadapter.h" + + +/* + * Structure to hold information necessary to fill FontBuf structure. + */ +typedef struct +{ + word FH_h_height; //top of 'H' + word FH_x_height; //top of 'x' + word FH_ascender; //top of 'd' + sword FH_descender; //bottom of 'p' + word FH_avgwidth; //average character width + word FH_maxwidth; //widest character width + word FH_height; //height of font box + sword FH_accent; //height of accents + word FH_ascent; //height of caps + sword FH_descent; //descent (from baseline) + sword FH_baseAdjust; //adjustment for baseline + word FH_firstChar; //first char defined + word FH_lastChar; //last char defined + word FH_defaultChar; //default character + sword FH_underPos; //position of underline + sword FH_underThick; //thickness of underline + word FH_strikePos; //position of strikethrough + word FH_numChars; //number of characters + sword FH_minLSB; //minimum left side bearing + sword FH_minTSB; //minimum top side bound + sword FH_maxBSB; //maximum bottom side bound + sword FH_maxRSB; //maximum right side bound + sword FH_continuitySize; //continuity cutoff +} FontHeader; + + + +/* + * constants for calculating values in FontHeader + */ +#define DEFAULT_CONTINUITY_CUTOFF( value ) ( value / 40 ) // 2.5% of size +#define DEFAULT_DEFAULT_CHAR '.' +#define BASELINE( value ) ( 3 * value / 4 ) // 75% of size +#define DESCENT( value ) ( value / 4 ) // 25% of size +#define DEFAULT_UNDER_THICK( value ) ( value / 10 ) // 10% of size +#define DEFAULT_UNDER_POSITION( value ) ( value / -10 ) // -10% of size +#define SAFETY( value ) ( value / 40 ) // 2.5% of size + + /*********************************************************************** @@ -35,6 +82,14 @@ void _pascal TrueType_Gen_Widths(); * internal functions ***********************************************************************/ +TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, + word character, + CharTableEntry* charTableEntry ); + +TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ); + +TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); + word GetNumKernPairs( TT_Face face); void ConvertHeader(); diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index f6b1a81af..31f3c0047 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -9,8 +9,9 @@ MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ truetypeInit.asm truetypeEC.asm truetypeChars.asm\ truetypePath.asm truetypeMacros.def truetypeVariable.def\ truetypeConstant.def -ADAPTER = ttinit.c ttcharmapper.c ttadapter.c ttwidths.c\ - ttcharmapper.h ttwidths.h ttinit.h ttadapter.h +ADAPTER = ttinit.c ttmetrics.c ttcharmapper.c ttwidths.c\ + ttcharmapper.h ttwidths.h ttinit.h ttmetrics.h\ + ttadapter.h FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ @@ -19,7 +20,7 @@ FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h UI_TO_RDFS = -OBJS = ttinit.obj ttcharmapper.obj ttadapter.obj ttwidths.obj\ +OBJS = ttinit.obj ttmetrics.obj ttcharmapper.obj ttwidths.obj\ ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ ttextend.obj ttcalc.obj ttapi.obj ftxkern.obj\ ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index f3fe2f3e3..a1f4b6870 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -14,15 +14,18 @@ Main.eobj: Main/mainManager.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm ttinit.obj \ -ttinit.eobj: Adapter/ttinit.h geos.h Adapter/../FreeType/freetype.h \ +ttinit.eobj: Adapter/ttinit.h geos.h fontID.h font.h graphics.h color.h \ + Adapter/../FreeType/freetype.h \ Adapter/../FreeType/fterrid.h \ - Adapter/../FreeType/ftnameid.h fileEnum.h file.h heap.h \ - ec.h -ttcharmapper.obj \ -ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h unicode.h -ttadapter.obj \ -ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ + Adapter/../FreeType/ftnameid.h Adapter/ttadapter.h ec.h \ + file.h Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h heap.h lmem.h \ + Ansi/stdlib.h Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h fileEnum.h +ttmetrics.obj \ +ttmetrics.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/freetype.h \ Adapter/../FreeType/fterrid.h \ Adapter/../FreeType/ftnameid.h \ @@ -32,13 +35,23 @@ ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/ft_conf.h resource.h graphics.h \ font.h color.h heap.h lmem.h Ansi/stdlib.h \ Adapter/../FreeType/ttmutex.h \ - Adapter/../FreeType/ttcalc.h Adapter/ttcharmapper.h \ - FreeType/freetype.h + Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h +ttcharmapper.obj \ +ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h unicode.h ttwidths.obj \ -ttwidths.eobj: Adapter/ttwidths.h Adapter/../FreeType/freetype.h \ +ttwidths.eobj: geos.h unicode.h Adapter/ttwidths.h \ + Adapter/../FreeType/freetype.h \ Adapter/../FreeType/fterrid.h \ - Adapter/../FreeType/ftnameid.h geos.h \ - Adapter/../FreeType/ftxkern.h + Adapter/../FreeType/ftnameid.h Adapter/ttadapter.h ec.h \ + fontID.h file.h Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h Adapter/ttcharmapper.h \ + FreeType/freetype.h Adapter/../FreeType/ftxkern.h ttcache.obj \ ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ From cc816256faa00cdd147f4341eaa049b0a7c1fee2 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 23 Dec 2022 21:02:53 +0100 Subject: [PATCH 106/246] add some infos and comments --- Driver/Font/TrueType/Adapter/ttinit.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index d5f7bf993..87a01bf2c 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -310,6 +310,8 @@ TT_Error _pascal Fill_FontInfo( TT_Face face, ECCheckBounds( (void*)fontInfo ); + //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein + // die Implementierung muss damit umgehen können error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); if ( error ) return error; @@ -378,6 +380,8 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, ECCheckBounds( (void*)trueTypeOutlineEntry ); + //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein + // die Implementierung muss damit umgehen können error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); if ( error != TT_Err_Ok ) return error; @@ -503,12 +507,21 @@ static TextStyle mapTextStyle( const char* subfamily ) static Boolean isMappedFont( const char* familiyName ) { + //Idee: + // -für das Fontmapping gibt es einen Abschnitt in der geos.ini [fontmapping] + // -das Mapping kann für einen Font dann so aussehen: + // familiyName = ID des Nimbus-Fonts + // diese Funktion soll prüfen ob es zu familyName einen Eintrag gibt //TODO: implement it return FALSE; } static FontID getMappedFontID( const char* familyName ) { + //Idee: + // -siehe oben + // diese Funktion gibt die FontID zum übergebenen familyName zurück + // wenn der familyName nicht vorhanden ist dann 0 //TODO: implement it //TODO: FontMaker austauschen return (FontID) FID_DTC_URW_SANS; @@ -518,8 +531,10 @@ static Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ) { byte* fontsAvailEntry; - /* set fontsAvailEntry to first Element */ + /* set fontsAvailEntry to first Element after LMemBlock */ fontsAvailEntry = MemDeref( fontInfoBlock ); + + // return FALSE; } From f9003b157cd96f75ae274d8279688d8cdea84788 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 26 Dec 2022 14:54:19 +0100 Subject: [PATCH 107/246] unicode ASCII problem resolved --- Driver/Font/TrueType/Adapter/ttinit.c | 64 ++++++++++++++++++++------- Driver/Font/TrueType/Adapter/ttinit.h | 12 +++++ 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 87a01bf2c..eb50752be 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -163,7 +163,7 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) FileHandle truetypeFile; TT_Face face; TT_Error error; - TT_String* familyName; + char familyName[FID_NAME_LEN]; word familyNameLength; FontID fontID; @@ -180,10 +180,7 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if( error ) goto Fin; - //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein - // die Implementierung muss damit umgehen können - error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); - if ( error != TT_Err_Ok ) + if ( getNameFromNameTable( familyName, face, FAMILY_NAME_INDEX ) == 0 ) goto Fin; if ( isMappedFont( familyName ) ) @@ -303,27 +300,16 @@ TT_Error _pascal Fill_FontInfo( TT_Face face, { TT_Error error; TT_Face_Properties faceProperties; - TT_String* familyName; - word familyNameLength; ECCheckBounds( (void*)fontInfo ); - //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein - // die Implementierung muss damit umgehen können - error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); - if ( error ) - return error; - - if ( familyNameLength >= FAMILY_NAME_LENGTH ) - return TT_Err_Invalid_Argument; - error = TT_Get_Face_Properties( face, &faceProperties ); if ( error ) return error; - strcpy( fontInfo->FI_faceName, familyName ); + getNameFromNameTable( fontInfo->FI_faceName, face, FAMILY_NAME_INDEX ); fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); fontInfo->FI_fontID = fontID; @@ -538,6 +524,50 @@ static Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ) return FALSE; } +static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex ) +{ + TT_Face_Properties faceProperties; + TT_UShort platformID; + TT_UShort encodingID; + TT_UShort languageID; + word nameLength; + word i, n; + char* str; + + + TT_Get_Face_Properties( face, &faceProperties ); + + for( n = 0; n < faceProperties.num_Names; n++ ) + { + TT_Get_Name_ID( face, n, nameIndex, platformID, encodingID, languageID ); + + if( platformID == PLATFORM_ID_MS && + encodingID == ENCODING_ID_MS_UNICODE_BMP && + languageID == LANGUAGE_ID_WIN_EN_US ) + { + TT_Get_Name_String( face, n, &str, &nameLength ); + + for (i = 1; str != 0 && i < nameLength; i += 2) + *name++ = str[i]; + *name = 0; + return nameLength >> 1; + } + else if( platformID == PLATFORM_ID_MAC && + encodingID == ENCODING_ID_MAC_ROMAN && + languageID == LANGUAGE_ID_MAC_EN ) + { + TT_Get_Name_String( face, n, &str, &nameLength ); + + for (i = 1; str != 0 && i < nameLength; i ++) + *name++ = str[i]; + *name = 0; + return nameLength; + } + } + + return 0; +} + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 21db817b0..23744d15d 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -44,6 +44,16 @@ #define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) +#define PLATFORM_ID_MAC 1 +#define PLATFORM_ID_MS 3 + +#define ENCODING_ID_MAC_ROMAN 0 +#define ENCODING_ID_MS_UNICODE_BMP 1 + +#define LANGUAGE_ID_MAC_EN 0 +#define LANGUAGE_ID_WIN_EN_US 0x0409 + + /*********************************************************************** * functions called by driver ***********************************************************************/ @@ -69,6 +79,8 @@ static FontWeight mapFontWeight( TT_Short weightClass ); static TextStyle mapTextStyle( const char* subfamily ); +static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex ); + static int toHash( const char* str ); static int strlen( const char* str ); From e2ad27516ff3079435a1ebaf6d874ad00d35f21f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 26 Dec 2022 15:03:57 +0100 Subject: [PATCH 108/246] add forgotten --- Driver/Font/TrueType/Adapter/ttinit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index eb50752be..5dffdd95f 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -524,13 +524,14 @@ static Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ) return FALSE; } -static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex ) +static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Face_Properties faceProperties; TT_UShort platformID; TT_UShort encodingID; TT_UShort languageID; word nameLength; + word id; word i, n; char* str; @@ -539,7 +540,9 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex for( n = 0; n < faceProperties.num_Names; n++ ) { - TT_Get_Name_ID( face, n, nameIndex, platformID, encodingID, languageID ); + TT_Get_Name_ID( face, n, &platformID, &encodingID, &languageID, &id ); + if( id != nameID ) + continue; if( platformID == PLATFORM_ID_MS && encodingID == ENCODING_ID_MS_UNICODE_BMP && From bd9dabed7ad1d866a0c202b1d520ebf5e54b1d1d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 26 Dec 2022 19:05:55 +0100 Subject: [PATCH 109/246] implement fontmappe via geos.ini --- Driver/Font/TrueType/Adapter/ttinit.c | 45 ++++++++++++--------------- Driver/Font/TrueType/Adapter/ttinit.h | 20 ++++++------ 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 5dffdd95f..ff065c94d 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -183,9 +183,7 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if ( getNameFromNameTable( familyName, face, FAMILY_NAME_INDEX ) == 0 ) goto Fin; - if ( isMappedFont( familyName ) ) - fontID = getMappedFontID( familyName ); - else + if ( !isMappedFont( familyName, &fontID ) ) fontID = MAKE_FONTID( familyName ); if ( !isRegistredFontID( fontID, fontInfoBlock ) ) @@ -491,36 +489,33 @@ static TextStyle mapTextStyle( const char* subfamily ) return TS_BOLD | TS_ITALIC; } -static Boolean isMappedFont( const char* familiyName ) +static Boolean isMappedFont( const char* familiyName, FontID* fontID ) { - //Idee: - // -für das Fontmapping gibt es einen Abschnitt in der geos.ini [fontmapping] - // -das Mapping kann für einen Font dann so aussehen: - // familiyName = ID des Nimbus-Fonts - // diese Funktion soll prüfen ob es zu familyName einen Eintrag gibt - //TODO: implement it - return FALSE; -} + Boolean result; -static FontID getMappedFontID( const char* familyName ) -{ - //Idee: - // -siehe oben - // diese Funktion gibt die FontID zum übergebenen familyName zurück - // wenn der familyName nicht vorhanden ist dann 0 - //TODO: implement it - //TODO: FontMaker austauschen - return (FontID) FID_DTC_URW_SANS; + result = !InitFileReadInteger( FONTMAPPING_CATEGORY, + familiyName, + fontID ); + + //ensure FM_TRUETYPE is set + *fontID = FM_TRUETYPE || (*fontID && 0x0fff); + return result; } static Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ) { - byte* fontsAvailEntry; + FontsAvailEntry* fontsAvailEntrys; + word elements; + word element; + + /* set fontsAvailEntrys to first Element after LMemBlockHeader */ + fontsAvailEntrys = ( (byte*)MemDeref( fontInfoBlock ) + sizeof( LMemBlockHeader ) ); + elements = LMemGetChunkSizePtr( fontsAvailEntrys ) / sizeof( FontsAvailEntry ); - /* set fontsAvailEntry to first Element after LMemBlock */ - fontsAvailEntry = MemDeref( fontInfoBlock ); + for( element = 0; element < elements; element++ ) + if( fontsAvailEntrys[element].FAE_fontID == fontID ) + return TRUE; - // return FALSE; } diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 23744d15d..56b680f88 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -32,16 +32,18 @@ * constants ***********************************************************************/ -#define TTF_DIRECTORY "TTF" -#define FAMILY_NAME_INDEX 1 // font family name -#define STYLE_NAME_INDEX 2 // font style +#define TTF_DIRECTORY "TTF" +#define FONTMAPPING_CATEGORY "FontMapping" -#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE +#define FAMILY_NAME_INDEX 1 // font family name +#define STYLE_NAME_INDEX 2 // font style -#define FAMILY_NAME_LENGTH 20 -#define STYLE_NAME_LENGTH 16 +#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE -#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) +#define FAMILY_NAME_LENGTH 20 +#define STYLE_NAME_LENGTH 16 + +#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) #define PLATFORM_ID_MAC 1 @@ -64,9 +66,7 @@ TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ); Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ); -Boolean isMappedFont( const char* familiyName ); - -FontID getMappedFontID( const char* familyName ); +static Boolean isMappedFont( const char* familiyName, FontID* font ); /*********************************************************************** From c504d895cebeabc0969a3a93c296408bc8d2c2f8 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Tue, 27 Dec 2022 21:31:43 +0100 Subject: [PATCH 110/246] Implementated asm to adapter.c stubs for the first set of truetype driver functions. #129 --- Driver/Font/TrueType/Adapter/ttinit.c | 1 + Driver/Font/TrueType/Adapter/ttinit.h | 1 + Driver/Font/TrueType/Adapter/ttmetrics.c | 7 +- Driver/Font/TrueType/Adapter/ttmetrics.h | 7 +- Driver/Font/TrueType/Adapter/ttwidths.c | 8 +- Driver/Font/TrueType/Adapter/ttwidths.h | 7 +- Driver/Font/TrueType/Main/mainManager.asm | 6 +- Driver/Font/TrueType/Main/truetypeChars.asm | 26 ++- .../Font/TrueType/Main/truetypeConstant.def | 3 + Driver/Font/TrueType/Main/truetypeInit.asm | 18 +- Driver/Font/TrueType/Main/truetypeMetrics.asm | 26 +++ Driver/Font/TrueType/Main/truetypeWidths.asm | 16 ++ Installed/Driver/Font/TrueType/Makefile | 42 ++-- .../Driver/Font/TrueType/dependencies.mk | 220 ++++++------------ 14 files changed, 205 insertions(+), 183 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index ff065c94d..43983677a 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -24,6 +24,7 @@ #include #include #include +#include /******************************************************************** diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 56b680f88..5a43b63dc 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -26,6 +26,7 @@ #include #include #include "../FreeType/freetype.h" +#include "ttadapter.h" /*********************************************************************** diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 5c3355576..98b2e0f45 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -21,7 +21,7 @@ #include "ttmetrics.h" /******************************************************************** - * Get_Char_Metrics + * TrueType_Char_Metrics ******************************************************************** * SYNOPSIS: Returns the metics of the given char. * @@ -53,9 +53,10 @@ * 23/12/22 JK Initial Revision * *******************************************************************/ -TT_Error _pascal Get_Char_Metrics( const FontInfo* fontInfo, - GStateHandle gstate, +TT_Error _pascal TrueType_Char_Metrics( word character, + const FontInfo* fontInfo, + void* gstatePtr, GCM_info info, dword* result ) { diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.h b/Driver/Font/TrueType/Adapter/ttmetrics.h index 35a15aa58..d82e31b34 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.h +++ b/Driver/Font/TrueType/Adapter/ttmetrics.h @@ -21,10 +21,11 @@ #define _TTMETRICS_H_ -TT_Error _pascal Get_Char_Metrics( const FontInfo* fontInfo, - GStateHandle gstate, +TT_Error _pascal TrueType_Char_Metrics( word character, + const FontInfo* fontInfo, + void* gstatePtr, GCM_info info, dword* result ); -#endif _TTMETRICS_H_ \ No newline at end of file +#endif _TTMETRICS_H_ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 54e7e91b9..719a1a138 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -45,7 +45,11 @@ * 20/12/22 JK Initial Revision *******************************************************************/ -void _pascal TrueType_Gen_Widths( ) +MemHandle _pascal TrueType_Gen_Widths( + MemHandle fontHandle, + void* gstatePtr, + void* tMaxtrix, + const FontInfo* fontInfo ) { word numKernPairs; word numCharacters; @@ -54,7 +58,7 @@ void _pascal TrueType_Gen_Widths( ) //Anzahl KernPairs ermitteln //Anzahl der Zeichen ermitteln - + return fontHandle; } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 4ebb68381..5b644f5e9 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -75,7 +75,12 @@ typedef struct * functions called by driver ***********************************************************************/ -void _pascal TrueType_Gen_Widths(); +MemHandle _pascal TrueType_Gen_Widths( + MemHandle fontHandle, + void* gstatePtr, + void* tMaxtrix, + const FontInfo* fontInfo +); /*********************************************************************** diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index d9d8c5af4..b49dc0913 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -111,9 +111,13 @@ NimbusStart label near AA_NIMBUS_SIZE equ $-NimbusStart CharMod ends -;routines form GEOS adapter +;routines from GEOS adapter global INIT_FREETYPE:far global EXIT_FREETYPE:far +global TRUETYPE_INITFONTS:far +global TRUETYPE_GEN_CHARS:far +global TRUETYPE_CHAR_METRICS:far +global TRUETYPE_GEN_WIDTHS:far global engineInstance:TrueTypeEngineInstance diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 4f5ecbdda..fea6a8ac5 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -53,9 +53,31 @@ TrueTypeGenChar proc far uses ax, bx, cx, dx, ds, si, di, bp .enter - + segmov cx, es + call MemSegmentToHandle + jnc err + + push cx ; remember handle + + push dx ; pass character code + push es ; pass font ptr + mov ax, 0 ; with segment offset 0 + push ax + push bp ; pass gstate ptr + push ax ; with segment offset 0 + push ds ; pass font info block + push ax ; with segment offset 0 + + segmov ds, dgroup, ax + call TRUETYPE_GEN_CHARS + + ; deref font block (may have moved) + pop bx + call MemDerefES + +err: + clc .leave - stc ;indicate no error ret TrueTypeGenChar endp diff --git a/Driver/Font/TrueType/Main/truetypeConstant.def b/Driver/Font/TrueType/Main/truetypeConstant.def index 942764157..2b58e8a71 100644 --- a/Driver/Font/TrueType/Main/truetypeConstant.def +++ b/Driver/Font/TrueType/Main/truetypeConstant.def @@ -59,6 +59,9 @@ TRANSFORM_STYLES = mask TS_SUPERSCRIPT or \ ; Miscellaneous constants ;---------------------------------------------------------------------------- + +;USE_OLD_FONT_LOADER = 1 + DEFAULT_CHAR = '.' ; diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index a1765019b..16a5e228e 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -176,7 +176,20 @@ initFontReturnAttr FileExtAttrDesc \ TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp .enter +ifndef USE_OLD_FONT_LOADER + segmov cx, ds + call MemSegmentToHandle + jnc err + push ds + + push cx ; handle to font info block + segmov ds, dgroup, cx + call TRUETYPE_INITFONTS + + pop ds +err: +else ; ; Enumerate files in SP_FONT ; @@ -220,13 +233,15 @@ fontLoop: call MemFree ; free file block done: call FilePopDir +endif clc + .leave ret TrueTypeInitFonts endp - +ifdef USE_OLD_FONT_LOADER COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ProcessFont %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -986,3 +1001,4 @@ notFound: jmp done MapFontStyle endp +endif diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index 647b96c0d..af12ea3f9 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -56,8 +56,34 @@ REVISION HISTORY: TrueTypeCharMetrics proc far uses bx, cx, si, di, ds + +resultAXDX local dword + .enter + push dx ; character code + push ds ; ptr to fontInfo + mov bx, 0 ; segment offset 0 + push bx + push es ; ptr to gstate + push bx ; segment offset 0 + push cx ; GCM_info + + push ss ; pass ptr to result dword in ss + lea cx, resultAXDX + push cx + + segmov ds, dgroup, cx + call TRUETYPE_CHAR_METRICS + + clc + cmp ax, 0 + jnc ok + stc +ok: + mov ax, {word} resultAXDX + mov dx, {word} resultAXDX+2 + .leave ret TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index df274e67b..ea7f9279f 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -61,6 +61,22 @@ TrueTypeGenWidths proc far mov bx, bp .enter + + push di ; font handle or 0 + push es ; pass gstate ptr + mov dx, 0 ; with segment offset 0 + push dx + push bx ; send tMatrix ptr + push cx + push ds ; pass font info ptr + push dx ; segment offset 0 + + segmov ds, dgroup, dx + call TRUETYPE_GEN_WIDTHS + + mov bx, ax ; mov font hdl to bx + call MemDerefDS + segmov ax, ds clc ;indicate no error diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 31f3c0047..9203697b6 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,31 +4,31 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ - truetypeWidths.asm ansic_memory.asm truetypeMetrics.asm\ - truetypeInit.asm truetypeEC.asm truetypeChars.asm\ - truetypePath.asm truetypeMacros.def truetypeVariable.def\ - truetypeConstant.def -ADAPTER = ttinit.c ttmetrics.c ttcharmapper.c ttwidths.c\ - ttcharmapper.h ttwidths.h ttinit.h ttmetrics.h\ - ttadapter.h -FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ - ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h ttinterp.h\ - ttload.h tttables.h ttobjs.h fterrid.h ttraster.h\ - ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ - ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h +ADAPTER = ttcharmapper.c ttchars.c ttinit.c ttmetrics.c ttpath.c\ + ttwidths.c ttadapter.h ttcharmapper.h ttinit.h\ + ttmetrics.h ttwidths.h +FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttextend.c\ + ttfile.c ttgload.c ttinterp.c ttload.c ttmemory.c\ + ttmutex.c ttobjs.c ttraster.c freetype.h fterrid.h\ + ftnameid.h ftxkern.h ft_conf.h ttcache.h ttcalc.h\ + ttcmap.h ttconfig.h ttengine.h ttextend.h ttfile.h\ + ttgload.h ttinterp.h ttload.h ttmemory.h ttmutex.h\ + ttobjs.h ttraster.h tttables.h tttags.h tttypes.h +MAIN = ansic_memory.asm ansic_runtime.asm mainManager.asm\ + truetypeChars.asm truetypeEC.asm truetypeEscape.asm\ + truetypeInit.asm truetypeMetrics.asm truetypePath.asm\ + truetypeWidths.asm truetypeConstant.def\ + truetypeMacros.def truetypeVariable.def UI_TO_RDFS = -OBJS = ttinit.obj ttmetrics.obj ttcharmapper.obj ttwidths.obj\ - ttcache.obj ttraster.obj ttmutex.obj ttgload.obj\ - ttextend.obj ttcalc.obj ttapi.obj ftxkern.obj\ - ttinterp.obj ttload.obj ttfile.obj ttcmap.obj ttobjs.obj\ - ttmemory.obj +OBJS = ttcharmapper.obj ttchars.obj ttinit.obj ttmetrics.obj\ + ttpath.obj ttwidths.obj ftxkern.obj ttapi.obj ttcache.obj\ + ttcalc.obj ttcmap.obj ttextend.obj ttfile.obj ttgload.obj\ + ttinterp.obj ttload.obj ttmemory.obj ttmutex.obj\ + ttobjs.obj ttraster.obj COMMON = MODULES = Main CMODULES = Adapter FreeType -SRCS = $(MAIN) $(ADAPTER) $(FREETYPE) $(COMMON) +SRCS = $(ADAPTER) $(FREETYPE) $(MAIN) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index a1f4b6870..dcd60a5b5 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -13,163 +13,85 @@ Main.eobj: Main/mainManager.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm +ttcharmapper.obj \ +ttcharmapper.eobj: +ttchars.obj \ +ttchars.eobj: ttinit.obj \ -ttinit.eobj: Adapter/ttinit.h geos.h fontID.h font.h graphics.h color.h \ - Adapter/../FreeType/freetype.h \ - Adapter/../FreeType/fterrid.h \ - Adapter/../FreeType/ftnameid.h Adapter/ttadapter.h ec.h \ - file.h Adapter/../FreeType/ttengine.h \ - Adapter/../FreeType/tttypes.h \ - Adapter/../FreeType/ttconfig.h \ - Adapter/../FreeType/ft_conf.h resource.h heap.h lmem.h \ - Ansi/stdlib.h Adapter/../FreeType/ttmutex.h \ - Adapter/../FreeType/ttcalc.h fileEnum.h +ttinit.eobj: ttmetrics.obj \ -ttmetrics.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ - Adapter/../FreeType/freetype.h \ - Adapter/../FreeType/fterrid.h \ - Adapter/../FreeType/ftnameid.h \ - Adapter/../FreeType/ttengine.h \ - Adapter/../FreeType/tttypes.h \ - Adapter/../FreeType/ttconfig.h \ - Adapter/../FreeType/ft_conf.h resource.h graphics.h \ - font.h color.h heap.h lmem.h Ansi/stdlib.h \ - Adapter/../FreeType/ttmutex.h \ - Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h -ttcharmapper.obj \ -ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h unicode.h +ttmetrics.eobj: +ttpath.obj \ +ttpath.eobj: ttwidths.obj \ -ttwidths.eobj: geos.h unicode.h Adapter/ttwidths.h \ - Adapter/../FreeType/freetype.h \ - Adapter/../FreeType/fterrid.h \ - Adapter/../FreeType/ftnameid.h Adapter/ttadapter.h ec.h \ - fontID.h file.h Adapter/../FreeType/ttengine.h \ - Adapter/../FreeType/tttypes.h \ - Adapter/../FreeType/ttconfig.h \ - Adapter/../FreeType/ft_conf.h resource.h graphics.h \ - font.h color.h heap.h lmem.h Ansi/stdlib.h \ - Adapter/../FreeType/ttmutex.h \ - Adapter/../FreeType/ttcalc.h Adapter/ttcharmapper.h \ - FreeType/freetype.h Adapter/../FreeType/ftxkern.h +ttwidths.eobj: +ftxkern.obj \ +ftxkern.eobj: +ttapi.obj \ +ttapi.eobj: ttcache.obj \ -ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ - FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ - fontID.h font.h color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmutex.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ - FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h -ttraster.obj \ -ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttengine.h \ - FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ - FreeType/ttmemory.h Ansi/string.h -ttmutex.obj \ -ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h -ttgload.obj \ -ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttcalc.h FreeType/ttfile.h \ - FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/tttags.h FreeType/ttload.h -ttextend.obj \ -ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ - FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h +ttcache.eobj: ttcalc.obj \ -ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/tttables.h \ - FreeType/tttypes.h -ttapi.obj \ -ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h graphics.h fontID.h font.h color.h heap.h \ - lmem.h ec.h Ansi/stdlib.h FreeType/freetype.h \ - FreeType/fterrid.h FreeType/ftnameid.h \ - FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttcache.h FreeType/ttfile.h FreeType/ttobjs.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttload.h \ - FreeType/ttgload.h FreeType/ttraster.h \ - FreeType/ttextend.h -ftxkern.obj \ -ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h geos.h FreeType/ttextend.h \ - FreeType/ttconfig.h FreeType/ft_conf.h file.h resource.h \ - graphics.h fontID.h font.h color.h heap.h lmem.h ec.h \ - Ansi/stdlib.h FreeType/tttypes.h FreeType/ttobjs.h \ - FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttmemory.h \ - Ansi/string.h FreeType/ttfile.h FreeType/ttload.h \ - FreeType/tttags.h +ttcalc.eobj: +ttcmap.obj \ +ttcmap.eobj: +ttextend.obj \ +ttextend.eobj: +ttfile.obj \ +ttfile.eobj: +ttgload.obj \ +ttgload.eobj: ttinterp.obj \ -ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ - geos.h FreeType/tttypes.h FreeType/ttconfig.h \ - FreeType/ft_conf.h file.h resource.h graphics.h fontID.h \ - font.h color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ - FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ - FreeType/ttcmap.h +ttinterp.eobj: ttload.obj \ -ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttcalc.h FreeType/ttfile.h \ - FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ - FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/tttags.h FreeType/ttload.h -ttfile.obj \ -ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ - resource.h graphics.h fontID.h font.h color.h heap.h \ - lmem.h ec.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/tttypes.h \ - FreeType/ttengine.h FreeType/ttmutex.h \ - FreeType/ttmemory.h FreeType/ttfile.h -ttcmap.obj \ -ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ - FreeType/ttmemory.h Ansi/string.h FreeType/ttload.h +ttload.eobj: +ttmemory.obj \ +ttmemory.eobj: +ttmutex.obj \ +ttmutex.eobj: ttobjs.obj \ -ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/ttengine.h FreeType/tttypes.h \ - FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ - FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ - FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ - FreeType/ttload.h FreeType/ttinterp.h FreeType/ttextend.h +ttobjs.eobj: +ttraster.obj \ +ttraster.eobj: +ttcharmapper.obj \ +ttcharmapper.eobj: +ttchars.obj \ +ttchars.eobj: +ttinit.obj \ +ttinit.eobj: +ttmetrics.obj \ +ttmetrics.eobj: +ttpath.obj \ +ttpath.eobj: +ttwidths.obj \ +ttwidths.eobj: +ftxkern.obj \ +ftxkern.eobj: +ttapi.obj \ +ttapi.eobj: +ttcache.obj \ +ttcache.eobj: +ttcalc.obj \ +ttcalc.eobj: +ttcmap.obj \ +ttcmap.eobj: +ttextend.obj \ +ttextend.eobj: +ttfile.obj \ +ttfile.eobj: +ttgload.obj \ +ttgload.eobj: +ttinterp.obj \ +ttinterp.eobj: +ttload.obj \ +ttload.eobj: ttmemory.obj \ -ttmemory.eobj: FreeType/ttmemory.h FreeType/ttconfig.h FreeType/ft_conf.h \ - geos.h file.h resource.h graphics.h fontID.h font.h \ - color.h heap.h lmem.h ec.h Ansi/stdlib.h \ - FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ - FreeType/ftnameid.h Ansi/string.h FreeType/ttengine.h \ - FreeType/ttmutex.h +ttmemory.eobj: +ttmutex.obj \ +ttmutex.eobj: +ttobjs.obj \ +ttobjs.eobj: +ttraster.obj \ +ttraster.eobj: truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file From bff4cea8aad5a091a57487eb1f18b22757458828 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Tue, 27 Dec 2022 21:32:27 +0100 Subject: [PATCH 111/246] Added more adapter files. #129 --- Driver/Font/TrueType/Adapter/ttchars.c | 61 +++++++++++++++++++++ Driver/Font/TrueType/Adapter/ttpath.c | 74 ++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 Driver/Font/TrueType/Adapter/ttchars.c create mode 100644 Driver/Font/TrueType/Adapter/ttpath.c diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c new file mode 100644 index 000000000..8d86dcf6d --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -0,0 +1,61 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttchars.c + * + * AUTHOR: Jirka Kunze: December 23 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial version + * + * DESCRIPTION: + * Definition of driver function DR_FONT_GEN_CHARS. + ***********************************************************************/ + +#include "ttadapter.h" +#include "ttmetrics.h" + +/******************************************************************** + * TrueType_Gen_Chars + ******************************************************************** + * SYNOPSIS: Generate one character for a font. + * + * PARAMETERS: character character to build (Chars) + * fontBuf Ptr to font data structure. + * fontInfo Pointer to FontInfo structure. + * gstatePtr Handle to current gstate. + * + * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * + * SIDE EFFECTS: none + * + * CONDITION: The current directory must be the ttf font directory. + * + * STRATEGY: - find font-file for the requested style from fontInfo + * - open outline of character in founded font-file + * - calculate requested metrics and return it + * + * TODO: If we want to support fake styles, this must also + * be implemented here. + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 23/12/22 JK Initial Revision + * + *******************************************************************/ +TT_Error _pascal TrueType_Gen_Chars( + word character, + void* fontBuf, + const FontInfo* fontInfo, + void* gstatePtr + ) +{ + /* Api-Funktion für DR_FONT_GEN_CHARS */ + return TT_Err_Ok; +} \ No newline at end of file diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c new file mode 100644 index 000000000..81973ff50 --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -0,0 +1,74 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttpath.c + * + * AUTHOR: Jirka Kunze: December 23 2022 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial version + * + * DESCRIPTION: + * Definition of driver function DR_FONT_CHAR_METRICS. + ***********************************************************************/ + +#include "ttadapter.h" + + +/******************************************************************** + * TrueType_Gen_Path + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void _pascal TrueType_Gen_Path( ) +{ + +} + + +/******************************************************************** + * TrueType_Gen_In_Region + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + +void _pascal TrueType_Gen_In_Region( ) +{ + +} From 69abbc237f613549f80700b852848e074eb05e02 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 27 Dec 2022 22:42:29 +0100 Subject: [PATCH 112/246] Correct mistake in ttinit.c --- Driver/Font/TrueType/Adapter/ttinit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 43983677a..b362e6441 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -127,12 +127,11 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) FilePushDir(); /* go to font/ttf directory */ - if( FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ) == NullHandle ) - goto Fin; + FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); /* get all filenames contained in current directory */ ttfEnumParams.FEP_searchFlags = FESF_NON_GEOS; - ttfEnumParams.FEP_returnAttrs = &ttfExtAttrDesc; + ttfEnumParams.FEP_returnAttrs = ttfExtAttrDesc; ttfEnumParams.FEP_returnSize = sizeof( FileLongName ); ttfEnumParams.FEP_matchAttrs = NullHandle; ttfEnumParams.FEP_bufSize = FE_BUFSIZE_UNLIMITED; @@ -150,7 +149,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /* iterate over all filenames and try to register a font.*/ ptrFileName = MemLock( fileEnumBlock ); for( file = 0; file < numFiles; file++ ) - TrueType_ProcessFont( ptrFileName++, fontInfoBlock ); + TrueType_ProcessFont( ptrFileName[file], fontInfoBlock ); MemFree( fileEnumBlock ); From 56d22c4480a77922602f2d98aa4c4b2ac11e7247 Mon Sep 17 00:00:00 2001 From: Falk Rehwagen Date: Fri, 30 Dec 2022 22:29:09 +0100 Subject: [PATCH 113/246] Base implementation of InitFont done in C, results should be the same as with the asm implementation. #129 --- Driver/Font/TrueType/Adapter/ttadapter.h | 14 +- Driver/Font/TrueType/Adapter/ttinit.c | 275 ++++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttinit.h | 1 + 3 files changed, 255 insertions(+), 35 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index c6d37fd37..784023a09 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -59,7 +59,6 @@ typedef struct typedef struct { FileHandle FI_fileHandle; - word FI_RESIDENT; word FI_fontID; FontMaker FI_maker; FontAttrs FI_family; @@ -200,6 +199,13 @@ typedef ByteEnum AdjustedWeight; #define AW_ULTRA_BOLD 120 +typedef struct +{ + dword OE_offset; /* offset in file */ + word OE_size; /* size in bytes) */ + Handle OE_handle; /* handle (if loaded) */ +} OutlineEntry; + /* * drivers OutlineDataEntry structure (see fontDr.def) */ @@ -210,9 +216,9 @@ typedef struct #ifdef DBCS_PCGEOS word ODE_extraData; #else - TrueTypeOutlineEntry ODE_header; - TrueTypeOutlineEntry ODE_first; - TrueTypeOutlineEntry ODE_second; + OutlineEntry ODE_header; + OutlineEntry ODE_first; + OutlineEntry ODE_second; #endif } OutlineDataEntry; diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index b362e6441..bd8940f4f 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -27,6 +27,26 @@ #include +TT_Error Fill_FontsAvailEntry( const char * fileName, + TT_Face face, + FontID fontID, + FontsAvailEntry* fontsAvailEntry ); + +TT_Error _pascal Fill_FontInfo( TT_Face face, + FontID fontID, + FontInfo* fontInfo ); + +TT_Error _pascal Fill_OutlineData( const char* fileName, + TT_Face face, + OutlineDataEntry* outlineDataEntry, + TrueTypeOutlineEntry* trueTypeOutlineEntry ); + +static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ); + +static Boolean isIdenticalStyle(TT_Face face, TextStyle style, AdjustedWeight weight); + +static word getNameFromNameTableByIndex( char* name, TT_Face face, TT_UShort index ); + /******************************************************************** * Init_FreeType ******************************************************************** @@ -162,11 +182,11 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { FileHandle truetypeFile; TT_Face face; - TT_Error error; + TT_Error error = TT_Err_Ok; char familyName[FID_NAME_LEN]; word familyNameLength; FontID fontID; - + sword availIndex; ECCheckBounds( (void*)fileName ); ECCheckMemHandle( fontInfoBlock ); @@ -186,19 +206,136 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if ( !isMappedFont( familyName, &fontID ) ) fontID = MAKE_FONTID( familyName ); - if ( !isRegistredFontID( fontID, fontInfoBlock ) ) + availIndex = getFontIDAvailIndex( fontID, fontInfoBlock ); + if ( availIndex < 0 ) { - //FontsAvailEntry erzeugen und füllen - //FontInfo erzeugen und füllen + ChunkHandle fontInfoChunk; + FontsAvailEntry* newEntry; + FontInfo* fontInfo; + + // allocate FontInfo chunk + if( LMemInsertAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ) ) + { + error = TT_Err_Out_Of_Memory; + goto Fin; + } + newEntry = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); + error = Fill_FontsAvailEntry( fileName, face, fontID, newEntry ); + + //FontInfo erzeugen und füllen + if( !error) + { + fontInfoChunk = LMemAlloc( fontInfoBlock, sizeof(OutlineDataEntry) + sizeof(FontInfo) ); + } + if( error || (fontInfoChunk == NullChunk) ) + { + // revert previous allocation + LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); + error = TT_Err_Out_Of_Memory; + goto Fin; + } + + fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); + error = Fill_FontInfo( face, fontID, fontInfo ); + if( !error ) + { + //Outline anhängen und füllen + TrueTypeOutlineEntry* trueTypeOutlineEntry; + ChunkHandle trueTypeOutlineChunk = + LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); + + if( trueTypeOutlineChunk == NullChunk) + { + LMemFreeHandles( fontInfoBlock, fontInfoChunk ); + LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); + goto Fin; + } + fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); + trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); + error = Fill_OutlineData( fileName, + face, + (OutlineDataEntry*) (fontInfo + 1), + trueTypeOutlineEntry ); + if( error ) { + + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + } + + *((ChunkHandle*)&(((OutlineDataEntry*) (fontInfo + 1))->ODE_header)) = trueTypeOutlineChunk; + + fontInfo->FI_outlineTab = sizeof( FontInfo ); + fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); + } + if( error ) + { + LMemFreeHandles( fontInfoBlock, fontInfoChunk ); + LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); + goto Fin; + } + //Referenz auf FontInfo in FontsAvailEntry füllen - //Outline anhängen und füllen - } + newEntry = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); + newEntry->FAE_infoHandle = fontInfoChunk; + } else { + word outlineOffset; + ChunkHandle trueTypeOutlineChunk; + OutlineDataEntry *outlineEntry; + //Gibt es schon noch keine Outline für den Style? //Outline anhängen und füllen - - } + FontsAvailEntry* availEntries = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); + ChunkHandle fontInfoChunk = availEntries[availIndex].FAE_infoHandle; + + FontInfo* fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); + OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); + + while( outlineData < fontInfo->FI_outlineEnd) + { + if(isIdenticalStyle( + face, + outlineData->ODE_style, + outlineData->ODE_weight)) + { + goto Fin; + } + outlineData++; + } + + /* not found append new outline entry */ + trueTypeOutlineChunk = + LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); + if( trueTypeOutlineChunk == NullChunk ) + { + error = TT_Err_Out_Of_Memory; + goto Fin; + } + + outlineOffset = fontInfo->FI_outlineTab; + if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry ) ) ) + { + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + error = TT_Err_Out_Of_Memory; + goto Fin; + } + + outlineEntry = (OutlineDataEntry*) (((byte*) LMemDerefHandles( fontInfoBlock, fontInfoChunk )) + outlineOffset); + error = Fill_OutlineData( fileName, + face, + outlineEntry, + LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ) ); + if( error ) { + + LMemDeleteAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry ) ); + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + } + + fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); + fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); + + *((ChunkHandle*)&(outlineEntry->ODE_header)) = trueTypeOutlineChunk; + } Fin: FileClose( truetypeFile, FALSE ); @@ -240,20 +377,10 @@ TT_Error Fill_FontsAvailEntry( const char * fileName, FontsAvailEntry* fontsAvailEntry ) { TT_Error error; - TT_String* familyName; - word familyNameLength; ECCheckBounds( (void*)fontsAvailEntry ); - - error = TT_Get_Name_String( face, FAMILY_NAME_INDEX, &familyName, &familyNameLength ); - if ( error ) - return error; - - if ( familyNameLength >= FAMILY_NAME_LENGTH ) - return TT_Err_Invalid_Argument; - fontsAvailEntry->FAE_fontID = fontID; /* We probably don't need this because we keep the file name in the */ @@ -354,7 +481,7 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, TrueTypeOutlineEntry* trueTypeOutlineEntry ) { TT_Face_Properties faceProperties; - TT_String* styleName; + char styleName[STYLE_NAME_LENGTH+1]; word styleNameLength; TT_Error error; @@ -366,9 +493,8 @@ TT_Error _pascal Fill_OutlineData( const char* fileName, //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein // die Implementierung muss damit umgehen können - error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); - if ( error != TT_Err_Ok ) - return error; + //error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); + styleNameLength = getNameFromNameTableByIndex(styleName, face, STYLE_NAME_INDEX); if ( styleNameLength >= STYLE_NAME_LENGTH ) return TT_Err_Invalid_Argument; @@ -449,7 +575,7 @@ static FontAttrs mapFamilyClass( TT_Short familyClass ) static AdjustedWeight mapFontWeight( TT_Short weightClass ) { - switch (weightClass) + switch (weightClass / 100) { case 1: return AW_ULTRA_LIGHT; @@ -502,21 +628,99 @@ static Boolean isMappedFont( const char* familiyName, FontID* fontID ) return result; } -static Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ) +static Boolean isIdenticalStyle(TT_Face face, TextStyle style, AdjustedWeight weight) +{ + TT_Error error; + TT_Face_Properties faceProperties; + TT_String* styleName; + word styleNameLength; + + //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein + // die Implementierung muss damit umgehen können + error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); + if ( error != TT_Err_Ok ) + return FALSE; + + if ( styleNameLength >= STYLE_NAME_LENGTH ) + return FALSE; + + + error = TT_Get_Face_Properties( face, &faceProperties ); + if ( error != TT_Err_Ok ) + return FALSE; + + /* fill outlineDataEntry */ + if( ( mapTextStyle( styleName ) == style ) && + ( mapFontWeight( faceProperties.os2->usWeightClass ) == weight ) ) + { + return TRUE; + } + return FALSE; +} + +static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) { FontsAvailEntry* fontsAvailEntrys; word elements; - word element; + sword element; /* set fontsAvailEntrys to first Element after LMemBlockHeader */ - fontsAvailEntrys = ( (byte*)MemDeref( fontInfoBlock ) + sizeof( LMemBlockHeader ) ); + fontsAvailEntrys = ( (byte*)LMemDeref( + ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader))) ); elements = LMemGetChunkSizePtr( fontsAvailEntrys ) / sizeof( FontsAvailEntry ); for( element = 0; element < elements; element++ ) if( fontsAvailEntrys[element].FAE_fontID == fontID ) - return TRUE; + return element; - return FALSE; + return -1; +} + +static word getNameFromNameTableByIndex( char* name, TT_Face face, TT_UShort index ) +{ + TT_UShort platformID; + TT_UShort encodingID; + TT_UShort languageID; + word nameLength; + char* str; + word i; + word id; + + TT_Get_Name_ID( face, index, &platformID, &encodingID, &languageID, &id ); + + if( platformID == PLATFORM_ID_MS && + encodingID == ENCODING_ID_MS_UNICODE_BMP && + languageID == LANGUAGE_ID_WIN_EN_US ) + { + TT_Get_Name_String( face, index, &str, &nameLength ); + + for (i = 0; str != 0 && i < nameLength; i += 2) + *name++ = str[i]; + *name = 0; + return nameLength >> 1; + } + else if( platformID == PLATFORM_ID_MAC && + encodingID == ENCODING_ID_MAC_ROMAN && + languageID == LANGUAGE_ID_MAC_EN ) + { + TT_Get_Name_String( face, index, &str, &nameLength ); + + for (i = 0; str != 0 && i < nameLength; i ++) + *name++ = str[i]; + *name = 0; + return nameLength; + } + else if( encodingID == ENCODING_ID_UNICODE ) + { + TT_Get_Name_String( face, index, &str, &nameLength ); + + for (i = 1; str != 0 && i < nameLength; i += 2) + *name++ = str[i]; + *name = 0; + return nameLength >> 1; + } + + return 0; } static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) @@ -545,7 +749,7 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Get_Name_String( face, n, &str, &nameLength ); - for (i = 1; str != 0 && i < nameLength; i += 2) + for (i = 0; str != 0 && i < nameLength; i += 2) *name++ = str[i]; *name = 0; return nameLength >> 1; @@ -556,11 +760,20 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Get_Name_String( face, n, &str, &nameLength ); - for (i = 1; str != 0 && i < nameLength; i ++) + for (i = 0; str != 0 && i < nameLength; i ++) *name++ = str[i]; *name = 0; return nameLength; } + else if( encodingID == ENCODING_ID_UNICODE ) + { + TT_Get_Name_String( face, n, &str, &nameLength ); + + for (i = 1; str != 0 && i < nameLength; i += 2) + *name++ = str[i]; + *name = 0; + return nameLength >> 1; + } } return 0; diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 5a43b63dc..25ebebacd 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -52,6 +52,7 @@ #define ENCODING_ID_MAC_ROMAN 0 #define ENCODING_ID_MS_UNICODE_BMP 1 +#define ENCODING_ID_UNICODE 3 #define LANGUAGE_ID_MAC_EN 0 #define LANGUAGE_ID_WIN_EN_US 0x0409 From c6ffb589195fbdcf75ab31ccfc278e912b6442b2 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 10 Jan 2023 21:40:12 +0100 Subject: [PATCH 114/246] Small clean-up in ttint.c --- Driver/Font/TrueType/Adapter/ttinit.c | 480 ++++++-------------------- Driver/Font/TrueType/Adapter/ttinit.h | 18 +- 2 files changed, 116 insertions(+), 382 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index bd8940f4f..88e202652 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -27,25 +27,21 @@ #include -TT_Error Fill_FontsAvailEntry( const char * fileName, - TT_Face face, - FontID fontID, - FontsAvailEntry* fontsAvailEntry ); +static TT_Error TrueType_ProcessFont( + const char* file, MemHandle fontInfoBlock ); -TT_Error _pascal Fill_FontInfo( TT_Face face, - FontID fontID, - FontInfo* fontInfo ); +static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ); -TT_Error _pascal Fill_OutlineData( const char* fileName, - TT_Face face, - OutlineDataEntry* outlineDataEntry, - TrueTypeOutlineEntry* trueTypeOutlineEntry ); +static Boolean isMappedFont( const char* familiyName, FontID* font ); -static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ); +static FontAttrs mapFamilyClass( TT_Short familyClass ); + +static FontWeight mapFontWeight( TT_Short weightClass ); -static Boolean isIdenticalStyle(TT_Face face, TextStyle style, AdjustedWeight weight); +static TextStyle mapTextStyle( const char* subfamily ); + +static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex ); -static word getNameFromNameTableByIndex( char* name, TT_Face face, TT_UShort index ); /******************************************************************** * Init_FreeType @@ -169,7 +165,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /* iterate over all filenames and try to register a font.*/ ptrFileName = MemLock( fileEnumBlock ); for( file = 0; file < numFiles; file++ ) - TrueType_ProcessFont( ptrFileName[file], fontInfoBlock ); + TrueType_ProcessFont( ptrFileName++, fontInfoBlock ); MemFree( fileEnumBlock ); @@ -180,13 +176,17 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { - FileHandle truetypeFile; - TT_Face face; - TT_Error error = TT_Err_Ok; - char familyName[FID_NAME_LEN]; - word familyNameLength; - FontID fontID; - sword availIndex; + FileHandle truetypeFile; + TT_Face face; + TT_Face_Properties faceProperties; + TT_Error error = TT_Err_Ok; + char familyName[FID_NAME_LEN]; + char styleName[STYLE_NAME_LENGTH]; + word familyNameLength; + word styleNameLegth; + FontID fontID; + sword availIndex; + ECCheckBounds( (void*)fileName ); ECCheckMemHandle( fontInfoBlock ); @@ -200,321 +200,146 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if( error ) goto Fin; - if ( getNameFromNameTable( familyName, face, FAMILY_NAME_INDEX ) == 0 ) - goto Fin; + error = TT_Get_Face_Properties( face, &faceProperties ); + if( error ) + goto Fail; + + if ( getNameFromNameTable( familyName, face, FAMILY_NAME_ID ) == 0 ) + goto Fail; + + if ( getNameFromNameTable( styleName, face, STYLE_NAME_ID ) == 0 ) + goto Fail; if ( !isMappedFont( familyName, &fontID ) ) fontID = MAKE_FONTID( familyName ); availIndex = getFontIDAvailIndex( fontID, fontInfoBlock ); + + /* if we have an new font FontAvailEntry, FontInfo and Outline must be created */ if ( availIndex < 0 ) { - ChunkHandle fontInfoChunk; - FontsAvailEntry* newEntry; - FontInfo* fontInfo; + ChunkHandle fontInfoChunk; + FontsAvailEntry* newEntry; + FontInfo* fontInfo; + TrueTypeOutlineEntry* trueTypeOutlineEntry; + ChunkHandle trueTypeOutlineChunk; + OutlineDataEntry* outlineDataEntry; - // allocate FontInfo chunk + /* allocate chunk for FontsAvailEntry and fill it */ if( LMemInsertAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ) ) { error = TT_Err_Out_Of_Memory; - goto Fin; - } - newEntry = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); - error = Fill_FontsAvailEntry( fileName, face, fontID, newEntry ); - - //FontInfo erzeugen und füllen - if( !error) - { - fontInfoChunk = LMemAlloc( fontInfoBlock, sizeof(OutlineDataEntry) + sizeof(FontInfo) ); + goto Fail; } - if( error || (fontInfoChunk == NullChunk) ) + newEntry = LMemDeref( ConstructOptr( fontInfoBlock, sizeof( LMemBlockHeader ) ) ); + newEntry->FAE_fontID = fontID; + newEntry->FAE_infoHandle = NullChunk; + *newEntry->FAE_fileName = 0; + + /* allocate chunk for FontInfo and OutlineDataEntry */ + fontInfoChunk = LMemAlloc( fontInfoBlock, sizeof(OutlineDataEntry) + sizeof(FontInfo) ); + if( fontInfoChunk == NullChunk ) { - // revert previous allocation + /* revert previous allocation of FontsAvailEntry */ LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); error = TT_Err_Out_Of_Memory; - goto Fin; + goto Fail; } + /* get pointer to FontInfo and fill it */ fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); - error = Fill_FontInfo( face, fontID, fontInfo ); - if( !error ) - { - //Outline anhängen und füllen - TrueTypeOutlineEntry* trueTypeOutlineEntry; - ChunkHandle trueTypeOutlineChunk = - LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); - - if( trueTypeOutlineChunk == NullChunk) - { - LMemFreeHandles( fontInfoBlock, fontInfoChunk ); - LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); - goto Fin; - } - fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); - trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); - error = Fill_OutlineData( fileName, - face, - (OutlineDataEntry*) (fontInfo + 1), - trueTypeOutlineEntry ); - if( error ) { - - LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); - } - - *((ChunkHandle*)&(((OutlineDataEntry*) (fontInfo + 1))->ODE_header)) = trueTypeOutlineChunk; - - fontInfo->FI_outlineTab = sizeof( FontInfo ); - fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); - } - if( error ) + strcpy( fontInfo->FI_faceName, familyName ); + fontInfo->FI_fileHandle = NullHandle; + fontInfo->FI_fontID = fontID; + fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); + fontInfo->FI_maker = FM_TRUETYPE; + fontInfo->FI_pointSizeTab = 0; + fontInfo->FI_pointSizeEnd = 0; + fontInfo->FI_outlineTab = 0; + fontInfo->FI_outlineEnd = 0; + + /* add Chunk for TrueTypeOutlineEntry */ + trueTypeOutlineChunk = LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); + if( trueTypeOutlineChunk == NullChunk) { LMemFreeHandles( fontInfoBlock, fontInfoChunk ); LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); - goto Fin; + goto Fail; } + fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); + trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); + + /* fill TrueTypeOutlineEntry */ + strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); + + /* fill OutlineDataEntry */ + outlineDataEntry = (OutlineDataEntry*) (fontInfo + 1); + outlineDataEntry->ODE_style = mapTextStyle( styleName ); + outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); + outlineDataEntry->ODE_header.OE_handle = trueTypeOutlineChunk; + + fontInfo->FI_outlineTab = sizeof( FontInfo ); + fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); - //Referenz auf FontInfo in FontsAvailEntry füllen - newEntry = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); + /* set Chunk to FontInfo into FontsAvailEntry */ + newEntry = LMemDeref( ConstructOptr( fontInfoBlock, sizeof( LMemBlockHeader ) ) ); newEntry->FAE_infoHandle = fontInfoChunk; } else { - word outlineOffset; - ChunkHandle trueTypeOutlineChunk; - OutlineDataEntry *outlineEntry; - - //Gibt es schon noch keine Outline für den Style? - //Outline anhängen und füllen - FontsAvailEntry* availEntries = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); - ChunkHandle fontInfoChunk = availEntries[availIndex].FAE_infoHandle; - - FontInfo* fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); - OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); - - while( outlineData < fontInfo->FI_outlineEnd) + word outlineOffset; + ChunkHandle trueTypeOutlineChunk; + TrueTypeOutlineEntry* trueTypeOutlineEntry; + FontsAvailEntry* availEntries = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); + ChunkHandle fontInfoChunk = availEntries[availIndex].FAE_infoHandle; + FontInfo* fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); + OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); + OutlineDataEntry* outlineDataEnd = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineEnd); + + while( outlineData < outlineDataEnd) { - if(isIdenticalStyle( - face, - outlineData->ODE_style, - outlineData->ODE_weight)) + if( ( mapTextStyle( styleName ) == outlineData->ODE_style ) && + ( mapFontWeight( faceProperties.os2->usWeightClass ) == outlineData->ODE_weight ) ) { - goto Fin; + goto Fail; } outlineData++; } /* not found append new outline entry */ - trueTypeOutlineChunk = - LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); + trueTypeOutlineChunk = LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); if( trueTypeOutlineChunk == NullChunk ) { error = TT_Err_Out_Of_Memory; - goto Fin; + goto Fail; } - outlineOffset = fontInfo->FI_outlineTab; - if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry ) ) ) - { - LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); - error = TT_Err_Out_Of_Memory; - goto Fin; - } - - outlineEntry = (OutlineDataEntry*) (((byte*) LMemDerefHandles( fontInfoBlock, fontInfoChunk )) + outlineOffset); - error = Fill_OutlineData( fileName, - face, - outlineEntry, - LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ) ); - if( error ) { - - LMemDeleteAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry ) ); - LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); - } + outlineOffset = fontInfo->FI_outlineTab; + LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry )); + + /* fill TrueTypeOutlineEntry */ + trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); + strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); + + /* fill OutlineDataEntry */ + fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); + outlineData = (OutlineDataEntry*) (fontInfo + 1); + outlineData->ODE_style = mapTextStyle( styleName ); + outlineData->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); + outlineData->ODE_header.OE_handle = trueTypeOutlineChunk; fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); - - *((ChunkHandle*)&(outlineEntry->ODE_header)) = trueTypeOutlineChunk; } +Fail: + TT_Close_Face( face ); Fin: FileClose( truetypeFile, FALSE ); return error; } -/******************************************************************** - * Fill_FontsAvialEntry - ******************************************************************** - * SYNOPSIS: Fills the FontsAvialEntry structure with infomations - * of the passed font file. - * - * PARAMETERS: fileName Name of font file. - * face Face from font file. - * fontID Calcualted FontID. - * fontsAvailEntry Pointer to FontsAvialEntry - * structure to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: - * - * STRATEGY: - * - * TODO: Prepare it for dbcs. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ - -TT_Error Fill_FontsAvailEntry( const char * fileName, - TT_Face face, - FontID fontID, - FontsAvailEntry* fontsAvailEntry ) -{ - TT_Error error; - - - ECCheckBounds( (void*)fontsAvailEntry ); - - fontsAvailEntry->FAE_fontID = fontID; - - /* We probably don't need this because we keep the file name in the */ - /* TrueTypeOutlineEntry for each style. */ - strcpy ( fontsAvailEntry->FAE_fileName, fileName ); - - /* Will be filled later with the ChunkHandle to the FontInfo. */ - fontsAvailEntry->FAE_infoHandle = NullChunk; - - return TT_Err_Ok; -} - - -/******************************************************************** - * Fill_FontInfo - ******************************************************************** - * SYNOPSIS: Fills the FontsInfo structure with infomations - * of the passed in FontsAvailEntry. - * - * PARAMETERS: face Face from font file. - * fontID Calculated FontID. - * fontInfo Pointer to FontInfo structure - * to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Fill_FontInfo( TT_Face face, - FontID fontID, - FontInfo* fontInfo ) -{ - TT_Error error; - TT_Face_Properties faceProperties; - - - ECCheckBounds( (void*)fontInfo ); - - - error = TT_Get_Face_Properties( face, &faceProperties ); - if ( error ) - return error; - - getNameFromNameTable( fontInfo->FI_faceName, face, FAMILY_NAME_INDEX ); - - fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); - fontInfo->FI_fontID = fontID; - fontInfo->FI_maker = FM_TRUETYPE; - fontInfo->FI_pointSizeTab = 0; - fontInfo->FI_pointSizeEnd = 0; - fontInfo->FI_outlineTab = 0; - fontInfo->FI_outlineEnd = 0; - - return TT_Err_Ok; -} - - -/******************************************************************** - * Fill_OutlineData - ******************************************************************** - * SYNOPSIS: Fills OutlineDataEntry and TrueTypeOutlineEntry - * structure with infomations of the passed file. - * - * PARAMETERS: fileName Name of font file. - * face Face from font file. - * outlineDataEntry Pointer to OutlineDataEntry - * structure to fill. - * trueTypeOutlineEntry Pointer to TrueTypeOutlineEntry - * structure to fill. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ - -TT_Error _pascal Fill_OutlineData( const char* fileName, - TT_Face face, - OutlineDataEntry* outlineDataEntry, - TrueTypeOutlineEntry* trueTypeOutlineEntry ) -{ - TT_Face_Properties faceProperties; - char styleName[STYLE_NAME_LENGTH+1]; - word styleNameLength; - TT_Error error; - - - ECCheckBounds( (void*)fileName ); - ECCheckBounds( (void*)outlineDataEntry ); - ECCheckBounds( (void*)trueTypeOutlineEntry ); - - - //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein - // die Implementierung muss damit umgehen können - //error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); - styleNameLength = getNameFromNameTableByIndex(styleName, face, STYLE_NAME_INDEX); - - if ( styleNameLength >= STYLE_NAME_LENGTH ) - return TT_Err_Invalid_Argument; - - - error = TT_Get_Face_Properties( face, &faceProperties ); - if ( error != TT_Err_Ok ) - return error; - - /* fill outlineDataEntry */ - outlineDataEntry->ODE_style = mapTextStyle( styleName ); - outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); - - /* fill trueTypeOutlineEntry */ - strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); - - return TT_Err_Ok; -} - - /*******************************************************************/ /* Implemetation of helperfunctions */ /*******************************************************************/ @@ -623,41 +448,11 @@ static Boolean isMappedFont( const char* familiyName, FontID* fontID ) familiyName, fontID ); - //ensure FM_TRUETYPE is set + /* ensure FM_TRUETYPE is set */ *fontID = FM_TRUETYPE || (*fontID && 0x0fff); return result; } -static Boolean isIdenticalStyle(TT_Face face, TextStyle style, AdjustedWeight weight) -{ - TT_Error error; - TT_Face_Properties faceProperties; - TT_String* styleName; - word styleNameLength; - - //TODO: der Namestring kann ASCII oder auch UNICODE codiert sein - // die Implementierung muss damit umgehen können - error = TT_Get_Name_String( face, STYLE_NAME_INDEX, &styleName, &styleNameLength ); - if ( error != TT_Err_Ok ) - return FALSE; - - if ( styleNameLength >= STYLE_NAME_LENGTH ) - return FALSE; - - - error = TT_Get_Face_Properties( face, &faceProperties ); - if ( error != TT_Err_Ok ) - return FALSE; - - /* fill outlineDataEntry */ - if( ( mapTextStyle( styleName ) == style ) && - ( mapFontWeight( faceProperties.os2->usWeightClass ) == weight ) ) - { - return TRUE; - } - return FALSE; -} - static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) { FontsAvailEntry* fontsAvailEntrys; @@ -676,53 +471,6 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) return -1; } -static word getNameFromNameTableByIndex( char* name, TT_Face face, TT_UShort index ) -{ - TT_UShort platformID; - TT_UShort encodingID; - TT_UShort languageID; - word nameLength; - char* str; - word i; - word id; - - TT_Get_Name_ID( face, index, &platformID, &encodingID, &languageID, &id ); - - if( platformID == PLATFORM_ID_MS && - encodingID == ENCODING_ID_MS_UNICODE_BMP && - languageID == LANGUAGE_ID_WIN_EN_US ) - { - TT_Get_Name_String( face, index, &str, &nameLength ); - - for (i = 0; str != 0 && i < nameLength; i += 2) - *name++ = str[i]; - *name = 0; - return nameLength >> 1; - } - else if( platformID == PLATFORM_ID_MAC && - encodingID == ENCODING_ID_MAC_ROMAN && - languageID == LANGUAGE_ID_MAC_EN ) - { - TT_Get_Name_String( face, index, &str, &nameLength ); - - for (i = 0; str != 0 && i < nameLength; i ++) - *name++ = str[i]; - *name = 0; - return nameLength; - } - else if( encodingID == ENCODING_ID_UNICODE ) - { - TT_Get_Name_String( face, index, &str, &nameLength ); - - for (i = 1; str != 0 && i < nameLength; i += 2) - *name++ = str[i]; - *name = 0; - return nameLength >> 1; - } - - return 0; -} - static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Face_Properties faceProperties; @@ -749,7 +497,7 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Get_Name_String( face, n, &str, &nameLength ); - for (i = 0; str != 0 && i < nameLength; i += 2) + for (i = 1; str != 0 && i < nameLength; i += 2) *name++ = str[i]; *name = 0; return nameLength >> 1; diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 25ebebacd..1593259d4 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -36,8 +36,8 @@ #define TTF_DIRECTORY "TTF" #define FONTMAPPING_CATEGORY "FontMapping" -#define FAMILY_NAME_INDEX 1 // font family name -#define STYLE_NAME_INDEX 2 // font style +#define FAMILY_NAME_ID 1 // id for font family name +#define STYLE_NAME_ID 2 // id for font style #define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE @@ -64,25 +64,11 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); -TT_Error TrueType_ProcessFont( const char* file, MemHandle fontInfoBlock ); - -Boolean isRegistredFontID( FontID fontID, MemHandle fontInfoBlock ); - -static Boolean isMappedFont( const char* familiyName, FontID* font ); - /*********************************************************************** * internal functions ***********************************************************************/ -static FontAttrs mapFamilyClass( TT_Short familyClass ); - -static FontWeight mapFontWeight( TT_Short weightClass ); - -static TextStyle mapTextStyle( const char* subfamily ); - -static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex ); - static int toHash( const char* str ); static int strlen( const char* str ); From 1e5ce14475eb416f4d904297cd1655608c3b44bf Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 11 Jan 2023 19:19:58 +0100 Subject: [PATCH 115/246] Fix mistake --- Driver/Font/TrueType/Adapter/ttinit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 88e202652..fcfe7513d 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -315,7 +315,12 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) } outlineOffset = fontInfo->FI_outlineTab; - LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry )); + if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry ) ) ) + { + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + error = TT_Err_Out_Of_Memory; + goto Fail; + } /* fill TrueTypeOutlineEntry */ trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); From 45f50608b345d94f91ac1973d51e397e0bd9e980 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 11 Jan 2023 21:53:33 +0100 Subject: [PATCH 116/246] Start implement TrueType_Gen_Widths --- Driver/Font/TrueType/Adapter/ttinit.c | 4 +- Driver/Font/TrueType/Adapter/ttinit.h | 2 +- Driver/Font/TrueType/Adapter/ttwidths.c | 91 ++++++++++++++++++-- Driver/Font/TrueType/Adapter/ttwidths.h | 35 ++------ Driver/Font/TrueType/Main/truetypeWidths.asm | 27 ++++-- 5 files changed, 113 insertions(+), 46 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index fcfe7513d..8cf61d222 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -349,7 +349,7 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* Implemetation of helperfunctions */ /*******************************************************************/ -static int toHash( const char* str ) +static word toHash( const char* str ) { word i; dword hash = strlen( str ); @@ -357,7 +357,7 @@ static int toHash( const char* str ) for ( i = 0; i < strlen( str ) ; i++ ) hash = ( hash * 7 ) % ( 2^16 ) + str[i]; - return (int) hash; + return (word) hash; } static FontAttrs mapFamilyClass( TT_Short familyClass ) diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 1593259d4..2178e6549 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -69,7 +69,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); * internal functions ***********************************************************************/ -static int toHash( const char* str ); +static word toHash( const char* str ); static int strlen( const char* str ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 719a1a138..c33a4ebce 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -18,12 +18,39 @@ ***********************************************************************/ #include +#include #include +#include #include "ttwidths.h" #include "ttcharmapper.h" #include "../FreeType/ftxkern.h" +static OutlineDataEntry* findOutlineData( + TextStyle* stylesToImplement, + const FontInfo* fontInfo, + word textStyle, + word fontWeight ); + +TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, + word character, + CharTableEntry* charTableEntry ); + +TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ); + +TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); + +word GetNumKernPairs( TT_Face face); + +void ConvertHeader(); + +void ConvertKernPairs(); + +void CalcTransform(); + +void CalcRoutines(); + + /******************************************************************** * TrueType_Gen_Widths ******************************************************************** @@ -46,22 +73,70 @@ *******************************************************************/ MemHandle _pascal TrueType_Gen_Widths( - MemHandle fontHandle, - void* gstatePtr, - void* tMaxtrix, - const FontInfo* fontInfo ) + MemHandle fontHandle, + void* tMatrix, + const FontInfo* fontInfo, + WWFixedAsDWord pointSize, + word textStyle, + word fontWeight ) { - word numKernPairs; - word numCharacters; + FileHandle truetypeFile; + OutlineDataEntry* OutlineDataEntry; + TT_Face face; + char* fileName; + TT_Error error; + + + ECCheckMemHandle( fontHandle ); + ECCheckBounds( tMatrix ); + ECCheckBounds( (void*)fontInfo ); + + + // finde passende Outline + + // ermittle Dateinamen der Outline + + + //Font öffnen und Face laden + truetypeFile = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); + + ECCheckFileHandle( truetypeFile ); + + error = TT_Open_Face( truetypeFile, &face ); + if( error ) + goto Fail; - //Font öffenen und Face laden //Anzahl KernPairs ermitteln - //Anzahl der Zeichen ermitteln + //FontBlock allocieren + + //FontBuf füllen + + //Kernpairs anhängen + + //Transformation (fehlende Styles) + + TT_Close_Face( face ); +Fail: + FileClose( truetypeFile, FALSE ); + +Fin: return fontHandle; } +static OutlineDataEntry* findOutlineData( + TextStyle* stylesToImplement, + const FontInfo* fontInfo, + word textStyle, + word fontWeight ) +{ + //finde die zum TextStyle und fontWeight passende Outline + //falls keine Ãœbereinstimmung gefunden wurde ermittle die + //nächst beste Outline und bestimme die zu implementierenden Styles +} + + /******************************************************************** * GenNumKernPairs ******************************************************************** diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 5b644f5e9..9fafe4940 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -69,41 +69,18 @@ typedef struct #define SAFETY( value ) ( value / 40 ) // 2.5% of size - - /*********************************************************************** * functions called by driver ***********************************************************************/ MemHandle _pascal TrueType_Gen_Widths( - MemHandle fontHandle, - void* gstatePtr, - void* tMaxtrix, - const FontInfo* fontInfo + MemHandle fontHandle, + void* tMatrix, + const FontInfo* fontInfo, + WWFixedAsDWord pointSize, + word textStyle, + word fontWeight ); -/*********************************************************************** - * internal functions - ***********************************************************************/ - -TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, - word character, - CharTableEntry* charTableEntry ); - -TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ); - -TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); - -word GetNumKernPairs( TT_Face face); - -void ConvertHeader(); - -void ConvertKernPairs(); - -void CalcTransform(); - -void CalcRoutines(); - - #endif /* _TTWIDTHS_H_ */ diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index ea7f9279f..03e823a48 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -63,14 +63,29 @@ TrueTypeGenWidths proc far .enter push di ; font handle or 0 - push es ; pass gstate ptr - mov dx, 0 ; with segment offset 0 - push dx + push bx ; send tMatrix ptr push cx + + ; find font info + mov cx, es:GS_fontAttr.FCA_fontID + call FontDrFindFontInfo push ds ; pass font info ptr - push dx ; segment offset 0 - + push di + + clr al ; pointsize from gstate + movwbf dxah, es:GS_fontAttr.FCA_pointsize + push dx ; pass point size + push ax + + clr ah ; text style from gstate + mov al, es:GS_fontAttr.FCA_textStyle + push ax ; pass text style + + clr ah ; font weight from gstate + mov al, es:GS_fontAttr.FCA_weight + push ax ; pass font weight + segmov ds, dgroup, dx call TRUETYPE_GEN_WIDTHS @@ -78,7 +93,7 @@ TrueTypeGenWidths proc far call MemDerefDS segmov ax, ds - clc ;indicate no error + clc ;indicate no error .leave ret From 69a4b5c3d1277f9d8c5a5dbc9a2f29558a428329 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 12 Jan 2023 21:31:11 +0100 Subject: [PATCH 117/246] Passing von TextStyle and FontWeight corrected --- Driver/Font/TrueType/Adapter/ttwidths.c | 35 ++++++++++++++++---- Driver/Font/TrueType/Adapter/ttwidths.h | 4 +-- Driver/Font/TrueType/Main/truetypeWidths.asm | 2 +- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index c33a4ebce..28c8e4231 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -29,8 +29,8 @@ static OutlineDataEntry* findOutlineData( TextStyle* stylesToImplement, const FontInfo* fontInfo, - word textStyle, - word fontWeight ); + TextStyle textStyle, + FontWeight fontWeight ); TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, word character, @@ -54,7 +54,8 @@ void CalcRoutines(); /******************************************************************** * TrueType_Gen_Widths ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Generate header width infomation about a front + * in a given pointsize, style and weight. * * PARAMETERS: * @@ -77,8 +78,8 @@ MemHandle _pascal TrueType_Gen_Widths( void* tMatrix, const FontInfo* fontInfo, WWFixedAsDWord pointSize, - word textStyle, - word fontWeight ) + TextStyle textStyle, + FontWeight fontWeight ) { FileHandle truetypeFile; OutlineDataEntry* OutlineDataEntry; @@ -128,8 +129,8 @@ MemHandle _pascal TrueType_Gen_Widths( static OutlineDataEntry* findOutlineData( TextStyle* stylesToImplement, const FontInfo* fontInfo, - word textStyle, - word fontWeight ) + TextStyle textStyle, + FontWeight fontWeight ) { //finde die zum TextStyle und fontWeight passende Outline //falls keine Ãœbereinstimmung gefunden wurde ermittle die @@ -621,4 +622,24 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea return TT_Err_Ok; +} + +static FontWeight convertAdjustedWeightToFontWeight(AdjustedWeight weight) +{ + switch (weight) + { + case AW_ULTRA_LIGHT: + case AW_EXTRA_LIGHT: + case AW_LIGHT: + return FW_MINIMUM; + case AW_SEMI_LIGHT: + case AW_MEDIUM: + case AW_SEMI_BOLD: + return FW_NORMAL; + case AW_BOLD: + case AW_EXTRA_BOLD: + case AW_ULTRA_BOLD: + return FW_MAXIMUM; + } + return 0; } \ No newline at end of file diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 9fafe4940..00499a7ce 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -78,8 +78,8 @@ MemHandle _pascal TrueType_Gen_Widths( void* tMatrix, const FontInfo* fontInfo, WWFixedAsDWord pointSize, - word textStyle, - word fontWeight + TextStyle textStyle, + FontWeight fontWeight ); diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index 03e823a48..2fb660dc1 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -82,7 +82,7 @@ TrueTypeGenWidths proc far mov al, es:GS_fontAttr.FCA_textStyle push ax ; pass text style - clr ah ; font weight from gstate + ; font weight from gstate mov al, es:GS_fontAttr.FCA_weight push ax ; pass font weight From df94046dcf3931f68266ab6930ea6f61584e19ec Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 14 Jan 2023 15:51:39 +0100 Subject: [PATCH 118/246] Function to find the font with matching style and weight implemented. --- Driver/Font/TrueType/Adapter/ttadapter.h | 3 + Driver/Font/TrueType/Adapter/ttinit.h | 1 - Driver/Font/TrueType/Adapter/ttwidths.c | 112 ++++++++++++++--------- 3 files changed, 74 insertions(+), 42 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 784023a09..fe99a46f5 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -34,6 +34,8 @@ extern TEngine_Instance engineInstance; +#define TTF_DIRECTORY "TTF" + /*********************************************************************** * structures ***********************************************************************/ @@ -197,6 +199,7 @@ typedef ByteEnum AdjustedWeight; #define AW_BOLD 110 #define AW_EXTRA_BOLD 115 #define AW_ULTRA_BOLD 120 +#define AW_BLACK 125 typedef struct diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 2178e6549..7c559521f 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -33,7 +33,6 @@ * constants ***********************************************************************/ -#define TTF_DIRECTORY "TTF" #define FONTMAPPING_CATEGORY "FontMapping" #define FAMILY_NAME_ID 1 // id for font family name diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 28c8e4231..65cd47559 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -26,11 +26,11 @@ #include "../FreeType/ftxkern.h" -static OutlineDataEntry* findOutlineData( - TextStyle* stylesToImplement, - const FontInfo* fontInfo, - TextStyle textStyle, - FontWeight fontWeight ); +static TextStyle findOutlineData( + ChunkHandle* truetypeOutlineEntryChunk, + const FontInfo* fontInfo, + TextStyle textStyle, + FontWeight fontWeight ); TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, word character, @@ -81,25 +81,27 @@ MemHandle _pascal TrueType_Gen_Widths( TextStyle textStyle, FontWeight fontWeight ) { - FileHandle truetypeFile; - OutlineDataEntry* OutlineDataEntry; - TT_Face face; - char* fileName; - TT_Error error; + FileHandle truetypeFile; + ChunkHandle truetypeChunkHandle; + TrueTypeOutlineEntry* trueTypeOutlineEntry; + TextStyle stylesToImplement; + TT_Face face; + TT_Error error; ECCheckMemHandle( fontHandle ); ECCheckBounds( tMatrix ); ECCheckBounds( (void*)fontInfo ); - - // finde passende Outline + /* find outline for textStyle and fontWeight */ + stylesToImplement = findOutlineData( &truetypeChunkHandle, fontInfo, textStyle, fontWeight ); - // ermittle Dateinamen der Outline - + /* get filename an load ttf file */ + FilePushDir(); + FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - //Font öffnen und Face laden - truetypeFile = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); + trueTypeOutlineEntry = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), truetypeChunkHandle ); + truetypeFile = FileOpen( trueTypeOutlineEntry->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( truetypeFile ); @@ -122,19 +124,67 @@ MemHandle _pascal TrueType_Gen_Widths( FileClose( truetypeFile, FALSE ); Fin: + FilePopDir(); return fontHandle; } -static OutlineDataEntry* findOutlineData( - TextStyle* stylesToImplement, +static TextStyle findOutlineData( + ChunkHandle* truetypeOutlineEntryChunk, const FontInfo* fontInfo, TextStyle textStyle, FontWeight fontWeight ) { - //finde die zum TextStyle und fontWeight passende Outline - //falls keine Ãœbereinstimmung gefunden wurde ermittle die - //nächst beste Outline und bestimme die zu implementierenden Styles + ChunkHandle chunkToUse; + OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); + OutlineDataEntry* outlineDataEnd = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineEnd); + TextStyle styleDiff = 127; + byte weightDiff = 127; + + + /* adjust textWeight for AW_BOLD */ + if( textStyle >= AW_BOLD ) + textStyle = AW_BLACK; + + while( outlineData < outlineDataEnd) + { + /* exact match? */ + if( outlineData->ODE_style == textStyle && + outlineData->ODE_weight == fontWeight ) + { + *truetypeOutlineEntryChunk = outlineData->ODE_header.OE_handle; + return 0; // no styles to implement + } + + /* style match? */ + if( outlineData->ODE_style == textStyle ) + { + byte currentWeightDiff = ABS( fontWeight - outlineData->ODE_weight ); + + styleDiff = 0; + if( weightDiff >= currentWeightDiff ) + { + chunkToUse = outlineData->ODE_header.OE_handle; + weightDiff = currentWeightDiff; + } + + } + + /* try to find nearest style */ + if( ( ( textStyle & outlineData->ODE_style ) ^ outlineData->ODE_style ) == 0 ) + { + byte currentStyleDiff = textStyle ^ outlineData->ODE_style; + if( styleDiff >= currentStyleDiff ) + { + chunkToUse = outlineData->ODE_header.OE_handle; + styleDiff = currentStyleDiff; + } + } + outlineData++; + } + + *truetypeOutlineEntryChunk = chunkToUse; + return styleDiff; } @@ -623,23 +673,3 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea return TT_Err_Ok; } - -static FontWeight convertAdjustedWeightToFontWeight(AdjustedWeight weight) -{ - switch (weight) - { - case AW_ULTRA_LIGHT: - case AW_EXTRA_LIGHT: - case AW_LIGHT: - return FW_MINIMUM; - case AW_SEMI_LIGHT: - case AW_MEDIUM: - case AW_SEMI_BOLD: - return FW_NORMAL; - case AW_BOLD: - case AW_EXTRA_BOLD: - case AW_ULTRA_BOLD: - return FW_MAXIMUM; - } - return 0; -} \ No newline at end of file From 2c0a9624485c83643be6361718cccd99740e6efc Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 15 Jan 2023 12:43:12 +0100 Subject: [PATCH 119/246] Implement TrueType_Gen_Char part 2. --- Driver/Font/TrueType/Adapter/ttadapter.h | 10 ++ Driver/Font/TrueType/Adapter/ttcharmapper.c | 8 +- Driver/Font/TrueType/Adapter/ttcharmapper.h | 4 +- Driver/Font/TrueType/Adapter/ttinit.c | 11 +- Driver/Font/TrueType/Adapter/ttwidths.c | 139 ++++++++++++-------- 5 files changed, 110 insertions(+), 62 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index fe99a46f5..11e9d3f6a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -35,6 +35,7 @@ extern TEngine_Instance engineInstance; #define TTF_DIRECTORY "TTF" +#define FONT_MAN_ID 0x20 /*********************************************************************** * structures @@ -225,6 +226,15 @@ typedef struct #endif } OutlineDataEntry; +/* + * drivers KernPair stucture (see fontDr.def) + */ +typedef struct +{ + char KB_char1; + char KB_char2; +} KernPair; + /*********************************************************************** * macros diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index fe11e547a..903065cf3 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -317,7 +317,7 @@ TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) /* * Counts the GEOS characters that are present in the font. */ -word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) +word InitGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) { word charIndex; word charCount = 0; @@ -338,3 +338,9 @@ word CountGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) return charCount; } + + +word CountKernPairsWithGeosChars( TT_Face face ) +{ + return 0; +} diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index d2dbfe92e..64d2b26d8 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -47,7 +47,9 @@ typedef struct * internal functions ***********************************************************************/ -word CountGeosCharsInCharMap( TT_CharMap map, word* firstChar, word* lastChar ); +word InitGeosCharsInCharMap( TT_CharMap map, word* firstChar, word* lastChar ); + +word CountKernPairsWithGeosChars( TT_Face face ); TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 8cf61d222..08497c329 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -110,17 +110,16 @@ TT_Error _pascal Exit_FreeType() /******************************************************************** * TrueType_InitFonts ******************************************************************** - * SYNOPSIS: Deinitialises the FreeType Engine. This is the - * adapter function for DR_EXIT. + * SYNOPSIS: Search for TTF fonts and register them. This is the + * adapter function for DR_FONT_INIT_FONTS. * - * PARAMETERS: void + * PARAMETERS: fontInfoBlock MemHandle to fontInfo. * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * RETURNS: void * * SIDE EFFECTS: none * - * STRATEGY: Deinitialises the FreeType engine by delegating to - * TT_Done_FreeType(). + * STRATEGY: * * REVISION HISTORY: * Date Name Description diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 65cd47559..af3455d0a 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "ttwidths.h" #include "ttcharmapper.h" #include "../FreeType/ftxkern.h" @@ -32,16 +33,21 @@ static TextStyle findOutlineData( TextStyle textStyle, FontWeight fontWeight ); -TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, - word character, - CharTableEntry* charTableEntry ); +static word AllocFontBlock( + word additionalSpace, + word numOfCharacters, + word numOfKernPairs, + MemHandle* fontHandle ); + +TT_Error Fill_CharTableEntry( + const FontInfo* fontInfo, + word character, + CharTableEntry* charTableEntry ); TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ); TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); -word GetNumKernPairs( TT_Face face); - void ConvertHeader(); void ConvertKernPairs(); @@ -57,9 +63,14 @@ void CalcRoutines(); * SYNOPSIS: Generate header width infomation about a front * in a given pointsize, style and weight. * - * PARAMETERS: + * PARAMETERS: fontHandle + * tMatrix + * fontInfo + * pointSize + * textStyle + * fontWeight * - * RETURNS: + * RETURNS: MemHandle * * SIDE EFFECTS: none * @@ -86,7 +97,12 @@ MemHandle _pascal TrueType_Gen_Widths( TrueTypeOutlineEntry* trueTypeOutlineEntry; TextStyle stylesToImplement; TT_Face face; + TT_CharMap charMap; TT_Error error; + word numChars; + word numKernPairs; + word firstChar; + word lastChar; ECCheckMemHandle( fontHandle ); @@ -107,22 +123,31 @@ MemHandle _pascal TrueType_Gen_Widths( error = TT_Open_Face( truetypeFile, &face ); if( error ) - goto Fail; + goto Fail_Face; - //Anzahl KernPairs ermitteln + error = getCharMap( face, &charMap ); + if( error ) + goto Fail_Map; - //FontBlock allocieren + numChars = InitGeosCharsInCharMap( charMap, &firstChar, &lastChar ); + numKernPairs = CountKernPairsWithGeosChars( face ); + + /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ + AllocFontBlock( 0, numChars, numKernPairs, &fontHandle ); + ECCheckMemHandle( fontHandle ); //FontBuf füllen //Kernpairs anhängen + //Chartableentries anhängen + //Transformation (fehlende Styles) +Fail_Map: TT_Close_Face( face ); -Fail: +Fail_Face: FileClose( truetypeFile, FALSE ); - Fin: FilePopDir(); return fontHandle; @@ -189,24 +214,19 @@ static TextStyle findOutlineData( /******************************************************************** - * GenNumKernPairs + * ConvertHeader ******************************************************************** - * SYNOPSIS: Gets number of kerning pairs. + * SYNOPSIS: * - * PARAMETERS: TT_Face Face from which the number of kerning - * pairs is to be determined. + * PARAMETERS: * - * RETURNS: word number of kerning pairs + * RETURNS: * * SIDE EFFECTS: none * * CONDITION: * - * STRATEGY: A TrueType font usually has a larger number of - * characters than are used in FreeGEOS. Therefore, the - * kerning pairs must be filtered so that only pairs - * containing characters from the FreeGEOS character - * set are delivered. + * STRATEGY: * * REVISION HISTORY: * Date Name Description @@ -214,18 +234,14 @@ static TextStyle findOutlineData( * 20/12/22 JK Initial Revision *******************************************************************/ -word GetNumKernPairs( TT_Face face ) +void ConvertHeader() { - TT_Kerning directory; - - //TODO: implement - return 0; } /******************************************************************** - * ConvertHeader + * ConvertKernPairs ******************************************************************** * SYNOPSIS: * @@ -245,14 +261,14 @@ word GetNumKernPairs( TT_Face face ) * 20/12/22 JK Initial Revision *******************************************************************/ -void ConvertHeader() +void ConvertKernPairs() { } /******************************************************************** - * ConvertKernPairs + * CalcTransform ******************************************************************** * SYNOPSIS: * @@ -272,14 +288,14 @@ void ConvertHeader() * 20/12/22 JK Initial Revision *******************************************************************/ -void ConvertKernPairs() +void CalcTransform() { } /******************************************************************** - * CalcTransform + * CalcRoutines ******************************************************************** * SYNOPSIS: * @@ -299,20 +315,26 @@ void ConvertKernPairs() * 20/12/22 JK Initial Revision *******************************************************************/ -void CalcTransform() +void CalcRoutines() { } /******************************************************************** - * CalcRoutines + * AllocFontBlock ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Allocate or reallocate memory block for font. * - * PARAMETERS: + * PARAMETERS: additionalSpace additional space in block + * for driver + * numOfCharacters number of characters + * numOfKernPairs number of kerning pairs + * fontHandle* pointer to MemHandle of font block + * if NullHandle alloc new block, if not + * realloc existing block * - * RETURNS: + * RETURNS: word size of allocated block * * SIDE EFFECTS: none * @@ -323,24 +345,33 @@ void CalcTransform() * REVISION HISTORY: * Date Name Description * ---- ---- ----------- - * 20/12/22 JK Initial Revision + * 14/01/23 JK Initial Revision *******************************************************************/ - -void CalcRoutines() +static word AllocFontBlock( + word additionalSpace, + word numOfCharacters, + word numOfKernPairs, + MemHandle* fontHandle ) { + word size = sizeof( FontBuf ) + + numOfCharacters * sizeof( CharTableEntry ) + + numOfKernPairs * ( sizeof( KernPair ) + sizeof( WBFixed ) ) + + additionalSpace; + + /* allocate memory for FontBuf, CharTableEntries, KernPairs and additional space */ + if( fontHandle == NullHandle ) + { + *fontHandle = MemAllocSetOwner( FONT_MAN_ID, size, + HF_SWAPABLE | HF_SHARABLE | HF_DISCARDABLE, + HAF_NO_ERR | HAF_LOCK ); + HandleP( *fontHandle ); + } + else + { + MemReAlloc( *fontHandle, size, HAF_NO_ERR | HAF_LOCK ); + } -} - - - -void AllocFontBlock( word additionSpaceInBlock, - word numOfCharacters, - word numOf) -{ - /* Geamtgröße berechnen */ - - - /* wenn alter Block ReAlloc sonst Alloc */ + return size; } /******************************************************************** @@ -567,9 +598,9 @@ TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHea fontHeader->FH_maxRSB = -9999; fontHeader->FH_avgwidth = 0; - fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, + /* fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, &fontHeader->FH_firstChar, - &fontHeader->FH_lastChar ); + &fontHeader->FH_lastChar ); */ for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) { From 1e5446f5c68de6bec33ceb1fa8738a886dd51f7b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 16 Jan 2023 21:09:30 +0100 Subject: [PATCH 120/246] Prototype for function CalcScaleForWidhts() --- Driver/Font/TrueType/Adapter/ttwidths.c | 49 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index af3455d0a..d0b99d983 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -39,6 +39,13 @@ static word AllocFontBlock( word numOfKernPairs, MemHandle* fontHandle ); +static WWFixedAsDWord CalcScaleForWidths( + WWFixedAsDWord pointSize, + FontWidth fontWidth, + FontWeight fontWeight, + TextStyle stylesToImplement, + word unitsPerEM ); + TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, word character, @@ -63,14 +70,14 @@ void CalcRoutines(); * SYNOPSIS: Generate header width infomation about a front * in a given pointsize, style and weight. * - * PARAMETERS: fontHandle - * tMatrix - * fontInfo - * pointSize - * textStyle - * fontWeight + * PARAMETERS: fontHandle Memory handle to font block. + * tMatrix Pointer to tranformation matrix. + * fontInfo Pointer to font info block. + * pointSize Desired point size. + * textStyle Desired text style. + * fontWeight Desired font weight. * - * RETURNS: MemHandle + * RETURNS: MemHandle Memory handle to font block. * * SIDE EFFECTS: none * @@ -103,6 +110,11 @@ MemHandle _pascal TrueType_Gen_Widths( word numKernPairs; word firstChar; word lastChar; + word size; + FontBuf* fontBuf; + CharTableEntry* charTableEntry; + KernPair* kernPair; + WBFixed* kernValue; ECCheckMemHandle( fontHandle ); @@ -136,19 +148,22 @@ MemHandle _pascal TrueType_Gen_Widths( AllocFontBlock( 0, numChars, numKernPairs, &fontHandle ); ECCheckMemHandle( fontHandle ); - //FontBuf füllen + //Scalefaktor für widths berechnen + + //Header konvertieren + + //Widths berechen und einfügen - //Kernpairs anhängen + //Kernpairs konvertieren und einfügen - //Chartableentries anhängen + //Mapping konvertieren und einfügen - //Transformation (fehlende Styles) + //Transformation (und fehlende Styles) Fail_Map: TT_Close_Face( face ); Fail_Face: FileClose( truetypeFile, FALSE ); -Fin: FilePopDir(); return fontHandle; } @@ -212,6 +227,16 @@ static TextStyle findOutlineData( return styleDiff; } +static WWFixedAsDWord CalcScaleForWidths( + WWFixedAsDWord pointSize, + FontWidth fontWidth, + FontWeight fontWeight, + TextStyle stylesToImplement, + word unitsPerEM ) +{ + return 0; +} + /******************************************************************** * ConvertHeader From 1e4fd14101f1562fbd00834d4e2e6cf8d4f6ac2f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 18 Jan 2023 20:45:48 +0100 Subject: [PATCH 121/246] CalcScaleForWidths() implemented --- Driver/Font/TrueType/Adapter/ttwidths.c | 20 +++++++++++++++++++- Driver/Font/TrueType/Adapter/ttwidths.h | 10 +++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index d0b99d983..3b7016413 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -234,7 +234,25 @@ static WWFixedAsDWord CalcScaleForWidths( TextStyle stylesToImplement, word unitsPerEM ) { - return 0; + WWFixedAsDWord scaleWidth = GrUDivWWFixed( pointSize, WORD_TO_WWFIXEDASDWORD( unitsPerEM ) ); + + /* do bold need to be added? */ + if( stylesToImplement & TS_BOLD ) + scaleWidth = GrMulWWFixed( scaleWidth, WWFIXED_1_POINR_1 ); + + /* do subscript or superscript to be added? */ + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) + scaleWidth = GrMulWWFixed( scaleWidth, WWFIXED_0_POINT_5 ); + + /* adjust for fontWeight */ + if( fontWeight != FWI_MEDIUM ) + scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWeight ) ); + + /* adjust für fontWidht */ + if( fontWidth != FW_NORMAL ) + scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWidth ) ); + + return scaleWidth; } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 00499a7ce..c10c34e5c 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -41,9 +41,9 @@ typedef struct word FH_ascent; //height of caps sword FH_descent; //descent (from baseline) sword FH_baseAdjust; //adjustment for baseline - word FH_firstChar; //first char defined - word FH_lastChar; //last char defined - word FH_defaultChar; //default character + char FH_firstChar; //first char defined + char FH_lastChar; //last char defined + char FH_defaultChar; //default character sword FH_underPos; //position of underline sword FH_underThick; //thickness of underline word FH_strikePos; //position of strikethrough @@ -69,6 +69,10 @@ typedef struct #define SAFETY( value ) ( value / 40 ) // 2.5% of size +#define WWFIXED_0_POINT_5 0x00008000 +#define WWFIXED_1_POINR_1 0x00012000 + + /*********************************************************************** * functions called by driver ***********************************************************************/ From 9a242f5453025d061db97e033d8907997bfd7eeb Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 18 Jan 2023 21:51:12 +0100 Subject: [PATCH 122/246] Begin to fill FontHeader in ttinit.c. --- Driver/Font/TrueType/Adapter/ttinit.c | 66 ++++++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttinit.h | 32 ++++++++++++ Driver/Font/TrueType/Adapter/ttwidths.h | 13 +++-- 3 files changed, 96 insertions(+), 15 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 08497c329..cb272c68c 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -28,11 +28,16 @@ static TT_Error TrueType_ProcessFont( - const char* file, MemHandle fontInfoBlock ); + const char* file, + MemHandle fontInfoBlock ); -static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ); +static sword getFontIDAvailIndex( + FontID fontID, + MemHandle fontInfoBlock ); -static Boolean isMappedFont( const char* familiyName, FontID* font ); +static Boolean isMappedFont( + const char* familiyName, + FontID* font ); static FontAttrs mapFamilyClass( TT_Short familyClass ); @@ -40,7 +45,15 @@ static FontWeight mapFontWeight( TT_Short weightClass ); static TextStyle mapTextStyle( const char* subfamily ); -static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameIndex ); +static word getNameFromNameTable( + char* name, + TT_Face face, + TT_UShort nameIndex ); + +static void convertHeader( + TT_Face face, + TT_Instance instance, + FontHeader* fontHeader ); /******************************************************************** @@ -177,6 +190,7 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { FileHandle truetypeFile; TT_Face face; + TT_Instance instance; TT_Face_Properties faceProperties; TT_Error error = TT_Err_Ok; char familyName[FID_NAME_LEN]; @@ -223,6 +237,8 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) TrueTypeOutlineEntry* trueTypeOutlineEntry; ChunkHandle trueTypeOutlineChunk; OutlineDataEntry* outlineDataEntry; + ChunkHandle fontHeaderChunk; + FontHeader* fontHeader; /* allocate chunk for FontsAvailEntry and fill it */ if( LMemInsertAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ) ) @@ -265,8 +281,20 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); goto Fail; } + + /* add chunk for FontHeader */ + fontHeaderChunk = LMemAlloc( fontInfoBlock, sizeof(FontHeader) ); + if( fontHeaderChunk == NullChunk ) + { + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + LMemFreeHandles( fontInfoBlock, fontInfoChunk ); + LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); + goto Fail; + } + fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); + fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); /* fill TrueTypeOutlineEntry */ strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); @@ -276,7 +304,11 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) outlineDataEntry->ODE_style = mapTextStyle( styleName ); outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); outlineDataEntry->ODE_header.OE_handle = trueTypeOutlineChunk; + outlineDataEntry->ODE_first.OE_handle = fontHeaderChunk; + /* fill FontHeader */ + convertHeader( face, instance, fontHeader ); + fontInfo->FI_outlineTab = sizeof( FontInfo ); fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); @@ -286,9 +318,10 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) } else { - word outlineOffset; ChunkHandle trueTypeOutlineChunk; TrueTypeOutlineEntry* trueTypeOutlineEntry; + ChunkHandle fontHeaderChunk; + FontHeader* fontHeader; FontsAvailEntry* availEntries = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); ChunkHandle fontInfoChunk = availEntries[availIndex].FAE_infoHandle; FontInfo* fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); @@ -312,9 +345,17 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) error = TT_Err_Out_Of_Memory; goto Fail; } + + /* add chunk for FontHeader */ + fontHeaderChunk = LMemAlloc( fontInfoBlock, sizeof(FontHeader) ); + if( fontHeaderChunk == NullChunk ) + { + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + error = TT_Err_Out_Of_Memory; + goto Fail; + } - outlineOffset = fontInfo->FI_outlineTab; - if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, outlineOffset, sizeof( OutlineDataEntry ) ) ) + if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, fontInfo->FI_outlineTab, sizeof( OutlineDataEntry ) ) ) { LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); error = TT_Err_Out_Of_Memory; @@ -331,6 +372,10 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) outlineData->ODE_style = mapTextStyle( styleName ); outlineData->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); outlineData->ODE_header.OE_handle = trueTypeOutlineChunk; + outlineData->ODE_first.OE_handle = fontHeaderChunk; + + /* fill FontHeader */ + convertHeader( face, instance, fontHeader ); fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); @@ -512,7 +557,7 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Get_Name_String( face, n, &str, &nameLength ); - for (i = 0; str != 0 && i < nameLength; i ++) + for (i = 0; str != 0 && i < nameLength; i++) *name++ = str[i]; *name = 0; return nameLength; @@ -531,6 +576,11 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) return 0; } +static void convertHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) +{ + // TODO: Funktion von ttwidhts.c hierher verschieben +} + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 7c559521f..02750ba5d 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -57,6 +57,38 @@ #define LANGUAGE_ID_WIN_EN_US 0x0409 +/*********************************************************************** + * structues + ***********************************************************************/ + +typedef struct +{ + word FH_h_height; //top of 'H' + word FH_x_height; //top of 'x' + word FH_ascender; //top of 'd' + word FH_descender; //bottom of 'p' + word FH_avgwidth; //average character width + word FH_maxwidth; //widest character width + word FH_height; //height of font box + word FH_accent; //height of accents + word FH_ascent; //height of caps + word FH_descent; //descent (from baseline) + word FH_baseAdjust; //adjustment for baseline + char FH_firstChar; //first char defined + char FH_lastChar; //last char defined + char FH_defaultChar; //default character + word FH_underPos; //position of underline + word FH_underThick; //thickness of underline + word FH_strikePos; //position of strikethrough + word FH_numChars; //number of characters + sword FH_minLSB; //minimum left side bearing + sword FH_minTSB; //minimum top side bound + sword FH_maxBSB; //maximum bottom side bound + sword FH_maxRSB; //maximum right side bound + sword FH_continuitySize; //continuity cutoff +} FontHeader; + + /*********************************************************************** * functions called by driver ***********************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index c10c34e5c..916045e72 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -33,19 +33,19 @@ typedef struct word FH_h_height; //top of 'H' word FH_x_height; //top of 'x' word FH_ascender; //top of 'd' - sword FH_descender; //bottom of 'p' + word FH_descender; //bottom of 'p' word FH_avgwidth; //average character width word FH_maxwidth; //widest character width word FH_height; //height of font box - sword FH_accent; //height of accents + word FH_accent; //height of accents word FH_ascent; //height of caps - sword FH_descent; //descent (from baseline) - sword FH_baseAdjust; //adjustment for baseline + word FH_descent; //descent (from baseline) + word FH_baseAdjust; //adjustment for baseline char FH_firstChar; //first char defined char FH_lastChar; //last char defined char FH_defaultChar; //default character - sword FH_underPos; //position of underline - sword FH_underThick; //thickness of underline + word FH_underPos; //position of underline + word FH_underThick; //thickness of underline word FH_strikePos; //position of strikethrough word FH_numChars; //number of characters sword FH_minLSB; //minimum left side bearing @@ -56,7 +56,6 @@ typedef struct } FontHeader; - /* * constants for calculating values in FontHeader */ From 0a6065d247f020e882613535c94eb8beebcaddce Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 23 Jan 2023 21:06:34 +0100 Subject: [PATCH 123/246] fixing convertHeader() --- Driver/Font/TrueType/Adapter/ttadapter.h | 2 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 8 +- Driver/Font/TrueType/Adapter/ttcharmapper.h | 2 +- Driver/Font/TrueType/Adapter/ttinit.c | 403 +++++++++++++++++-- Driver/Font/TrueType/Adapter/ttinit.h | 62 +-- Driver/Font/TrueType/Adapter/ttwidths.c | 243 +++-------- Driver/Font/TrueType/Adapter/ttwidths.h | 57 +-- Driver/Font/TrueType/Main/truetypeInit.asm | 1 - Driver/Font/TrueType/Main/truetypeWidths.asm | 4 + Driver/Font/TrueType/backlog.md | 22 + 10 files changed, 496 insertions(+), 308 deletions(-) create mode 100644 Driver/Font/TrueType/backlog.md diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 11e9d3f6a..c5eb8c689 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -207,7 +207,7 @@ typedef struct { dword OE_offset; /* offset in file */ word OE_size; /* size in bytes) */ - Handle OE_handle; /* handle (if loaded) */ + ChunkHandle OE_handle; /* handle (if loaded) */ } OutlineEntry; /* diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 903065cf3..807e32458 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -317,26 +317,24 @@ TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) /* * Counts the GEOS characters that are present in the font. */ -word InitGeosCharsInCharMap( TT_CharMap map, word *firstChar, word *lastChar ) +word InitGeosCharsInCharMap( TT_CharMap map, char *firstChar, char *lastChar ) { word charIndex; - word charCount = 0; - *firstChar = 9999; + *firstChar = 255; *lastChar = 0; for( charIndex = 0; charIndex < NUM_CHARMAPENTRIES; ++charIndex ) { if( TT_Char_Index( map, geosCharMap[ charIndex ].unicode ) ) { - ++charCount; if ( *firstChar > ( charIndex + C_SPACE ) ) *firstChar = charIndex + C_SPACE; if ( *lastChar < ( charIndex + C_SPACE ) ) *lastChar = charIndex + C_SPACE; } } - return charCount; + return lastChar - firstChar; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 64d2b26d8..779719380 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -47,7 +47,7 @@ typedef struct * internal functions ***********************************************************************/ -word InitGeosCharsInCharMap( TT_CharMap map, word* firstChar, word* lastChar ); +word InitGeosCharsInCharMap( TT_CharMap map, char* firstChar, char* lastChar ); word CountKernPairsWithGeosChars( TT_Face face ); diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index cb272c68c..7d0d2f9a3 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -19,25 +19,23 @@ #include "ttinit.h" #include "ttadapter.h" +#include "ttcharmapper.h" #include #include #include #include #include #include +#include -static TT_Error TrueType_ProcessFont( - const char* file, - MemHandle fontInfoBlock ); +static TT_Error ProcessFont( const char* file, MemHandle fontInfoBlock ); static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ); -static Boolean isMappedFont( - const char* familiyName, - FontID* font ); +static FontID getFontID( const char* familiyName ); static FontAttrs mapFamilyClass( TT_Short familyClass ); @@ -51,9 +49,16 @@ static word getNameFromNameTable( TT_UShort nameIndex ); static void convertHeader( - TT_Face face, - TT_Instance instance, - FontHeader* fontHeader ); + TT_Face face, + TT_Face_Properties faceProperties, + TT_CharMap charMap, + FontHeader* fontHeader ); + +static word toHash( const char* str ); + +static int strlen( const char* str ); + +static void strcpy( char* dest, const char* source ); /******************************************************************** @@ -177,7 +182,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /* iterate over all filenames and try to register a font.*/ ptrFileName = MemLock( fileEnumBlock ); for( file = 0; file < numFiles; file++ ) - TrueType_ProcessFont( ptrFileName++, fontInfoBlock ); + ProcessFont( ptrFileName++, fontInfoBlock ); MemFree( fileEnumBlock ); @@ -186,11 +191,32 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) } -TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) +/******************************************************************** + * ProcessFont + ******************************************************************** + * SYNOPSIS: Registers a font with its styles as an available font. + * + * PARAMETERS: fileName Name of font file. + * fontInfoBlock Handle to memory block with all + * infos about aviable fonts. + * + * RETURNS: TT_Error Error code (see fterror.h). + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/01/23 JK Initial Revision + *******************************************************************/ + +static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { FileHandle truetypeFile; TT_Face face; - TT_Instance instance; + TT_CharMap charMap; TT_Face_Properties faceProperties; TT_Error error = TT_Err_Ok; char familyName[FID_NAME_LEN]; @@ -217,15 +243,17 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if( error ) goto Fail; + error = getCharMap( face, &charMap ); + if ( error != TT_Err_Ok ) + goto Fail; + if ( getNameFromNameTable( familyName, face, FAMILY_NAME_ID ) == 0 ) goto Fail; if ( getNameFromNameTable( styleName, face, STYLE_NAME_ID ) == 0 ) goto Fail; - if ( !isMappedFont( familyName, &fontID ) ) - fontID = MAKE_FONTID( familyName ); - + fontID = getFontID( familyName ); availIndex = getFontIDAvailIndex( fontID, fontInfoBlock ); /* if we have an new font FontAvailEntry, FontInfo and Outline must be created */ @@ -294,7 +322,6 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); - fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); /* fill TrueTypeOutlineEntry */ strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); @@ -307,7 +334,8 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) outlineDataEntry->ODE_first.OE_handle = fontHeaderChunk; /* fill FontHeader */ - convertHeader( face, instance, fontHeader ); + fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); + convertHeader( face, faceProperties, charMap, fontHeader ); fontInfo->FI_outlineTab = sizeof( FontInfo ); fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); @@ -322,9 +350,9 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) TrueTypeOutlineEntry* trueTypeOutlineEntry; ChunkHandle fontHeaderChunk; FontHeader* fontHeader; + FontInfo* fontInfo; FontsAvailEntry* availEntries = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); ChunkHandle fontInfoChunk = availEntries[availIndex].FAE_infoHandle; - FontInfo* fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); OutlineDataEntry* outlineDataEnd = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineEnd); @@ -346,6 +374,15 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) goto Fail; } + /* insert OutlineDataEntry behinde fontinfo */ + fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); + if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, fontInfo->FI_outlineTab, sizeof( OutlineDataEntry ) ) ) + { + LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); + error = TT_Err_Out_Of_Memory; + goto Fail; + } + /* add chunk for FontHeader */ fontHeaderChunk = LMemAlloc( fontInfoBlock, sizeof(FontHeader) ); if( fontHeaderChunk == NullChunk ) @@ -355,13 +392,6 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) goto Fail; } - if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, fontInfo->FI_outlineTab, sizeof( OutlineDataEntry ) ) ) - { - LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); - error = TT_Err_Out_Of_Memory; - goto Fail; - } - /* fill TrueTypeOutlineEntry */ trueTypeOutlineEntry = LMemDerefHandles( fontInfoBlock, trueTypeOutlineChunk ); strcpy( trueTypeOutlineEntry->TTOE_fontFileName, fileName ); @@ -375,7 +405,8 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) outlineData->ODE_first.OE_handle = fontHeaderChunk; /* fill FontHeader */ - convertHeader( face, instance, fontHeader ); + fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); + convertHeader( face, faceProperties, charMap, fontHeader ); fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); @@ -389,9 +420,24 @@ TT_Error TrueType_ProcessFont( const char* fileName, MemHandle fontInfoBlock ) } -/*******************************************************************/ -/* Implemetation of helperfunctions */ -/*******************************************************************/ +/******************************************************************** + * toHash + ******************************************************************** + * SYNOPSIS: Calculates the hash value of the passed string. + * + * PARAMETERS: str Pointer to the string. + * + * RETURNS: word Hash value for passed string. + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ static word toHash( const char* str ) { @@ -404,6 +450,26 @@ static word toHash( const char* str ) return (word) hash; } + +/******************************************************************** + * mapFamiliClass + ******************************************************************** + * SYNOPSIS: Maps the TrueType family class to FreeGEOS FontAttrs. + * + * PARAMETERS: familyClass TrueType family class. + * + * RETURNS: FontAttrs FreeGEOS FontAttrs. + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ + static FontAttrs mapFamilyClass( TT_Short familyClass ) { byte class = familyClass >> 8; @@ -447,6 +513,27 @@ static FontAttrs mapFamilyClass( TT_Short familyClass ) return FA_USEFUL | FA_OUTLINE | family; } + +/******************************************************************** + * mapFontWeight + ******************************************************************** + * SYNOPSIS: Maps the TrueType font weight class to FreeGEOS + * AdjustedWeight. + * + * PARAMETERS: weightClass TrueType weight class. + * + * RETURNS: AdjustedWeight FreeGEOS AdjustedWeight. + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ + static AdjustedWeight mapFontWeight( TT_Short weightClass ) { switch (weightClass / 100) @@ -472,6 +559,26 @@ static AdjustedWeight mapFontWeight( TT_Short weightClass ) } } + +/******************************************************************** + * mapTextStyle + ******************************************************************** + * SYNOPSIS: Maps the TrueType subfamily to FreeGEOS TextStyle. + * + * PARAMETERS: subfamily* String with subfamiliy name. + * + * RETURNS: TextStyle FreeGEOS TextStyle. + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ + static TextStyle mapTextStyle( const char* subfamily ) { if ( strcmp( subfamily, "Regular" ) == 0 ) @@ -489,19 +596,60 @@ static TextStyle mapTextStyle( const char* subfamily ) return TS_BOLD | TS_ITALIC; } -static Boolean isMappedFont( const char* familiyName, FontID* fontID ) + +/******************************************************************** + * getFontID + ******************************************************************** + * SYNOPSIS: If the passed font family is a mapped font, + * the FontID form geos.ini is returned, otherwise + * we calculate new FontID and return it. + * + * PARAMETERS: familyName* Font family name. + * + * RETURNS: FontID FontID found geos.ini or calculated. + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ + +static FontID getFontID( const char* familyName ) { - Boolean result; + FontID fontID; - result = !InitFileReadInteger( FONTMAPPING_CATEGORY, - familiyName, - fontID ); + if( !InitFileReadInteger( FONTMAPPING_CATEGORY, familyName, &fontID ) ) + return FM_TRUETYPE || (fontID && 0x0fff); - /* ensure FM_TRUETYPE is set */ - *fontID = FM_TRUETYPE || (*fontID && 0x0fff); - return result; + return MAKE_FONTID( familyName ); } + +/******************************************************************** + * getFontIDAvailIndex + ******************************************************************** + * SYNOPSIS: Searches all FontsAvailEntries for the passed + * FontID and returns its index. If no FontsAvailEntry + * is found for the FontID, -1 is returned. + * + * PARAMETERS: fontID Searched FontID. + * fontInfoBlock Memory block with font information. + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) { FontsAvailEntry* fontsAvailEntrys; @@ -520,6 +668,29 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) return -1; } + +/******************************************************************** + * getNameFromNameTable + ******************************************************************** + * SYNOPSIS: Searches the font's name tables for the given NameID + * and returns its content. + * + * PARAMETERS: name* Pointer to result string. + * face TrueType face to be searched. + * nameID ID to be searched. + * + * RETURNS: word Length of the table entry found. + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ + static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) { TT_Face_Properties faceProperties; @@ -576,9 +747,163 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) return 0; } -static void convertHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) + +/******************************************************************** + * convertHeader + ******************************************************************** + * SYNOPSIS: Converts information from a TrueType font into a + * FreeGEOS FontHeader. + * + * PARAMETERS: face Face from which the information + * is to be converted. + * faceProperties FaceProperties to be used. + * charMap CharMap to be used. + * instance Instance to be used. + * fontHeader* Pointer to FontInfo in which the + * converted information is to be stored. + * + * RETURNS: void + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 21/01/23 JK Initial Revision + *******************************************************************/ + +static void convertHeader( + TT_Face face, + TT_Face_Properties faceProperties, + TT_CharMap charMap, + FontHeader* fontHeader ) { - // TODO: Funktion von ttwidhts.c hierher verschieben + TT_UShort charIndex; + TT_Glyph glyph; + TT_Glyph_Metrics metrics; + TT_Instance instance; + word geosChar; + word unitsPerEM; + sword maxAccentOrAscent; + + + ECCheckBounds( (void*)fontHeader ); + + /* initialize min, max and avg values in fontHeader */ + fontHeader->FH_minLSB = 9999; + fontHeader->FH_maxBSB = -9999; + fontHeader->FH_minTSB = -9999; + fontHeader->FH_maxRSB = -9999; + fontHeader->FH_avgwidth = 0; + + fontHeader->FH_numChars = InitGeosCharsInCharMap( charMap, + &fontHeader->FH_firstChar, + &fontHeader->FH_lastChar ); + + TT_New_Glyph( face, &glyph ); //TEST + TT_New_Instance( face, &instance ); + + for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) + { + word unicode = GeosCharToUnicode( geosChar + 1 ); + + charIndex = TT_Char_Index( charMap, unicode ); + if ( charIndex == 0 ) + break; + + /* load glyph without scaling or hinting */ + TT_Load_Glyph( instance, glyph, charIndex, TTLOAD_DEFAULT ); + TT_Get_Glyph_Metrics( glyph, &metrics ); + + //h_height + if( unicode == C_LATIN_CAPITAL_LETTER_H ) + fontHeader->FH_h_height = metrics.bbox.yMax; + + //x_height + if ( unicode == C_LATIN_SMALL_LETTER_X ) + fontHeader->FH_x_height = metrics.bbox.yMax; + + //ascender + if ( unicode == C_LATIN_SMALL_LETTER_D ) + fontHeader->FH_ascender = metrics.bbox.yMax; + + //descender + if ( unicode == C_LATIN_SMALL_LETTER_P ) + fontHeader->FH_descender = metrics.bbox.yMin; + + //width + if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) + fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; + + //avg width + if ( GeosAvgWidth( geosChar ) ) + { + fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( + ( metrics.bbox.xMax - metrics.bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); + } + + /* scan xMin */ + if( fontHeader->FH_minLSB > metrics.bbox.xMin ) + fontHeader->FH_minLSB = (sword) metrics.bbox.xMin; + + /* scan xMax */ + if ( fontHeader->FH_maxRSB < metrics.bbox.xMax ) + fontHeader->FH_maxRSB = metrics.bbox.xMax; + /* scan yMin */ + if ( fontHeader->FH_maxBSB < metrics.bbox.yMin ) + fontHeader->FH_maxBSB = metrics.bbox.yMin; + + //yMax + if ( fontHeader->FH_minTSB < metrics.bbox.yMax ) + { + fontHeader->FH_minTSB = metrics.bbox.yMax; + if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT && + fontHeader->FH_accent < metrics.bbox.yMax ) + fontHeader->FH_accent = metrics.bbox.yMax; + } + + } + TT_Done_Glyph( glyph ); // TEST + TT_Done_Instance( instance ); + + unitsPerEM = faceProperties.header->Units_Per_EM; + + //baseline + if ( fontHeader->FH_accent <= 0 ) + { + fontHeader->FH_accent = 0; + maxAccentOrAscent = fontHeader->FH_ascent; + } + else + { + maxAccentOrAscent = fontHeader->FH_accent; + fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; + } + + fontHeader->FH_baseAdjust = BASELINE( unitsPerEM )- maxAccentOrAscent; + fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; + fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( unitsPerEM ); + fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( unitsPerEM ) - + SAFETY( unitsPerEM ) ); + + fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; + if( fontHeader->FH_underPos == 0 ) + fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( unitsPerEM ); + + fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; + + fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; + if( fontHeader->FH_underThick == 0 ) + fontHeader->FH_underThick = DEFAULT_UNDER_THICK( unitsPerEM ); + + if( fontHeader->FH_x_height > 0 ) + fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; + else + fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; + + fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( unitsPerEM ); } diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 02750ba5d..a4aef447d 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -14,8 +14,7 @@ * 20/12/22 JK Initial version * * DESCRIPTION: - * Declarations of types and functions for the driver function - * DR_INIT. + * Declarations of types and functions for the driver function DR_INIT. ***********************************************************************/ #ifndef _TTINIT_H_ @@ -30,33 +29,59 @@ /*********************************************************************** - * constants + * constants for font mapping ***********************************************************************/ -#define FONTMAPPING_CATEGORY "FontMapping" +#define FONTMAPPING_CATEGORY "FontMapping" -#define FAMILY_NAME_ID 1 // id for font family name -#define STYLE_NAME_ID 2 // id for font style -#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE - -#define FAMILY_NAME_LENGTH 20 -#define STYLE_NAME_LENGTH 16 - -#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) +/*********************************************************************** + * constants for ttf name tables + ***********************************************************************/ +#define FAMILY_NAME_ID 1 +#define STYLE_NAME_ID 2 #define PLATFORM_ID_MAC 1 #define PLATFORM_ID_MS 3 #define ENCODING_ID_MAC_ROMAN 0 #define ENCODING_ID_MS_UNICODE_BMP 1 -#define ENCODING_ID_UNICODE 3 +#define ENCODING_ID_UNICODE 3 #define LANGUAGE_ID_MAC_EN 0 #define LANGUAGE_ID_WIN_EN_US 0x0409 +/*********************************************************************** + * constants for string length + ***********************************************************************/ + +#define FAMILY_NAME_LENGTH 20 +#define STYLE_NAME_LENGTH 16 +#define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE + + +/*********************************************************************** + * macros for calculating values in FontHeader + ***********************************************************************/ + +#define DEFAULT_CONTINUITY_CUTOFF( value ) ( value / 40 ) // 2.5% of size +#define DEFAULT_DEFAULT_CHAR '.' +#define BASELINE( value ) ( 3 * value / 4 ) // 75% of size +#define DESCENT( value ) ( value / 4 ) // 25% of size +#define DEFAULT_UNDER_THICK( value ) ( value / 10 ) // 10% of size +#define DEFAULT_UNDER_POSITION( value ) ( value / -10 ) // -10% of size +#define SAFETY( value ) ( value / 40 ) // 2.5% of size + + +/*********************************************************************** + * macro for calculating font ID + ***********************************************************************/ + +#define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) + + /*********************************************************************** * structues ***********************************************************************/ @@ -96,15 +121,4 @@ typedef struct void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); -/*********************************************************************** - * internal functions - ***********************************************************************/ - -static word toHash( const char* str ); - -static int strlen( const char* str ); - -static void strcpy( char* dest, const char* source ); - - #endif /* _TTINT_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 3b7016413..4751a7688 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -24,11 +24,13 @@ #include #include "ttwidths.h" #include "ttcharmapper.h" +#include "ttinit.h" #include "../FreeType/ftxkern.h" static TextStyle findOutlineData( ChunkHandle* truetypeOutlineEntryChunk, + ChunkHandle* fontHeaderChunk, const FontInfo* fontInfo, TextStyle textStyle, FontWeight fontWeight ); @@ -53,15 +55,13 @@ TT_Error Fill_CharTableEntry( TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ); -TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ); - void ConvertHeader(); void ConvertKernPairs(); -void CalcTransform(); - -void CalcRoutines(); +void CalcTransform( TT_Matrix* resultMatrix, + FontMatrix* transformMatrix, + TextStyle styleToImplement ); /******************************************************************** @@ -81,8 +81,6 @@ void CalcRoutines(); * * SIDE EFFECTS: none * - * CONDITION: - * * STRATEGY: * * REVISION HISTORY: @@ -93,36 +91,41 @@ void CalcRoutines(); MemHandle _pascal TrueType_Gen_Widths( MemHandle fontHandle, - void* tMatrix, + FontMatrix* fontMatrix, const FontInfo* fontInfo, WWFixedAsDWord pointSize, TextStyle textStyle, + FontWidth fontWidth, FontWeight fontWeight ) { FileHandle truetypeFile; ChunkHandle truetypeChunkHandle; + ChunkHandle fontHeaderChunkHandle; TrueTypeOutlineEntry* trueTypeOutlineEntry; TextStyle stylesToImplement; TT_Face face; + TT_Face_Properties faceProperties; TT_CharMap charMap; TT_Error error; word numChars; word numKernPairs; - word firstChar; - word lastChar; + char firstChar; + char lastChar; word size; + FontHeader* fontHeader; FontBuf* fontBuf; CharTableEntry* charTableEntry; KernPair* kernPair; WBFixed* kernValue; + WWFixedAsDWord scaleFactor; ECCheckMemHandle( fontHandle ); - ECCheckBounds( tMatrix ); + ECCheckBounds( fontMatrix ); ECCheckBounds( (void*)fontInfo ); /* find outline for textStyle and fontWeight */ - stylesToImplement = findOutlineData( &truetypeChunkHandle, fontInfo, textStyle, fontWeight ); + stylesToImplement = findOutlineData( &truetypeChunkHandle, &fontHeaderChunkHandle, fontInfo, textStyle, fontWeight ); /* get filename an load ttf file */ FilePushDir(); @@ -137,6 +140,10 @@ MemHandle _pascal TrueType_Gen_Widths( if( error ) goto Fail_Face; + error = TT_Get_Face_Properties( face, &faceProperties ); + if( error ) + goto Fail_Map; + error = getCharMap( face, &charMap ); if( error ) goto Fail_Map; @@ -148,17 +155,21 @@ MemHandle _pascal TrueType_Gen_Widths( AllocFontBlock( 0, numChars, numKernPairs, &fontHandle ); ECCheckMemHandle( fontHandle ); - //Scalefaktor für widths berechnen + /* calculate scale factor and transformation matrix */ + scaleFactor = CalcScaleForWidths( pointSize, + fontWidth, + fontWeight, + stylesToImplement, + faceProperties.header->Units_Per_EM ); + + //Widths berechen und einfügen (CharTableEntries) + //Header konvertieren - - //Widths berechen und einfügen - //Kernpairs konvertieren und einfügen - //Mapping konvertieren und einfügen + //Kernpairs konvertieren und einfügen - //Transformation (und fehlende Styles) Fail_Map: TT_Close_Face( face ); @@ -171,11 +182,12 @@ MemHandle _pascal TrueType_Gen_Widths( static TextStyle findOutlineData( ChunkHandle* truetypeOutlineEntryChunk, + ChunkHandle* fontHeaderChunk, const FontInfo* fontInfo, TextStyle textStyle, FontWeight fontWeight ) { - ChunkHandle chunkToUse; + OutlineDataEntry* outlineToUse; OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); OutlineDataEntry* outlineDataEnd = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineEnd); TextStyle styleDiff = 127; @@ -193,6 +205,7 @@ static TextStyle findOutlineData( outlineData->ODE_weight == fontWeight ) { *truetypeOutlineEntryChunk = outlineData->ODE_header.OE_handle; + *fontHeaderChunk = outlineData->ODE_first.OE_handle; return 0; // no styles to implement } @@ -204,7 +217,7 @@ static TextStyle findOutlineData( styleDiff = 0; if( weightDiff >= currentWeightDiff ) { - chunkToUse = outlineData->ODE_header.OE_handle; + outlineToUse = outlineData; weightDiff = currentWeightDiff; } @@ -216,14 +229,15 @@ static TextStyle findOutlineData( byte currentStyleDiff = textStyle ^ outlineData->ODE_style; if( styleDiff >= currentStyleDiff ) { - chunkToUse = outlineData->ODE_header.OE_handle; + outlineToUse = outlineData; styleDiff = currentStyleDiff; } } outlineData++; } - *truetypeOutlineEntryChunk = chunkToUse; + *truetypeOutlineEntryChunk = outlineToUse->ODE_header.OE_handle; + *fontHeaderChunk = outlineToUse->ODE_first.OE_handle; return styleDiff; } @@ -244,13 +258,13 @@ static WWFixedAsDWord CalcScaleForWidths( if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) scaleWidth = GrMulWWFixed( scaleWidth, WWFIXED_0_POINT_5 ); - /* adjust for fontWeight */ + /* adjust for fontWidth */ if( fontWeight != FWI_MEDIUM ) - scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWeight ) ); + scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWidth ) ); - /* adjust für fontWidht */ + /* adjust für fontWeight */ if( fontWidth != FW_NORMAL ) - scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWidth ) ); + scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWeight ) ); return scaleWidth; } @@ -313,43 +327,17 @@ void ConvertKernPairs() /******************************************************************** * CalcTransform ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Calculates the transformation matrix to + * calculate missing style attributes and weights. * - * PARAMETERS: + * PARAMETERS: resultMatrix* + * styleToImplement + * * * RETURNS: * * SIDE EFFECTS: none * - * CONDITION: - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 20/12/22 JK Initial Revision - *******************************************************************/ - -void CalcTransform() -{ - -} - - -/******************************************************************** - * CalcRoutines - ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: - * - * RETURNS: - * - * SIDE EFFECTS: none - * - * CONDITION: - * * STRATEGY: * * REVISION HISTORY: @@ -358,7 +346,9 @@ void CalcTransform() * 20/12/22 JK Initial Revision *******************************************************************/ -void CalcRoutines() +static void CalcTransform( TT_Matrix* resultMatrix, + FontMatrix* fontMatrix, + TextStyle styleToImplement ) { } @@ -465,7 +455,7 @@ TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, /******************************************************************** - * Fill_FontBuf + * ConvertHeader ******************************************************************** * SYNOPSIS: Fills the FontBuf structure with informations * of the passed in ttf file. @@ -514,10 +504,6 @@ TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) if ( error ) return error; - error = fillFontHeader( face, instance, &fontHeader ); - if ( error ) - return error; - scaleFactor = instanceMetrics.x_scale; /* Fill elements in FontBuf structure. */ @@ -614,136 +600,5 @@ TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) TT_Done_Instance( instance ); - return TT_Err_Ok; -} - -TT_Error fillFontHeader( TT_Face face, TT_Instance instance, FontHeader* fontHeader ) -{ - TT_CharMap charMap; - TT_Error error; - TT_UShort charIndex; - TT_Glyph glyph; - TT_Glyph_Metrics metrics; - TT_Face_Properties faceProperties; - word geosChar; - word unitsPerEM; - sword maxAccentOrAscent; - - - error = getCharMap( face, &charMap ); - if ( error != TT_Err_Ok ) - return error; - - /* initialize min, max and avg values in fontHeader */ - fontHeader->FH_minLSB = 9999; - fontHeader->FH_maxBSB = -9999; - fontHeader->FH_minTSB = -9999; - fontHeader->FH_maxRSB = -9999; - fontHeader->FH_avgwidth = 0; - - /* fontHeader->FH_numChars = CountGeosCharsInCharMap( charMap, - &fontHeader->FH_firstChar, - &fontHeader->FH_lastChar ); */ - - for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) - { - word unicode = GeosCharToUnicode( geosChar ); - - charIndex = TT_Char_Index( charMap, unicode ); - if ( charIndex == 0 ) - break; - - /* load glyph without scaling or hinting */ - TT_New_Glyph( face, &glyph ); - TT_Load_Glyph( instance, glyph, charIndex, 0 ); - TT_Get_Glyph_Metrics( glyph, &metrics ); - - //h_height - if( unicode == C_LATIN_CAPITAL_LETTER_H ) - fontHeader->FH_h_height = metrics.bbox.yMax; - - //x_height - if ( unicode == C_LATIN_SMALL_LETTER_X ) - fontHeader->FH_x_height = metrics.bbox.yMax; - - //ascender - if ( unicode == C_LATIN_SMALL_LETTER_D ) - fontHeader->FH_ascender = metrics.bbox.yMax; - - //descender - if ( unicode == C_LATIN_SMALL_LETTER_P ) - fontHeader->FH_descender = metrics.bbox.yMin; - - //width - if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) - fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; - - //avg width - if ( GeosAvgWidth( geosChar ) ) - { - fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( - ( metrics.bbox.xMax - metrics.bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); - } - - /* scan xMin */ - if( fontHeader->FH_minLSB > metrics.bbox.xMin ) - fontHeader->FH_minLSB = (sword) metrics.bbox.xMin; - - /* scan xMax */ - if ( fontHeader->FH_maxRSB < metrics.bbox.xMax ) - fontHeader->FH_maxRSB = metrics.bbox.xMax; - /* scan yMin */ - if ( fontHeader->FH_maxBSB < metrics.bbox.yMin ) - fontHeader->FH_maxBSB = metrics.bbox.yMin; - - //yMax - if ( fontHeader->FH_minTSB < metrics.bbox.yMax ) - { - fontHeader->FH_minTSB = metrics.bbox.yMax; - if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT && - fontHeader->FH_accent < metrics.bbox.yMax ) - fontHeader->FH_accent = metrics.bbox.yMax; - } - } - - TT_Get_Face_Properties( face, &faceProperties ); - unitsPerEM = faceProperties.header->Units_Per_EM; - - //baseline - if ( fontHeader->FH_accent <= 0 ) - { - fontHeader->FH_accent = 0; - maxAccentOrAscent = fontHeader->FH_ascent; - } - else - { - maxAccentOrAscent = fontHeader->FH_accent; - fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; - } - - fontHeader->FH_baseAdjust = BASELINE( unitsPerEM )- maxAccentOrAscent; - fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; - fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( unitsPerEM ); - fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( unitsPerEM ) - - SAFETY( unitsPerEM ) ); - - fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; - if( fontHeader->FH_underPos == 0 ) - fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( unitsPerEM ); - - fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; - - fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; - if( fontHeader->FH_underThick == 0 ) - fontHeader->FH_underThick = DEFAULT_UNDER_THICK( unitsPerEM ); - - if( fontHeader->FH_x_height > 0 ) - fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; - else - fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; - - fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( unitsPerEM ); - - return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 916045e72..75273b8c3 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -25,51 +25,21 @@ #include "ttadapter.h" -/* - * Structure to hold information necessary to fill FontBuf structure. - */ -typedef struct -{ - word FH_h_height; //top of 'H' - word FH_x_height; //top of 'x' - word FH_ascender; //top of 'd' - word FH_descender; //bottom of 'p' - word FH_avgwidth; //average character width - word FH_maxwidth; //widest character width - word FH_height; //height of font box - word FH_accent; //height of accents - word FH_ascent; //height of caps - word FH_descent; //descent (from baseline) - word FH_baseAdjust; //adjustment for baseline - char FH_firstChar; //first char defined - char FH_lastChar; //last char defined - char FH_defaultChar; //default character - word FH_underPos; //position of underline - word FH_underThick; //thickness of underline - word FH_strikePos; //position of strikethrough - word FH_numChars; //number of characters - sword FH_minLSB; //minimum left side bearing - sword FH_minTSB; //minimum top side bound - sword FH_maxBSB; //maximum bottom side bound - sword FH_maxRSB; //maximum right side bound - sword FH_continuitySize; //continuity cutoff -} FontHeader; - +#define WWFIXED_0_POINT_5 0x00008000 +#define WWFIXED_1_POINR_1 0x00012000 -/* - * constants for calculating values in FontHeader - */ -#define DEFAULT_CONTINUITY_CUTOFF( value ) ( value / 40 ) // 2.5% of size -#define DEFAULT_DEFAULT_CHAR '.' -#define BASELINE( value ) ( 3 * value / 4 ) // 75% of size -#define DESCENT( value ) ( value / 4 ) // 25% of size -#define DEFAULT_UNDER_THICK( value ) ( value / 10 ) // 10% of size -#define DEFAULT_UNDER_POSITION( value ) ( value / -10 ) // -10% of size -#define SAFETY( value ) ( value / 40 ) // 2.5% of size +/*********************************************************************** + * structues + ***********************************************************************/ -#define WWFIXED_0_POINT_5 0x00008000 -#define WWFIXED_1_POINR_1 0x00012000 +typedef struct +{ + WWFixed FM_11; + WWFixed FM_12; + WWFixed FM_21; + WWFixed FM_22; +} FontMatrix; /*********************************************************************** @@ -78,10 +48,11 @@ typedef struct MemHandle _pascal TrueType_Gen_Widths( MemHandle fontHandle, - void* tMatrix, + FontMatrix* fontMatrix, const FontInfo* fontInfo, WWFixedAsDWord pointSize, TextStyle textStyle, + FontWidth fontWidth, FontWeight fontWeight ); diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index 16a5e228e..63b8df15f 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -235,7 +235,6 @@ done: call FilePopDir endif clc - .leave ret diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index 2fb660dc1..b668a41cf 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -86,6 +86,10 @@ TrueTypeGenWidths proc far mov al, es:GS_fontAttr.FCA_weight push ax ; pass font weight + ; font width from gstate + mov al, es:GS_fontAttr.FCA_width + push ax ; pass font width + segmov ds, dgroup, dx call TRUETYPE_GEN_WIDTHS diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md new file mode 100644 index 000000000..b70fc8c79 --- /dev/null +++ b/Driver/Font/TrueType/backlog.md @@ -0,0 +1,22 @@ +## TODOs +- ~~FontHeader füllen und im FontInfoBlock ablegen~~ +- FontBuf auf Basis des FontHeaders füllen (Gen_Widths) +- CharTableEntries füllen (Gen_Widths) +- KernPairs und KernValues füllen (Achtung: sie offene Probleme) +- Transformationsmatrix berechnen und im FontBlock halten (die FakeStyles sind in der Matrix 'enthalten')(Gen_Widths) +- in Gen_Char eine Bitmap erzeugen (notfalls eine Fake Bitmap damit entlich etwas zu sehen ist) + +## Refactorings +- ttinit.c refactorn (Hilfsfunktionen auslagern, lokale Variablen reduzieren) +- FreeType Strukturen zusammenführen (Strukturen die eine 1:1 Kardinalität zu TT_Engine haben in TT_Engine integrieren) +- bessere Lösung für das Mappen GeosChar -> UniCode finden + +## Optimierungen +- prüfen: ob TT_Error in tterrid.h von long auf word reduziert werden kann +- prüfen: ob in ttraster.c traceG, gTarget, traceLastLine entfernt werden kann +- in ttobj.h kann in T_Font_Input_ ->fontIndex entfernt werden (Ãœberbleibsel der TTCollections die wir nicht brauchen) +- in ttraster.c (Set_Hight_Precision) kann gesteuert werden wie 'genau' ein Glyph gerendert wird; falls wir noch Performanceprobleme haben kann hier auch angesetzt werden (ggf. auch mehrstufig) + +## offene Probleme +- klären: der Aufruf von TT_Init_Kerning lässt swat crachen + From 425e866fc0975f8eacfa7fd48f3fd1b1daad9e18 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 28 Jan 2023 21:17:27 +0100 Subject: [PATCH 124/246] Begin to implement ConvertWidths() --- Driver/Font/TrueType/Adapter/ttadapter.h | 8 +- Driver/Font/TrueType/Adapter/ttinit.c | 8 +- Driver/Font/TrueType/Adapter/ttwidths.c | 266 ++++++++---------- Driver/Font/TrueType/backlog.md | 26 +- Installed/Driver/Font/TrueType/Makefile | 42 +-- .../Driver/Font/TrueType/dependencies.mk | 241 +++++++++++----- Installed/Driver/Font/TrueType/swat.rc | 5 + 7 files changed, 349 insertions(+), 247 deletions(-) create mode 100644 Installed/Driver/Font/TrueType/swat.rc diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index c5eb8c689..06319caef 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -37,6 +37,8 @@ extern TEngine_Instance engineInstance; #define TTF_DIRECTORY "TTF" #define FONT_MAN_ID 0x20 +#define CHAR_NOT_BUILT 2 + /*********************************************************************** * structures ***********************************************************************/ @@ -98,13 +100,13 @@ typedef struct * flags for describing rendered char (see fontDr.def) */ typedef ByteFlags CharTableFlags; -#define CTF_NEGATIVE_LSB 0x40 +#define CTF_NEGATIVE_LSB 0x40 //set is negativ left side bearing #define CTF_ABOVE_ASCENT 0x20 #define CTF_BELOW_DESCENT 0x10 -#define CTF_NO_DATA 0x08 +#define CTF_NO_DATA 0x08 //set if char is missing in chracter set #define CTF_IS_FIRST_KERN 0x04 #define CTF_IS_SECOND_KERN 0x02 -#define CTF_NOT_VISIBLE 0x01 +#define CTF_NOT_VISIBLE 0x01 //set if char is normally invisible /* diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 7d0d2f9a3..09e11ccf6 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -802,12 +802,12 @@ static void convertHeader( &fontHeader->FH_firstChar, &fontHeader->FH_lastChar ); - TT_New_Glyph( face, &glyph ); //TEST + TT_New_Glyph( face, &glyph ); TT_New_Instance( face, &instance ); for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) { - word unicode = GeosCharToUnicode( geosChar + 1 ); + word unicode = GeosCharToUnicode( geosChar ); charIndex = TT_Char_Index( charMap, unicode ); if ( charIndex == 0 ) @@ -865,8 +865,8 @@ static void convertHeader( } } - TT_Done_Glyph( glyph ); // TEST - TT_Done_Instance( instance ); + TT_Done_Glyph( glyph ); + TT_Done_Instance( instance ); unitsPerEM = faceProperties.header->Units_Per_EM; diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 4751a7688..8fe88c4c3 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -25,12 +25,12 @@ #include "ttwidths.h" #include "ttcharmapper.h" #include "ttinit.h" +#include "freetype.h" #include "../FreeType/ftxkern.h" static TextStyle findOutlineData( - ChunkHandle* truetypeOutlineEntryChunk, - ChunkHandle* fontHeaderChunk, + OutlineDataEntry** outlineData, const FontInfo* fontInfo, TextStyle textStyle, FontWeight fontWeight ); @@ -48,18 +48,16 @@ static WWFixedAsDWord CalcScaleForWidths( TextStyle stylesToImplement, word unitsPerEM ); -TT_Error Fill_CharTableEntry( - const FontInfo* fontInfo, - word character, - CharTableEntry* charTableEntry ); - -TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ); +TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* fontHeader, FontBuf* fontBuf ); -void ConvertHeader(); +static void ConvertWidhts( TT_Face face, + FontHeader* fontHeader, + WWFixedAsDWord scaleFactor, + CharTableEntry* charTableEntries ); void ConvertKernPairs(); -void CalcTransform( TT_Matrix* resultMatrix, +static void CalcTransform( TT_Matrix* resultMatrix, FontMatrix* transformMatrix, TextStyle styleToImplement ); @@ -99,61 +97,54 @@ MemHandle _pascal TrueType_Gen_Widths( FontWeight fontWeight ) { FileHandle truetypeFile; - ChunkHandle truetypeChunkHandle; - ChunkHandle fontHeaderChunkHandle; + OutlineDataEntry* outlineData; TrueTypeOutlineEntry* trueTypeOutlineEntry; TextStyle stylesToImplement; TT_Face face; TT_Face_Properties faceProperties; - TT_CharMap charMap; TT_Error error; - word numChars; word numKernPairs; - char firstChar; - char lastChar; word size; FontHeader* fontHeader; FontBuf* fontBuf; - CharTableEntry* charTableEntry; + CharTableEntry* charTableEntries; KernPair* kernPair; WBFixed* kernValue; WWFixedAsDWord scaleFactor; - + ECCheckMemHandle( fontHandle ); ECCheckBounds( fontMatrix ); ECCheckBounds( (void*)fontInfo ); /* find outline for textStyle and fontWeight */ - stylesToImplement = findOutlineData( &truetypeChunkHandle, &fontHeaderChunkHandle, fontInfo, textStyle, fontWeight ); + stylesToImplement = findOutlineData( &outlineData, fontInfo, textStyle, fontWeight ); /* get filename an load ttf file */ FilePushDir(); FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - trueTypeOutlineEntry = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), truetypeChunkHandle ); + /* get pointer to TrueTypeOutline and FontHeader*/ + trueTypeOutlineEntry = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineData->ODE_header.OE_handle ); + fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineData->ODE_first.OE_handle ); + + /* open ttf file, face, properties and properties */ truetypeFile = FileOpen( trueTypeOutlineEntry->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( truetypeFile ); error = TT_Open_Face( truetypeFile, &face ); if( error ) - goto Fail_Face; + goto Fail; error = TT_Get_Face_Properties( face, &faceProperties ); if( error ) - goto Fail_Map; + goto Fail; - error = getCharMap( face, &charMap ); - if( error ) - goto Fail_Map; - - numChars = InitGeosCharsInCharMap( charMap, &firstChar, &lastChar ); numKernPairs = CountKernPairsWithGeosChars( face ); /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ - AllocFontBlock( 0, numChars, numKernPairs, &fontHandle ); - ECCheckMemHandle( fontHandle ); + size = AllocFontBlock( 0, fontHeader->FH_numChars, numKernPairs, &fontHandle ); /* calculate scale factor and transformation matrix */ scaleFactor = CalcScaleForWidths( pointSize, @@ -162,30 +153,98 @@ MemHandle _pascal TrueType_Gen_Widths( stylesToImplement, faceProperties.header->Units_Per_EM ); - //Widths berechen und einfügen (CharTableEntries) - + /* convert FontHeader */ + fontBuf = MemDeref( fontHandle ); + ConvertHeader( face, pointSize, fontHeader, fontBuf ); - //Header konvertieren + /* convert Widths */ + charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + ConvertWidths( face, fontHeader, scaleFactor, charTableEntries ); + //TODO: Kernpairs konvertieren und einfügen - //Kernpairs konvertieren und einfügen + //TODO: Tranformationsmatix berechnen und in FontBlock kopieren -Fail_Map: +Fail: TT_Close_Face( face ); -Fail_Face: FileClose( truetypeFile, FALSE ); FilePopDir(); return fontHandle; } +static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, CharTableEntry* charTableEntry ) +{ + TT_Instance instance; + TT_Glyph glyph; + TT_CharMap charMap; + TT_Glyph_Metrics metrics; + char currentChar; + + TT_New_Glyph( face, &glyph ); + TT_New_Instance( face, &instance ); + getCharMap( face, &charMap ); + + for( currentChar = fontHeader->FH_firstChar; currentChar < fontHeader->FH_lastChar; currentChar++ ) + { + word charIndex; + word width; + WWFixedAsDWord scaledWidth; + + + //Geos Char to Unicode + word unicode = GeosCharToUnicode( currentChar ); + + //Unicode to TT ID + charIndex = TT_Char_Index( charMap, unicode ); + if ( charIndex == 0 ) + { + charTableEntry->CTE_flags = CTF_NO_DATA; + charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; + charTableEntry->CTE_width.WBF_int = 0; + charTableEntry->CTE_width.WBF_frac = 0; + + charTableEntry++; + continue; + } + + //Glyph laden + TT_Load_Glyph( instance, glyph, charIndex, TTLOAD_DEFAULT ); + TT_Get_Glyph_Metrics( glyph, &metrics ); + + //width berechnen + width = metrics.bbox.xMax - metrics.bbox.xMin; + scaledWidth = SCALE_WORD( width, scaleFactor ); + charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); + charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD(scaledWidth ); + charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; + charTableEntry->CTE_flags = 0; + + /* set flags in CTE_flags if needed */ + + //negativ lsb + + //above ascent + + //below descent + + //first kern + + //second kern + + charTableEntry++; + } + + TT_Done_Glyph( glyph ); + TT_Done_Instance( instance ); +} + static TextStyle findOutlineData( - ChunkHandle* truetypeOutlineEntryChunk, - ChunkHandle* fontHeaderChunk, - const FontInfo* fontInfo, - TextStyle textStyle, - FontWeight fontWeight ) + OutlineDataEntry** outline, + const FontInfo* fontInfo, + TextStyle textStyle, + FontWeight fontWeight ) { OutlineDataEntry* outlineToUse; OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); @@ -204,8 +263,7 @@ static TextStyle findOutlineData( if( outlineData->ODE_style == textStyle && outlineData->ODE_weight == fontWeight ) { - *truetypeOutlineEntryChunk = outlineData->ODE_header.OE_handle; - *fontHeaderChunk = outlineData->ODE_first.OE_handle; + *outline = outlineData; return 0; // no styles to implement } @@ -236,8 +294,7 @@ static TextStyle findOutlineData( outlineData++; } - *truetypeOutlineEntryChunk = outlineToUse->ODE_header.OE_handle; - *fontHeaderChunk = outlineToUse->ODE_first.OE_handle; + *outline = outlineToUse; return styleDiff; } @@ -270,33 +327,6 @@ static WWFixedAsDWord CalcScaleForWidths( } -/******************************************************************** - * ConvertHeader - ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: - * - * RETURNS: - * - * SIDE EFFECTS: none - * - * CONDITION: - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 20/12/22 JK Initial Revision - *******************************************************************/ - -void ConvertHeader() -{ - -} - - /******************************************************************** * ConvertKernPairs ******************************************************************** @@ -407,58 +437,11 @@ static word AllocFontBlock( return size; } -/******************************************************************** - * Fill_CharTableEntry - ******************************************************************** - * SYNOPSIS: Fills the FontBuf structure with infomations - * of the passed in FontInfo. - * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * word Character to which the entry - * is to be filled. - * charTableEntry Pointer to entry to be filled. - * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * STRATEGY: Pointsize, scale and rotation will read from gstate. - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 11/12/22 JK Initial Revision - *******************************************************************/ -TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, - word character, - CharTableEntry* charTableEntry ) -{ - TT_CharMap charMap; - word geosChar; - - - ECCheckBounds( (void*)fontInfo ); - ECCheckBounds( (void*)charTableEntry ); - - geosChar = GeosCharToUnicode( character ); - if ( geosChar == 0 ) - { - charTableEntry->CTE_width.WBF_int = 0; - charTableEntry->CTE_width.WBF_frac = 0; - charTableEntry->CTE_flags = CTF_NO_DATA; - } - - -Fin: - return TT_Err_Ok; -} - /******************************************************************** * ConvertHeader ******************************************************************** - * SYNOPSIS: Fills the FontBuf structure with informations - * of the passed in ttf file. + * SYNOPSIS: Converts FontInfo and fill FontBuf structure. * * PARAMETERS: fileName Name of font file. * pointSize Current Pointsize. @@ -479,9 +462,8 @@ TT_Error Fill_CharTableEntry( const FontInfo* fontInfo, * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) +TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* fontHeader, FontBuf* fontBuf ) { - FontHeader fontHeader; TT_Error error; TT_Instance instance; TT_Instance_Metrics instanceMetrics; @@ -490,13 +472,14 @@ TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) ECCheckBounds( (void*)fontBuf ); + ECCheckBounds( (void*)fontHeader ); error = TT_New_Instance( face, &instance ); if ( error ) return error; - error = TT_Set_Instance_CharSize( instance, WBFIXED_TO_FIXED26DOT6( pointSize ) ); + error = TT_Set_Instance_CharSize( instance, pointSize >> 10 ); if ( error ) return error; @@ -515,78 +498,77 @@ TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) fontBuf->FB_heapCount = 0; fontBuf->FB_flags = FBF_IS_OUTLINE; - ttfElement = SCALE_WORD( fontHeader.FH_minLSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleFactor ); fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_avgwidth, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_avgwidth, scaleFactor ); fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_maxwidth, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_maxwidth, scaleFactor ); fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); #ifndef DBCS_PCGEOS - ttfElement = SCALE_WORD( fontHeader.FH_maxRSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleFactor ); fontBuf->FB_maxRSB = ROUND_WWFIXEDASDWORD( ttfElement ); #endif /* DBCS_PCGEOS */ scaleFactor = instanceMetrics.y_scale; - ttfElement = SCALE_WORD( fontHeader.FH_height, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_height, scaleFactor ); fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); /* FB_heightAdjust = pointSize - FH_height */ - ttfElement = WBFIXED_TO_WWFIXEDASDWORD( pointSize ) - - WORD_TO_WWFIXEDASDWORD( fontHeader.FH_height ); + ttfElement = pointSize - WORD_TO_WWFIXEDASDWORD( fontHeader->FH_height ); fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_pixHeight = ROUND_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_baseAdjust, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleFactor ); fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ROUND_WWFIXEDASDWORD( ttfElement ) ); fontBuf->FB_baseAdjust.WBF_frac = 0; - ttfElement = SCALE_WORD( fontHeader.FH_minTSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_minTSB, scaleFactor ); fontBuf->FB_aboveBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_aboveBox.WBF_frac = 0; fontBuf->FB_minTSB = CEIL_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_pixHeight += CEIL_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_maxBSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleFactor ); fontBuf->FB_belowBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_belowBox.WBF_frac = 0; #ifdef SBCS_PCGEOS fontBuf->FB_maxBSB = CEIL_WWFIXEDASDWORD( ttfElement ); #endif /* SBCS_PCGEOS */ - ttfElement = SCALE_WORD( fontHeader.FH_underPos, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_underPos, scaleFactor ); fontBuf->FB_underPos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_underPos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_underThick, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_underThick, scaleFactor ); fontBuf->FB_underThickness.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_underThickness.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_strikePos, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_strikePos, scaleFactor ); fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_x_height, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_x_height, scaleFactor ); fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_descent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleFactor ); fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader.FH_accent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_accent, scaleFactor ); fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); /* baslinepos = accent + ascent */ - ttfElement = SCALE_WORD( fontHeader.FH_ascent + fontHeader.FH_accent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleFactor ); fontBuf->FB_baselinePos.WBF_int = ROUND_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_baselinePos.WBF_frac = 0; @@ -594,9 +576,9 @@ TT_Error Fill_FontBuf( TT_Face face, WBFixed pointSize, FontBuf* fontBuf ) fontBuf->FB_extLeading.WBF_int = 0; fontBuf->FB_extLeading.WBF_frac = 0; - fontBuf->FB_firstChar = fontHeader.FH_firstChar; - fontBuf->FB_lastChar = fontHeader.FH_lastChar; - fontBuf->FB_defaultChar = fontHeader.FH_defaultChar; + fontBuf->FB_firstChar = fontHeader->FH_firstChar; + fontBuf->FB_lastChar = fontHeader->FH_lastChar; + fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; TT_Done_Instance( instance ); diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index b70fc8c79..e8646dac9 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -1,22 +1,34 @@ -## TODOs +## 1 TODOs - ~~FontHeader füllen und im FontInfoBlock ablegen~~ -- FontBuf auf Basis des FontHeaders füllen (Gen_Widths) +- ~~FontBuf auf Basis des FontHeaders füllen (Gen_Widths)~~ - CharTableEntries füllen (Gen_Widths) - KernPairs und KernValues füllen (Achtung: sie offene Probleme) - Transformationsmatrix berechnen und im FontBlock halten (die FakeStyles sind in der Matrix 'enthalten')(Gen_Widths) -- in Gen_Char eine Bitmap erzeugen (notfalls eine Fake Bitmap damit entlich etwas zu sehen ist) +- in Gen_Char eine Bitmap erzeugen (notfalls eine Fake Bitmap damit endlich etwas zu sehen ist) -## Refactorings -- ttinit.c refactorn (Hilfsfunktionen auslagern, lokale Variablen reduzieren) +## 2 Refactorings + +### 2.1 ttinit.c +- Hilfsfunktionen auslagern +- lokale Variablen reduzieren + +### 2.2 ttwidths.c +- Ermittlung stylesToImplement in ASM-Teil verschieben (Kernel-Routine FontDrFindOutlineData) + +### 2.3 FreeType - FreeType Strukturen zusammenführen (Strukturen die eine 1:1 Kardinalität zu TT_Engine haben in TT_Engine integrieren) + +### 2.4 Sonstiges - bessere Lösung für das Mappen GeosChar -> UniCode finden ## Optimierungen - prüfen: ob TT_Error in tterrid.h von long auf word reduziert werden kann -- prüfen: ob in ttraster.c traceG, gTarget, traceLastLine entfernt werden kann +- prüfen: ob in ttraster.c traceG, gTarget entfernt werden kann +- prüfen: ob in ttraster.c in TRasterInstance für lastX, lastY, minX, minY, TraceOfs und TraceOfsLastLine ein word genügt - in ttobj.h kann in T_Font_Input_ ->fontIndex entfernt werden (Ãœberbleibsel der TTCollections die wir nicht brauchen) - in ttraster.c (Set_Hight_Precision) kann gesteuert werden wie 'genau' ein Glyph gerendert wird; falls wir noch Performanceprobleme haben kann hier auch angesetzt werden (ggf. auch mehrstufig) +- prüfen: kann die AvgWidth aus der OS/2 übernommen werden kann ## offene Probleme -- klären: der Aufruf von TT_Init_Kerning lässt swat crachen +- klären: der Aufruf von TT_Init_Kerning lässt swat crashen diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 9203697b6..4640e06f7 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,31 +4,31 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -ADAPTER = ttcharmapper.c ttchars.c ttinit.c ttmetrics.c ttpath.c\ - ttwidths.c ttadapter.h ttcharmapper.h ttinit.h\ - ttmetrics.h ttwidths.h -FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttextend.c\ - ttfile.c ttgload.c ttinterp.c ttload.c ttmemory.c\ - ttmutex.c ttobjs.c ttraster.c freetype.h fterrid.h\ - ftnameid.h ftxkern.h ft_conf.h ttcache.h ttcalc.h\ - ttcmap.h ttconfig.h ttengine.h ttextend.h ttfile.h\ - ttgload.h ttinterp.h ttload.h ttmemory.h ttmutex.h\ - ttobjs.h ttraster.h tttables.h tttags.h tttypes.h -MAIN = ansic_memory.asm ansic_runtime.asm mainManager.asm\ - truetypeChars.asm truetypeEC.asm truetypeEscape.asm\ - truetypeInit.asm truetypeMetrics.asm truetypePath.asm\ - truetypeWidths.asm truetypeConstant.def\ - truetypeMacros.def truetypeVariable.def +MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ + truetypeWidths.asm ansic_memory.asm truetypeMetrics.asm\ + truetypeInit.asm truetypeEC.asm truetypeChars.asm\ + truetypePath.asm truetypeMacros.def truetypeVariable.def\ + truetypeConstant.def +ADAPTER = ttchars.c ttinit.c ttmetrics.c ttcharmapper.c ttwidths.c\ + ttpath.c ttcharmapper.h ttwidths.h ttinit.h ttmetrics.h\ + ttadapter.h +FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ + ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ + ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ + ttconfig.h freetype.h ttgload.h ttfile.h ttinterp.h\ + ttload.h tttables.h ttobjs.h fterrid.h ttraster.h\ + ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ + ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h UI_TO_RDFS = -OBJS = ttcharmapper.obj ttchars.obj ttinit.obj ttmetrics.obj\ - ttpath.obj ttwidths.obj ftxkern.obj ttapi.obj ttcache.obj\ - ttcalc.obj ttcmap.obj ttextend.obj ttfile.obj ttgload.obj\ - ttinterp.obj ttload.obj ttmemory.obj ttmutex.obj\ - ttobjs.obj ttraster.obj +OBJS = ttchars.obj ttinit.obj ttmetrics.obj ttcharmapper.obj\ + ttwidths.obj ttpath.obj ttcache.obj ttraster.obj\ + ttmutex.obj ttgload.obj ttextend.obj ttcalc.obj ttapi.obj\ + ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ + ttobjs.obj ttmemory.obj COMMON = MODULES = Main CMODULES = Adapter FreeType -SRCS = $(ADAPTER) $(FREETYPE) $(MAIN) $(COMMON) +SRCS = $(MAIN) $(ADAPTER) $(FREETYPE) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index dcd60a5b5..24b484802 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -13,85 +13,186 @@ Main.eobj: Main/mainManager.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm -ttcharmapper.obj \ -ttcharmapper.eobj: ttchars.obj \ -ttchars.eobj: +ttchars.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ + Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h ttinit.obj \ -ttinit.eobj: +ttinit.eobj: Adapter/ttinit.h geos.h fontID.h font.h graphics.h color.h \ + Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h Adapter/ttadapter.h ec.h \ + file.h Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h heap.h lmem.h \ + Ansi/stdlib.h Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h fileEnum.h initfile.h ttmetrics.obj \ -ttmetrics.eobj: -ttpath.obj \ -ttpath.eobj: -ttwidths.obj \ -ttwidths.eobj: -ftxkern.obj \ -ftxkern.eobj: -ttapi.obj \ -ttapi.eobj: -ttcache.obj \ -ttcache.eobj: -ttcalc.obj \ -ttcalc.eobj: -ttcmap.obj \ -ttcmap.eobj: -ttextend.obj \ -ttextend.eobj: -ttfile.obj \ -ttfile.eobj: -ttgload.obj \ -ttgload.eobj: -ttinterp.obj \ -ttinterp.eobj: -ttload.obj \ -ttload.eobj: -ttmemory.obj \ -ttmemory.eobj: -ttmutex.obj \ -ttmutex.eobj: -ttobjs.obj \ -ttobjs.eobj: -ttraster.obj \ -ttraster.eobj: +ttmetrics.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ + Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h ttcharmapper.obj \ -ttcharmapper.eobj: -ttchars.obj \ -ttchars.eobj: -ttinit.obj \ -ttinit.eobj: -ttmetrics.obj \ -ttmetrics.eobj: -ttpath.obj \ -ttpath.eobj: +ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h unicode.h ttwidths.obj \ -ttwidths.eobj: -ftxkern.obj \ -ftxkern.eobj: -ttapi.obj \ -ttapi.eobj: +ttwidths.eobj: geos.h ec.h unicode.h graphics.h fontID.h font.h color.h \ + heap.h Adapter/ttwidths.h Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h Adapter/ttadapter.h file.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h lmem.h \ + Ansi/stdlib.h Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h Adapter/ttcharmapper.h \ + FreeType/freetype.h Adapter/../FreeType/ftxkern.h +ttpath.obj \ +ttpath.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ + Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h ttcache.obj \ -ttcache.eobj: -ttcalc.obj \ -ttcalc.eobj: -ttcmap.obj \ -ttcmap.eobj: -ttextend.obj \ -ttextend.eobj: -ttfile.obj \ -ttfile.eobj: +ttcache.eobj: FreeType/ttengine.h FreeType/tttypes.h FreeType/ttconfig.h \ + FreeType/ft_conf.h geos.h file.h resource.h graphics.h \ + fontID.h font.h color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttcache.h \ + FreeType/ttobjs.h FreeType/tttables.h FreeType/ttcmap.h +ttraster.obj \ +ttraster.eobj: FreeType/ttraster.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttengine.h \ + FreeType/tttypes.h FreeType/ttmutex.h FreeType/ttcalc.h \ + FreeType/ttmemory.h Ansi/string.h +ttmutex.obj \ +ttmutex.eobj: FreeType/ttmutex.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h ttgload.obj \ -ttgload.eobj: +ttgload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttcalc.h FreeType/ttfile.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttgload.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/tttags.h FreeType/ttload.h +ttextend.obj \ +ttextend.eobj: FreeType/ttextend.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h +ttcalc.obj \ +ttcalc.eobj: FreeType/ttcalc.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttables.h \ + FreeType/tttypes.h +ttapi.obj \ +ttapi.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h graphics.h fontID.h font.h color.h heap.h \ + lmem.h ec.h Ansi/stdlib.h FreeType/freetype.h \ + FreeType/fterrid.h FreeType/ftnameid.h \ + FreeType/ttengine.h FreeType/tttypes.h FreeType/ttmutex.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttcache.h FreeType/ttfile.h FreeType/ttobjs.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttload.h \ + FreeType/ttgload.h FreeType/ttraster.h \ + FreeType/ttextend.h +ftxkern.obj \ +ftxkern.eobj: FreeType/ftxkern.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h geos.h FreeType/ttextend.h \ + FreeType/ttconfig.h FreeType/ft_conf.h file.h resource.h \ + graphics.h fontID.h font.h color.h heap.h lmem.h ec.h \ + Ansi/stdlib.h FreeType/tttypes.h FreeType/ttobjs.h \ + FreeType/ttengine.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttmemory.h \ + Ansi/string.h FreeType/ttfile.h FreeType/ttload.h \ + FreeType/tttags.h ttinterp.obj \ -ttinterp.eobj: +ttinterp.eobj: FreeType/freetype.h FreeType/fterrid.h FreeType/ftnameid.h \ + geos.h FreeType/tttypes.h FreeType/ttconfig.h \ + FreeType/ft_conf.h file.h resource.h graphics.h fontID.h \ + font.h color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttinterp.h FreeType/ttobjs.h FreeType/ttengine.h \ + FreeType/ttmutex.h FreeType/ttcache.h FreeType/tttables.h \ + FreeType/ttcmap.h ttload.obj \ -ttload.eobj: -ttmemory.obj \ -ttmemory.eobj: -ttmutex.obj \ -ttmutex.eobj: +ttload.eobj: FreeType/tttypes.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttcalc.h FreeType/ttfile.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/tttables.h FreeType/ttobjs.h FreeType/ttcache.h \ + FreeType/ttcmap.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/tttags.h FreeType/ttload.h +ttfile.obj \ +ttfile.eobj: FreeType/ttconfig.h FreeType/ft_conf.h geos.h file.h \ + resource.h graphics.h fontID.h font.h color.h heap.h \ + lmem.h ec.h Ansi/stdlib.h Ansi/stdio.h Ansi/string.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/tttypes.h \ + FreeType/ttengine.h FreeType/ttmutex.h \ + FreeType/ttmemory.h FreeType/ttfile.h +ttcmap.obj \ +ttcmap.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ + FreeType/ttmemory.h Ansi/string.h FreeType/ttload.h ttobjs.obj \ -ttobjs.eobj: -ttraster.obj \ -ttraster.eobj: +ttobjs.eobj: FreeType/ttobjs.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/ttengine.h FreeType/tttypes.h \ + FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h FreeType/ttmutex.h FreeType/ttcache.h \ + FreeType/tttables.h FreeType/ttcmap.h FreeType/ttfile.h \ + FreeType/ttcalc.h FreeType/ttmemory.h Ansi/string.h \ + FreeType/ttload.h FreeType/ttinterp.h FreeType/ttextend.h +ttmemory.obj \ +ttmemory.eobj: FreeType/ttmemory.h FreeType/ttconfig.h FreeType/ft_conf.h \ + geos.h file.h resource.h graphics.h fontID.h font.h \ + color.h heap.h lmem.h ec.h Ansi/stdlib.h \ + FreeType/tttypes.h FreeType/freetype.h FreeType/fterrid.h \ + FreeType/ftnameid.h Ansi/string.h FreeType/ttengine.h \ + FreeType/ttmutex.h truetypeEC.geo truetype.geo : geos.ldf \ No newline at end of file diff --git a/Installed/Driver/Font/TrueType/swat.rc b/Installed/Driver/Font/TrueType/swat.rc new file mode 100644 index 000000000..cce03f86c --- /dev/null +++ b/Installed/Driver/Font/TrueType/swat.rc @@ -0,0 +1,5 @@ +send truetype +spawn truetype +brk TrueType_Gen_Widths +c + From 733cd305bf68b569b32ba3f2a56e48d1c0550114 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 1 Feb 2023 21:35:04 +0100 Subject: [PATCH 125/246] Unneeded variables removed --- Driver/Font/TrueType/FreeType/ttraster.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index ba673255a..eede22dd1 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -249,7 +249,6 @@ UShort bWidth; /* target bitmap width */ PByte bTarget; /* target bitmap buffer */ - PByte gTarget; /* target pixmap buffer */ #ifdef __GEOS__ PShort rTarget; /* target region buffer */ #endif /* __GEOS__ */ @@ -273,13 +272,8 @@ Long traceOfs; /* current offset in target bitmap */ Long traceOfsLastLine; /* offset in traget region before line step */ - Long traceG; /* current offset in target pixmap */ - Short traceIncr; /* sweep's increment in target bitmap */ - Short gray_min_x; /* current min x during gray rendering */ - Short gray_max_x; /* current max x during gray rendering */ - /* dispatch variables */ Function_Sweep_Init* Proc_Sweep_Init; @@ -1519,8 +1513,6 @@ ras.traceIncr = -ras.target.cols; } - ras.gray_min_x = 0; - ras.gray_max_x = 0; } @@ -1556,9 +1548,6 @@ f1 = e1 & 7; f2 = e2 & 7; - if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1; - if ( ras.gray_max_x < c2 ) ras.gray_max_x = c2; - target = ras.bTarget + ras.traceOfs + c1; if ( c1 != c2 ) @@ -1676,9 +1665,6 @@ c1 = (Short)(e1 >> 3); f1 = e1 & 7; - if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1; - if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1; - ras.bTarget[ras.traceOfs + c1] |= (Char)(0x80 >> f1); } } @@ -1714,9 +1700,6 @@ ras.traceOfs = 0; ras.traceIncr = 0; ras.traceOfsLastLine = -1; - - ras.gray_min_x = 0; - ras.gray_max_x = 0; } static void Vertical_Region_Sweep_Span( RAS_ARGS Short y, From 5b29a1ddfeeb630f338356ce6ba45365221045a7 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 4 Feb 2023 10:35:03 +0100 Subject: [PATCH 126/246] Better hash algorithm implemented. --- Driver/Font/TrueType/Adapter/ttadapter.h | 5 +++-- Driver/Font/TrueType/Adapter/ttinit.c | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 06319caef..b6b072ff2 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -37,6 +37,7 @@ extern TEngine_Instance engineInstance; #define TTF_DIRECTORY "TTF" #define FONT_MAN_ID 0x20 +#define CHAR_NOT_EXIST 0 #define CHAR_NOT_BUILT 2 /*********************************************************************** @@ -207,8 +208,8 @@ typedef ByteEnum AdjustedWeight; typedef struct { - dword OE_offset; /* offset in file */ - word OE_size; /* size in bytes) */ + dword OE_offset; /* offset in file */ + word OE_size; /* size in bytes) */ ChunkHandle OE_handle; /* handle (if loaded) */ } OutlineEntry; diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 09e11ccf6..f2bd21d05 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -444,8 +444,8 @@ static word toHash( const char* str ) word i; dword hash = strlen( str ); - for ( i = 0; i < strlen( str ) ; i++ ) - hash = ( hash * 7 ) % ( 2^16 ) + str[i]; + for ( i = 0; i < strlen( str ) ; ++i ) + hash = ( ( hash * 7 ) % 65535 ) + str[i]; return (word) hash; } @@ -785,8 +785,8 @@ static void convertHeader( TT_Glyph_Metrics metrics; TT_Instance instance; word geosChar; - word unitsPerEM; sword maxAccentOrAscent; + word unitsPerEM = faceProperties.header->Units_Per_EM; ECCheckBounds( (void*)fontHeader ); @@ -868,8 +868,6 @@ static void convertHeader( TT_Done_Glyph( glyph ); TT_Done_Instance( instance ); - unitsPerEM = faceProperties.header->Units_Per_EM; - //baseline if ( fontHeader->FH_accent <= 0 ) { From 3e4767bf3fd8b254ebd1eb7250b65a0bd1e56023 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 4 Feb 2023 15:46:36 +0100 Subject: [PATCH 127/246] Unneeded variables removed --- Driver/Font/TrueType/Adapter/ttmetrics.h | 2 +- Driver/Font/TrueType/Adapter/ttwidths.c | 31 ++++++++++++++---------- Driver/Font/TrueType/FreeType/ttapi.c | 1 - Driver/Font/TrueType/FreeType/ttload.c | 4 +-- Driver/Font/TrueType/FreeType/ttload.h | 4 +-- Driver/Font/TrueType/FreeType/ttmemory.c | 30 ++++++++++++++++++++++- Driver/Font/TrueType/FreeType/ttobjs.c | 2 +- Driver/Font/TrueType/FreeType/ttobjs.h | 1 - Driver/Font/TrueType/FreeType/ttraster.c | 4 +-- 9 files changed, 53 insertions(+), 26 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.h b/Driver/Font/TrueType/Adapter/ttmetrics.h index d82e31b34..5ed6a2b46 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.h +++ b/Driver/Font/TrueType/Adapter/ttmetrics.h @@ -28,4 +28,4 @@ TT_Error _pascal TrueType_Char_Metrics( GCM_info info, dword* result ); -#endif _TTMETRICS_H_ +#endif /* _TTMETRICS_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 8fe88c4c3..26fbea124 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -70,7 +70,7 @@ static void CalcTransform( TT_Matrix* resultMatrix, * * PARAMETERS: fontHandle Memory handle to font block. * tMatrix Pointer to tranformation matrix. - * fontInfo Pointer to font info block. + * fontInfo Pointer to font info structure. * pointSize Desired point size. * textStyle Desired text style. * fontWeight Desired font weight. @@ -103,7 +103,6 @@ MemHandle _pascal TrueType_Gen_Widths( TT_Face face; TT_Face_Properties faceProperties; TT_Error error; - word numKernPairs; word size; FontHeader* fontHeader; FontBuf* fontBuf; @@ -140,11 +139,12 @@ MemHandle _pascal TrueType_Gen_Widths( error = TT_Get_Face_Properties( face, &faceProperties ); if( error ) goto Fail; - - numKernPairs = CountKernPairsWithGeosChars( face ); /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ - size = AllocFontBlock( 0, fontHeader->FH_numChars, numKernPairs, &fontHandle ); + size = AllocFontBlock( 0, + fontHeader->FH_numChars, + CountKernPairsWithGeosChars( face ), + &fontHandle ); /* calculate scale factor and transformation matrix */ scaleFactor = CalcScaleForWidths( pointSize, @@ -155,6 +155,8 @@ MemHandle _pascal TrueType_Gen_Widths( /* convert FontHeader */ fontBuf = MemDeref( fontHandle ); + fontBuf->FB_dataSize = size; + ConvertHeader( face, pointSize, fontHeader, fontBuf ); /* convert Widths */ @@ -200,7 +202,7 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord if ( charIndex == 0 ) { charTableEntry->CTE_flags = CTF_NO_DATA; - charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; + charTableEntry->CTE_dataOffset = CHAR_NOT_EXIST; charTableEntry->CTE_width.WBF_int = 0; charTableEntry->CTE_width.WBF_frac = 0; @@ -220,23 +222,27 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; charTableEntry->CTE_flags = 0; - /* set flags in CTE_flags if needed */ + // set flags in CTE_flags if needed + if( metrics.bbox.xMin < 0 ) + charTableEntry->CTE_flags |= CTF_NEGATIVE_LSB; - //negativ lsb + //below descent + if( -metrics.bbox.yMin > fontHeader->FH_descent ) + charTableEntry->CTE_flags |= CTF_BELOW_DESCENT; //above ascent - - //below descent + if( metrics.bbox.yMax > fontHeader->FH_accent ) + charTableEntry->CTE_flags |= CTF_ABOVE_ASCENT; //first kern //second kern charTableEntry++; - } + } - TT_Done_Glyph( glyph ); TT_Done_Instance( instance ); + TT_Done_Glyph( glyph ); } @@ -293,7 +299,6 @@ static TextStyle findOutlineData( } outlineData++; } - *outline = outlineToUse; return styleDiff; } diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 819b59feb..b00d97262 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -203,7 +203,6 @@ extern TEngine_Instance engineInstance; return error; input.stream = stream; - input.fontIndex = 0; input.engine = _engine; /* Create and load the new face object - this is thread-safe */ diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 63dfbc0d7..49756702a 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -71,15 +71,13 @@ * * Input : face face record to look for * - * faceIndex the index of the TrueType font, when - * we're opening a collection. * * Output : SUCCESS on success. FAILURE on error. * ******************************************************************/ LOCAL_FUNC - TT_Error Load_TrueType_Directory( PFace face, ULong faceIndex ) + TT_Error Load_TrueType_Directory( PFace face ) { DEFINE_LOCALS; diff --git a/Driver/Font/TrueType/FreeType/ttload.h b/Driver/Font/TrueType/FreeType/ttload.h index 6172fd965..324ddec5c 100644 --- a/Driver/Font/TrueType/FreeType/ttload.h +++ b/Driver/Font/TrueType/FreeType/ttload.h @@ -34,9 +34,7 @@ EXPORT_DEF Long TT_LookUp_Table( PFace face, ULong tag ); - LOCAL_DEF TT_Error Load_TrueType_Directory ( PFace face, - ULong faceIndex ); - + LOCAL_DEF TT_Error Load_TrueType_Directory ( PFace face ); LOCAL_DEF TT_Error Load_TrueType_MaxProfile ( PFace face ); LOCAL_DEF TT_Error Load_TrueType_Gasp ( PFace face ); LOCAL_DEF TT_Error Load_TrueType_Header ( PFace face ); diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c index db8602c04..298ce9fb9 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.c +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -25,6 +25,9 @@ #include "ttmemory.h" #include "ttengine.h" +#include +#include +#include /* required by the tracing mode */ #undef TT_COMPONENT @@ -38,6 +41,13 @@ #define MAX_BLOCK_SIZE 32000 +#define MAX_LMEM_BLOCKS 32 + +/* Block for small allocs */ +MemHandle lmem; + +ChunkHandle lmemBlock[MAX_LMEM_BLOCKS]; +void* ptrToBlock[MAX_LMEM_BLOCKS]; /******************************************************************* @@ -67,11 +77,17 @@ return TT_Err_Invalid_Argument; if ( Size > MAX_BLOCK_SIZE ) + { + EC_ERROR( 100 ); return TT_Err_Out_Of_Memory; + } if ( Size > 0 ) { - handle = MemAlloc( Size, HF_SHARABLE | HF_SWAPABLE, HAF_ZERO_INIT | HAF_LOCK ); + handle = MemAllocSetOwner( GeodeGetCodeProcessHandle(), + Size, + HF_SHARABLE | HF_SWAPABLE, + HAF_ZERO_INIT | HAF_LOCK ); if ( !handle ) return TT_Err_Out_Of_Memory; @@ -125,6 +141,16 @@ LOCAL_FUNC TT_Error TTMemory_Init( void ) { + /* lmem = MemAllocSetOwner(GeodeGetCodeProcessHandle(), + 10 * 1024, + HF_SHARABLE | HF_SWAPABLE, + HAF_ZERO_INIT | HAF_NO_ERR | HAF_LOCK ); + + LMemInitHeap(block, LMEM_TYPE_GENERAL, + LMF_NO_HANDLES | LMF_NO_ENLARGE | LMF_RETURN_ERRORS, + sizeof(LMemBlockHeader), 0, + newSize - sizeof(LMemBlockHeader));*/ + return TT_Err_Ok; } @@ -142,6 +168,8 @@ LOCAL_FUNC TT_Error TTMemory_Done( void ) { + //MemFree( lmem ); + return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index e4fda537a..609d8c7c8 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -1161,7 +1161,7 @@ /* Load collection directory if present, then font directory */ - error = Load_TrueType_Directory( face, input->fontIndex ); + error = Load_TrueType_Directory( face ); if ( error ) goto Fail; diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h index 71c46613d..5257a4da4 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.h +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -770,7 +770,6 @@ struct TFont_Input_ { TT_Stream stream; /* input stream */ - ULong fontIndex; /* index of font in collection */ PEngine_Instance engine; /* parent engine instance */ }; diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index eede22dd1..8670c65d5 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -270,8 +270,8 @@ TT_Raster_Map target; /* description of target bit/pixmap */ - Long traceOfs; /* current offset in target bitmap */ - Long traceOfsLastLine; /* offset in traget region before line step */ + Short traceOfs; /* current offset in target bitmap */ + Short traceOfsLastLine; /* offset in traget region before line step */ Short traceIncr; /* sweep's increment in target bitmap */ /* dispatch variables */ From 82f09c03bd9f2224cb02ee171372fdc83f3df0f1 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 6 Feb 2023 21:10:49 +0100 Subject: [PATCH 128/246] Correct mistake --- Driver/Font/TrueType/FreeType/ttfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttfile.c b/Driver/Font/TrueType/FreeType/ttfile.c index b4a913b5d..d81d7ba2d 100644 --- a/Driver/Font/TrueType/FreeType/ttfile.c +++ b/Driver/Font/TrueType/FreeType/ttfile.c @@ -94,10 +94,10 @@ struct TStream_Rec_ { - Long position; /* current position within the file */ - FILE* file; /* file handle */ - Long base; /* stream base in file */ - Long size; /* stream size in file */ + Long position; /* current position within the file */ + FileHandle file; /* file handle */ + Long base; /* stream base in file */ + Long size; /* stream size in file */ }; /* We support embedded TrueType files by allowing them to be */ From c64cc0761a336c99430ddfe88140a67b2a513c87 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 11 Feb 2023 21:45:52 +0100 Subject: [PATCH 129/246] Unneeded variables removed. --- Driver/Font/TrueType/FreeType/ttraster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 8670c65d5..ac9f59f27 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -223,7 +223,6 @@ Int precision_bits; /* precision related variables */ Int precision; Int precision_half; - Long precision_mask; Int precision_shift; Int precision_step; Int precision_jitter; @@ -339,7 +338,6 @@ ras.precision = 1 << ras.precision_bits; ras.precision_half = ras.precision / 2; ras.precision_shift = ras.precision_bits - Pixel_Bits; - ras.precision_mask = -ras.precision; } @@ -2695,6 +2693,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, #ifndef TT_CONFIG_OPTION_STATIC_RASTER FREE( engine->raster_component ); + //GFREE( engine->raster_component ); #endif return TT_Err_Ok; @@ -2712,6 +2711,7 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras = engine->raster_component = &cur_ras; #else if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) + //if ( GALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) return error; ras = (TRaster_Instance*)engine->raster_component; From bb48576e595437c79417c0350f890dee6ec98fb4 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 14 Feb 2023 20:56:05 +0100 Subject: [PATCH 130/246] GEN_WIDTHS almost finished. --- Driver/Font/TrueType/Adapter/ttadapter.h | 1 + Driver/Font/TrueType/Adapter/ttchars.c | 2 +- Driver/Font/TrueType/Adapter/ttinit.c | 2 - Driver/Font/TrueType/Adapter/ttmetrics.c | 2 +- Driver/Font/TrueType/Adapter/ttwidths.c | 196 ++++++++++++++---- Driver/Font/TrueType/Adapter/ttwidths.h | 11 +- Driver/Font/TrueType/FreeType/ttmemory.c | 130 +++++++----- Driver/Font/TrueType/FreeType/ttmemory.h | 19 +- Driver/Font/TrueType/Main/mainManager.asm | 9 +- .../Font/TrueType/Main/truetypeVariable.def | 1 + Driver/Font/TrueType/backlog.md | 16 +- 11 files changed, 281 insertions(+), 108 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index b6b072ff2..6cbfed6d2 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -32,6 +32,7 @@ * global dgoup objects ***********************************************************************/ extern TEngine_Instance engineInstance; +extern MemHandle engineBlock; #define TTF_DIRECTORY "TTF" diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 8d86dcf6d..17892a64a 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -58,4 +58,4 @@ TT_Error _pascal TrueType_Gen_Chars( { /* Api-Funktion für DR_FONT_GEN_CHARS */ return TT_Err_Ok; -} \ No newline at end of file +} diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index f2bd21d05..e2ac92b8a 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -221,8 +221,6 @@ static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) TT_Error error = TT_Err_Ok; char familyName[FID_NAME_LEN]; char styleName[STYLE_NAME_LENGTH]; - word familyNameLength; - word styleNameLegth; FontID fontID; sword availIndex; diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 98b2e0f45..d4de73263 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -67,4 +67,4 @@ TT_Error _pascal TrueType_Char_Metrics( /* by the pointsize and font attributes requested. */ /* siehe GrCharMetrics() */ return TT_Err_Ok; -} \ No newline at end of file +} diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 26fbea124..27b5ca3dd 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -48,17 +48,23 @@ static WWFixedAsDWord CalcScaleForWidths( TextStyle stylesToImplement, word unitsPerEM ); -TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* fontHeader, FontBuf* fontBuf ); - -static void ConvertWidhts( TT_Face face, - FontHeader* fontHeader, - WWFixedAsDWord scaleFactor, - CharTableEntry* charTableEntries ); - -void ConvertKernPairs(); - -static void CalcTransform( TT_Matrix* resultMatrix, - FontMatrix* transformMatrix, +static TT_Error ConvertHeader( + TT_Face face, + WWFixedAsDWord pointSize, + FontHeader* fontHeader, + FontBuf* fontBuf ); + +static void ConvertWidths( + TT_Face face, + FontHeader* fontHeader, + WWFixedAsDWord scaleFactor, + FontBuf* fontBuf ); + +static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ); + +static void CalcTransform( + TT_Matrix* transMatrix, + FontMatrix* fontMatrix, TextStyle styleToImplement ); @@ -69,10 +75,11 @@ static void CalcTransform( TT_Matrix* resultMatrix, * in a given pointsize, style and weight. * * PARAMETERS: fontHandle Memory handle to font block. - * tMatrix Pointer to tranformation matrix. + * fontMatrix Pointer to tranformation matrix. * fontInfo Pointer to font info structure. * pointSize Desired point size. * textStyle Desired text style. + * fontWidth Desired font width. * fontWeight Desired font weight. * * RETURNS: MemHandle Memory handle to font block. @@ -106,9 +113,6 @@ MemHandle _pascal TrueType_Gen_Widths( word size; FontHeader* fontHeader; FontBuf* fontBuf; - CharTableEntry* charTableEntries; - KernPair* kernPair; - WBFixed* kernValue; WWFixedAsDWord scaleFactor; @@ -141,7 +145,7 @@ MemHandle _pascal TrueType_Gen_Widths( goto Fail; /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ - size = AllocFontBlock( 0, + size = AllocFontBlock( sizeof( TT_Matrix ), fontHeader->FH_numChars, CountKernPairsWithGeosChars( face ), &fontHandle ); @@ -153,20 +157,21 @@ MemHandle _pascal TrueType_Gen_Widths( stylesToImplement, faceProperties.header->Units_Per_EM ); - /* convert FontHeader */ - fontBuf = MemDeref( fontHandle ); + /* convert FontHeader and fill FontBuf structure */ + fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; - ConvertHeader( face, pointSize, fontHeader, fontBuf ); - /* convert Widths */ - charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); - ConvertWidths( face, fontHeader, scaleFactor, charTableEntries ); - - //TODO: Kernpairs konvertieren und einfügen + /* fill kerning pairs and kerning values */ + ConvertKernPairs( face, fontBuf ); - //TODO: Tranformationsmatix berechnen und in FontBlock kopieren + /* convert widths and fill CharTableEntries */ + ConvertWidths( face, fontHeader, scaleFactor, fontBuf ); + /* calculate the transformation matrix and copy it into the FontBlock */ + CalcTransform( (TT_Matrix*)((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry ), + fontMatrix, + stylesToImplement ); Fail: TT_Close_Face( face ); @@ -175,13 +180,38 @@ MemHandle _pascal TrueType_Gen_Widths( return fontHandle; } -static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, CharTableEntry* charTableEntry ) + +/******************************************************************** + * ConvertWidths + ******************************************************************** + * SYNOPSIS: Converts the information from the FontHeader and + * fills FontBuf with it. + * + * PARAMETERS: face + * fontHeader + * scaleFactor + * fontbuf + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/02/23 JK Initial Revision + *******************************************************************/ + +static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, FontBuf* fontBuf ) { TT_Instance instance; TT_Glyph glyph; TT_CharMap charMap; TT_Glyph_Metrics metrics; char currentChar; + CharTableEntry* charTableEntry = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); TT_New_Glyph( face, &glyph ); TT_New_Instance( face, &instance ); @@ -231,12 +261,16 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord charTableEntry->CTE_flags |= CTF_BELOW_DESCENT; //above ascent - if( metrics.bbox.yMax > fontHeader->FH_accent ) + if( metrics.bbox.yMax > fontHeader->FH_ascent ) charTableEntry->CTE_flags |= CTF_ABOVE_ASCENT; - //first kern - //second kern + if( fontBuf->FB_kernCount > 0 ) + { + //first kern + + //second kern + } charTableEntry++; } @@ -246,6 +280,25 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord } +/******************************************************************** + * findOutlineData + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/02/23 JK Initial Revision + *******************************************************************/ + static TextStyle findOutlineData( OutlineDataEntry** outline, const FontInfo* fontInfo, @@ -303,6 +356,26 @@ static TextStyle findOutlineData( return styleDiff; } + +/******************************************************************** + * CalcScaleForWidths + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/02/23 JK Initial Revision + *******************************************************************/ + static WWFixedAsDWord CalcScaleForWidths( WWFixedAsDWord pointSize, FontWidth fontWidth, @@ -343,8 +416,6 @@ static WWFixedAsDWord CalcScaleForWidths( * * SIDE EFFECTS: none * - * CONDITION: - * * STRATEGY: * * REVISION HISTORY: @@ -353,22 +424,38 @@ static WWFixedAsDWord CalcScaleForWidths( * 20/12/22 JK Initial Revision *******************************************************************/ -void ConvertKernPairs() +static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) { + KernPair* kernPair; + WBFixed* wbFixed; + + //lade TT_Kern Tabelle + + //iteriere über den FreeGEOS Zeichensatz + + //wandle das akt. Zeichen in den TT Index + + //suche den Index in der TT Kern Tabelle + // wenn gefunden: ist das zweite Zeichen auch ein GEOS Zeichen? + // ja: Kernpair in den FontBuf eintragen + // Kernvalue in den FontBuf eintragen + // KernCounter hochzählen + + fontBuf->FB_kernValuePtr = 0; } /******************************************************************** * CalcTransform ******************************************************************** - * SYNOPSIS: Calculates the transformation matrix to - * calculate missing style attributes and weights. + * SYNOPSIS: Calculates the transformation matrix for + * missing style attributes and weights. * - * PARAMETERS: resultMatrix* + * PARAMETERS: fontBuf + * fontMatrix * styleToImplement * - * * RETURNS: * * SIDE EFFECTS: none @@ -381,11 +468,35 @@ void ConvertKernPairs() * 20/12/22 JK Initial Revision *******************************************************************/ -static void CalcTransform( TT_Matrix* resultMatrix, - FontMatrix* fontMatrix, - TextStyle styleToImplement ) +static void CalcTransform( TT_Matrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle stylesToImplement ) { + /* copy fontMatrix into transMatrix */ + transMatrix->xx = fontMatrix->FM_11; + transMatrix->xy = fontMatrix->FM_12; + transMatrix->yx = fontMatrix->FM_21; + transMatrix->yy = fontMatrix->FM_22; + + /* fake bold style */ + /* xx = xx * BOLD_FACTOR */ + if( stylesToImplement & TS_BOLD ) + { + transMatrix->xx = GrMulWWFixed( transMatrix->xx, BOLD_FACTOR ); + } + /* fake italic style */ + /* yx = yy * ITALIC_FACTOR */ + if( stylesToImplement & TS_ITALIC ) + { + transMatrix->yx = GrMulWWFixed( transMatrix->yy, ITALIC_FACTOR ); + } + + /* fake script style */ + if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) + { + + } } @@ -406,8 +517,6 @@ static void CalcTransform( TT_Matrix* resultMatrix, * * SIDE EFFECTS: none * - * CONDITION: - * * STRATEGY: * * REVISION HISTORY: @@ -421,8 +530,7 @@ static word AllocFontBlock( word numOfKernPairs, MemHandle* fontHandle ) { - word size = sizeof( FontBuf ) + - numOfCharacters * sizeof( CharTableEntry ) + + word size = sizeof( FontBuf ) + numOfCharacters * sizeof( CharTableEntry ) + numOfKernPairs * ( sizeof( KernPair ) + sizeof( WBFixed ) ) + additionalSpace; @@ -457,8 +565,6 @@ static word AllocFontBlock( * * SIDE EFFECTS: none * - * CONDITION: The current directory must be the ttf font directory. - * * STRATEGY: * * REVISION HISTORY: diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 75273b8c3..efc693fab 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -28,6 +28,9 @@ #define WWFIXED_0_POINT_5 0x00008000 #define WWFIXED_1_POINR_1 0x00012000 +#define ITALIC_FACTOR 0x0000366A +#define BOLD_FACTOR 0x00012000 + /*********************************************************************** * structues @@ -35,10 +38,10 @@ typedef struct { - WWFixed FM_11; - WWFixed FM_12; - WWFixed FM_21; - WWFixed FM_22; + WWFixedAsDWord FM_11; + WWFixedAsDWord FM_12; + WWFixedAsDWord FM_21; + WWFixedAsDWord FM_22; } FontMatrix; diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c index 298ce9fb9..8558c0e74 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.c +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -25,30 +25,12 @@ #include "ttmemory.h" #include "ttengine.h" +#include "ttadapter.h" #include +#include #include #include -/* required by the tracing mode */ -#undef TT_COMPONENT -#define TT_COMPONENT trace_memory - - -#ifndef TT_CONFIG_OPTION_THREAD_SAFE - Long TTMemory_Allocated; - Long TTMemory_MaxAllocated; -#endif - - -#define MAX_BLOCK_SIZE 32000 -#define MAX_LMEM_BLOCKS 32 - -/* Block for small allocs */ -MemHandle lmem; - -ChunkHandle lmemBlock[MAX_LMEM_BLOCKS]; -void* ptrToBlock[MAX_LMEM_BLOCKS]; - /******************************************************************* * @@ -61,37 +43,78 @@ void* ptrToBlock[MAX_LMEM_BLOCKS]; * * Output : Error code. * - * NOTE : The newly allocated block should _always_ be zeroed - * on return. Many parts of the engine rely on this to - * work properly. + * NOTE : - The newly allocated block should _always_ be zeroed + * on return. Many parts of the engine rely on this to + * work properly. + * - This function is replaced step by step by GTT_Alloc(). * ******************************************************************/ EXPORT_FUNC - TT_Error TT_Alloc( ULong Size, void** P ) + TT_Error TT_Alloc( UShort Size, void** P ) { - MemHandle handle; - + MemHandle M; if ( !P ) return TT_Err_Invalid_Argument; if ( Size > MAX_BLOCK_SIZE ) - { - EC_ERROR( 100 ); return TT_Err_Out_Of_Memory; + + if ( Size > 0 ) + { + M = MemAllocSetOwner( GeodeGetCodeProcessHandle(), + Size, + HF_SHARABLE | HF_SWAPABLE, + HAF_ZERO_INIT | HAF_LOCK ); + + if ( !M ) + return TT_Err_Out_Of_Memory; + + *P = MemDeref( M ); } + else + *P = NULL; + + return TT_Err_Ok; + } + +/******************************************************************* + * + * Function : GTT_Alloc + * + * Description : Allocates memory from the engine memory block. + * + * Input : Size size of the memory to be allocated + * chunk ChunkHandle to allocated memory + * + * Output : Error code. + * + * NOTE : - The newly allocated block should _always_ be zeroed + * on return. Many parts of the engine rely on this to + * work properly. + * - We want to move all the memory blocks to the engine + * block step by step. So that TT_Alloc() is no longer + * needed. + * + ******************************************************************/ + EXPORT_FUNC + TT_Error GTT_Alloc( UShort Size, void** P ) + { + ChunkHandle H; + + if ( !P ) + return TT_Err_Invalid_Argument; + + if ( Size > MAX_BLOCK_SIZE ) + return TT_Err_Out_Of_Memory; + if ( Size > 0 ) { - handle = MemAllocSetOwner( GeodeGetCodeProcessHandle(), - Size, - HF_SHARABLE | HF_SWAPABLE, - HAF_ZERO_INIT | HAF_LOCK ); - if ( !handle ) - return TT_Err_Out_Of_Memory; - - *P = MemDeref( handle ); + H = LMemAlloc( engineBlock, Size ); + *P = ConstructOptr( engineBlock, H ); + MEM_Set( *P, 0, Size ); } else *P = NULL; @@ -121,6 +144,19 @@ void* ptrToBlock[MAX_LMEM_BLOCKS]; return TT_Err_Ok; MemFree( MemPtrToHandle( *P ) ); + + *P = NULL; + + return TT_Err_Ok; + } + + EXPORT_FUNC + TT_Error GTT_Free( void** P ) + { + if ( !P || !*P ) + return TT_Err_Ok; + + LMemFree( *P ); *P = NULL; @@ -141,15 +177,17 @@ void* ptrToBlock[MAX_LMEM_BLOCKS]; LOCAL_FUNC TT_Error TTMemory_Init( void ) { - /* lmem = MemAllocSetOwner(GeodeGetCodeProcessHandle(), + engineBlock = MemAllocSetOwner(GeodeGetCodeProcessHandle(), 10 * 1024, - HF_SHARABLE | HF_SWAPABLE, - HAF_ZERO_INIT | HAF_NO_ERR | HAF_LOCK ); + HF_SHARABLE | HF_FIXED, HAF_ZERO_INIT ); + + ECCheckMemHandle( engineBlock ); - LMemInitHeap(block, LMEM_TYPE_GENERAL, - LMF_NO_HANDLES | LMF_NO_ENLARGE | LMF_RETURN_ERRORS, - sizeof(LMemBlockHeader), 0, - newSize - sizeof(LMemBlockHeader));*/ + LMemInitHeap( engineBlock, LMEM_TYPE_GENERAL, + LMF_NO_HANDLES, + sizeof(LMemBlockHeader), + STD_INIT_HANDLES, + STD_INIT_HEAP ); return TT_Err_Ok; } @@ -168,10 +206,6 @@ void* ptrToBlock[MAX_LMEM_BLOCKS]; LOCAL_FUNC TT_Error TTMemory_Done( void ) { - //MemFree( lmem ); - + MemFree( engineBlock ); return TT_Err_Ok; } - - -/* END */ diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h index 914e6c3a7..7839e96d4 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.h +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -35,6 +35,8 @@ extern "C" { #endif +#define MAX_BLOCK_SIZE 32000 + #define MEM_Set( dest, byte, count ) memset( dest, byte, count ) #ifdef __GEOS__ @@ -57,9 +59,15 @@ #define MEM_Alloc( _pointer_, _size_ ) \ TT_Alloc( _size_, (void**)&(_pointer_) ) +#define MEM_GAlloc( _pointer_, _size_ ) \ + GTT_Alloc( _size_, &_pointer_ ) + #define ALLOC( _pointer_, _size_ ) \ ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok ) +#define GALLOC( _chunk_, _size_ ) \ + ( ( error = MEM_GAlloc( _chunk_, _size_ ) ) != TT_Err_Ok ) + #define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ ( ( error = MEM_Alloc( _pointer_, \ (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) @@ -67,13 +75,19 @@ #define FREE( _pointer_ ) \ TT_Free( (void**)&(_pointer_) ) +#define GFREE( _pointer_ ) \ + GTT_Free( &_pointer_ ) + /* Allocate a block of memory of 'Size' bytes from the heap, and */ /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ /* case of error, the pointer is always set to NULL. */ EXPORT_DEF - TT_Error TT_Alloc( ULong Size, void** P ); + TT_Error TT_Alloc( UShort Size, void** P ); + + EXPORT_DEF + TT_Error GTT_Alloc( UShort Size, void** P ); /* Releases a block that was previously allocated through Alloc. */ @@ -84,6 +98,9 @@ EXPORT_DEF TT_Error TT_Free( void** P ); + EXPORT_DEF + TT_Error GTT_Free( void** P ); + LOCAL_DEF TT_Error TTMemory_Init( void ); LOCAL_DEF TT_Error TTMemory_Done( void ); diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index b49dc0913..a010f8abe 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -82,10 +82,10 @@ ForceRef DriverTable idata ends ;TODO: remove dependencys from ansic -udata segment - mallocOffset word (?) - public mallocOffset -udata ends +;udata segment +; mallocOffset word (?) +; public mallocOffset +;udata ends include truetypeMacros.def @@ -120,6 +120,7 @@ global TRUETYPE_CHAR_METRICS:far global TRUETYPE_GEN_WIDTHS:far global engineInstance:TrueTypeEngineInstance +global engineBlock:hptr MetricsMod segment resource include truetypeMetrics.asm diff --git a/Driver/Font/TrueType/Main/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def index b18e41e92..d08ed1329 100644 --- a/Driver/Font/TrueType/Main/truetypeVariable.def +++ b/Driver/Font/TrueType/Main/truetypeVariable.def @@ -119,6 +119,7 @@ variableHandle hptr ;handle of our variable block ;This structure is later moved to the variable block. engineInstance TrueTypeEngineInstance <> +engineBlock hptr udata ends diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index e8646dac9..ba5338d6a 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -11,6 +11,7 @@ ### 2.1 ttinit.c - Hilfsfunktionen auslagern - lokale Variablen reduzieren +- das Ermitteln des KernCounts hierhin auslagern -> das macht es in ttwidths.c leichter ### 2.2 ttwidths.c - Ermittlung stylesToImplement in ASM-Teil verschieben (Kernel-Routine FontDrFindOutlineData) @@ -23,12 +24,23 @@ ## Optimierungen - prüfen: ob TT_Error in tterrid.h von long auf word reduziert werden kann -- prüfen: ob in ttraster.c traceG, gTarget entfernt werden kann +- ~~prüfen: ob in ttraster.c traceG, gTarget entfernt werden kann~~ - prüfen: ob in ttraster.c in TRasterInstance für lastX, lastY, minX, minY, TraceOfs und TraceOfsLastLine ein word genügt -- in ttobj.h kann in T_Font_Input_ ->fontIndex entfernt werden (Ãœberbleibsel der TTCollections die wir nicht brauchen) +- ~~in ttobj.h kann in T_Font_Input_ ->fontIndex entfernt werden (Ãœberbleibsel der TTCollections die wir nicht brauchen)~~ - in ttraster.c (Set_Hight_Precision) kann gesteuert werden wie 'genau' ein Glyph gerendert wird; falls wir noch Performanceprobleme haben kann hier auch angesetzt werden (ggf. auch mehrstufig) - prüfen: kann die AvgWidth aus der OS/2 übernommen werden kann ## offene Probleme - klären: der Aufruf von TT_Init_Kerning lässt swat crashen +- das Speichermanagements muss überarbeitet werden, aktuell ist in ttwidths.c Schluss + +## aktuelle Verbräuche + +Speicherbedarf/Blöcke (ohne Code): +| Stand | 10.02.2023 | +|----------------|------------| +|vor ProcessFont | 4896/5 | +|nach ProcessFont| 19232/18 | +|vor Gen_Widths | 19232/18 | +|nach Gen_Widths | n.a. | From 6117e42107c8ca3c1b568d1cb60268e072f9a531 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 19 Feb 2023 20:13:17 +0100 Subject: [PATCH 131/246] Corrected the calculation of the number of characters in the font. Thanks to Marcus --- Driver/Font/TrueType/Adapter/ttcharmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 807e32458..b1bc4a49f 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -334,7 +334,7 @@ word InitGeosCharsInCharMap( TT_CharMap map, char *firstChar, char *lastChar ) } } - return lastChar - firstChar; + return *lastChar - *firstChar; } From fcff3d2a91ef770e5b7634bb09038f56f76446b8 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 20 Feb 2023 19:51:28 +0100 Subject: [PATCH 132/246] Fakestyle subscript and superscript implemented --- Driver/Font/TrueType/Adapter/ttadapter.h | 10 ++++ Driver/Font/TrueType/Adapter/ttwidths.c | 61 ++++++++++++++---------- Driver/Font/TrueType/Adapter/ttwidths.h | 9 +++- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 6cbfed6d2..13b3d10a2 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -239,6 +239,16 @@ typedef struct char KB_char2; } KernPair; +/* + * drivers TransformMatrix structure + */ +typedef struct +{ + TT_Matrix TM_matrix; + WWFixedAsDWord TM_shiftY; +} TransformMatrix; + + /*********************************************************************** * macros diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 27b5ca3dd..a72d8d272 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -63,9 +63,9 @@ static void ConvertWidths( static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ); static void CalcTransform( - TT_Matrix* transMatrix, - FontMatrix* fontMatrix, - TextStyle styleToImplement ); + TransformMatrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle styleToImplement ); /******************************************************************** @@ -145,10 +145,10 @@ MemHandle _pascal TrueType_Gen_Widths( goto Fail; /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ - size = AllocFontBlock( sizeof( TT_Matrix ), - fontHeader->FH_numChars, - CountKernPairsWithGeosChars( face ), - &fontHandle ); + size = AllocFontBlock( sizeof( TransformMatrix ), + fontHeader->FH_numChars, + CountKernPairsWithGeosChars( face ), + &fontHandle ); /* calculate scale factor and transformation matrix */ scaleFactor = CalcScaleForWidths( pointSize, @@ -169,7 +169,7 @@ MemHandle _pascal TrueType_Gen_Widths( ConvertWidths( face, fontHeader, scaleFactor, fontBuf ); /* calculate the transformation matrix and copy it into the FontBlock */ - CalcTransform( (TT_Matrix*)((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry ), + CalcTransform( (TransformMatrix*)((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry ), fontMatrix, stylesToImplement ); @@ -449,14 +449,14 @@ static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) /******************************************************************** * CalcTransform ******************************************************************** - * SYNOPSIS: Calculates the transformation matrix for - * missing style attributes and weights. + * SYNOPSIS: Calculates the transformation matrix for missing + * style attributes and weights. * - * PARAMETERS: fontBuf - * fontMatrix - * styleToImplement + * PARAMETERS: fontBuf Pointer to FontBuf stucture. + * fontMatrix Systems transformation matrix. + * styleToImplement Styles that must be added. * - * RETURNS: + * RETURNS: void * * SIDE EFFECTS: none * @@ -468,35 +468,48 @@ static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) * 20/12/22 JK Initial Revision *******************************************************************/ -static void CalcTransform( TT_Matrix* transMatrix, - FontMatrix* fontMatrix, - TextStyle stylesToImplement ) +static void CalcTransform( TransformMatrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle stylesToImplement ) { /* copy fontMatrix into transMatrix */ - transMatrix->xx = fontMatrix->FM_11; - transMatrix->xy = fontMatrix->FM_12; - transMatrix->yx = fontMatrix->FM_21; - transMatrix->yy = fontMatrix->FM_22; + transMatrix->TM_matrix.xx = 1 << 16; + transMatrix->TM_matrix.xy = 0; + transMatrix->TM_matrix.yx = 0; + transMatrix->TM_matrix.yy = 1 << 16; /* fake bold style */ /* xx = xx * BOLD_FACTOR */ if( stylesToImplement & TS_BOLD ) { - transMatrix->xx = GrMulWWFixed( transMatrix->xx, BOLD_FACTOR ); + transMatrix->TM_matrix.xx = GrMulWWFixed( transMatrix->TM_matrix.xx, BOLD_FACTOR ); } /* fake italic style */ /* yx = yy * ITALIC_FACTOR */ if( stylesToImplement & TS_ITALIC ) { - transMatrix->yx = GrMulWWFixed( transMatrix->yy, ITALIC_FACTOR ); + transMatrix->TM_matrix.yx = ITALIC_FACTOR; } /* fake script style */ if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) - { + { + transMatrix->TM_matrix.xx = GrMulWWFixed( transMatrix->TM_matrix.xx, SCRIPT_FACTOR ); + transMatrix->TM_matrix.yy = GrMulWWFixed( transMatrix->TM_matrix.yy, SCRIPT_FACTOR ); + if( stylesToImplement & TS_SUBSCRIPT ) + { + transMatrix->TM_shiftY = -SCRIPT_SHIFT_FACTOR; + } + else + { + transMatrix->TM_shiftY = SCRIPT_SHIFT_FACTOR; + } } + + /* integrate fontMatrix */ + //TODO } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index efc693fab..394f1d8b0 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -14,7 +14,7 @@ * 20/12/22 JK Initial version * * DESCRIPTION: - * Declarations of types and functions for the driver function + * Declarations of types and functions for the driver function * DR_FONT_GEN_WIDTHS. ***********************************************************************/ @@ -29,13 +29,18 @@ #define WWFIXED_1_POINR_1 0x00012000 #define ITALIC_FACTOR 0x0000366A -#define BOLD_FACTOR 0x00012000 +#define BOLD_FACTOR 0x00012000 +#define SCRIPT_FACTOR 0x00006000 +#define SCRIPT_SHIFT_FACTOR 0x00015000 /*********************************************************************** * structues ***********************************************************************/ +/* + * c definition of kernels FontMatrix structure + */ typedef struct { WWFixedAsDWord FM_11; From 97f5b7b379a474d8ebf3e22e875e27480e206d45 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 21 Feb 2023 21:11:32 +0100 Subject: [PATCH 133/246] Integrate systems transformation matrix --- Driver/Font/TrueType/Adapter/ttwidths.c | 88 +++++++++++++------------ Driver/Font/TrueType/Adapter/ttwidths.h | 2 +- Driver/Font/TrueType/FreeType/ttfile.c | 84 ----------------------- 3 files changed, 47 insertions(+), 127 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index a72d8d272..b10d0e508 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -75,8 +75,8 @@ static void CalcTransform( * in a given pointsize, style and weight. * * PARAMETERS: fontHandle Memory handle to font block. - * fontMatrix Pointer to tranformation matrix. - * fontInfo Pointer to font info structure. + * *fontMatrix Pointer to tranformation matrix. + * *fontInfo Pointer to font info structure. * pointSize Desired point size. * textStyle Desired text style. * fontWidth Desired font width. @@ -187,14 +187,13 @@ MemHandle _pascal TrueType_Gen_Widths( * SYNOPSIS: Converts the information from the FontHeader and * fills FontBuf with it. * - * PARAMETERS: face - * fontHeader - * scaleFactor - * fontbuf + * PARAMETERS: face TrueType face of font file. + * *fontHeader Pointer to FontHeader structure. + * scaleFactor Factor by which the chars width + * must be scaled. + * *fontBuf Pointer to FontBuf structure. * - * RETURNS: - * - * SIDE EFFECTS: none + * RETURNS: void * * STRATEGY: * @@ -289,8 +288,6 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord * * RETURNS: * - * SIDE EFFECTS: none - * * STRATEGY: * * REVISION HISTORY: @@ -452,14 +449,13 @@ static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) * SYNOPSIS: Calculates the transformation matrix for missing * style attributes and weights. * - * PARAMETERS: fontBuf Pointer to FontBuf stucture. - * fontMatrix Systems transformation matrix. - * styleToImplement Styles that must be added. + * PARAMETERS: *transMatrix Pointer to TransformMatrix + * in font block. + * *fontMatrix Systems transformation matrix. + * styleToImplement Styles that must be added. * * RETURNS: void * - * SIDE EFFECTS: none - * * STRATEGY: * * REVISION HISTORY: @@ -472,31 +468,31 @@ static void CalcTransform( TransformMatrix* transMatrix, FontMatrix* fontMatrix, TextStyle stylesToImplement ) { + TT_Matrix tempMatrix; + /* copy fontMatrix into transMatrix */ - transMatrix->TM_matrix.xx = 1 << 16; - transMatrix->TM_matrix.xy = 0; - transMatrix->TM_matrix.yx = 0; - transMatrix->TM_matrix.yy = 1 << 16; + tempMatrix.xx = 1 << 16; + tempMatrix.xy = 0; + tempMatrix.yx = 0; + tempMatrix.yy = 1 << 16; /* fake bold style */ - /* xx = xx * BOLD_FACTOR */ if( stylesToImplement & TS_BOLD ) { - transMatrix->TM_matrix.xx = GrMulWWFixed( transMatrix->TM_matrix.xx, BOLD_FACTOR ); + tempMatrix.xx = BOLD_FACTOR; } /* fake italic style */ - /* yx = yy * ITALIC_FACTOR */ if( stylesToImplement & TS_ITALIC ) { - transMatrix->TM_matrix.yx = ITALIC_FACTOR; + tempMatrix.yx = ITALIC_FACTOR; } /* fake script style */ if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) { - transMatrix->TM_matrix.xx = GrMulWWFixed( transMatrix->TM_matrix.xx, SCRIPT_FACTOR ); - transMatrix->TM_matrix.yy = GrMulWWFixed( transMatrix->TM_matrix.yy, SCRIPT_FACTOR ); + tempMatrix.xx = GrMulWWFixed( tempMatrix.xx, SCRIPT_FACTOR ); + tempMatrix.yy = GrMulWWFixed( tempMatrix.yy, SCRIPT_FACTOR ); if( stylesToImplement & TS_SUBSCRIPT ) { @@ -509,7 +505,14 @@ static void CalcTransform( TransformMatrix* transMatrix, } /* integrate fontMatrix */ - //TODO + transMatrix->TM_matrix.xx = GrMulWWFixed( tempMatrix.xx, fontMatrix->FM_11 ) + + GrMulWWFixed( tempMatrix.xy, fontMatrix->FM_21 ); + transMatrix->TM_matrix.xy = GrMulWWFixed( tempMatrix.xx, fontMatrix->FM_12 ) + + GrMulWWFixed( tempMatrix.xy, fontMatrix->FM_22 ); + transMatrix->TM_matrix.yx = GrMulWWFixed( tempMatrix.yx, fontMatrix->FM_11 ) + + GrMulWWFixed( tempMatrix.yy, fontMatrix->FM_21 ); + transMatrix->TM_matrix.yy = GrMulWWFixed( tempMatrix.yx, fontMatrix->FM_12 ) + + GrMulWWFixed( tempMatrix.yy, fontMatrix->FM_22 ); } @@ -518,17 +521,18 @@ static void CalcTransform( TransformMatrix* transMatrix, ******************************************************************** * SYNOPSIS: Allocate or reallocate memory block for font. * - * PARAMETERS: additionalSpace additional space in block - * for driver - * numOfCharacters number of characters - * numOfKernPairs number of kerning pairs - * fontHandle* pointer to MemHandle of font block - * if NullHandle alloc new block, if not - * realloc existing block - * - * RETURNS: word size of allocated block + * PARAMETERS: additionalSpace Additional space in block + * for driver. + * numOfCharacters Number of GEOS characters in + * font. + * numOfKernPairs Number of kerning pairs of + * GEOS characters in font. + * *fontHandle Pointer to MemHandle of font + * block. If NullHandle alloc new + * block. If not, realloc existing + * one. * - * SIDE EFFECTS: none + * RETURNS: word Size of allocated block. * * STRATEGY: * @@ -569,15 +573,15 @@ static word AllocFontBlock( ******************************************************************** * SYNOPSIS: Converts FontInfo and fill FontBuf structure. * - * PARAMETERS: fileName Name of font file. - * pointSize Current Pointsize. - * fontBuf Pointer to FontBuf structure + * PARAMETERS: face TrueType face of font file. + * pointSize Current pointsize. + * *fontHeader Pointer to FontHeader structure + * to fill fontBuf. + * *fontBuf Pointer to FontBuf structure * to fill. * * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) * - * SIDE EFFECTS: none - * * STRATEGY: * * REVISION HISTORY: diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 394f1d8b0..84772e944 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -39,7 +39,7 @@ ***********************************************************************/ /* - * c definition of kernels FontMatrix structure + * c definition of drivers FontMatrix structure */ typedef struct { diff --git a/Driver/Font/TrueType/FreeType/ttfile.c b/Driver/Font/TrueType/FreeType/ttfile.c index d81d7ba2d..066735aa3 100644 --- a/Driver/Font/TrueType/FreeType/ttfile.c +++ b/Driver/Font/TrueType/FreeType/ttfile.c @@ -976,28 +976,6 @@ } -/******************************************************************* - * - * Function : GET_Byte - * - * Description : Extracts a byte from the current file frame. - * - * Input : None or current frame - * - * Output : Extracted Byte. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - Byte TT_Get_Byte( FRAME_ARG ) - { - CHECK_FRAME( CUR_Frame, 1 ); - - return (Byte)(*CUR_Frame.cursor++); - } -#endif - - /******************************************************************* * * Function : GET_Char @@ -1047,36 +1025,6 @@ } -/******************************************************************* - * - * Function : GET_UShort - * - * Description : Extracts an unsigned short from the frame. - * - * Input : None or current frame - * - * Output : Extracted ushort. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - UShort TT_Get_UShort( FRAME_ARG ) - { - UShort getshort; - - - CHECK_FRAME( CUR_Frame, 2 ); - - getshort = (UShort)((CUR_Frame.cursor[0] << 8) | - CUR_Frame.cursor[1]); - - CUR_Frame.cursor += 2; - - return getshort; - } -#endif - - /******************************************************************* * * Function : GET_Long @@ -1108,36 +1056,4 @@ } -/******************************************************************* - * - * Function : GET_ULong - * - * Description : Extracts an unsigned long from the frame. - * - * Input : None or current frame - * - * Output : Extracted ulong. - * - ******************************************************************/ -#if 0 - EXPORT_FUNC - ULong TT_Get_ULong( FRAME_ARG ) - { - ULong getlong; - - - CHECK_FRAME( CUR_Frame, 4 ); - - getlong = ( ((ULong)CUR_Frame.cursor[0] << 24) | - ((ULong)CUR_Frame.cursor[1] << 16) | - ((ULong)CUR_Frame.cursor[2] << 8 ) | - (ULong)CUR_Frame.cursor[3] ); - - CUR_Frame.cursor += 4; - - return getlong; - } -#endif - - /* END */ From 4d0dad76d89d2ddd56cbc582b39e437f840dafde Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 24 Feb 2023 23:08:44 +0100 Subject: [PATCH 134/246] Gen_Metrics implemented --- Driver/Font/TrueType/Adapter/ttadapter.h | 11 ++ Driver/Font/TrueType/Adapter/ttmetrics.c | 157 +++++++++++++++--- Driver/Font/TrueType/Adapter/ttmetrics.h | 12 +- Driver/Font/TrueType/Adapter/ttwidths.h | 9 - Driver/Font/TrueType/Main/truetypeMetrics.asm | 48 ++++-- 5 files changed, 183 insertions(+), 54 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 13b3d10a2..a83fb9160 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -41,6 +41,14 @@ extern MemHandle engineBlock; #define CHAR_NOT_EXIST 0 #define CHAR_NOT_BUILT 2 +#define WWFIXED_0_POINT_5 0x00008000 +#define WWFIXED_1_POINR_1 0x00012000 + +#define ITALIC_FACTOR 0x0000366A +#define BOLD_FACTOR 0x00012000 +#define SCRIPT_FACTOR 0x00006000 +#define SCRIPT_SHIFT_FACTOR 0x00015000 + /*********************************************************************** * structures ***********************************************************************/ @@ -266,6 +274,9 @@ typedef struct #define FIXED26DOT6_TO_WWFIXEDASDWORD( value ) \ ( (WWFixedAsDWord)value << 10 ) +#define WWFIXEDASDWORD_TO_FIXED26DOT6( value ) \ + ( (TT_F26Dot6)value >> 10 ) + /* * scale value (word) by factor (WWFixedAsDWord) */ diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index d4de73263..c4d1af1aa 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -19,33 +19,32 @@ #include "ttadapter.h" #include "ttmetrics.h" +#include "ttadapter.h" +#include "freetype.h" +#include "ttcharmapper.h" + + +static void CalcTransformMatrix( TextStyle stylesToImplement, + TransformMatrix* transMatrix ); /******************************************************************** * TrueType_Char_Metrics ******************************************************************** - * SYNOPSIS: Returns the metics of the given char. + * SYNOPSIS: Return character metrics information in document coords. * - * PARAMETERS: fontInfo Pointer to FontInfo structure. - * gstate Handle to current gstate. - * character Character from which the metrics - * are requested. - * info Information to return. + * PARAMETERS: character Character to get metrics of. + * info Info to return (GCM_info). + * *fontInfo + * *outlineData + * stylesToImplement * result Pointer in wich the result will - * stored. The result is not affected - * by scaling, rotation, etc. + * stored. * * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) * * SIDE EFFECTS: none * - * CONDITION: The current directory must be the ttf font directory. - * - * STRATEGY: - find font-file for the requested style from fontInfo - * - open outline of character in founded font-file - * - calculate requested metrics and return it - * - * TODO: If we want to support fake styles, this must also - * be implemented here. + * STRATEGY: * * REVISION HISTORY: * Date Name Description @@ -54,17 +53,121 @@ * *******************************************************************/ TT_Error _pascal TrueType_Char_Metrics( - word character, - const FontInfo* fontInfo, - void* gstatePtr, - GCM_info info, - dword* result ) + word character, + GCM_info info, + const FontInfo* fontInfo, + const OutlineDataEntry* outlineData, + TextStyle stylesToImplement, + WWFixedAsDWord pointSize, + dword* result ) { - /* Api-Funktion für DR_FONT_GET_METRICS */ - /* Transformationen werden nicht beachtet!!! */ - /* The information is in document coordinates, which is to say it is not affected by */ - /* scaling, rotation, etc. that modifies the way the document is viewed, but simply */ - /* by the pointsize and font attributes requested. */ - /* siehe GrCharMetrics() */ + FileHandle truetypeFile; + TrueTypeOutlineEntry* trueTypeOutline; + TransformMatrix transMatrix; + TT_Face face; + word charIndex; + word unicode; + TT_Outline outline; + TT_Instance instance; + TT_Instance_Metrics instanceMetrics; + TT_CharMap charMap; + TT_Glyph glyph; + TT_Glyph_Metrics glyphMetrics; + TT_Error error; + + + /* get filename an load ttf file */ + FilePushDir(); + FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); + + trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineData->ODE_header.OE_handle ); + truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); + + CalcTransformMatrix( stylesToImplement, &transMatrix ); + + error = TT_Open_Face( truetypeFile, &face ); + if( error ) + goto Fail; + + /* get TT char index */ + getCharMap( face, &charMap ); + + charIndex = TT_Char_Index( charMap, GeosCharToUnicode( character ) ); + + /* load glyph */ + TT_New_Glyph( face, &glyph ); + TT_New_Instance( face, &instance ); + + /* transform glyphs outline */ + TT_Get_Glyph_Outline( glyph, &outline ); + TT_Transform_Outline( &outline, &transMatrix.TM_matrix ); + TT_Translate_Outline( &outline, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_shiftY ) ); + + /* scale glyph */ + TT_Set_Instance_CharSize( instance, pointSize ); + TT_Get_Instance_Metrics( instance, &instanceMetrics ); + + /* get metrics */ + TT_Get_Glyph_Metrics( glyph, &glyphMetrics ); + + switch( info ) + { + case GCMI_MIN_X: + case GCMI_MIN_X_ROUNDED: + *result = SCALE_WORD( glyphMetrics.bbox.xMin, instanceMetrics.x_scale ); + break; + case GCMI_MIN_Y: + case GCMI_MIN_Y_ROUNDED: + *result = SCALE_WORD( glyphMetrics.bbox.yMin, instanceMetrics.y_scale ); + break; + case GCMI_MAX_X: + case GCMI_MAX_X_ROUNDED: + *result = SCALE_WORD( glyphMetrics.bbox.xMax, instanceMetrics.x_scale ); + break; + case GCMI_MAX_Y: + case GCMI_MAX_Y_ROUNDED: + *result = SCALE_WORD( glyphMetrics.bbox.yMax, instanceMetrics.y_scale ); + break; + } + + TT_Done_Instance( instance ); + TT_Done_Glyph( glyph ); + +Fail: + TT_Close_Face( face ); + FileClose( truetypeFile, FALSE ); + FilePopDir(); return TT_Err_Ok; } + + +static void CalcTransformMatrix( TextStyle stylesToImplement, + TransformMatrix* transMatrix ) +{ + /* make unity matrix */ + transMatrix->TM_matrix.xx = 1 << 16; + transMatrix->TM_matrix.xy = 0; + transMatrix->TM_matrix.yx = 0; + transMatrix->TM_matrix.yy = 1 << 16; + transMatrix->TM_shiftY = 0; + + /* fake bold style */ + if( stylesToImplement & TS_BOLD ) + transMatrix->TM_matrix.xx = BOLD_FACTOR; + + /* fake italic style */ + if( stylesToImplement & TS_ITALIC ) + transMatrix->TM_matrix.yx = ITALIC_FACTOR; + + /* fake script style */ + if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) + { + transMatrix->TM_matrix.xx = GrMulWWFixed( transMatrix->TM_matrix.xx, SCRIPT_FACTOR ); + transMatrix->TM_matrix.yy = GrMulWWFixed( transMatrix->TM_matrix.yy, SCRIPT_FACTOR ); + + if( stylesToImplement & TS_SUBSCRIPT ) + transMatrix->TM_shiftY = -SCRIPT_SHIFT_FACTOR; + else + transMatrix->TM_shiftY = SCRIPT_SHIFT_FACTOR; + } +} diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.h b/Driver/Font/TrueType/Adapter/ttmetrics.h index 5ed6a2b46..b2985f719 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.h +++ b/Driver/Font/TrueType/Adapter/ttmetrics.h @@ -22,10 +22,12 @@ TT_Error _pascal TrueType_Char_Metrics( - word character, - const FontInfo* fontInfo, - void* gstatePtr, - GCM_info info, - dword* result ); + word character, + GCM_info info, + const FontInfo* fontInfo, + const OutlineDataEntry* outlineData, + TextStyle stylesToImplement, + WWFixedAsDWord pointSize, + dword* result ); #endif /* _TTMETRICS_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 84772e944..355bce3c9 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -25,15 +25,6 @@ #include "ttadapter.h" -#define WWFIXED_0_POINT_5 0x00008000 -#define WWFIXED_1_POINR_1 0x00012000 - -#define ITALIC_FACTOR 0x0000366A -#define BOLD_FACTOR 0x00012000 -#define SCRIPT_FACTOR 0x00006000 -#define SCRIPT_SHIFT_FACTOR 0x00015000 - - /*********************************************************************** * structues ***********************************************************************/ diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index af12ea3f9..8cb7b6a41 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -55,19 +55,32 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TrueTypeCharMetrics proc far - uses bx, cx, si, di, ds + uses ax, bx, cx, si, di, ds resultAXDX local dword .enter - push dx ; character code - push ds ; ptr to fontInfo - mov bx, 0 ; segment offset 0 - push bx - push es ; ptr to gstate - push bx ; segment offset 0 - push cx ; GCM_info + mov si, cx + push dx ; pass character code + push cx ; pass GCM_info + + mov cx, es:GS_fontAttr.FCA_fontID + call FontDrFindFontInfo + push ds ; pass ptr to FontInfo + push di + + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + call FontDrFindOutlineData + push ds ; pass ptr to OutlineEntry + push di + push ax ; pass stylesToImplement + + clr al + movwbf dxah, es:GS_fontAttr.FCA_pointsize + push dx ; pass point size + push ax push ss ; pass ptr to result dword in ss lea cx, resultAXDX @@ -76,14 +89,23 @@ resultAXDX local dword segmov ds, dgroup, cx call TRUETYPE_CHAR_METRICS - clc - cmp ax, 0 - jnc ok - stc -ok: +; clc +; cmp ax, 0 +; jnc ok +; stc + mov ax, {word} resultAXDX mov dx, {word} resultAXDX+2 + test si, GCMI_ROUNDED + jnz roundToInt + rndwwbf axdx +done: .leave ret + +roundToInt: + rndwwf dxcx + jmp done + TrueTypeCharMetrics endp From 083f004868a9205ba233ffbcb3610735c9c280a5 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 25 Feb 2023 17:41:55 +0100 Subject: [PATCH 135/246] Experimental code removed. --- Driver/Font/TrueType/FreeType/ttmemory.c | 69 ------------------------ Driver/Font/TrueType/FreeType/ttmemory.h | 15 ------ 2 files changed, 84 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c index 8558c0e74..843069ea6 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.c +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -79,49 +79,6 @@ return TT_Err_Ok; } -/******************************************************************* - * - * Function : GTT_Alloc - * - * Description : Allocates memory from the engine memory block. - * - * Input : Size size of the memory to be allocated - * chunk ChunkHandle to allocated memory - * - * Output : Error code. - * - * NOTE : - The newly allocated block should _always_ be zeroed - * on return. Many parts of the engine rely on this to - * work properly. - * - We want to move all the memory blocks to the engine - * block step by step. So that TT_Alloc() is no longer - * needed. - * - ******************************************************************/ - EXPORT_FUNC - TT_Error GTT_Alloc( UShort Size, void** P ) - { - ChunkHandle H; - - if ( !P ) - return TT_Err_Invalid_Argument; - - - if ( Size > MAX_BLOCK_SIZE ) - return TT_Err_Out_Of_Memory; - - if ( Size > 0 ) - { - H = LMemAlloc( engineBlock, Size ); - *P = ConstructOptr( engineBlock, H ); - MEM_Set( *P, 0, Size ); - } - else - *P = NULL; - - return TT_Err_Ok; - } - /******************************************************************* * @@ -150,19 +107,6 @@ return TT_Err_Ok; } - EXPORT_FUNC - TT_Error GTT_Free( void** P ) - { - if ( !P || !*P ) - return TT_Err_Ok; - - LMemFree( *P ); - - *P = NULL; - - return TT_Err_Ok; - } - /******************************************************************* * @@ -177,18 +121,6 @@ LOCAL_FUNC TT_Error TTMemory_Init( void ) { - engineBlock = MemAllocSetOwner(GeodeGetCodeProcessHandle(), - 10 * 1024, - HF_SHARABLE | HF_FIXED, HAF_ZERO_INIT ); - - ECCheckMemHandle( engineBlock ); - - LMemInitHeap( engineBlock, LMEM_TYPE_GENERAL, - LMF_NO_HANDLES, - sizeof(LMemBlockHeader), - STD_INIT_HANDLES, - STD_INIT_HEAP ); - return TT_Err_Ok; } @@ -206,6 +138,5 @@ LOCAL_FUNC TT_Error TTMemory_Done( void ) { - MemFree( engineBlock ); return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/FreeType/ttmemory.h b/Driver/Font/TrueType/FreeType/ttmemory.h index 7839e96d4..3c1e3eeef 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.h +++ b/Driver/Font/TrueType/FreeType/ttmemory.h @@ -59,15 +59,9 @@ #define MEM_Alloc( _pointer_, _size_ ) \ TT_Alloc( _size_, (void**)&(_pointer_) ) -#define MEM_GAlloc( _pointer_, _size_ ) \ - GTT_Alloc( _size_, &_pointer_ ) - #define ALLOC( _pointer_, _size_ ) \ ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok ) -#define GALLOC( _chunk_, _size_ ) \ - ( ( error = MEM_GAlloc( _chunk_, _size_ ) ) != TT_Err_Ok ) - #define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ ( ( error = MEM_Alloc( _pointer_, \ (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) @@ -75,9 +69,6 @@ #define FREE( _pointer_ ) \ TT_Free( (void**)&(_pointer_) ) -#define GFREE( _pointer_ ) \ - GTT_Free( &_pointer_ ) - /* Allocate a block of memory of 'Size' bytes from the heap, and */ /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ @@ -86,9 +77,6 @@ EXPORT_DEF TT_Error TT_Alloc( UShort Size, void** P ); - EXPORT_DEF - TT_Error GTT_Alloc( UShort Size, void** P ); - /* Releases a block that was previously allocated through Alloc. */ /* Note that the function returns successfully when P or *P are */ @@ -98,9 +86,6 @@ EXPORT_DEF TT_Error TT_Free( void** P ); - EXPORT_DEF - TT_Error GTT_Free( void** P ); - LOCAL_DEF TT_Error TTMemory_Init( void ); LOCAL_DEF TT_Error TTMemory_Done( void ); From 77f3e3b13c5ce1c8390d848013c2ff456e1f6eb2 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 26 Feb 2023 15:37:48 +0100 Subject: [PATCH 136/246] - unneeded block removed - OutlineEntry in ttMetrics.c is now determined correctly --- Driver/Font/TrueType/Adapter/ttadapter.h | 1 - Driver/Font/TrueType/Adapter/ttmetrics.c | 36 +++++++++++-------- Driver/Font/TrueType/Adapter/ttmetrics.h | 14 ++++---- Driver/Font/TrueType/Main/mainManager.asm | 2 +- Driver/Font/TrueType/Main/truetypeMetrics.asm | 2 ++ .../Font/TrueType/Main/truetypeVariable.def | 1 - 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index a83fb9160..834c27bdd 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -32,7 +32,6 @@ * global dgoup objects ***********************************************************************/ extern TEngine_Instance engineInstance; -extern MemHandle engineBlock; #define TTF_DIRECTORY "TTF" diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index c4d1af1aa..7af791015 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -22,6 +22,7 @@ #include "ttadapter.h" #include "freetype.h" #include "ttcharmapper.h" +#include static void CalcTransformMatrix( TextStyle stylesToImplement, @@ -53,20 +54,19 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, * *******************************************************************/ TT_Error _pascal TrueType_Char_Metrics( - word character, - GCM_info info, - const FontInfo* fontInfo, - const OutlineDataEntry* outlineData, - TextStyle stylesToImplement, - WWFixedAsDWord pointSize, - dword* result ) + word character, + GCM_info info, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + TextStyle stylesToImplement, + WWFixedAsDWord pointSize, + dword* result ) { FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; TransformMatrix transMatrix; TT_Face face; word charIndex; - word unicode; TT_Outline outline; TT_Instance instance; TT_Instance_Metrics instanceMetrics; @@ -76,38 +76,44 @@ TT_Error _pascal TrueType_Char_Metrics( TT_Error error; - /* get filename an load ttf file */ + ECCheckBounds( (void*)fontInfo ); + ECCheckBounds( (void*)outlineEntry ); + + + // get filename an load ttf file FilePushDir(); FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineData->ODE_header.OE_handle ); + trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); + ECCheckFileHandle( truetypeFile ); + CalcTransformMatrix( stylesToImplement, &transMatrix ); error = TT_Open_Face( truetypeFile, &face ); if( error ) goto Fail; - /* get TT char index */ + // get TT char index getCharMap( face, &charMap ); charIndex = TT_Char_Index( charMap, GeosCharToUnicode( character ) ); - /* load glyph */ + // load glyph TT_New_Glyph( face, &glyph ); TT_New_Instance( face, &instance ); - /* transform glyphs outline */ + // transform glyphs outline TT_Get_Glyph_Outline( glyph, &outline ); TT_Transform_Outline( &outline, &transMatrix.TM_matrix ); TT_Translate_Outline( &outline, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_shiftY ) ); - /* scale glyph */ + // scale glyph TT_Set_Instance_CharSize( instance, pointSize ); TT_Get_Instance_Metrics( instance, &instanceMetrics ); - /* get metrics */ + // get metrics TT_Get_Glyph_Metrics( glyph, &glyphMetrics ); switch( info ) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.h b/Driver/Font/TrueType/Adapter/ttmetrics.h index b2985f719..1c3c93a5f 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.h +++ b/Driver/Font/TrueType/Adapter/ttmetrics.h @@ -22,12 +22,12 @@ TT_Error _pascal TrueType_Char_Metrics( - word character, - GCM_info info, - const FontInfo* fontInfo, - const OutlineDataEntry* outlineData, - TextStyle stylesToImplement, - WWFixedAsDWord pointSize, - dword* result ); + word character, + GCM_info info, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + TextStyle stylesToImplement, + WWFixedAsDWord pointSize, + dword* result ); #endif /* _TTMETRICS_H_ */ diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index a010f8abe..7b435862d 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -120,7 +120,7 @@ global TRUETYPE_CHAR_METRICS:far global TRUETYPE_GEN_WIDTHS:far global engineInstance:TrueTypeEngineInstance -global engineBlock:hptr +;global engineBlock:hptr MetricsMod segment resource include truetypeMetrics.asm diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index 8cb7b6a41..d2fefee9f 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -72,6 +72,7 @@ resultAXDX local dword clr ah mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_HEADER call FontDrFindOutlineData push ds ; pass ptr to OutlineEntry push di @@ -101,6 +102,7 @@ resultAXDX local dword jnz roundToInt rndwwbf axdx done: + clc .leave ret diff --git a/Driver/Font/TrueType/Main/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def index d08ed1329..b18e41e92 100644 --- a/Driver/Font/TrueType/Main/truetypeVariable.def +++ b/Driver/Font/TrueType/Main/truetypeVariable.def @@ -119,7 +119,6 @@ variableHandle hptr ;handle of our variable block ;This structure is later moved to the variable block. engineInstance TrueTypeEngineInstance <> -engineBlock hptr udata ends From d0a6b50ca13ba72fb7261ca15a754e2efbcf4029 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 27 Feb 2023 20:29:11 +0100 Subject: [PATCH 137/246] Begin to implement TrueType_Gen_Char. --- Driver/Font/TrueType/Adapter/ttchars.c | 37 ++++++++------- Driver/Font/TrueType/Adapter/ttchars.h | 46 +++++++++++++++++++ Driver/Font/TrueType/Adapter/ttmetrics.c | 2 +- Driver/Font/TrueType/Adapter/ttwidths.c | 4 +- Driver/Font/TrueType/Main/mainManager.asm | 9 +--- Driver/Font/TrueType/Main/truetypeChars.asm | 23 ++++++++-- Driver/Font/TrueType/Main/truetypeMetrics.asm | 5 -- 7 files changed, 89 insertions(+), 37 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttchars.h diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 17892a64a..6c9940413 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -18,44 +18,43 @@ ***********************************************************************/ #include "ttadapter.h" -#include "ttmetrics.h" +#include "ttchars.h" /******************************************************************** * TrueType_Gen_Chars ******************************************************************** * SYNOPSIS: Generate one character for a font. * - * PARAMETERS: character character to build (Chars) - * fontBuf Ptr to font data structure. - * fontInfo Pointer to FontInfo structure. - * gstatePtr Handle to current gstate. + * PARAMETERS: character Character to build (Chars). + * pointsize + * *fontBuf Ptr to font data structure. + * *fontInfo Pointer to FontInfo structure. + * *outlineEntry Handle to current gstate. + * stylesToImplement * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) - * - * SIDE EFFECTS: none - * - * CONDITION: The current directory must be the ttf font directory. + * RETURNS: void * * STRATEGY: - find font-file for the requested style from fontInfo * - open outline of character in founded font-file * - calculate requested metrics and return it * - * TODO: If we want to support fake styles, this must also - * be implemented here. - * * REVISION HISTORY: * Date Name Description * ---- ---- ----------- * 23/12/22 JK Initial Revision * *******************************************************************/ -TT_Error _pascal TrueType_Gen_Chars( - word character, - void* fontBuf, - const FontInfo* fontInfo, - void* gstatePtr + +void _pascal TrueType_Gen_Chars( + word character, + WWFixedAsDWord pointSize, + void* fontBuf, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + TextStyle stylesToImplement ) { /* Api-Funktion für DR_FONT_GEN_CHARS */ - return TT_Err_Ok; + + } diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h new file mode 100644 index 000000000..173ddadbe --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -0,0 +1,46 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttinit.h + * + * AUTHOR: Jirka Kunze: February 27 2023 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 23/02/23 JK Initial version + * + * DESCRIPTION: + * Declarations of types and functions for the driver function DR_GEN_CHAR. + ***********************************************************************/ + +#ifndef _TTCHARS_H_ +#define _TTCHARS_H_ + +#include + + +/*********************************************************************** + * varaibles initialized by driver + ***********************************************************************/ + +extern MemHandle bitmapHandle; +extern word bitmapSize; + + +/*********************************************************************** + * functions called by driver + ***********************************************************************/ + +void _pascal TrueType_Gen_Chars( word character, + WWFixedAsDWord pointSize, + void* fontBuf, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + TextStyle stylesToImplement ); + + +#endif /* _TTCHARS_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 7af791015..ac955fa1a 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -143,7 +143,7 @@ TT_Error _pascal TrueType_Char_Metrics( TT_Close_Face( face ); FileClose( truetypeFile, FALSE ); FilePopDir(); - return TT_Err_Ok; + return error; } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index b10d0e508..f15e47930 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -439,7 +439,9 @@ static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) // Kernvalue in den FontBuf eintragen // KernCounter hochzählen - fontBuf->FB_kernValuePtr = 0; + fontBuf->FB_kernCount = 0; + fontBuf->FB_kernValuePtr = NULL; + fontBuf->FB_kernPairPtr = NULL; } diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index 7b435862d..bc9018af7 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -81,12 +81,6 @@ ForceRef DriverTable idata ends -;TODO: remove dependencys from ansic -;udata segment -; mallocOffset word (?) -; public mallocOffset -;udata ends - include truetypeMacros.def WidthMod segment resource @@ -119,8 +113,9 @@ global TRUETYPE_GEN_CHARS:far global TRUETYPE_CHAR_METRICS:far global TRUETYPE_GEN_WIDTHS:far +global bitmapHandle:hptr +global bitmapSize:word global engineInstance:TrueTypeEngineInstance -;global engineBlock:hptr MetricsMod segment resource include truetypeMetrics.asm diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index fea6a8ac5..6b433cb00 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -60,13 +60,28 @@ TrueTypeGenChar proc far push cx ; remember handle push dx ; pass character code + + clr al + movwbf dxah, es:GS_fontAttr.FCA_pointsize + push dx ; pass point size + push ax + push es ; pass font ptr mov ax, 0 ; with segment offset 0 push ax - push bp ; pass gstate ptr - push ax ; with segment offset 0 - push ds ; pass font info block - push ax ; with segment offset 0 + + mov cx, es:GS_fontAttr.FCA_fontID + call FontDrFindFontInfo + push ds ; pass ptr to FontInfo + push di + + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_HEADER + call FontDrFindOutlineData + push ds ; pass ptr to OutlineEntry + push di + push ax ; pass stylesToImplement segmov ds, dgroup, ax call TRUETYPE_GEN_CHARS diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index d2fefee9f..df0a70c3b 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -90,11 +90,6 @@ resultAXDX local dword segmov ds, dgroup, cx call TRUETYPE_CHAR_METRICS -; clc -; cmp ax, 0 -; jnc ok -; stc - mov ax, {word} resultAXDX mov dx, {word} resultAXDX+2 From 5bbb96454b785eb5c2841215b17a311884e04845 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 1 Mar 2023 21:45:50 +0100 Subject: [PATCH 138/246] Calculation of numbers of character in font corrected. --- Driver/Font/TrueType/Adapter/ttcharmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index b1bc4a49f..059067e87 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -334,7 +334,7 @@ word InitGeosCharsInCharMap( TT_CharMap map, char *firstChar, char *lastChar ) } } - return *lastChar - *firstChar; + return 1 + ( *lastChar - *firstChar ); } From 9f637a7283de56e96b97691cb7a50fcba61a8e87 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 1 Mar 2023 21:47:46 +0100 Subject: [PATCH 139/246] Potential problem when reading ttf directory reading fixed. --- Driver/Font/TrueType/FreeType/ttload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 49756702a..344a3051b 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -87,7 +87,7 @@ PTableDirEntry entry; - if ( ACCESS_Frame( 12L ) ) + if ( FILE_Seek( 0L ) || ACCESS_Frame( 12L ) ) return error; tableDir.version = GET_Long(); From 86a08b2a8a2c30b9e4be4d05a7b543159b026144 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 5 Mar 2023 21:09:03 +0100 Subject: [PATCH 140/246] Gen_Chars partially implemented. --- Driver/Font/TrueType/Adapter/ttchars.c | 102 ++++++++++++++++++++++- Driver/Font/TrueType/Adapter/ttchars.h | 2 +- Driver/Font/TrueType/Adapter/ttmetrics.c | 2 +- 3 files changed, 102 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 6c9940413..fa21ec330 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -19,6 +19,7 @@ #include "ttadapter.h" #include "ttchars.h" +#include /******************************************************************** * TrueType_Gen_Chars @@ -48,13 +49,110 @@ void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, - void* fontBuf, + FontBuf* fontBuf, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, TextStyle stylesToImplement ) { - /* Api-Funktion für DR_FONT_GEN_CHARS */ + FileHandle truetypeFile; + TrueTypeOutlineEntry* trueTypeOutline; + TT_Error error; + TT_Face face; + TT_Instance instance; + TT_Glyph glyph; + TT_Outline outline; + TT_BBox bbox; + TT_CharMap charMap; + TT_UShort charIndex; + word width, height; + + ECCheckBounds( fontBuf ); + ECCheckBounds( fontInfo ); + ECCheckBounds( outlineEntry ); + + + FilePushDir(); + FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); + + // get filename an load ttf file + trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); + truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); + + ECCheckFileHandle( truetypeFile ); + + /* open face, create instance and glyph */ + error = TT_Open_Face( truetypeFile, &face ); + if( error ) + goto Fail; + + TT_New_Glyph( face, &glyph ); + TT_New_Instance( face, &instance ); + + /* get TT char index */ + getCharMap( face, &charMap ); + charIndex = TT_Char_Index( charMap, GeosCharToUnicode( character ) ); + + /* set pointsize and get metrics */ + TT_Set_Instance_CharSize( instance, ( pointSize >> 10 ) ); + + /* load glyph and load glyphs outline */ + TT_Load_Glyph( instance, glyph, charIndex, TTLOAD_DEFAULT ); + + // TODO: Transformationsmatrix anwenden + + + TT_Get_Glyph_Outline( glyph, &outline ); + TT_Get_Outline_BBox( &outline, &bbox ); + + /* Grid-fit it */ + bbox.xMin &= -64; + bbox.xMax = ( bbox.xMax + 63 ) & -64; + bbox.yMin &= -64; + bbox.yMax = ( bbox.yMax + 63 ) & -64; + + /* compute pixel dimensions */ + width = (bbox.xMax - bbox.xMin) / 64; + height = (bbox.yMax - bbox.yMin) / 64; + + if( fontBuf->FB_flags && FBF_IS_REGION ) + { + // Platzbedarf der Region ermitteln + + // absichern dass im BitmapBlock genügend Platz vorhanden ist + + // Outline verschieben + + // an TT_Get_Outline_Region delegieren + + // Header in Region verschieben + + // size in dgoup zurückschreiben + } + else + { + word size = height * (width + 7) / 8; // + sizeof(bitmap) + + // absichern dass im BitmapBlock genügend Platz vorhanden ist + + // Outline verschieben + + // an TT_Get_Outline_Bitmap delegieren + + // Header in Bitmap füllen + + // size in dgoup zurückschreiben + + } + + // FontBlock ggf. kürzen und neues Glyph anhängen erfolgt auf asm Seite + + TT_Done_Glyph( glyph ); + TT_Done_Instance( instance ); + +Fail: + FileClose( truetypeFile, FALSE ); + FilePopDir(); } diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index 173ddadbe..ec1ce42fa 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -37,7 +37,7 @@ extern word bitmapSize; void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, - void* fontBuf, + FontBuf* fontBuf, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, TextStyle stylesToImplement ); diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index ac955fa1a..4e7c8513c 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -110,7 +110,7 @@ TT_Error _pascal TrueType_Char_Metrics( TT_Translate_Outline( &outline, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_shiftY ) ); // scale glyph - TT_Set_Instance_CharSize( instance, pointSize ); + TT_Set_Instance_CharSize( instance, ( pointSize >> 10 ) ); TT_Get_Instance_Metrics( instance, &instanceMetrics ); // get metrics From 3a33f2bcbc3b7e3ff21dc3015452d8efbba3cfa9 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 6 Mar 2023 21:45:20 +0100 Subject: [PATCH 141/246] Begin to fill CharData structure --- Driver/Font/TrueType/Adapter/ttadapter.h | 13 +++++++++++++ Driver/Font/TrueType/Adapter/ttchars.c | 13 +++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 834c27bdd..ec9e93786 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -255,6 +255,19 @@ typedef struct WWFixedAsDWord TM_shiftY; } TransformMatrix; +/* + * drivers CharData structure (see fontDr.def) + */ +typedef struct +{ + byte CD_pictureWidth; + byte CD_numRows; + sbyte CD_yoff; + sbyte CD_xoff; + byte CD_data; +} CharData; + +#define SIZE_CHAR_HEADER ( sizeof( CharData ) - 1 ) /*********************************************************************** diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index fa21ec330..e1876b6ed 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -132,7 +132,8 @@ void _pascal TrueType_Gen_Chars( } else { - word size = height * (width + 7) / 8; // + sizeof(bitmap) + CharData* charData; + word size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; // absichern dass im BitmapBlock genügend Platz vorhanden ist @@ -140,10 +141,14 @@ void _pascal TrueType_Gen_Chars( // an TT_Get_Outline_Bitmap delegieren - // Header in Bitmap füllen - - // size in dgoup zurückschreiben + /* fill charData */ + charData->CD_pictureWidth = width; + charData->CD_numRows = height; + charData->CD_xoff = bbox.xMin; + charData->CD_yoff = bbox.yMin; + /* save size of bitmap */ + bitmapSize = size; } // FontBlock ggf. kürzen und neues Glyph anhängen erfolgt auf asm Seite From bae7ccc6c8361ee4f5b2a4a2a8fb74489efd5054 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 7 Mar 2023 22:06:45 +0100 Subject: [PATCH 142/246] Rendering into bitmaps implemented. --- Driver/Font/TrueType/Adapter/ttchars.c | 48 ++++++++++++++++++-------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index e1876b6ed..2f4a6343f 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -19,8 +19,13 @@ #include "ttadapter.h" #include "ttchars.h" +#include "ttcharmapper.h" #include + +static void EnsureBitmapHandle( word size ); + + /******************************************************************** * TrueType_Gen_Chars ******************************************************************** @@ -68,9 +73,9 @@ void _pascal TrueType_Gen_Chars( word width, height; - ECCheckBounds( fontBuf ); - ECCheckBounds( fontInfo ); - ECCheckBounds( outlineEntry ); + ECCheckBounds( (void*)fontBuf ); + ECCheckBounds( (void*)fontInfo ); + ECCheckBounds( (void*)outlineEntry ); FilePushDir(); @@ -132,16 +137,26 @@ void _pascal TrueType_Gen_Chars( } else { - CharData* charData; - word size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; - - // absichern dass im BitmapBlock genügend Platz vorhanden ist - - // Outline verschieben - - // an TT_Get_Outline_Bitmap delegieren - - /* fill charData */ + CharData* charData; + TT_Raster_Map rasterMap; + word size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; + + /* get pointer to bitmapBlock */ + EnsureBitmapHandle( size ); + charData = MemDeref( bitmapHandle ); + + /* init rasterMap */ + rasterMap.rows = height; + rasterMap.width = width; + rasterMap.cols = (width + 7) / 8; + rasterMap.size = rasterMap.rows * rasterMap.cols; + rasterMap.bitmap = charData + SIZE_CHAR_HEADER; + + /* translate outline and render it */ + TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); + TT_Get_Outline_Bitmap( &outline, &rasterMap ); + + /* fill header of charData */ charData->CD_pictureWidth = width; charData->CD_numRows = height; charData->CD_xoff = bbox.xMin; @@ -158,6 +173,9 @@ void _pascal TrueType_Gen_Chars( Fail: FileClose( truetypeFile, FALSE ); - FilePopDir(); - + FilePopDir(); +} + +static void EnsureBitmapHandle( word size ) { + //TODO: implement } From 89cf40479df82823bc5866dd45c1bd7e18b927b1 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 10 Mar 2023 21:26:41 +0100 Subject: [PATCH 143/246] Some small corrections. --- Driver/Font/TrueType/Adapter/ttadapter.h | 9 +++++---- Driver/Font/TrueType/Adapter/ttchars.c | 14 ++++---------- Driver/Font/TrueType/Adapter/ttwidths.c | 4 ++-- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index ec9e93786..e571fb602 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -34,11 +34,11 @@ extern TEngine_Instance engineInstance; -#define TTF_DIRECTORY "TTF" -#define FONT_MAN_ID 0x20 +#define TTF_DIRECTORY "TTF" +#define FONT_MAN_ID 0x20 -#define CHAR_NOT_EXIST 0 -#define CHAR_NOT_BUILT 2 +#define CHAR_NOT_EXIST 0 +#define CHAR_NOT_BUILT 2 #define WWFIXED_0_POINT_5 0x00008000 #define WWFIXED_1_POINR_1 0x00012000 @@ -48,6 +48,7 @@ extern TEngine_Instance engineInstance; #define SCRIPT_FACTOR 0x00006000 #define SCRIPT_SHIFT_FACTOR 0x00015000 + /*********************************************************************** * structures ***********************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 2f4a6343f..0cee9207c 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -23,9 +23,6 @@ #include -static void EnsureBitmapHandle( word size ); - - /******************************************************************** * TrueType_Gen_Chars ******************************************************************** @@ -121,7 +118,7 @@ void _pascal TrueType_Gen_Chars( width = (bbox.xMax - bbox.xMin) / 64; height = (bbox.yMax - bbox.yMin) / 64; - if( fontBuf->FB_flags && FBF_IS_REGION ) + if( fontBuf->FB_flags & FBF_IS_REGION ) { // Platzbedarf der Region ermitteln @@ -142,8 +139,9 @@ void _pascal TrueType_Gen_Chars( word size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; /* get pointer to bitmapBlock */ - EnsureBitmapHandle( size ); - charData = MemDeref( bitmapHandle ); + if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) + MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); + charData = MemLock( bitmapHandle ); /* init rasterMap */ rasterMap.rows = height; @@ -175,7 +173,3 @@ void _pascal TrueType_Gen_Chars( FileClose( truetypeFile, FALSE ); FilePopDir(); } - -static void EnsureBitmapHandle( word size ) { - //TODO: implement -} diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index f15e47930..d2923b9df 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -473,10 +473,10 @@ static void CalcTransform( TransformMatrix* transMatrix, TT_Matrix tempMatrix; /* copy fontMatrix into transMatrix */ - tempMatrix.xx = 1 << 16; + tempMatrix.xx = 1L << 16; tempMatrix.xy = 0; tempMatrix.yx = 0; - tempMatrix.yy = 1 << 16; + tempMatrix.yy = 1L << 16; /* fake bold style */ if( stylesToImplement & TS_BOLD ) From 45074aa72e39f1b4eac9830201863239e6566e7d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 15 Mar 2023 20:41:33 +0100 Subject: [PATCH 144/246] Rendering of glyphs in regions started. --- Driver/Font/TrueType/Adapter/ttadapter.h | 18 ++++++++++++++++++ Driver/Font/TrueType/Adapter/ttchars.c | 20 ++++++++++++++------ Driver/Font/TrueType/Adapter/ttchars.h | 2 +- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index e571fb602..af90ee2cb 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -271,6 +271,24 @@ typedef struct #define SIZE_CHAR_HEADER ( sizeof( CharData ) - 1 ) +/* + * drivers RegionCharData structure (see fontDr.def) + */ +typedef struct +{ + sword RCD_yoff; /* (signed) offset to first row */ + sword RCD_xoff; /* (signed) offset to first column */ + word RCD_size; /* size of region (in bytes) */ +if DBCS_PCGEOS + word RCD_usage; /* LRU count */ +endif + Recangle RCD_bounds; /* bounding box of region */ + word RCD_data; /* data for region */ +} RegionCharData; + +#define SIZE_REGION_HEADER ( sizeof( RegionCharData) - 2 ) + + /*********************************************************************** * macros ***********************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 0cee9207c..32661c7db 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -35,7 +35,7 @@ * *outlineEntry Handle to current gstate. * stylesToImplement * - * RETURNS: void + * RETURNS: word Size of bitmap or region. * * STRATEGY: - find font-file for the requested style from fontInfo * - open outline of character in founded font-file @@ -48,7 +48,7 @@ * *******************************************************************/ -void _pascal TrueType_Gen_Chars( +word _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, FontBuf* fontBuf, @@ -67,7 +67,7 @@ void _pascal TrueType_Gen_Chars( TT_BBox bbox; TT_CharMap charMap; TT_UShort charIndex; - word width, height; + word width, height, size; ECCheckBounds( (void*)fontBuf ); @@ -120,9 +120,15 @@ void _pascal TrueType_Gen_Chars( if( fontBuf->FB_flags & FBF_IS_REGION ) { - // Platzbedarf der Region ermitteln + RegionCharData* regionData; - // absichern dass im BitmapBlock genügend Platz vorhanden ist + /* We calculate with an average of 4 on/off points, line number and line end code. */ + size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; + + /* get pointer to bitmapBlock */ + if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) + MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); + regionData = MemLock( bitmapHandle ); // Outline verschieben @@ -136,7 +142,8 @@ void _pascal TrueType_Gen_Chars( { CharData* charData; TT_Raster_Map rasterMap; - word size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; + + size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; /* get pointer to bitmapBlock */ if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) @@ -172,4 +179,5 @@ void _pascal TrueType_Gen_Chars( Fail: FileClose( truetypeFile, FALSE ); FilePopDir(); + return size; } diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index ec1ce42fa..962e94e41 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -35,7 +35,7 @@ extern word bitmapSize; * functions called by driver ***********************************************************************/ -void _pascal TrueType_Gen_Chars( word character, +word _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, FontBuf* fontBuf, const FontInfo* fontInfo, From 8612852b0d87497871c5a8662b33ed8fc2e8a8b8 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 16 Mar 2023 20:49:35 +0100 Subject: [PATCH 145/246] Glyph rendering into regions completed. --- Driver/Font/TrueType/Adapter/ttadapter.h | 7 ++++--- Driver/Font/TrueType/Adapter/ttchars.c | 25 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index af90ee2cb..36343ec95 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "../FreeType/freetype.h" #include "../FreeType/ttengine.h" #include "../FreeType/ttcalc.h" @@ -279,10 +280,10 @@ typedef struct sword RCD_yoff; /* (signed) offset to first row */ sword RCD_xoff; /* (signed) offset to first column */ word RCD_size; /* size of region (in bytes) */ -if DBCS_PCGEOS +#if DBCS_PCGEOS word RCD_usage; /* LRU count */ -endif - Recangle RCD_bounds; /* bounding box of region */ +#endif + Rectangle RCD_bounds; /* bounding box of region */ word RCD_data; /* data for region */ } RegionCharData; diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 32661c7db..477e5d679 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -121,6 +121,7 @@ word _pascal TrueType_Gen_Chars( if( fontBuf->FB_flags & FBF_IS_REGION ) { RegionCharData* regionData; + TT_Raster_Map rasterMap; /* We calculate with an average of 4 on/off points, line number and line end code. */ size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; @@ -130,13 +131,26 @@ word _pascal TrueType_Gen_Chars( MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); regionData = MemLock( bitmapHandle ); - // Outline verschieben - - // an TT_Get_Outline_Region delegieren + /* init rasterMap */ + rasterMap.rows = height; + rasterMap.width = width; + rasterMap.flow = TT_Flow_Down; + rasterMap.bitmap = regionData + SIZE_REGION_HEADER; - // Header in Region verschieben + /* translate outline and render it */ + TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); + TT_Get_Outline_Region( &outline, &rasterMap ); - // size in dgoup zurückschreiben + /* fill header of charData */ + regionData->RCD_xoff = bbox.xMin; + regionData->RCD_xoff = bbox.yMin; + regionData->RCD_size = rasterMap.size; + regionData->RCD_bounds.R_left = 0; + regionData->RCD_bounds.R_right = width; + regionData->RCD_bounds.R_top = height; + regionData->RCD_bounds.R_bottom = 0; + + size = rasterMap.size; } else { @@ -155,6 +169,7 @@ word _pascal TrueType_Gen_Chars( rasterMap.width = width; rasterMap.cols = (width + 7) / 8; rasterMap.size = rasterMap.rows * rasterMap.cols; + rasterMap.flow = TT_Flow_Down; rasterMap.bitmap = charData + SIZE_CHAR_HEADER; /* translate outline and render it */ From 2a509d238904c90fb0c90770c7c13da9726ff8ee Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 20 Mar 2023 22:06:55 +0100 Subject: [PATCH 146/246] Begin to copy rendered glyphs into fontBuf. --- Driver/Font/TrueType/Adapter/ttchars.c | 17 +++++++++++++---- Driver/Font/TrueType/Main/truetypeChars.asm | 17 +++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 477e5d679..e4f3544b0 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -35,7 +35,7 @@ * *outlineEntry Handle to current gstate. * stylesToImplement * - * RETURNS: word Size of bitmap or region. + * RETURNS: void * * STRATEGY: - find font-file for the requested style from fontInfo * - open outline of character in founded font-file @@ -44,11 +44,11 @@ * REVISION HISTORY: * Date Name Description * ---- ---- ----------- - * 23/12/22 JK Initial Revision + * 12/23/22 JK Initial Revision * *******************************************************************/ -word _pascal TrueType_Gen_Chars( +void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, FontBuf* fontBuf, @@ -194,5 +194,14 @@ word _pascal TrueType_Gen_Chars( Fail: FileClose( truetypeFile, FALSE ); FilePopDir(); - return size; +} + + +/******************************************************************** + * DeleteLRUChar + ******************************************************************** + * + *******************************************************************/ +void DeleteLRUChar() { + } diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 6b433cb00..22a8ca6ec 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -57,31 +57,32 @@ TrueTypeGenChar proc far call MemSegmentToHandle jnc err - push cx ; remember handle + push cx ; remember handle + push dx ; remember character to build - push dx ; pass character code + push dx ; pass character code clr al movwbf dxah, es:GS_fontAttr.FCA_pointsize - push dx ; pass point size + push dx ; pass point size push ax - push es ; pass font ptr - mov ax, 0 ; with segment offset 0 + push es ; pass font ptr + mov ax, 0 ; with segment offset 0 push ax mov cx, es:GS_fontAttr.FCA_fontID call FontDrFindFontInfo - push ds ; pass ptr to FontInfo + push ds ; pass ptr to FontInfo push di clr ah mov al, es:GS_fontAttr.FCA_textStyle mov bx, ODF_HEADER call FontDrFindOutlineData - push ds ; pass ptr to OutlineEntry + push ds ; pass ptr to OutlineEntry push di - push ax ; pass stylesToImplement + push ax ; pass stylesToImplement segmov ds, dgroup, ax call TRUETYPE_GEN_CHARS From 7e71cdfa86b8cbfa053c2a1d12761e760d6e9e5a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 24 Mar 2023 21:11:15 +0100 Subject: [PATCH 147/246] Implement shrinking of fontBuf if necessary. --- Driver/Font/TrueType/Adapter/ttadapter.h | 8 +- Driver/Font/TrueType/Adapter/ttchars.c | 128 ++++++++++++++++++++++- Driver/Font/TrueType/Adapter/ttchars.h | 2 +- 3 files changed, 132 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 36343ec95..6e37035b5 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -32,6 +32,7 @@ /*********************************************************************** * global dgoup objects ***********************************************************************/ + extern TEngine_Instance engineInstance; @@ -39,7 +40,9 @@ extern TEngine_Instance engineInstance; #define FONT_MAN_ID 0x20 #define CHAR_NOT_EXIST 0 -#define CHAR_NOT_BUILT 2 +#define CHAR_NOT_LOADED 1 +#define CHAR_NOT_BUILT 2 +#define CHAR_MISSING 3 #define WWFIXED_0_POINT_5 0x00008000 #define WWFIXED_1_POINR_1 0x00012000 @@ -50,6 +53,9 @@ extern TEngine_Instance engineInstance; #define SCRIPT_SHIFT_FACTOR 0x00015000 +#define MAX_FONTBUF_SIZE 10 * 1024 + + /*********************************************************************** * structures ***********************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index e4f3544b0..558c81a32 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -21,6 +21,13 @@ #include "ttchars.h" #include "ttcharmapper.h" #include +#include + + +static void CopyChar( FontBuf* fontBuf, word sizeToAdd ); + +static word ShiftCharData( FontBuf* fontBuf, CharData* charData ); +static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ); /******************************************************************** @@ -186,11 +193,12 @@ void _pascal TrueType_Gen_Chars( bitmapSize = size; } - // FontBlock ggf. kürzen und neues Glyph anhängen erfolgt auf asm Seite - TT_Done_Glyph( glyph ); TT_Done_Instance( instance ); + /* add rendered glyph to fontbuf */ + CopyChar( fontBuf, size ); + Fail: FileClose( truetypeFile, FALSE ); FilePopDir(); @@ -198,10 +206,122 @@ void _pascal TrueType_Gen_Chars( /******************************************************************** - * DeleteLRUChar + * CopyChar ******************************************************************** * *******************************************************************/ -void DeleteLRUChar() { +static void CopyChar( FontBuf* fontBuf, word sizeToAdd ) +{ + word numOfChars = fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1; + CharTableEntry* charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + + + /* shrink fontBuf if necessary */ + while( fontBuf->FB_dataSize > MAX_FONTBUF_SIZE ) + { + word sizeCharData; + word indexLRUChar = FindLRUChar( fontBuf, numOfChars ); + void* charData = ((byte*)fontBuf) + charTableEntries[indexLRUChar].CTE_dataOffset; + + + /* remove CharData of lru char */ + if( fontBuf->FB_flags & FBF_IS_REGION ) + sizeCharData = ShiftRegionCharData( fontBuf, (RegionCharData*)charData ); + else + sizeCharData = ShiftCharData( fontBuf, (CharData*)charData ); + + /* adjust pointers in CharTableEntries */ + AdjustPointers( charTableEntries, &charTableEntries[indexLRUChar], sizeCharData, numOfChars ); + + /* update CharTableEntry */ + charTableEntries[indexLRUChar].CTE_dataOffset = CHAR_NOT_BUILT; + charTableEntries[indexLRUChar].CTE_usage = 0; + + /* update FontBuf */ + fontBuf->FB_dataSize -= sizeCharData; + } + + /* copy rendered Glyph to fontBuf */ + // TODO +} + +/******************************************************************** + * FindLRUChar + ******************************************************************** + * + *******************************************************************/ +static int FindLRUChar( FontBuf* fontBuf, int numOfChars ) +{ + word lru = 0xffff; + int indexLRUChar = -1; + int i; + CharTableEntry* charTableEntry = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + + + for( i = 0; i < numOfChars; i++, charTableEntry++ ) + { + /* if no data, go to next char */ + if( charTableEntry->CTE_dataOffset < CHAR_MISSING ) + continue; + + if( charTableEntry->CTE_usage < lru ) + { + lru = charTableEntry->CTE_usage; + indexLRUChar = i; + } + + } + + return indexLRUChar; +} + +/******************************************************************** + * AdjustPointers + ******************************************************************** + * + *******************************************************************/ +static void AdjustPointers( CharTableEntry* charTableEntries, + CharTableEntry* lruEntry, + word sizeLRUEntry, + word numOfChars ) +{ + word i; + + for( i = 0; i < numOfChars; i++ ) + if( charTableEntries[i].CTE_dataOffset > lruEntry->CTE_dataOffset ) + charTableEntries[i].CTE_dataOffset -= sizeLRUEntry; +} + +/******************************************************************** + * ShiftCharData + ******************************************************************** + * + *******************************************************************/ +static word ShiftCharData( FontBuf* fontBuf, CharData* charData ) +{ + word size = charData->CD_pictureWidth * charData->CD_numRows + SIZE_CHAR_HEADER; + + + memmove( charData, + ((byte*)charData) + size, + ((byte*)charData) - ((byte*)fontBuf) + fontBuf->FB_dataSize ); + + return size; +} + +/******************************************************************** + * ShiftRegionCharData + ******************************************************************** + * + *******************************************************************/ +static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ) +{ + word size = charData->RCD_size + SIZE_REGION_HEADER; + + + memmove( charData, + ((byte*)charData) + size, + ((byte*)charData) - ((byte*)fontBuf) + fontBuf->FB_dataSize ); + return size; } diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index 962e94e41..ec1ce42fa 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -35,7 +35,7 @@ extern word bitmapSize; * functions called by driver ***********************************************************************/ -word _pascal TrueType_Gen_Chars( word character, +void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, FontBuf* fontBuf, const FontInfo* fontInfo, From 4364b07b84cb08136a18b19687108a380e51937e Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 25 Mar 2023 18:33:57 +0100 Subject: [PATCH 148/246] Adding rendered glyph to fontBuf implemented. --- Driver/Font/TrueType/Adapter/ttchars.c | 75 ++++++++++++++++++-------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 558c81a32..d600db412 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -24,8 +24,13 @@ #include -static void CopyChar( FontBuf* fontBuf, word sizeToAdd ); - +static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word charDataSize ); +static void ShrinkFontBuf( FontBuf* fontBuf ); +static int FindLRUChar( FontBuf* fontBuf, int numOfChars ); +static void AdjustPointers( CharTableEntry* charTableEntries, + CharTableEntry* lruEntry, + word sizeLRUEntry, + word numOfChars ); static word ShiftCharData( FontBuf* fontBuf, CharData* charData ); static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ); @@ -74,6 +79,7 @@ void _pascal TrueType_Gen_Chars( TT_BBox bbox; TT_CharMap charMap; TT_UShort charIndex; + void* charData; word width, height, size; @@ -127,7 +133,6 @@ void _pascal TrueType_Gen_Chars( if( fontBuf->FB_flags & FBF_IS_REGION ) { - RegionCharData* regionData; TT_Raster_Map rasterMap; /* We calculate with an average of 4 on/off points, line number and line end code. */ @@ -136,26 +141,26 @@ void _pascal TrueType_Gen_Chars( /* get pointer to bitmapBlock */ if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); - regionData = MemLock( bitmapHandle ); + charData = MemLock( bitmapHandle ); /* init rasterMap */ rasterMap.rows = height; rasterMap.width = width; rasterMap.flow = TT_Flow_Down; - rasterMap.bitmap = regionData + SIZE_REGION_HEADER; + rasterMap.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; /* translate outline and render it */ TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); TT_Get_Outline_Region( &outline, &rasterMap ); /* fill header of charData */ - regionData->RCD_xoff = bbox.xMin; - regionData->RCD_xoff = bbox.yMin; - regionData->RCD_size = rasterMap.size; - regionData->RCD_bounds.R_left = 0; - regionData->RCD_bounds.R_right = width; - regionData->RCD_bounds.R_top = height; - regionData->RCD_bounds.R_bottom = 0; + ((RegionCharData*)charData)->RCD_xoff = bbox.xMin; + ((RegionCharData*)charData)->RCD_xoff = bbox.yMin; + ((RegionCharData*)charData)->RCD_size = rasterMap.size; + ((RegionCharData*)charData)->RCD_bounds.R_left = 0; + ((RegionCharData*)charData)->RCD_bounds.R_right = width; + ((RegionCharData*)charData)->RCD_bounds.R_top = height; + ((RegionCharData*)charData)->RCD_bounds.R_bottom = 0; size = rasterMap.size; } @@ -188,17 +193,28 @@ void _pascal TrueType_Gen_Chars( charData->CD_numRows = height; charData->CD_xoff = bbox.xMin; charData->CD_yoff = bbox.yMin; - - /* save size of bitmap */ - bitmapSize = size; } TT_Done_Glyph( glyph ); TT_Done_Instance( instance ); + if( fontBuf->FB_dataSize > MAX_FONTBUF_SIZE ) + ShrinkFontBuf( fontBuf ); + + /* realloc FontBuf if necessary */ + if( MemGetInfo( PtrToSegment( fontBuf ), MGIT_SIZE ) < fontBuf->FB_dataSize + size ) + { + MemReAlloc( PtrToSegment( fontBuf ), + fontBuf->FB_dataSize + size, + HAF_STANDARD_NO_ERR ); + fontBuf = MemDeref( PtrToSegment( fontBuf )); + } + /* add rendered glyph to fontbuf */ - CopyChar( fontBuf, size ); + CopyChar( fontBuf, character, charData ,size ); + /* cleanup */ + MemUnlock( bitmapHandle ); Fail: FileClose( truetypeFile, FALSE ); FilePopDir(); @@ -210,16 +226,36 @@ void _pascal TrueType_Gen_Chars( ******************************************************************** * *******************************************************************/ -static void CopyChar( FontBuf* fontBuf, word sizeToAdd ) +static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word charDataSize ) +{ + word indexGeosChar = geosChar - fontBuf->FB_firstChar; + CharTableEntry* charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + + + /* copy rendered Glyph to fontBuf */ + memmove( ((byte*)fontBuf) + fontBuf->FB_dataSize, charData, charDataSize ); + + /* update CharTableEntry and FontBuf */ + charTableEntries[indexGeosChar].CTE_dataOffset = fontBuf->FB_dataSize; + fontBuf->FB_dataSize += charDataSize; +} + + +/******************************************************************** + * ShrinkFontBuf + ******************************************************************** + * + *******************************************************************/ +static void ShrinkFontBuf( FontBuf* fontBuf ) { word numOfChars = fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1; CharTableEntry* charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + word sizeCharData; /* shrink fontBuf if necessary */ while( fontBuf->FB_dataSize > MAX_FONTBUF_SIZE ) { - word sizeCharData; word indexLRUChar = FindLRUChar( fontBuf, numOfChars ); void* charData = ((byte*)fontBuf) + charTableEntries[indexLRUChar].CTE_dataOffset; @@ -240,9 +276,6 @@ static void CopyChar( FontBuf* fontBuf, word sizeToAdd ) /* update FontBuf */ fontBuf->FB_dataSize -= sizeCharData; } - - /* copy rendered Glyph to fontBuf */ - // TODO } /******************************************************************** From 1a477bc3f330fff9e42f9058cbdc9521a3017455 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 25 Mar 2023 21:54:01 +0100 Subject: [PATCH 149/246] Guard condition included. --- Driver/Font/TrueType/Adapter/ttchars.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index d600db412..c1c3c7020 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -259,6 +259,9 @@ static void ShrinkFontBuf( FontBuf* fontBuf ) word indexLRUChar = FindLRUChar( fontBuf, numOfChars ); void* charData = ((byte*)fontBuf) + charTableEntries[indexLRUChar].CTE_dataOffset; + /* ensure that we have a char to remove */ + if( indexLRUChar == -1 ) + return; /* remove CharData of lru char */ if( fontBuf->FB_flags & FBF_IS_REGION ) From a7b9c971f374d6314eae703a816b08fc15c95eaa Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 7 Apr 2023 19:04:25 +0200 Subject: [PATCH 150/246] Small refactoring to reduce the amount of space needed on stack. --- Driver/Font/TrueType/Adapter/ttinit.c | 7 +++---- Driver/Font/TrueType/Adapter/ttmetrics.c | 4 ++-- Driver/Font/TrueType/Main/truetypeInit.asm | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index e2ac92b8a..2e6c4d7d3 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -149,7 +149,6 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) FileEnumParams ttfEnumParams; word numOtherFiles; word numFiles; - word file; FileLongName* ptrFileName; MemHandle fileEnumBlock = NullHandle; FileExtAttrDesc ttfExtAttrDesc[] = @@ -181,7 +180,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /* iterate over all filenames and try to register a font.*/ ptrFileName = MemLock( fileEnumBlock ); - for( file = 0; file < numFiles; file++ ) + while( numFiles-- ) ProcessFont( ptrFileName++, fontInfoBlock ); MemFree( fileEnumBlock ); @@ -800,8 +799,8 @@ static void convertHeader( &fontHeader->FH_firstChar, &fontHeader->FH_lastChar ); - TT_New_Glyph( face, &glyph ); TT_New_Instance( face, &instance ); + TT_New_Glyph( face, &glyph ); for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) { @@ -812,7 +811,7 @@ static void convertHeader( break; /* load glyph without scaling or hinting */ - TT_Load_Glyph( instance, glyph, charIndex, TTLOAD_DEFAULT ); + TT_Load_Glyph( instance, glyph, charIndex, 0 ); TT_Get_Glyph_Metrics( glyph, &metrics ); //h_height diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 4e7c8513c..9c21eb0fb 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -151,10 +151,10 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, TransformMatrix* transMatrix ) { /* make unity matrix */ - transMatrix->TM_matrix.xx = 1 << 16; + transMatrix->TM_matrix.xx = 1L << 16; transMatrix->TM_matrix.xy = 0; transMatrix->TM_matrix.yx = 0; - transMatrix->TM_matrix.yy = 1 << 16; + transMatrix->TM_matrix.yy = 1L << 16; transMatrix->TM_shiftY = 0; /* fake bold style */ diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index 63b8df15f..8b9965aaf 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -173,7 +173,11 @@ initFontReturnAttr FileExtAttrDesc \ , +ifndef USE_OLD_FONT_LOADER +TrueTypeInitFonts proc far uses cx +else TrueTypeInitFonts proc far uses ax,bx,cx,dx,si,di,es,bp +endif .enter ifndef USE_OLD_FONT_LOADER From 38b12e0a8e86232a435deffa1780f4ae31b53d01 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 9 Apr 2023 20:19:19 +0200 Subject: [PATCH 151/246] Filling of CharTabelEntries corrected. --- Driver/Font/TrueType/Adapter/ttwidths.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index d2923b9df..d5cc94a59 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -234,6 +234,7 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord charTableEntry->CTE_dataOffset = CHAR_NOT_EXIST; charTableEntry->CTE_width.WBF_int = 0; charTableEntry->CTE_width.WBF_frac = 0; + charTableEntry->CTE_usage = 0; charTableEntry++; continue; @@ -247,9 +248,10 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord width = metrics.bbox.xMax - metrics.bbox.xMin; scaledWidth = SCALE_WORD( width, scaleFactor ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); - charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD(scaledWidth ); + charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; charTableEntry->CTE_flags = 0; + charTableEntry->CTE_usage = 0; // set flags in CTE_flags if needed if( metrics.bbox.xMin < 0 ) From ed126bcf5c1c1b1d6eeda452b8019b17ec511b44 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 13 Apr 2023 22:08:08 +0200 Subject: [PATCH 152/246] Some fixes for rendering glyphs. --- Driver/Font/TrueType/Adapter/ttchars.c | 4 ++-- Driver/Font/TrueType/Adapter/ttchars.h | 2 +- Driver/Font/TrueType/Main/truetypeChars.asm | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index c1c3c7020..ea2653c7f 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -62,8 +62,8 @@ static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ); void _pascal TrueType_Gen_Chars( word character, - WWFixedAsDWord pointSize, FontBuf* fontBuf, + WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, TextStyle stylesToImplement @@ -182,7 +182,7 @@ void _pascal TrueType_Gen_Chars( rasterMap.cols = (width + 7) / 8; rasterMap.size = rasterMap.rows * rasterMap.cols; rasterMap.flow = TT_Flow_Down; - rasterMap.bitmap = charData + SIZE_CHAR_HEADER; + rasterMap.bitmap = ((byte*)charData) + SIZE_CHAR_HEADER; /* translate outline and render it */ TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index ec1ce42fa..651b8fa50 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -36,8 +36,8 @@ extern word bitmapSize; ***********************************************************************/ void _pascal TrueType_Gen_Chars( word character, - WWFixedAsDWord pointSize, FontBuf* fontBuf, + WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, TextStyle stylesToImplement ); diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 22a8ca6ec..ad233b9a3 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -58,19 +58,20 @@ TrueTypeGenChar proc far jnc err push cx ; remember handle - push dx ; remember character to build push dx ; pass character code + push es ; pass font ptr + mov ax, 0 ; with segment offset 0 + push ax + + mov es, bp ; es <- seg addr of gstate + clr al movwbf dxah, es:GS_fontAttr.FCA_pointsize push dx ; pass point size push ax - push es ; pass font ptr - mov ax, 0 ; with segment offset 0 - push ax - mov cx, es:GS_fontAttr.FCA_fontID call FontDrFindFontInfo push ds ; pass ptr to FontInfo From de538ee15f3c9d067f26f1cba7cad1cfe407cf86 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 15 Apr 2023 22:21:13 +0200 Subject: [PATCH 153/246] Begin to refactor ttinit.c to reduce stack consumption. --- Driver/Font/TrueType/Adapter/ttinit.c | 226 +++++++++++++++++--------- 1 file changed, 150 insertions(+), 76 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 2e6c4d7d3..472adf2c3 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -29,7 +29,9 @@ #include -static TT_Error ProcessFont( const char* file, MemHandle fontInfoBlock ); +static word DetectFontFiles( MemHandle* fileEnumBlock ); + +static void ProcessFont( const char* file, MemHandle fontInfoBlock ); static sword getFontIDAvailIndex( FontID fontID, @@ -144,16 +146,12 @@ TT_Error _pascal Exit_FreeType() * ---- ---- ----------- * 7/15/22 JK Initial Revision *******************************************************************/ + void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) { - FileEnumParams ttfEnumParams; - word numOtherFiles; word numFiles; FileLongName* ptrFileName; MemHandle fileEnumBlock = NullHandle; - FileExtAttrDesc ttfExtAttrDesc[] = - { { FEA_NAME, 0, sizeof( FileLongName ), NULL }, - { FEA_END_OF_LIST, 0, 0, NULL } }; FilePushDir(); @@ -161,24 +159,14 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /* go to font/ttf directory */ FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - /* get all filenames contained in current directory */ - ttfEnumParams.FEP_searchFlags = FESF_NON_GEOS; - ttfEnumParams.FEP_returnAttrs = ttfExtAttrDesc; - ttfEnumParams.FEP_returnSize = sizeof( FileLongName ); - ttfEnumParams.FEP_matchAttrs = NullHandle; - ttfEnumParams.FEP_bufSize = FE_BUFSIZE_UNLIMITED; - ttfEnumParams.FEP_skipCount = 0; - ttfEnumParams.FEP_callback = NullHandle; - ttfEnumParams.FEP_callbackAttrs = NullHandle; - ttfEnumParams.FEP_headerSize = 0; - - numFiles = FileEnum( &ttfEnumParams, &fileEnumBlock, &numOtherFiles ); + /* detect all filenames in current directory */ + numFiles = DetectFontFiles( &fileEnumBlock ); ECCheckMemHandle( fileEnumBlock ); if( numFiles == 0 ) goto Fin; - /* iterate over all filenames and try to register a font.*/ + /* iterate over all filenames and try to register a font */ ptrFileName = MemLock( fileEnumBlock ); while( numFiles-- ) ProcessFont( ptrFileName++, fontInfoBlock ); @@ -190,6 +178,47 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) } +/******************************************************************** + * DetectFontFiles + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: fileEnumBlock + * + * RETURNS: word + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 14/4/23 JK Initial Revision + *******************************************************************/ + +static word DetectFontFiles( MemHandle* fileEnumBlock ) +{ + FileEnumParams ttfEnumParams; + word numOtherFiles; + FileExtAttrDesc ttfExtAttrDesc[] = { { FEA_NAME, 0, sizeof( FileLongName ), NULL }, + { FEA_END_OF_LIST, 0, 0, NULL } }; + + /* get all filenames contained in current directory */ + ttfEnumParams.FEP_searchFlags = FESF_NON_GEOS; + ttfEnumParams.FEP_returnAttrs = ttfExtAttrDesc; + ttfEnumParams.FEP_returnSize = sizeof( FileLongName ); + ttfEnumParams.FEP_matchAttrs = NullHandle; + ttfEnumParams.FEP_bufSize = FE_BUFSIZE_UNLIMITED; + ttfEnumParams.FEP_skipCount = 0; + ttfEnumParams.FEP_callback = NullHandle; + ttfEnumParams.FEP_callbackAttrs = NullHandle; + ttfEnumParams.FEP_headerSize = 0; + + return FileEnum( &ttfEnumParams, fileEnumBlock, &numOtherFiles ); +} + + /******************************************************************** * ProcessFont ******************************************************************** @@ -199,7 +228,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) * fontInfoBlock Handle to memory block with all * infos about aviable fonts. * - * RETURNS: TT_Error Error code (see fterror.h). + * RETURNS: void * * SIDE EFFECTS: none * @@ -211,17 +240,23 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) * 20/01/23 JK Initial Revision *******************************************************************/ -static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) +static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { - FileHandle truetypeFile; - TT_Face face; - TT_CharMap charMap; - TT_Face_Properties faceProperties; - TT_Error error = TT_Err_Ok; - char familyName[FID_NAME_LEN]; - char styleName[STYLE_NAME_LENGTH]; - FontID fontID; - sword availIndex; + FileHandle truetypeFile; + TT_Face face; + TT_CharMap charMap; + TT_Face_Properties faceProperties; + ChunkHandle trueTypeOutlineChunk; + ChunkHandle fontHeaderChunk; + ChunkHandle fontInfoChunk; + FontHeader* fontHeader; + FontInfo* fontInfo; + TrueTypeOutlineEntry* trueTypeOutlineEntry; + TT_Error error = TT_Err_Ok; + char familyName[FID_NAME_LEN]; + char styleName[STYLE_NAME_LENGTH]; + FontID fontID; + sword availIndex; ECCheckBounds( (void*)fileName ); @@ -256,14 +291,9 @@ static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* if we have an new font FontAvailEntry, FontInfo and Outline must be created */ if ( availIndex < 0 ) { - ChunkHandle fontInfoChunk; - FontsAvailEntry* newEntry; - FontInfo* fontInfo; - TrueTypeOutlineEntry* trueTypeOutlineEntry; - ChunkHandle trueTypeOutlineChunk; + FontsAvailEntry* newEntry; OutlineDataEntry* outlineDataEntry; - ChunkHandle fontHeaderChunk; - FontHeader* fontHeader; + /* allocate chunk for FontsAvailEntry and fill it */ if( LMemInsertAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ) ) @@ -332,7 +362,8 @@ static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* fill FontHeader */ fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); - convertHeader( face, faceProperties, charMap, fontHeader ); + convertHeader( face, faceProperties, charMap, fontHeader ); // Stackoverflow!!! + convert( face, faceProperties, charMap, fontHeader ); fontInfo->FI_outlineTab = sizeof( FontInfo ); fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); @@ -343,16 +374,11 @@ static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) } else { - ChunkHandle trueTypeOutlineChunk; - TrueTypeOutlineEntry* trueTypeOutlineEntry; - ChunkHandle fontHeaderChunk; - FontHeader* fontHeader; - FontInfo* fontInfo; FontsAvailEntry* availEntries = LMemDeref( ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader)) ); - ChunkHandle fontInfoChunk = availEntries[availIndex].FAE_infoHandle; OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); OutlineDataEntry* outlineDataEnd = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineEnd); + fontInfoChunk = availEntries[availIndex].FAE_infoHandle; while( outlineData < outlineDataEnd) { if( ( mapTextStyle( styleName ) == outlineData->ODE_style ) && @@ -403,7 +429,8 @@ static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* fill FontHeader */ fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); - convertHeader( face, faceProperties, charMap, fontHeader ); + //convertHeader( face, faceProperties, charMap, fontHeader ); + convert( face, faceProperties, charMap, fontHeader ); fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); @@ -413,7 +440,6 @@ static TT_Error ProcessFont( const char* fileName, MemHandle fontInfoBlock ) TT_Close_Face( face ); Fin: FileClose( truetypeFile, FALSE ); - return error; } @@ -779,11 +805,11 @@ static void convertHeader( { TT_UShort charIndex; TT_Glyph glyph; - TT_Glyph_Metrics metrics; TT_Instance instance; + TT_Outline outline; + TT_BBox bbox; word geosChar; sword maxAccentOrAscent; - word unitsPerEM = faceProperties.header->Units_Per_EM; ECCheckBounds( (void*)fontHeader ); @@ -794,6 +820,8 @@ static void convertHeader( fontHeader->FH_minTSB = -9999; fontHeader->FH_maxRSB = -9999; fontHeader->FH_avgwidth = 0; + fontHeader->FH_descent = 9999; + fontHeader->FH_accent = -9999; fontHeader->FH_numChars = InitGeosCharsInCharMap( charMap, &fontHeader->FH_firstChar, @@ -812,55 +840,65 @@ static void convertHeader( /* load glyph without scaling or hinting */ TT_Load_Glyph( instance, glyph, charIndex, 0 ); - TT_Get_Glyph_Metrics( glyph, &metrics ); + TT_Get_Glyph_Outline( glyph, &outline ); + TT_Get_Outline_BBox( &outline, &bbox ); //h_height if( unicode == C_LATIN_CAPITAL_LETTER_H ) - fontHeader->FH_h_height = metrics.bbox.yMax; + fontHeader->FH_h_height = bbox.yMax; //x_height if ( unicode == C_LATIN_SMALL_LETTER_X ) - fontHeader->FH_x_height = metrics.bbox.yMax; + fontHeader->FH_x_height = bbox.yMax; //ascender if ( unicode == C_LATIN_SMALL_LETTER_D ) - fontHeader->FH_ascender = metrics.bbox.yMax; + fontHeader->FH_ascender = bbox.yMax; //descender if ( unicode == C_LATIN_SMALL_LETTER_P ) - fontHeader->FH_descender = metrics.bbox.yMin; + fontHeader->FH_descender = bbox.yMin; //width - if ( fontHeader->FH_maxwidth < ( metrics.bbox.xMax - metrics.bbox.xMin ) ) - fontHeader->FH_maxwidth = metrics.bbox.xMax - metrics.bbox.xMin; + if ( fontHeader->FH_maxwidth < ( bbox.xMax - bbox.xMin ) ) + fontHeader->FH_maxwidth = bbox.xMax - bbox.xMin; //avg width if ( GeosAvgWidth( geosChar ) ) { fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( - ( metrics.bbox.xMax - metrics.bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); + ( bbox.xMax - bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); } /* scan xMin */ - if( fontHeader->FH_minLSB > metrics.bbox.xMin ) - fontHeader->FH_minLSB = (sword) metrics.bbox.xMin; + if( fontHeader->FH_minLSB > bbox.xMin ) + fontHeader->FH_minLSB = (sword) bbox.xMin; /* scan xMax */ - if ( fontHeader->FH_maxRSB < metrics.bbox.xMax ) - fontHeader->FH_maxRSB = metrics.bbox.xMax; - /* scan yMin */ - if ( fontHeader->FH_maxBSB < metrics.bbox.yMin ) - fontHeader->FH_maxBSB = metrics.bbox.yMin; + if ( fontHeader->FH_maxRSB < bbox.xMax ) + fontHeader->FH_maxRSB = bbox.xMax; - //yMax - if ( fontHeader->FH_minTSB < metrics.bbox.yMax ) + /* scan yMin */ + if ( fontHeader->FH_maxBSB < bbox.yMin ) + fontHeader->FH_maxBSB = bbox.yMin; + if ( GeosCharMapFlag( geosChar) & CMF_DESCENT && + fontHeader->FH_descent > bbox.yMin ) + fontHeader->FH_descent = bbox.yMin; + + /* scan yMax */ + if ( fontHeader->FH_minTSB < bbox.yMax ) { - fontHeader->FH_minTSB = metrics.bbox.yMax; - if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT && - fontHeader->FH_accent < metrics.bbox.yMax ) - fontHeader->FH_accent = metrics.bbox.yMax; + fontHeader->FH_minTSB = bbox.yMax; + + if ( GeosCharMapFlag( geosChar ) & ( CMF_ASCENT || CMF_CAP ) ) + fontHeader->FH_ascent = bbox.yMax; + + if ( GeosCharMapFlag( geosChar ) & CMF_ACCENT && + fontHeader->FH_accent < bbox.yMax ) + fontHeader->FH_accent = bbox.yMax; } + TT_Flush_Face( face ); } TT_Done_Glyph( glyph ); TT_Done_Instance( instance ); @@ -877,28 +915,64 @@ static void convertHeader( fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; } - fontHeader->FH_baseAdjust = BASELINE( unitsPerEM )- maxAccentOrAscent; + fontHeader->FH_baseAdjust = BASELINE( faceProperties.header->Units_Per_EM )- maxAccentOrAscent; fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; - fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( unitsPerEM ); - fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( unitsPerEM ) - - SAFETY( unitsPerEM ) ); + fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( faceProperties.header->Units_Per_EM ); + fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( faceProperties.header->Units_Per_EM ) - + SAFETY( faceProperties.header->Units_Per_EM ) ); fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; if( fontHeader->FH_underPos == 0 ) - fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( unitsPerEM ); + fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( faceProperties.header->Units_Per_EM ); fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; if( fontHeader->FH_underThick == 0 ) - fontHeader->FH_underThick = DEFAULT_UNDER_THICK( unitsPerEM ); + fontHeader->FH_underThick = DEFAULT_UNDER_THICK( faceProperties.header->Units_Per_EM ); if( fontHeader->FH_x_height > 0 ) fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; else fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; - fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( unitsPerEM ); + fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( faceProperties.header->Units_Per_EM ); +} + +/* temporarily for the test */ +void convert( TT_Face face, + TT_Face_Properties faceProperties, + TT_CharMap charMap, + FontHeader* fontHeader) +{ + + fontHeader->FH_numChars = InitGeosCharsInCharMap( charMap, + &fontHeader->FH_firstChar, + &fontHeader->FH_lastChar ); + + fontHeader->FH_h_height = 0x0233; + fontHeader->FH_x_height = 0x01b1; + + fontHeader->FH_ascender = 0x0276; + fontHeader->FH_descender = 0xff65; + fontHeader->FH_avgwidth = 0x0258; + fontHeader->FH_maxwidth = 0x0258; + + fontHeader->FH_height = 0x040e; + fontHeader->FH_accent = 0x0075; + fontHeader->FH_ascent = 0x0292; + fontHeader->FH_descent = 0x006a; + + fontHeader->FH_baseAdjust = 0xffe7; + fontHeader->FH_underPos = 0x0354; + fontHeader->FH_underThick = 0x004d; + fontHeader->FH_strikePos = 0x02035; + + fontHeader->FH_minLSB = 0xffea; + fontHeader->FH_maxRSB = 0x0274; + fontHeader->FH_maxBSB = 0x0026; + fontHeader->FH_minTSB = 0x0019; + fontHeader->FH_continuitySize = 0x0019; } From 0a508a9951d96f232800d4a09c993f50e00be831 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 22 Apr 2023 23:18:20 +0200 Subject: [PATCH 154/246] Refactoring ttinit.* --- Driver/Font/TrueType/Adapter/ttadapter.h | 70 ++++++ Driver/Font/TrueType/Adapter/ttinit.c | 280 ++++++++------------- Driver/Font/TrueType/Adapter/ttinit.h | 31 +-- Driver/Font/TrueType/Main/truetypeInit.asm | 1 + 4 files changed, 182 insertions(+), 200 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 6e37035b5..b004e4452 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -55,6 +55,9 @@ extern TEngine_Instance engineInstance; #define MAX_FONTBUF_SIZE 10 * 1024 +#define FAMILY_NAME_LENGTH 20 +#define STYLE_NAME_LENGTH 16 + /*********************************************************************** * structures @@ -296,6 +299,73 @@ typedef struct #define SIZE_REGION_HEADER ( sizeof( RegionCharData) - 2 ) +typedef struct +{ + word FH_h_height; //top of 'H' + word FH_x_height; //top of 'x' + word FH_ascender; //top of 'd' + word FH_descender; //bottom of 'p' + word FH_avgwidth; //average character width + word FH_maxwidth; //widest character width + word FH_height; //height of font box + word FH_accent; //height of accents + word FH_ascent; //height of caps + word FH_descent; //descent (from baseline) + word FH_baseAdjust; //adjustment for baseline + char FH_firstChar; //first char defined + char FH_lastChar; //last char defined + char FH_defaultChar; //default character + word FH_underPos; //position of underline + word FH_underThick; //thickness of underline + word FH_strikePos; //position of strikethrough + word FH_numChars; //number of characters + sword FH_minLSB; //minimum left side bearing + sword FH_minTSB; //minimum top side bound + sword FH_maxBSB; //maximum bottom side bound + sword FH_maxRSB; //maximum right side bound + sword FH_continuitySize; //continuity cutoff +} FontHeader; + + +typedef struct +{ + /* init fonts */ + char familyName[FID_NAME_LEN]; + char styleName[STYLE_NAME_LENGTH]; + + /* render glyphs */ + TT_Raster_Map rasterMap; + + /* general purpose */ + TT_Face face; + TT_Face_Properties faceProperties; + TT_Instance instance; + TT_Glyph glyph; + TT_Glyph_Metrics glyphMetrics; + TT_CharMap charMap; + TT_Outline outline; + TT_BBox bbox; +} TrueTypeVars; + + +#define TRUETYPE_VARS TrueTypeVars* trueTypeVars + +#define FAMILY_NAME trueTypeVars->familyName +#define STYLE_NAME trueTypeVars->styleName +#define FACE trueTypeVars->face +#define FACE_PROPERTIES trueTypeVars->faceProperties +#define INSTANCE trueTypeVars->instance +#define GLYPH trueTypeVars->glyph +#define CHAR_MAP trueTypeVars->charMap +#define OUTLINE trueTypeVars->outline +#define BBOX trueTypeVars->bbox +#define GLYPH_METRICS trueTypeVars->glyphMetrics +#define GLYPH_BBOX trueTypeVars->glyphMetrics.bbox + +#define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM + + + /*********************************************************************** * macros ***********************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 472adf2c3..2d9099d2f 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -14,7 +14,7 @@ * 20/12/22 JK Initial version * * DESCRIPTION: - * Definition of driver function DR_INIT. + * Implementations for functions DR_INIT and DR_FONT_INIT_FONTS. ***********************************************************************/ #include "ttinit.h" @@ -29,13 +29,15 @@ #include -static word DetectFontFiles( MemHandle* fileEnumBlock ); +static word DetectFontFiles( MemHandle* fileEnumBlock ); -static void ProcessFont( const char* file, MemHandle fontInfoBlock ); +static void ProcessFont( TRUETYPE_VARS, + const char* file, + MemHandle fontInfoBlock ); static sword getFontIDAvailIndex( - FontID fontID, - MemHandle fontInfoBlock ); + FontID fontID, + MemHandle fontInfoBlock ); static FontID getFontID( const char* familiyName ); @@ -46,15 +48,11 @@ static FontWeight mapFontWeight( TT_Short weightClass ); static TextStyle mapTextStyle( const char* subfamily ); static word getNameFromNameTable( - char* name, - TT_Face face, - TT_UShort nameIndex ); + TRUETYPE_VARS, + char* name, + TT_UShort nameIndex ); -static void convertHeader( - TT_Face face, - TT_Face_Properties faceProperties, - TT_CharMap charMap, - FontHeader* fontHeader ); +static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ); static word toHash( const char* str ); @@ -134,6 +132,7 @@ TT_Error _pascal Exit_FreeType() * adapter function for DR_FONT_INIT_FONTS. * * PARAMETERS: fontInfoBlock MemHandle to fontInfo. + * varBlock MemHandle to truetypeVarBlock. * * RETURNS: void * @@ -147,16 +146,28 @@ TT_Error _pascal Exit_FreeType() * 7/15/22 JK Initial Revision *******************************************************************/ -void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) +void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ) { - word numFiles; - FileLongName* ptrFileName; - MemHandle fileEnumBlock = NullHandle; + word numFiles; + FileLongName* ptrFileName; + MemHandle fileEnumBlock; + TrueTypeVars* trueTypeVars; - FilePushDir(); + ECCheckMemHandle( fontInfoBlock ); + ECCheckMemHandle( varBlock ); + + + /* get trueTypeVar block */ + trueTypeVars = MemLock( varBlock ); + if( trueTypeVars == NULL ) + { + MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); + trueTypeVars = MemLock( varBlock ); + } /* go to font/ttf directory */ + FilePushDir(); FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); /* detect all filenames in current directory */ @@ -169,11 +180,12 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /* iterate over all filenames and try to register a font */ ptrFileName = MemLock( fileEnumBlock ); while( numFiles-- ) - ProcessFont( ptrFileName++, fontInfoBlock ); + ProcessFont( trueTypeVars, ptrFileName++, fontInfoBlock ); MemFree( fileEnumBlock ); Fin: + MemUnlock( varBlock ); FilePopDir(); } @@ -181,9 +193,10 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ) /******************************************************************** * DetectFontFiles ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Lists all file names in the current directory. * - * PARAMETERS: fileEnumBlock + * PARAMETERS: fileEnumBlock Handle to the memory block in + * which the file names are stored. * * RETURNS: word * @@ -240,52 +253,42 @@ static word DetectFontFiles( MemHandle* fileEnumBlock ) * 20/01/23 JK Initial Revision *******************************************************************/ -static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) +static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfoBlock ) { FileHandle truetypeFile; - TT_Face face; - TT_CharMap charMap; - TT_Face_Properties faceProperties; ChunkHandle trueTypeOutlineChunk; ChunkHandle fontHeaderChunk; ChunkHandle fontInfoChunk; FontHeader* fontHeader; FontInfo* fontInfo; TrueTypeOutlineEntry* trueTypeOutlineEntry; - TT_Error error = TT_Err_Ok; - char familyName[FID_NAME_LEN]; - char styleName[STYLE_NAME_LENGTH]; FontID fontID; sword availIndex; ECCheckBounds( (void*)fileName ); - ECCheckMemHandle( fontInfoBlock ); - - + ECCheckBounds( (void*)trueTypeVars ); + truetypeFile = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( truetypeFile ); - error = TT_Open_Face( truetypeFile, &face ); - if( error ) + if ( TT_Open_Face( truetypeFile, &FACE ) ) goto Fin; - error = TT_Get_Face_Properties( face, &faceProperties ); - if( error ) + if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) goto Fail; - error = getCharMap( face, &charMap ); - if ( error != TT_Err_Ok ) + if ( getCharMap( FACE, &CHAR_MAP ) ) goto Fail; - if ( getNameFromNameTable( familyName, face, FAMILY_NAME_ID ) == 0 ) + if ( getNameFromNameTable( trueTypeVars, FAMILY_NAME, FAMILY_NAME_ID ) == 0 ) goto Fail; - if ( getNameFromNameTable( styleName, face, STYLE_NAME_ID ) == 0 ) + if ( getNameFromNameTable( trueTypeVars, STYLE_NAME, STYLE_NAME_ID ) == 0 ) goto Fail; - fontID = getFontID( familyName ); + fontID = getFontID( FAMILY_NAME ); availIndex = getFontIDAvailIndex( fontID, fontInfoBlock ); /* if we have an new font FontAvailEntry, FontInfo and Outline must be created */ @@ -297,10 +300,8 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* allocate chunk for FontsAvailEntry and fill it */ if( LMemInsertAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ) ) - { - error = TT_Err_Out_Of_Memory; goto Fail; - } + newEntry = LMemDeref( ConstructOptr( fontInfoBlock, sizeof( LMemBlockHeader ) ) ); newEntry->FAE_fontID = fontID; newEntry->FAE_infoHandle = NullChunk; @@ -312,16 +313,15 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) { /* revert previous allocation of FontsAvailEntry */ LMemDeleteAtHandles( fontInfoBlock, sizeof(LMemBlockHeader), 0, sizeof(FontsAvailEntry) ); - error = TT_Err_Out_Of_Memory; goto Fail; } /* get pointer to FontInfo and fill it */ fontInfo = LMemDerefHandles( fontInfoBlock, fontInfoChunk ); - strcpy( fontInfo->FI_faceName, familyName ); + strcpy( fontInfo->FI_faceName, FAMILY_NAME ); fontInfo->FI_fileHandle = NullHandle; fontInfo->FI_fontID = fontID; - fontInfo->FI_family = mapFamilyClass( faceProperties.os2->sFamilyClass ); + fontInfo->FI_family = mapFamilyClass( FACE_PROPERTIES.os2->sFamilyClass ); fontInfo->FI_maker = FM_TRUETYPE; fontInfo->FI_pointSizeTab = 0; fontInfo->FI_pointSizeEnd = 0; @@ -355,15 +355,14 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* fill OutlineDataEntry */ outlineDataEntry = (OutlineDataEntry*) (fontInfo + 1); - outlineDataEntry->ODE_style = mapTextStyle( styleName ); - outlineDataEntry->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); + outlineDataEntry->ODE_style = mapTextStyle( STYLE_NAME ); + outlineDataEntry->ODE_weight = mapFontWeight( FACE_PROPERTIES.os2->usWeightClass ); outlineDataEntry->ODE_header.OE_handle = trueTypeOutlineChunk; outlineDataEntry->ODE_first.OE_handle = fontHeaderChunk; /* fill FontHeader */ fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); - convertHeader( face, faceProperties, charMap, fontHeader ); // Stackoverflow!!! - convert( face, faceProperties, charMap, fontHeader ); + ConvertHeader( trueTypeVars, fontHeader ); fontInfo->FI_outlineTab = sizeof( FontInfo ); fontInfo->FI_outlineEnd = sizeof( FontInfo ) + sizeof( OutlineDataEntry ); @@ -381,8 +380,8 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) fontInfoChunk = availEntries[availIndex].FAE_infoHandle; while( outlineData < outlineDataEnd) { - if( ( mapTextStyle( styleName ) == outlineData->ODE_style ) && - ( mapFontWeight( faceProperties.os2->usWeightClass ) == outlineData->ODE_weight ) ) + if( ( mapTextStyle( STYLE_NAME ) == outlineData->ODE_style ) && + ( mapFontWeight( FACE_PROPERTIES.os2->usWeightClass ) == outlineData->ODE_weight ) ) { goto Fail; } @@ -393,7 +392,6 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) trueTypeOutlineChunk = LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); if( trueTypeOutlineChunk == NullChunk ) { - error = TT_Err_Out_Of_Memory; goto Fail; } @@ -402,7 +400,6 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if( LMemInsertAtHandles( fontInfoBlock, fontInfoChunk, fontInfo->FI_outlineTab, sizeof( OutlineDataEntry ) ) ) { LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); - error = TT_Err_Out_Of_Memory; goto Fail; } @@ -411,7 +408,6 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) if( fontHeaderChunk == NullChunk ) { LMemFreeHandles( fontInfoBlock, trueTypeOutlineChunk ); - error = TT_Err_Out_Of_Memory; goto Fail; } @@ -422,22 +418,21 @@ static void ProcessFont( const char* fileName, MemHandle fontInfoBlock ) /* fill OutlineDataEntry */ fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); outlineData = (OutlineDataEntry*) (fontInfo + 1); - outlineData->ODE_style = mapTextStyle( styleName ); - outlineData->ODE_weight = mapFontWeight( faceProperties.os2->usWeightClass ); + outlineData->ODE_style = mapTextStyle( STYLE_NAME ); + outlineData->ODE_weight = mapFontWeight( FACE_PROPERTIES.os2->usWeightClass ); outlineData->ODE_header.OE_handle = trueTypeOutlineChunk; outlineData->ODE_first.OE_handle = fontHeaderChunk; /* fill FontHeader */ fontHeader = LMemDerefHandles( fontInfoBlock, fontHeaderChunk ); - //convertHeader( face, faceProperties, charMap, fontHeader ); - convert( face, faceProperties, charMap, fontHeader ); - + ConvertHeader( trueTypeVars, fontHeader ); + fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); } Fail: - TT_Close_Face( face ); + TT_Close_Face( FACE ); Fin: FileClose( truetypeFile, FALSE ); } @@ -698,11 +693,11 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) * SYNOPSIS: Searches the font's name tables for the given NameID * and returns its content. * - * PARAMETERS: name* Pointer to result string. - * face TrueType face to be searched. - * nameID ID to be searched. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * name* Pointer to result string. + * nameID ID to be searched. * - * RETURNS: word Length of the table entry found. + * RETURNS: word Length of the table entry found. * * SIDE EFFECTS: none * @@ -714,9 +709,8 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) * 21/01/23 JK Initial Revision *******************************************************************/ -static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) +static word getNameFromNameTable( TRUETYPE_VARS, char* name, TT_UShort nameID ) { - TT_Face_Properties faceProperties; TT_UShort platformID; TT_UShort encodingID; TT_UShort languageID; @@ -726,11 +720,9 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) char* str; - TT_Get_Face_Properties( face, &faceProperties ); - - for( n = 0; n < faceProperties.num_Names; n++ ) + for( n = 0; n < FACE_PROPERTIES.num_Names; n++ ) { - TT_Get_Name_ID( face, n, &platformID, &encodingID, &languageID, &id ); + TT_Get_Name_ID( FACE, n, &platformID, &encodingID, &languageID, &id ); if( id != nameID ) continue; @@ -738,7 +730,7 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) encodingID == ENCODING_ID_MS_UNICODE_BMP && languageID == LANGUAGE_ID_WIN_EN_US ) { - TT_Get_Name_String( face, n, &str, &nameLength ); + TT_Get_Name_String( FACE, n, &str, &nameLength ); for (i = 1; str != 0 && i < nameLength; i += 2) *name++ = str[i]; @@ -749,7 +741,7 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) encodingID == ENCODING_ID_MAC_ROMAN && languageID == LANGUAGE_ID_MAC_EN ) { - TT_Get_Name_String( face, n, &str, &nameLength ); + TT_Get_Name_String( FACE, n, &str, &nameLength ); for (i = 0; str != 0 && i < nameLength; i++) *name++ = str[i]; @@ -758,7 +750,7 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) } else if( encodingID == ENCODING_ID_UNICODE ) { - TT_Get_Name_String( face, n, &str, &nameLength ); + TT_Get_Name_String( FACE, n, &str, &nameLength ); for (i = 1; str != 0 && i < nameLength; i += 2) *name++ = str[i]; @@ -772,16 +764,12 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) /******************************************************************** - * convertHeader + * ConvertHeader ******************************************************************** * SYNOPSIS: Converts information from a TrueType font into a * FreeGEOS FontHeader. * - * PARAMETERS: face Face from which the information - * is to be converted. - * faceProperties FaceProperties to be used. - * charMap CharMap to be used. - * instance Instance to be used. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. * fontHeader* Pointer to FontInfo in which the * converted information is to be stored. * @@ -797,17 +785,9 @@ static word getNameFromNameTable( char* name, TT_Face face, TT_UShort nameID ) * 21/01/23 JK Initial Revision *******************************************************************/ -static void convertHeader( - TT_Face face, - TT_Face_Properties faceProperties, - TT_CharMap charMap, - FontHeader* fontHeader ) +static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) { TT_UShort charIndex; - TT_Glyph glyph; - TT_Instance instance; - TT_Outline outline; - TT_BBox bbox; word geosChar; sword maxAccentOrAscent; @@ -820,88 +800,83 @@ static void convertHeader( fontHeader->FH_minTSB = -9999; fontHeader->FH_maxRSB = -9999; fontHeader->FH_avgwidth = 0; + fontHeader->FH_maxwidth = 0; fontHeader->FH_descent = 9999; fontHeader->FH_accent = -9999; - fontHeader->FH_numChars = InitGeosCharsInCharMap( charMap, + fontHeader->FH_numChars = InitGeosCharsInCharMap( CHAR_MAP, &fontHeader->FH_firstChar, &fontHeader->FH_lastChar ); - TT_New_Instance( face, &instance ); - TT_New_Glyph( face, &glyph ); + TT_New_Instance( FACE, &INSTANCE ); + TT_New_Glyph( FACE, &GLYPH ); for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) { word unicode = GeosCharToUnicode( geosChar ); - charIndex = TT_Char_Index( charMap, unicode ); + charIndex = TT_Char_Index( CHAR_MAP, unicode ); if ( charIndex == 0 ) break; /* load glyph without scaling or hinting */ - TT_Load_Glyph( instance, glyph, charIndex, 0 ); - TT_Get_Glyph_Outline( glyph, &outline ); - TT_Get_Outline_BBox( &outline, &bbox ); + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); + TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); //h_height if( unicode == C_LATIN_CAPITAL_LETTER_H ) - fontHeader->FH_h_height = bbox.yMax; + fontHeader->FH_h_height = GLYPH_BBOX.yMax; //x_height if ( unicode == C_LATIN_SMALL_LETTER_X ) - fontHeader->FH_x_height = bbox.yMax; + fontHeader->FH_x_height = GLYPH_BBOX.yMax; //ascender if ( unicode == C_LATIN_SMALL_LETTER_D ) - fontHeader->FH_ascender = bbox.yMax; + fontHeader->FH_ascender = GLYPH_BBOX.yMax; //descender if ( unicode == C_LATIN_SMALL_LETTER_P ) - fontHeader->FH_descender = bbox.yMin; + fontHeader->FH_descender = GLYPH_BBOX.yMin; //width - if ( fontHeader->FH_maxwidth < ( bbox.xMax - bbox.xMin ) ) - fontHeader->FH_maxwidth = bbox.xMax - bbox.xMin; - - //avg width - if ( GeosAvgWidth( geosChar ) ) - { - fontHeader->FH_avgwidth = fontHeader->FH_avgwidth + ( - ( bbox.xMax - bbox.xMin ) * GeosAvgWidth( geosChar ) / 1000 ); - } + if ( fontHeader->FH_maxwidth < GLYPH_METRICS.advance ) + fontHeader->FH_maxwidth = GLYPH_METRICS.advance; /* scan xMin */ - if( fontHeader->FH_minLSB > bbox.xMin ) - fontHeader->FH_minLSB = (sword) bbox.xMin; + if( fontHeader->FH_minLSB > GLYPH_BBOX.xMin ) + fontHeader->FH_minLSB = (sword) GLYPH_BBOX.xMin; /* scan xMax */ - if ( fontHeader->FH_maxRSB < bbox.xMax ) - fontHeader->FH_maxRSB = bbox.xMax; + if ( fontHeader->FH_maxRSB < GLYPH_BBOX.xMax ) + fontHeader->FH_maxRSB = GLYPH_BBOX.xMax; /* scan yMin */ - if ( fontHeader->FH_maxBSB < bbox.yMin ) - fontHeader->FH_maxBSB = bbox.yMin; + if ( fontHeader->FH_maxBSB < -GLYPH_BBOX.yMin ) + fontHeader->FH_maxBSB = -GLYPH_BBOX.yMin; + if ( GeosCharMapFlag( geosChar) & CMF_DESCENT && - fontHeader->FH_descent > bbox.yMin ) - fontHeader->FH_descent = bbox.yMin; + fontHeader->FH_descent > GLYPH_BBOX.yMin ) + fontHeader->FH_descent = GLYPH_BBOX.yMin; /* scan yMax */ - if ( fontHeader->FH_minTSB < bbox.yMax ) + if ( fontHeader->FH_minTSB < GLYPH_BBOX.yMax ) { - fontHeader->FH_minTSB = bbox.yMax; + fontHeader->FH_minTSB = GLYPH_BBOX.yMax; if ( GeosCharMapFlag( geosChar ) & ( CMF_ASCENT || CMF_CAP ) ) - fontHeader->FH_ascent = bbox.yMax; + fontHeader->FH_ascent = GLYPH_BBOX.yMax; if ( GeosCharMapFlag( geosChar ) & CMF_ACCENT && - fontHeader->FH_accent < bbox.yMax ) - fontHeader->FH_accent = bbox.yMax; + fontHeader->FH_accent < GLYPH_BBOX.yMax ) + fontHeader->FH_accent = GLYPH_BBOX.yMax; } - - TT_Flush_Face( face ); } - TT_Done_Glyph( glyph ); - TT_Done_Instance( instance ); + TT_Done_Glyph( GLYPH ); + TT_Done_Instance( INSTANCE ); + + //avg width + fontHeader->FH_avgwidth = FACE_PROPERTIES.os2->xAvgCharWidth; //baseline if ( fontHeader->FH_accent <= 0 ) @@ -915,64 +890,27 @@ static void convertHeader( fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; } - fontHeader->FH_baseAdjust = BASELINE( faceProperties.header->Units_Per_EM )- maxAccentOrAscent; + fontHeader->FH_baseAdjust = BASELINE( UNITS_PER_EM )- maxAccentOrAscent; fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; - fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( faceProperties.header->Units_Per_EM ); - fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( faceProperties.header->Units_Per_EM ) - - SAFETY( faceProperties.header->Units_Per_EM ) ); + fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( UNITS_PER_EM ); + fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( UNITS_PER_EM ) - SAFETY( UNITS_PER_EM ) ); - fontHeader->FH_underPos = faceProperties.postscript->underlinePosition; + fontHeader->FH_underPos = FACE_PROPERTIES.postscript->underlinePosition; if( fontHeader->FH_underPos == 0 ) - fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( faceProperties.header->Units_Per_EM ); + fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( UNITS_PER_EM ); fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; - fontHeader->FH_underThick = faceProperties.postscript->underlineThickness; + fontHeader->FH_underThick = FACE_PROPERTIES.postscript->underlineThickness; if( fontHeader->FH_underThick == 0 ) - fontHeader->FH_underThick = DEFAULT_UNDER_THICK( faceProperties.header->Units_Per_EM ); + fontHeader->FH_underThick = DEFAULT_UNDER_THICK( UNITS_PER_EM ); if( fontHeader->FH_x_height > 0 ) fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; else fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; - fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( faceProperties.header->Units_Per_EM ); -} - -/* temporarily for the test */ -void convert( TT_Face face, - TT_Face_Properties faceProperties, - TT_CharMap charMap, - FontHeader* fontHeader) -{ - - fontHeader->FH_numChars = InitGeosCharsInCharMap( charMap, - &fontHeader->FH_firstChar, - &fontHeader->FH_lastChar ); - - fontHeader->FH_h_height = 0x0233; - fontHeader->FH_x_height = 0x01b1; - - fontHeader->FH_ascender = 0x0276; - fontHeader->FH_descender = 0xff65; - fontHeader->FH_avgwidth = 0x0258; - fontHeader->FH_maxwidth = 0x0258; - - fontHeader->FH_height = 0x040e; - fontHeader->FH_accent = 0x0075; - fontHeader->FH_ascent = 0x0292; - fontHeader->FH_descent = 0x006a; - - fontHeader->FH_baseAdjust = 0xffe7; - fontHeader->FH_underPos = 0x0354; - fontHeader->FH_underThick = 0x004d; - fontHeader->FH_strikePos = 0x02035; - - fontHeader->FH_minLSB = 0xffea; - fontHeader->FH_maxRSB = 0x0274; - fontHeader->FH_maxBSB = 0x0026; - fontHeader->FH_minTSB = 0x0019; - fontHeader->FH_continuitySize = 0x0019; + fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( UNITS_PER_EM ); } diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index a4aef447d..ebb2f97df 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -57,8 +57,6 @@ * constants for string length ***********************************************************************/ -#define FAMILY_NAME_LENGTH 20 -#define STYLE_NAME_LENGTH 16 #define FONT_FILE_LENGTH FILE_LONGNAME_BUFFER_SIZE @@ -86,39 +84,14 @@ * structues ***********************************************************************/ -typedef struct -{ - word FH_h_height; //top of 'H' - word FH_x_height; //top of 'x' - word FH_ascender; //top of 'd' - word FH_descender; //bottom of 'p' - word FH_avgwidth; //average character width - word FH_maxwidth; //widest character width - word FH_height; //height of font box - word FH_accent; //height of accents - word FH_ascent; //height of caps - word FH_descent; //descent (from baseline) - word FH_baseAdjust; //adjustment for baseline - char FH_firstChar; //first char defined - char FH_lastChar; //last char defined - char FH_defaultChar; //default character - word FH_underPos; //position of underline - word FH_underThick; //thickness of underline - word FH_strikePos; //position of strikethrough - word FH_numChars; //number of characters - sword FH_minLSB; //minimum left side bearing - sword FH_minTSB; //minimum top side bound - sword FH_maxBSB; //maximum bottom side bound - sword FH_maxRSB; //maximum right side bound - sword FH_continuitySize; //continuity cutoff -} FontHeader; + /*********************************************************************** * functions called by driver ***********************************************************************/ -void _pascal TrueType_InitFonts( MemHandle fontInfoBlock ); +void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ); #endif /* _TTINT_H_ */ diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index 8b9965aaf..c6c87e78b 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -188,6 +188,7 @@ ifndef USE_OLD_FONT_LOADER push cx ; handle to font info block segmov ds, dgroup, cx + push ds:variableHandle call TRUETYPE_INITFONTS pop ds From 54e936f7f43cb0387a1629f90d1d21122ec74c6c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 28 Apr 2023 21:54:22 +0200 Subject: [PATCH 155/246] Fix filling FontHeader --- Driver/Font/TrueType/Adapter/ttadapter.h | 1 - Driver/Font/TrueType/Adapter/ttcharmapper.h | 2 + Driver/Font/TrueType/Adapter/ttchars.c | 16 ++- Driver/Font/TrueType/Adapter/ttinit.c | 114 ++++++++++++-------- Driver/Font/TrueType/Adapter/ttinit.h | 4 +- 5 files changed, 79 insertions(+), 58 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index b004e4452..8ec8dffb3 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -358,7 +358,6 @@ typedef struct #define GLYPH trueTypeVars->glyph #define CHAR_MAP trueTypeVars->charMap #define OUTLINE trueTypeVars->outline -#define BBOX trueTypeVars->bbox #define GLYPH_METRICS trueTypeVars->glyphMetrics #define GLYPH_BBOX trueTypeVars->glyphMetrics.bbox diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 779719380..6a8282eda 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -53,5 +53,7 @@ word CountKernPairsWithGeosChars( TT_Face face ); TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); +CharMapFlags GeosCharMapFlag( word geosChar ); + #endif /* _TTCHARMAPPER_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index ea2653c7f..775636755 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -79,6 +79,7 @@ void _pascal TrueType_Gen_Chars( TT_BBox bbox; TT_CharMap charMap; TT_UShort charIndex; + TT_Raster_Map rasterMap; void* charData; word width, height, size; @@ -133,8 +134,6 @@ void _pascal TrueType_Gen_Chars( if( fontBuf->FB_flags & FBF_IS_REGION ) { - TT_Raster_Map rasterMap; - /* We calculate with an average of 4 on/off points, line number and line end code. */ size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; @@ -165,10 +164,7 @@ void _pascal TrueType_Gen_Chars( size = rasterMap.size; } else - { - CharData* charData; - TT_Raster_Map rasterMap; - + { size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; /* get pointer to bitmapBlock */ @@ -189,10 +185,10 @@ void _pascal TrueType_Gen_Chars( TT_Get_Outline_Bitmap( &outline, &rasterMap ); /* fill header of charData */ - charData->CD_pictureWidth = width; - charData->CD_numRows = height; - charData->CD_xoff = bbox.xMin; - charData->CD_yoff = bbox.yMin; + ((CharData*)charData)->CD_pictureWidth = width; + ((CharData*)charData)->CD_numRows = height; + ((CharData*)charData)->CD_xoff = bbox.xMin; + ((CharData*)charData)->CD_yoff = bbox.yMin; } TT_Done_Glyph( glyph ); diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 2d9099d2f..b25ec8b29 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -54,6 +54,8 @@ static word getNameFromNameTable( static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ); +static char GetDefaultChar( TRUETYPE_VARS, char firstChar ); + static word toHash( const char* str ); static int strlen( const char* str ); @@ -462,7 +464,7 @@ static word toHash( const char* str ) word i; dword hash = strlen( str ); - for ( i = 0; i < strlen( str ) ; ++i ) + for ( i = 0; i < strlen( str ); ++i ) hash = ( ( hash * 7 ) % 65535 ) + str[i]; return (word) hash; @@ -676,7 +678,7 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) /* set fontsAvailEntrys to first Element after LMemBlockHeader */ fontsAvailEntrys = ( (byte*)LMemDeref( - ConstructOptr(fontInfoBlock, sizeof(LMemBlockHeader))) ); + ConstructOptr( fontInfoBlock, sizeof(LMemBlockHeader))) ); elements = LMemGetChunkSizePtr( fontsAvailEntrys ) / sizeof( FontsAvailEntry ); for( element = 0; element < elements; element++ ) @@ -789,7 +791,6 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) { TT_UShort charIndex; word geosChar; - sword maxAccentOrAscent; ECCheckBounds( (void*)fontHeader ); @@ -802,104 +803,96 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) fontHeader->FH_avgwidth = 0; fontHeader->FH_maxwidth = 0; fontHeader->FH_descent = 9999; - fontHeader->FH_accent = -9999; + fontHeader->FH_accent = 0; + fontHeader->FH_ascent = 0; fontHeader->FH_numChars = InitGeosCharsInCharMap( CHAR_MAP, &fontHeader->FH_firstChar, &fontHeader->FH_lastChar ); + fontHeader->FH_defaultChar = GetDefaultChar( trueTypeVars, fontHeader->FH_firstChar ); TT_New_Instance( FACE, &INSTANCE ); TT_New_Glyph( FACE, &GLYPH ); - for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; ++geosChar ) + for ( geosChar = fontHeader->FH_firstChar; geosChar < fontHeader->FH_lastChar; geosChar++ ) { word unicode = GeosCharToUnicode( geosChar ); + charIndex = TT_Char_Index( CHAR_MAP, unicode ); if ( charIndex == 0 ) - break; + continue; /* load glyph without scaling or hinting */ TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); - //h_height + //h_height -> check if( unicode == C_LATIN_CAPITAL_LETTER_H ) fontHeader->FH_h_height = GLYPH_BBOX.yMax; - //x_height + //x_height -> check if ( unicode == C_LATIN_SMALL_LETTER_X ) fontHeader->FH_x_height = GLYPH_BBOX.yMax; - - //ascender + + //ascender -> check if ( unicode == C_LATIN_SMALL_LETTER_D ) fontHeader->FH_ascender = GLYPH_BBOX.yMax; - //descender + //descender -> check if ( unicode == C_LATIN_SMALL_LETTER_P ) fontHeader->FH_descender = GLYPH_BBOX.yMin; - //width + //width -> check if ( fontHeader->FH_maxwidth < GLYPH_METRICS.advance ) fontHeader->FH_maxwidth = GLYPH_METRICS.advance; - /* scan xMin */ + /* scan xMin -> check */ if( fontHeader->FH_minLSB > GLYPH_BBOX.xMin ) - fontHeader->FH_minLSB = (sword) GLYPH_BBOX.xMin; + fontHeader->FH_minLSB = GLYPH_BBOX.xMin; - /* scan xMax */ + /* scan xMax -> check */ if ( fontHeader->FH_maxRSB < GLYPH_BBOX.xMax ) fontHeader->FH_maxRSB = GLYPH_BBOX.xMax; - /* scan yMin */ + /* scan yMin -> check */ if ( fontHeader->FH_maxBSB < -GLYPH_BBOX.yMin ) fontHeader->FH_maxBSB = -GLYPH_BBOX.yMin; + /* check */ if ( GeosCharMapFlag( geosChar) & CMF_DESCENT && - fontHeader->FH_descent > GLYPH_BBOX.yMin ) - fontHeader->FH_descent = GLYPH_BBOX.yMin; + fontHeader->FH_descent > -GLYPH_BBOX.yMin ) + fontHeader->FH_descent = -GLYPH_BBOX.yMin; - /* scan yMax */ + /* scan yMax -> check */ if ( fontHeader->FH_minTSB < GLYPH_BBOX.yMax ) - { fontHeader->FH_minTSB = GLYPH_BBOX.yMax; - if ( GeosCharMapFlag( geosChar ) & ( CMF_ASCENT || CMF_CAP ) ) - fontHeader->FH_ascent = GLYPH_BBOX.yMax; + /* check */ + if ( GeosCharMapFlag( geosChar ) & ( CMF_ASCENT | CMF_CAP ) ) + if ( fontHeader->FH_ascent < GLYPH_BBOX.yMax ) + fontHeader->FH_ascent = GLYPH_BBOX.yMax; - if ( GeosCharMapFlag( geosChar ) & CMF_ACCENT && - fontHeader->FH_accent < GLYPH_BBOX.yMax ) - fontHeader->FH_accent = GLYPH_BBOX.yMax; - } + /* check */ + if ( GeosCharMapFlag( geosChar ) == CMF_ACCENT ) + if ( fontHeader->FH_accent < GLYPH_BBOX.yMax ) + fontHeader->FH_accent = GLYPH_BBOX.yMax; } + TT_Done_Glyph( GLYPH ); TT_Done_Instance( INSTANCE ); - //avg width fontHeader->FH_avgwidth = FACE_PROPERTIES.os2->xAvgCharWidth; - - //baseline - if ( fontHeader->FH_accent <= 0 ) - { - fontHeader->FH_accent = 0; - maxAccentOrAscent = fontHeader->FH_ascent; - } - else - { - maxAccentOrAscent = fontHeader->FH_accent; - fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; - } - - fontHeader->FH_baseAdjust = BASELINE( UNITS_PER_EM )- maxAccentOrAscent; - fontHeader->FH_height = fontHeader->FH_maxBSB + maxAccentOrAscent; + fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; + fontHeader->FH_baseAdjust = BASELINE( UNITS_PER_EM ) - fontHeader->FH_ascent - fontHeader->FH_accent; + fontHeader->FH_height = fontHeader->FH_maxBSB + fontHeader->FH_ascent + DESCENT( UNITS_PER_EM ) - SAFETY( UNITS_PER_EM ); fontHeader->FH_minTSB = fontHeader->FH_minTSB - BASELINE( UNITS_PER_EM ); fontHeader->FH_maxBSB = fontHeader->FH_maxBSB - ( DESCENT( UNITS_PER_EM ) - SAFETY( UNITS_PER_EM ) ); - fontHeader->FH_underPos = FACE_PROPERTIES.postscript->underlinePosition; + fontHeader->FH_underPos = -FACE_PROPERTIES.postscript->underlinePosition; if( fontHeader->FH_underPos == 0 ) fontHeader->FH_underPos = DEFAULT_UNDER_POSITION( UNITS_PER_EM ); - - fontHeader->FH_underPos = maxAccentOrAscent - fontHeader->FH_underPos; + fontHeader->FH_underPos = fontHeader->FH_underPos + fontHeader->FH_accent + fontHeader->FH_ascent; fontHeader->FH_underThick = FACE_PROPERTIES.postscript->underlineThickness; if( fontHeader->FH_underThick == 0 ) @@ -914,6 +907,37 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) } +/******************************************************************** + * GetDefaultChar + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: char + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 23/04/23 JK Initial Revision + *******************************************************************/ +static char GetDefaultChar( TRUETYPE_VARS, char firstChar ) +{ + word unicode = GeosCharToUnicode( DEFAULT_DEFAULT_CHAR ); + word charIndex = TT_Char_Index( CHAR_MAP, unicode ); + + + if ( charIndex == 0 ) + return firstChar; + + return DEFAULT_DEFAULT_CHAR; +} + + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ /* cycle. Therefore, the required functions are reimplemented here.*/ diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index ebb2f97df..2d5df6a75 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -69,8 +69,8 @@ #define BASELINE( value ) ( 3 * value / 4 ) // 75% of size #define DESCENT( value ) ( value / 4 ) // 25% of size #define DEFAULT_UNDER_THICK( value ) ( value / 10 ) // 10% of size -#define DEFAULT_UNDER_POSITION( value ) ( value / -10 ) // -10% of size -#define SAFETY( value ) ( value / 40 ) // 2.5% of size +#define DEFAULT_UNDER_POSITION( value ) ( value / 10 ) // -10% of size +#define SAFETY( value ) ( value / 40 ) // 2.5% of size /*********************************************************************** From eb6a4d37d6bb4db4cef61280e49ea22907136820 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 1 May 2023 21:00:11 +0200 Subject: [PATCH 156/246] Use some hacks to render our first character. --- Driver/Font/TrueType/Adapter/ttchars.c | 7 +- Driver/Font/TrueType/Adapter/ttchars.h | 4 +- Driver/Font/TrueType/Adapter/ttwidths.c | 133 +++++++++++++++++++- Driver/Font/TrueType/Main/truetypeChars.asm | 1 + 4 files changed, 138 insertions(+), 7 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 775636755..5808dbdcb 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -66,7 +66,8 @@ void _pascal TrueType_Gen_Chars( WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - TextStyle stylesToImplement + TextStyle stylesToImplement, + MemHandle bitmapHandle ) { FileHandle truetypeFile; @@ -198,13 +199,13 @@ void _pascal TrueType_Gen_Chars( ShrinkFontBuf( fontBuf ); /* realloc FontBuf if necessary */ - if( MemGetInfo( PtrToSegment( fontBuf ), MGIT_SIZE ) < fontBuf->FB_dataSize + size ) + /* if( MemGetInfo( MemPtrToHandle( fontBuf ), MGIT_SIZE ) < fontBuf->FB_dataSize + size ) { MemReAlloc( PtrToSegment( fontBuf ), fontBuf->FB_dataSize + size, HAF_STANDARD_NO_ERR ); fontBuf = MemDeref( PtrToSegment( fontBuf )); - } + } */ /* add rendered glyph to fontbuf */ CopyChar( fontBuf, character, charData ,size ); diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index 651b8fa50..149307482 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -27,7 +27,6 @@ * varaibles initialized by driver ***********************************************************************/ -extern MemHandle bitmapHandle; extern word bitmapSize; @@ -40,7 +39,8 @@ void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - TextStyle stylesToImplement ); + TextStyle stylesToImplement, + MemHandle bitmapBlock ); #endif /* _TTCHARS_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index d5cc94a59..04d723296 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -161,6 +161,7 @@ MemHandle _pascal TrueType_Gen_Widths( fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; ConvertHeader( face, pointSize, fontHeader, fontBuf ); + //Convert( face, pointSize, fontHeader, fontBuf ); /* fill kerning pairs and kerning values */ ConvertKernPairs( face, fontBuf ); @@ -210,7 +211,7 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord TT_CharMap charMap; TT_Glyph_Metrics metrics; char currentChar; - CharTableEntry* charTableEntry = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); TT_New_Glyph( face, &glyph ); TT_New_Instance( face, &instance ); @@ -249,10 +250,13 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord scaledWidth = SCALE_WORD( width, scaleFactor ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); + + /* nur TEST */ charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; charTableEntry->CTE_flags = 0; charTableEntry->CTE_usage = 0; + // set flags in CTE_flags if needed if( metrics.bbox.xMin < 0 ) charTableEntry->CTE_flags |= CTF_NEGATIVE_LSB; @@ -264,7 +268,7 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord //above ascent if( metrics.bbox.yMax > fontHeader->FH_ascent ) charTableEntry->CTE_flags |= CTF_ABOVE_ASCENT; - + if( fontBuf->FB_kernCount > 0 ) { @@ -712,7 +716,132 @@ TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* font fontBuf->FB_lastChar = fontHeader->FH_lastChar; fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; + //TODO: MAX_BSB, MAX_RSB + TT_Done_Instance( instance ); + /* Test */ + /* fontBuf->FB_minLSB = 0xffff; + + fontBuf->FB_avgwidth.WBF_int = 0x000e; + fontBuf->FB_avgwidth.WBF_frac = 0x64; + fontBuf->FB_maxwidth.WBF_int = 0x000e; + fontBuf->FB_maxwidth.WBF_frac = 0x64; + + fontBuf->FB_height.WBF_int = 0x0038; + //TEST fontBuf->FB_height.WBF_int = 0x0018; + fontBuf->FB_height.WBF_frac = 0xe6; + + fontBuf->FB_heightAdjust.WBF_int = 0xffff; + fontBuf->FB_heightAdjust.WBF_frac = 0x1a; + + fontBuf->FB_accent.WBF_int = 0x0004; + //TEST fontBuf->FB_accent.WBF_int = 0x0002; + fontBuf->FB_accent.WBF_frac = 0xce; + + fontBuf->FB_mean.WBF_int = 0x000a; + fontBuf->FB_mean.WBF_frac = 0x63; + + fontBuf->FB_baseAdjust.WBF_int = 0xffff; + fontBuf->FB_baseAdjust.WBF_frac = 0x0; + + fontBuf->FB_baselinePos.WBF_int = 0x0043; + //TEST fontBuf->FB_baselinePos.WBF_int = 0x0023; + fontBuf->FB_baselinePos.WBF_frac = 0; + + fontBuf->FB_descent.WBF_int = 0x0003; + fontBuf->FB_descent.WBF_frac = 0xfb; + + fontBuf->FB_extLeading.WBF_int = 0; + fontBuf->FB_extLeading.WBF_frac = 0; + + fontBuf->FB_underPos.WBF_int = 0x0014; + fontBuf->FB_underPos.WBF_frac = 0x70; + + fontBuf->FB_underThickness.WBF_int = 0x0001; + fontBuf->FB_underThickness.WBF_frac = 0xd9; + + fontBuf->FB_strikePos.WBF_int = 0x000c; + fontBuf->FB_strikePos.WBF_frac = 0x5a; + + fontBuf->FB_aboveBox.WBF_int = 0x0003; + //TEST fontBuf->FB_aboveBox.WBF_int = 0x0001; + fontBuf->FB_aboveBox.WBF_frac = 0; + + fontBuf->FB_belowBox.WBF_int = 0x0001; + fontBuf->FB_belowBox.WBF_frac = 0; + + fontBuf->FB_minTSB = 0x0001; + fontBuf->FB_maxBSB = 0x0001; + fontBuf->FB_maxRSB = 0x000f; + fontBuf->FB_pixHeight = 0x1a;*/ + return TT_Err_Ok; } + +/*** +static void Convert( TT_Face face, WWFixedAsDWord pointSize, FontHeader* fontHeader, FontBuf* fontBuf ) +{ + fontBuf->FB_maker = FM_TRUETYPE; + fontBuf->FB_kernPairPtr = 0; + fontBuf->FB_kernValuePtr = 0; + fontBuf->FB_kernCount = 0; + fontBuf->FB_heapCount = 0; + fontBuf->FB_flags = FBF_IS_OUTLINE; + + fontBuf->FB_minLSB = 0xffff; + + fontBuf->FB_avgwidth.WBF_int = 0x000e; + fontBuf->FB_avgwidth.WBF_frac = 0x64; + fontBuf->FB_maxwidth.WBF_int = 0x000e; + fontBuf->FB_maxwidth.WBF_frac = 0x64; + + fontBuf->FB_height.WBF_int = 0x0018; + fontBuf->FB_height.WBF_frac = 0xe6; + + fontBuf->FB_heightAdjust.WBF_int = 0xffff; + fontBuf->FB_heightAdjust.WBF_frac = 0x1a; + + fontBuf->FB_accent.WBF_int = 0x0002; + fontBuf->FB_accent.WBF_frac = 0xce; + + fontBuf->FB_mean.WBF_int = 0x000a; + fontBuf->FB_mean.WBF_frac = 0x63; + + fontBuf->FB_baseAdjust.WBF_int = 0xffff; + fontBuf->FB_baseAdjust.WBF_frac = 0x0; + + fontBuf->FB_baselinePos.WBF_int = 0x0023; + fontBuf->FB_baselinePos.WBF_frac = 0; + + fontBuf->FB_descent.WBF_int = 0x0003; + fontBuf->FB_descent.WBF_frac = 0xfb; + + fontBuf->FB_extLeading.WBF_int = 0; + fontBuf->FB_extLeading.WBF_frac = 0; + + fontBuf->FB_firstChar = fontHeader->FH_firstChar; + fontBuf->FB_lastChar = fontHeader->FH_lastChar; + fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; + + fontBuf->FB_underPos.WBF_int = 0x0014; + fontBuf->FB_underPos.WBF_frac = 0x70; + + fontBuf->FB_underThickness.WBF_int = 0x0001; + fontBuf->FB_underThickness.WBF_frac = 0xd9; + + fontBuf->FB_strikePos.WBF_int = 0x000c; + fontBuf->FB_strikePos.WBF_frac = 0x5a; + + fontBuf->FB_aboveBox.WBF_int = 0x0001; + fontBuf->FB_aboveBox.WBF_frac = 0; + + fontBuf->FB_belowBox.WBF_int = 0x0001; + fontBuf->FB_belowBox.WBF_frac = 0; + + fontBuf->FB_minTSB = 0x0001; + fontBuf->FB_maxBSB = 0x0001; + fontBuf->FB_maxRSB = 0x000f; + fontBuf->FB_pixHeight = 0x1a; + +} ****/ diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index ad233b9a3..673a5da0a 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -86,6 +86,7 @@ TrueTypeGenChar proc far push ax ; pass stylesToImplement segmov ds, dgroup, ax + push ds:bitmapHandle call TRUETYPE_GEN_CHARS ; deref font block (may have moved) From bb909b330cb588546a337c474c79924de6644f19 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 7 May 2023 12:02:38 +0200 Subject: [PATCH 157/246] fix: dirver renders more than one character --- Driver/Font/TrueType/Adapter/ttadapter.h | 10 + Driver/Font/TrueType/Adapter/ttchars.c | 15 +- Driver/Font/TrueType/Adapter/ttinit.c | 64 +-- Driver/Font/TrueType/Adapter/ttwidths.c | 514 +++++-------------- Driver/Font/TrueType/Adapter/ttwidths.h | 15 +- Driver/Font/TrueType/Main/truetypeWidths.asm | 45 +- 6 files changed, 209 insertions(+), 454 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 8ec8dffb3..62a079237 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -29,6 +29,7 @@ #include "../FreeType/ttengine.h" #include "../FreeType/ttcalc.h" + /*********************************************************************** * global dgoup objects ***********************************************************************/ @@ -345,6 +346,10 @@ typedef struct TT_CharMap charMap; TT_Outline outline; TT_BBox bbox; + + /* iterating over glyphs of a font */ + word charIndex; + word unicode; } TrueTypeVars; @@ -363,6 +368,9 @@ typedef struct #define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM +#define UNICODE trueTypeVars->unicode +#define CHARINDEX trueTypeVars->charIndex + /*********************************************************************** @@ -406,6 +414,8 @@ typedef struct ( value & 0x00ff ? ( ( value >> 16 ) - 1 ) : ( ( value >> 16 ) ) ) : \ ( value >> 16 ) ) +#define CEIL( value ) ( value & 0x000000ff ? ( value >> 16 ) + 1 : ( value ) ) + /* * get integral part of value (WWFixedAsDWord) */ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 5808dbdcb..cb1dc990a 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -169,9 +169,14 @@ void _pascal TrueType_Gen_Chars( size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; /* get pointer to bitmapBlock */ - if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) - MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); charData = MemLock( bitmapHandle ); + if( charData == NULL ) + { + MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); + charData = MemLock( bitmapHandle ); + } + memset( charData, 0, size ); + //if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) /* init rasterMap */ rasterMap.rows = height; @@ -188,8 +193,8 @@ void _pascal TrueType_Gen_Chars( /* fill header of charData */ ((CharData*)charData)->CD_pictureWidth = width; ((CharData*)charData)->CD_numRows = height; - ((CharData*)charData)->CD_xoff = bbox.xMin; - ((CharData*)charData)->CD_yoff = bbox.yMin; + ((CharData*)charData)->CD_xoff = bbox.xMin / 64; + ((CharData*)charData)->CD_yoff = bbox.yMin / 64; } TT_Done_Glyph( glyph ); @@ -226,7 +231,7 @@ void _pascal TrueType_Gen_Chars( static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word charDataSize ) { word indexGeosChar = geosChar - fontBuf->FB_firstChar; - CharTableEntry* charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + CharTableEntry* charTableEntries = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); /* copy rendered Glyph to fontBuf */ diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index b25ec8b29..8bc398b81 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -71,7 +71,7 @@ static void strcpy( char* dest, const char* source ); * * PARAMETERS: void * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * RETURNS: TT_Error FreeType errorcode (see tterrid.h) * * SIDE EFFECTS: none * @@ -108,7 +108,7 @@ TT_Error _pascal Init_FreeType() * * PARAMETERS: void * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * RETURNS: TT_Error FreeType errorcode (see tterrid.h) * * SIDE EFFECTS: none * @@ -133,8 +133,8 @@ TT_Error _pascal Exit_FreeType() * SYNOPSIS: Search for TTF fonts and register them. This is the * adapter function for DR_FONT_INIT_FONTS. * - * PARAMETERS: fontInfoBlock MemHandle to fontInfo. - * varBlock MemHandle to truetypeVarBlock. + * PARAMETERS: fontInfoBlock MemHandle to fontInfo. + * varBlock MemHandle to truetypeVarBlock. * * RETURNS: void * @@ -197,8 +197,8 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ) ******************************************************************** * SYNOPSIS: Lists all file names in the current directory. * - * PARAMETERS: fileEnumBlock Handle to the memory block in - * which the file names are stored. + * PARAMETERS: fileEnumBlock Handle to the memory block in + * which the file names are stored. * * RETURNS: word * @@ -239,9 +239,9 @@ static word DetectFontFiles( MemHandle* fileEnumBlock ) ******************************************************************** * SYNOPSIS: Registers a font with its styles as an available font. * - * PARAMETERS: fileName Name of font file. - * fontInfoBlock Handle to memory block with all - * infos about aviable fonts. + * PARAMETERS: fileName Name of font file. + * fontInfoBlock Handle to memory block with all + * infos about aviable fonts. * * RETURNS: void * @@ -445,9 +445,9 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo ******************************************************************** * SYNOPSIS: Calculates the hash value of the passed string. * - * PARAMETERS: str Pointer to the string. + * PARAMETERS: str Pointer to the string. * - * RETURNS: word Hash value for passed string. + * RETURNS: word Hash value for passed string. * * SIDE EFFECTS: none * @@ -476,9 +476,9 @@ static word toHash( const char* str ) ******************************************************************** * SYNOPSIS: Maps the TrueType family class to FreeGEOS FontAttrs. * - * PARAMETERS: familyClass TrueType family class. + * PARAMETERS: familyClass TrueType family class. * - * RETURNS: FontAttrs FreeGEOS FontAttrs. + * RETURNS: FontAttrs FreeGEOS FontAttrs. * * SIDE EFFECTS: none * @@ -540,9 +540,9 @@ static FontAttrs mapFamilyClass( TT_Short familyClass ) * SYNOPSIS: Maps the TrueType font weight class to FreeGEOS * AdjustedWeight. * - * PARAMETERS: weightClass TrueType weight class. + * PARAMETERS: weightClass TrueType weight class. * - * RETURNS: AdjustedWeight FreeGEOS AdjustedWeight. + * RETURNS: AdjustedWeight FreeGEOS AdjustedWeight. * * SIDE EFFECTS: none * @@ -585,9 +585,9 @@ static AdjustedWeight mapFontWeight( TT_Short weightClass ) ******************************************************************** * SYNOPSIS: Maps the TrueType subfamily to FreeGEOS TextStyle. * - * PARAMETERS: subfamily* String with subfamiliy name. + * PARAMETERS: subfamily* String with subfamiliy name. * - * RETURNS: TextStyle FreeGEOS TextStyle. + * RETURNS: TextStyle FreeGEOS TextStyle. * * SIDE EFFECTS: none * @@ -620,13 +620,13 @@ static TextStyle mapTextStyle( const char* subfamily ) /******************************************************************** * getFontID ******************************************************************** - * SYNOPSIS: If the passed font family is a mapped font, - * the FontID form geos.ini is returned, otherwise - * we calculate new FontID and return it. + * SYNOPSIS: If the passed font family is a mapped font, the + * FontID form geos.ini is returned, otherwise we + * calculate new FontID and return it. * - * PARAMETERS: familyName* Font family name. + * PARAMETERS: familyName* Font family name. * - * RETURNS: FontID FontID found geos.ini or calculated. + * RETURNS: FontID FontID found geos.ini or calculated. * * SIDE EFFECTS: none * @@ -652,14 +652,15 @@ static FontID getFontID( const char* familyName ) /******************************************************************** * getFontIDAvailIndex ******************************************************************** - * SYNOPSIS: Searches all FontsAvailEntries for the passed - * FontID and returns its index. If no FontsAvailEntry - * is found for the FontID, -1 is returned. + * SYNOPSIS: Searches all FontsAvailEntries for the passed + * FontID and returns its index. If no FontsAvailEntry + * is found for the FontID, -1 is returned. * - * PARAMETERS: fontID Searched FontID. - * fontInfoBlock Memory block with font information. + * PARAMETERS: fontID Searched FontID. + * fontInfoBlock Memory block with font information. * - * RETURNS: + * RETURNS: sword Index in FontBlock, if FontID + * was not found -1 will return. * * SIDE EFFECTS: none * @@ -910,9 +911,12 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) /******************************************************************** * GetDefaultChar ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Returns the default character, if this is not present + * in the face, the first GEOS character in the font is + * the default character. * - * PARAMETERS: + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * firstChar First GEOS char in face. * * RETURNS: char * diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 04d723296..7c502edfa 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -29,12 +29,6 @@ #include "../FreeType/ftxkern.h" -static TextStyle findOutlineData( - OutlineDataEntry** outlineData, - const FontInfo* fontInfo, - TextStyle textStyle, - FontWeight fontWeight ); - static word AllocFontBlock( word additionalSpace, word numOfCharacters, @@ -43,24 +37,21 @@ static word AllocFontBlock( static WWFixedAsDWord CalcScaleForWidths( WWFixedAsDWord pointSize, - FontWidth fontWidth, - FontWeight fontWeight, TextStyle stylesToImplement, word unitsPerEM ); -static TT_Error ConvertHeader( - TT_Face face, - WWFixedAsDWord pointSize, +static void ConvertHeader( + WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ); static void ConvertWidths( - TT_Face face, + TRUETYPE_VARS, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, FontBuf* fontBuf ); -static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ); +static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ); static void CalcTransform( TransformMatrix* transMatrix, @@ -72,15 +63,14 @@ static void CalcTransform( * TrueType_Gen_Widths ******************************************************************** * SYNOPSIS: Generate header width infomation about a front - * in a given pointsize, style and weight. + * in a given pointsize and style. * * PARAMETERS: fontHandle Memory handle to font block. * *fontMatrix Pointer to tranformation matrix. - * *fontInfo Pointer to font info structure. * pointSize Desired point size. + * *fontInfo Pointer to font info structure. * textStyle Desired text style. - * fontWidth Desired font width. - * fontWeight Desired font weight. + * MemHandle Memory handle to var block. * * RETURNS: MemHandle Memory handle to font block. * @@ -95,79 +85,79 @@ static void CalcTransform( *******************************************************************/ MemHandle _pascal TrueType_Gen_Widths( - MemHandle fontHandle, - FontMatrix* fontMatrix, - const FontInfo* fontInfo, - WWFixedAsDWord pointSize, - TextStyle textStyle, - FontWidth fontWidth, - FontWeight fontWeight ) + MemHandle fontHandle, + FontMatrix* fontMatrix, + WWFixedAsDWord pointSize, + const FontInfo* fontInfo, + const OutlineEntry* headerEntry, + const OutlineEntry* firstEntry, + TextStyle stylesToImplement, + MemHandle varBlock ) { FileHandle truetypeFile; - OutlineDataEntry* outlineData; - TrueTypeOutlineEntry* trueTypeOutlineEntry; - TextStyle stylesToImplement; - TT_Face face; - TT_Face_Properties faceProperties; - TT_Error error; - word size; + TrueTypeOutlineEntry* trueTypeOutline; + TrueTypeVars* trueTypeVars; FontHeader* fontHeader; FontBuf* fontBuf; WWFixedAsDWord scaleFactor; - - + word size; + + ECCheckMemHandle( fontHandle ); ECCheckBounds( fontMatrix ); ECCheckBounds( (void*)fontInfo ); + ECCheckBounds( (void*)headerEntry ); + ECCheckBounds( (void*)firstEntry ); + - /* find outline for textStyle and fontWeight */ - stylesToImplement = findOutlineData( &outlineData, fontInfo, textStyle, fontWeight ); + // get trueTypeVar block + trueTypeVars = MemLock( varBlock ); + if( trueTypeVars == NULL ) + { + MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); + trueTypeVars = MemLock( varBlock ); + } - /* get filename an load ttf file */ + // get filename an load ttf file FilePushDir(); FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - /* get pointer to TrueTypeOutline and FontHeader*/ - trueTypeOutlineEntry = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineData->ODE_header.OE_handle ); - fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineData->ODE_first.OE_handle ); - - /* open ttf file, face, properties and properties */ - truetypeFile = FileOpen( trueTypeOutlineEntry->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); + // get filename an load ttf file + trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), headerEntry->OE_handle ); + truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); ECCheckFileHandle( truetypeFile ); - error = TT_Open_Face( truetypeFile, &face ); - if( error ) - goto Fail; + // get pointer to FontHeader + fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), firstEntry->OE_handle ); + + if ( TT_Open_Face( truetypeFile, &FACE ) ) + goto Fin; - error = TT_Get_Face_Properties( face, &faceProperties ); - if( error ) + if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) goto Fail; - + /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ size = AllocFontBlock( sizeof( TransformMatrix ), fontHeader->FH_numChars, - CountKernPairsWithGeosChars( face ), + CountKernPairsWithGeosChars( FACE ), &fontHandle ); /* calculate scale factor and transformation matrix */ scaleFactor = CalcScaleForWidths( pointSize, - fontWidth, - fontWeight, stylesToImplement, - faceProperties.header->Units_Per_EM ); + FACE_PROPERTIES.header->Units_Per_EM ); /* convert FontHeader and fill FontBuf structure */ fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; - ConvertHeader( face, pointSize, fontHeader, fontBuf ); - //Convert( face, pointSize, fontHeader, fontBuf ); + ConvertHeader( scaleFactor, fontHeader, fontBuf ); /* fill kerning pairs and kerning values */ - ConvertKernPairs( face, fontBuf ); + ConvertKernPairs( trueTypeVars, fontBuf ); /* convert widths and fill CharTableEntries */ - ConvertWidths( face, fontHeader, scaleFactor, fontBuf ); + ConvertWidths( trueTypeVars, fontHeader, scaleFactor, fontBuf ); /* calculate the transformation matrix and copy it into the FontBlock */ CalcTransform( (TransformMatrix*)((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry ), @@ -175,10 +165,12 @@ MemHandle _pascal TrueType_Gen_Widths( stylesToImplement ); Fail: - TT_Close_Face( face ); + TT_Close_Face( FACE ); +Fin: FileClose( truetypeFile, FALSE ); + MemUnlock( varBlock ); FilePopDir(); - return fontHandle; + return fontHandle; } @@ -204,32 +196,22 @@ MemHandle _pascal TrueType_Gen_Widths( * 12/02/23 JK Initial Revision *******************************************************************/ -static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, FontBuf* fontBuf ) +static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, FontBuf* fontBuf ) { - TT_Instance instance; - TT_Glyph glyph; - TT_CharMap charMap; - TT_Glyph_Metrics metrics; - char currentChar; - CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); + char currentChar; + CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); + WWFixedAsDWord scaledWidth; + - TT_New_Glyph( face, &glyph ); - TT_New_Instance( face, &instance ); - getCharMap( face, &charMap ); + TT_New_Glyph( FACE, &GLYPH ); + TT_New_Instance( FACE, &INSTANCE ); + getCharMap( FACE, &CHAR_MAP ); for( currentChar = fontHeader->FH_firstChar; currentChar < fontHeader->FH_lastChar; currentChar++ ) { - word charIndex; - word width; - WWFixedAsDWord scaledWidth; - - - //Geos Char to Unicode - word unicode = GeosCharToUnicode( currentChar ); - //Unicode to TT ID - charIndex = TT_Char_Index( charMap, unicode ); - if ( charIndex == 0 ) + CHARINDEX = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( currentChar ) ); + if ( CHARINDEX == 0 ) { charTableEntry->CTE_flags = CTF_NO_DATA; charTableEntry->CTE_dataOffset = CHAR_NOT_EXIST; @@ -242,12 +224,11 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord } //Glyph laden - TT_Load_Glyph( instance, glyph, charIndex, TTLOAD_DEFAULT ); - TT_Get_Glyph_Metrics( glyph, &metrics ); + TT_Load_Glyph( INSTANCE, GLYPH, CHARINDEX, 0 ); + TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); //width berechnen - width = metrics.bbox.xMax - metrics.bbox.xMin; - scaledWidth = SCALE_WORD( width, scaleFactor ); + scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), scaleFactor ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); @@ -258,15 +239,15 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord // set flags in CTE_flags if needed - if( metrics.bbox.xMin < 0 ) + if( GLYPH_BBOX.xMin < 0 ) charTableEntry->CTE_flags |= CTF_NEGATIVE_LSB; //below descent - if( -metrics.bbox.yMin > fontHeader->FH_descent ) + if( -GLYPH_BBOX.yMin > fontHeader->FH_descent ) charTableEntry->CTE_flags |= CTF_BELOW_DESCENT; //above ascent - if( metrics.bbox.yMax > fontHeader->FH_ascent ) + if( GLYPH_BBOX.yMax > fontHeader->FH_ascent ) charTableEntry->CTE_flags |= CTF_ABOVE_ASCENT; @@ -280,83 +261,8 @@ static void ConvertWidths( TT_Face face, FontHeader* fontHeader, WWFixedAsDWord charTableEntry++; } - TT_Done_Instance( instance ); - TT_Done_Glyph( glyph ); -} - - -/******************************************************************** - * findOutlineData - ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: - * - * RETURNS: - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 12/02/23 JK Initial Revision - *******************************************************************/ - -static TextStyle findOutlineData( - OutlineDataEntry** outline, - const FontInfo* fontInfo, - TextStyle textStyle, - FontWeight fontWeight ) -{ - OutlineDataEntry* outlineToUse; - OutlineDataEntry* outlineData = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineTab); - OutlineDataEntry* outlineDataEnd = (OutlineDataEntry*) (((byte*)fontInfo) + fontInfo->FI_outlineEnd); - TextStyle styleDiff = 127; - byte weightDiff = 127; - - - /* adjust textWeight for AW_BOLD */ - if( textStyle >= AW_BOLD ) - textStyle = AW_BLACK; - - while( outlineData < outlineDataEnd) - { - /* exact match? */ - if( outlineData->ODE_style == textStyle && - outlineData->ODE_weight == fontWeight ) - { - *outline = outlineData; - return 0; // no styles to implement - } - - /* style match? */ - if( outlineData->ODE_style == textStyle ) - { - byte currentWeightDiff = ABS( fontWeight - outlineData->ODE_weight ); - - styleDiff = 0; - if( weightDiff >= currentWeightDiff ) - { - outlineToUse = outlineData; - weightDiff = currentWeightDiff; - } - - } - - /* try to find nearest style */ - if( ( ( textStyle & outlineData->ODE_style ) ^ outlineData->ODE_style ) == 0 ) - { - byte currentStyleDiff = textStyle ^ outlineData->ODE_style; - if( styleDiff >= currentStyleDiff ) - { - outlineToUse = outlineData; - styleDiff = currentStyleDiff; - } - } - outlineData++; - } - *outline = outlineToUse; - return styleDiff; + TT_Done_Instance( INSTANCE ); + TT_Done_Glyph( GLYPH ); } @@ -381,12 +287,10 @@ static TextStyle findOutlineData( static WWFixedAsDWord CalcScaleForWidths( WWFixedAsDWord pointSize, - FontWidth fontWidth, - FontWeight fontWeight, TextStyle stylesToImplement, word unitsPerEM ) { - WWFixedAsDWord scaleWidth = GrUDivWWFixed( pointSize, WORD_TO_WWFIXEDASDWORD( unitsPerEM ) ); + WWFixedAsDWord scaleWidth = GrUDivWWFixed( pointSize, MakeWWFixed( unitsPerEM ) ); /* do bold need to be added? */ if( stylesToImplement & TS_BOLD ) @@ -396,14 +300,6 @@ static WWFixedAsDWord CalcScaleForWidths( if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) scaleWidth = GrMulWWFixed( scaleWidth, WWFIXED_0_POINT_5 ); - /* adjust for fontWidth */ - if( fontWeight != FWI_MEDIUM ) - scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWidth ) ); - - /* adjust für fontWeight */ - if( fontWidth != FW_NORMAL ) - scaleWidth = GrMulWWFixed( scaleWidth, MakeWWFixed( fontWeight ) ); - return scaleWidth; } @@ -427,7 +323,7 @@ static WWFixedAsDWord CalcScaleForWidths( * 20/12/22 JK Initial Revision *******************************************************************/ -static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) +static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) { KernPair* kernPair; WBFixed* wbFixed; @@ -457,8 +353,7 @@ static void ConvertKernPairs( TT_Face face, FontBuf* fontBuf ) * SYNOPSIS: Calculates the transformation matrix for missing * style attributes and weights. * - * PARAMETERS: *transMatrix Pointer to TransformMatrix - * in font block. + * PARAMETERS: *transMatrix Pointer to TransformMatrix. * *fontMatrix Systems transformation matrix. * styleToImplement Styles that must be added. * @@ -486,15 +381,11 @@ static void CalcTransform( TransformMatrix* transMatrix, /* fake bold style */ if( stylesToImplement & TS_BOLD ) - { tempMatrix.xx = BOLD_FACTOR; - } /* fake italic style */ if( stylesToImplement & TS_ITALIC ) - { tempMatrix.yx = ITALIC_FACTOR; - } /* fake script style */ if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) @@ -503,13 +394,9 @@ static void CalcTransform( TransformMatrix* transMatrix, tempMatrix.yy = GrMulWWFixed( tempMatrix.yy, SCRIPT_FACTOR ); if( stylesToImplement & TS_SUBSCRIPT ) - { transMatrix->TM_shiftY = -SCRIPT_SHIFT_FACTOR; - } else - { transMatrix->TM_shiftY = SCRIPT_SHIFT_FACTOR; - } } /* integrate fontMatrix */ @@ -529,16 +416,11 @@ static void CalcTransform( TransformMatrix* transMatrix, ******************************************************************** * SYNOPSIS: Allocate or reallocate memory block for font. * - * PARAMETERS: additionalSpace Additional space in block - * for driver. - * numOfCharacters Number of GEOS characters in - * font. - * numOfKernPairs Number of kerning pairs of - * GEOS characters in font. + * PARAMETERS: additionalSpace Additional space in block. + * numOfCharacters Number of GEOS characters. + * numOfKernPairs Number of kerning pairs. * *fontHandle Pointer to MemHandle of font - * block. If NullHandle alloc new - * block. If not, realloc existing - * one. + * block. * * RETURNS: word Size of allocated block. * @@ -560,16 +442,16 @@ static word AllocFontBlock( additionalSpace; /* allocate memory for FontBuf, CharTableEntries, KernPairs and additional space */ - if( fontHandle == NullHandle ) + if( *fontHandle == NullHandle ) { - *fontHandle = MemAllocSetOwner( FONT_MAN_ID, size, + *fontHandle = MemAllocSetOwner( FONT_MAN_ID, MAX_FONTBUF_SIZE, HF_SWAPABLE | HF_SHARABLE | HF_DISCARDABLE, HAF_NO_ERR | HAF_LOCK ); HandleP( *fontHandle ); } else { - MemReAlloc( *fontHandle, size, HAF_NO_ERR | HAF_LOCK ); + MemReAlloc( *fontHandle, MAX_FONTBUF_SIZE, HAF_NO_ERR | HAF_LOCK ); } return size; @@ -581,14 +463,11 @@ static word AllocFontBlock( ******************************************************************** * SYNOPSIS: Converts FontInfo and fill FontBuf structure. * - * PARAMETERS: face TrueType face of font file. - * pointSize Current pointsize. - * *fontHeader Pointer to FontHeader structure - * to fill fontBuf. - * *fontBuf Pointer to FontBuf structure - * to fill. + * PARAMETERS: pointSize Current pointsize. + * *fontHeader Ptr to FontHeader structure. + * *fontBuf Ptr to FontBuf structure. * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * RETURNS: void * * STRATEGY: * @@ -598,12 +477,8 @@ static word AllocFontBlock( * 11/12/22 JK Initial Revision *******************************************************************/ -TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* fontHeader, FontBuf* fontBuf ) +void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ) { - TT_Error error; - TT_Instance instance; - TT_Instance_Metrics instanceMetrics; - WWFixedAsDWord scaleFactor; WWFixedAsDWord ttfElement; @@ -611,22 +486,7 @@ TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* font ECCheckBounds( (void*)fontHeader ); - error = TT_New_Instance( face, &instance ); - if ( error ) - return error; - - error = TT_Set_Instance_CharSize( instance, pointSize >> 10 ); - if ( error ) - return error; - - error = TT_Get_Instance_Metrics( instance, &instanceMetrics ); - if ( error ) - return error; - - scaleFactor = instanceMetrics.x_scale; - /* Fill elements in FontBuf structure. */ - fontBuf->FB_maker = FM_TRUETYPE; fontBuf->FB_kernPairPtr = 0; fontBuf->FB_kernValuePtr = 0; @@ -634,9 +494,6 @@ TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* font fontBuf->FB_heapCount = 0; fontBuf->FB_flags = FBF_IS_OUTLINE; - ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleFactor ); - fontBuf->FB_minLSB = ROUND_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_avgwidth, scaleFactor ); fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); @@ -645,39 +502,36 @@ TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* font fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); -#ifndef DBCS_PCGEOS - ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleFactor ); - fontBuf->FB_maxRSB = ROUND_WWFIXEDASDWORD( ttfElement ); -#endif /* DBCS_PCGEOS */ - - scaleFactor = instanceMetrics.y_scale; + ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleFactor ); + fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); ttfElement = SCALE_WORD( fontHeader->FH_height, scaleFactor ); fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - /* FB_heightAdjust = pointSize - FH_height */ - ttfElement = pointSize - WORD_TO_WWFIXEDASDWORD( fontHeader->FH_height ); - fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_pixHeight = ROUND_WWFIXEDASDWORD( ttfElement ); - + ttfElement = SCALE_WORD( fontHeader->FH_accent, scaleFactor ); + fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + ttfElement = SCALE_WORD( fontHeader->FH_x_height, scaleFactor ); + fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleFactor ); - fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ROUND_WWFIXEDASDWORD( ttfElement ) ); + fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_baseAdjust.WBF_frac = 0; - ttfElement = SCALE_WORD( fontHeader->FH_minTSB, scaleFactor ); - fontBuf->FB_aboveBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_aboveBox.WBF_frac = 0; - fontBuf->FB_minTSB = CEIL_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_pixHeight += CEIL_WWFIXEDASDWORD( ttfElement ); + ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleFactor ); + fontBuf->FB_baselinePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_baselinePos.WBF_frac = 0; - ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleFactor ); - fontBuf->FB_belowBox.WBF_int = CEIL_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_belowBox.WBF_frac = 0; -#ifdef SBCS_PCGEOS - fontBuf->FB_maxBSB = CEIL_WWFIXEDASDWORD( ttfElement ); -#endif /* SBCS_PCGEOS */ + ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleFactor ); + fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); + + fontBuf->FB_extLeading.WBF_int = 0; + fontBuf->FB_extLeading.WBF_frac = 0; ttfElement = SCALE_WORD( fontHeader->FH_underPos, scaleFactor ); fontBuf->FB_underPos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); @@ -691,157 +545,29 @@ TT_Error ConvertHeader( TT_Face face, WWFixedAsDWord pointSize, FontHeader* font fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_x_height, scaleFactor ); - fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleFactor ); - fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - ttfElement = SCALE_WORD( fontHeader->FH_accent, scaleFactor ); - fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - - /* baslinepos = accent + ascent */ - ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleFactor ); - fontBuf->FB_baselinePos.WBF_int = ROUND_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_baselinePos.WBF_frac = 0; - - /* Nimbus fonts and TrueType fonts has no external leading */ - fontBuf->FB_extLeading.WBF_int = 0; - fontBuf->FB_extLeading.WBF_frac = 0; - - fontBuf->FB_firstChar = fontHeader->FH_firstChar; - fontBuf->FB_lastChar = fontHeader->FH_lastChar; - fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; - - //TODO: MAX_BSB, MAX_RSB - - TT_Done_Instance( instance ); - - /* Test */ - /* fontBuf->FB_minLSB = 0xffff; - - fontBuf->FB_avgwidth.WBF_int = 0x000e; - fontBuf->FB_avgwidth.WBF_frac = 0x64; - fontBuf->FB_maxwidth.WBF_int = 0x000e; - fontBuf->FB_maxwidth.WBF_frac = 0x64; - - fontBuf->FB_height.WBF_int = 0x0038; - //TEST fontBuf->FB_height.WBF_int = 0x0018; - fontBuf->FB_height.WBF_frac = 0xe6; - - fontBuf->FB_heightAdjust.WBF_int = 0xffff; - fontBuf->FB_heightAdjust.WBF_frac = 0x1a; - - fontBuf->FB_accent.WBF_int = 0x0004; - //TEST fontBuf->FB_accent.WBF_int = 0x0002; - fontBuf->FB_accent.WBF_frac = 0xce; - - fontBuf->FB_mean.WBF_int = 0x000a; - fontBuf->FB_mean.WBF_frac = 0x63; - - fontBuf->FB_baseAdjust.WBF_int = 0xffff; - fontBuf->FB_baseAdjust.WBF_frac = 0x0; - - fontBuf->FB_baselinePos.WBF_int = 0x0043; - //TEST fontBuf->FB_baselinePos.WBF_int = 0x0023; - fontBuf->FB_baselinePos.WBF_frac = 0; - - fontBuf->FB_descent.WBF_int = 0x0003; - fontBuf->FB_descent.WBF_frac = 0xfb; - - fontBuf->FB_extLeading.WBF_int = 0; - fontBuf->FB_extLeading.WBF_frac = 0; - - fontBuf->FB_underPos.WBF_int = 0x0014; - fontBuf->FB_underPos.WBF_frac = 0x70; - - fontBuf->FB_underThickness.WBF_int = 0x0001; - fontBuf->FB_underThickness.WBF_frac = 0xd9; - - fontBuf->FB_strikePos.WBF_int = 0x000c; - fontBuf->FB_strikePos.WBF_frac = 0x5a; - - fontBuf->FB_aboveBox.WBF_int = 0x0003; - //TEST fontBuf->FB_aboveBox.WBF_int = 0x0001; + ttfElement = SCALE_WORD( fontHeader->FH_minTSB, scaleFactor ); + fontBuf->FB_aboveBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_aboveBox.WBF_frac = 0; + fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_belowBox.WBF_int = 0x0001; + ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleFactor ); + //fontBuf->FB_belowBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_belowBox.WBF_int = 1; //hack fontBuf->FB_belowBox.WBF_frac = 0; + //fontBuf->FB_maxBSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_maxBSB = 1; //hack - fontBuf->FB_minTSB = 0x0001; - fontBuf->FB_maxBSB = 0x0001; - fontBuf->FB_maxRSB = 0x000f; - fontBuf->FB_pixHeight = 0x1a;*/ - - return TT_Err_Ok; -} - -/*** -static void Convert( TT_Face face, WWFixedAsDWord pointSize, FontHeader* fontHeader, FontBuf* fontBuf ) -{ - fontBuf->FB_maker = FM_TRUETYPE; - fontBuf->FB_kernPairPtr = 0; - fontBuf->FB_kernValuePtr = 0; - fontBuf->FB_kernCount = 0; - fontBuf->FB_heapCount = 0; - fontBuf->FB_flags = FBF_IS_OUTLINE; - - fontBuf->FB_minLSB = 0xffff; - - fontBuf->FB_avgwidth.WBF_int = 0x000e; - fontBuf->FB_avgwidth.WBF_frac = 0x64; - fontBuf->FB_maxwidth.WBF_int = 0x000e; - fontBuf->FB_maxwidth.WBF_frac = 0x64; - - fontBuf->FB_height.WBF_int = 0x0018; - fontBuf->FB_height.WBF_frac = 0xe6; - - fontBuf->FB_heightAdjust.WBF_int = 0xffff; - fontBuf->FB_heightAdjust.WBF_frac = 0x1a; - - fontBuf->FB_accent.WBF_int = 0x0002; - fontBuf->FB_accent.WBF_frac = 0xce; - - fontBuf->FB_mean.WBF_int = 0x000a; - fontBuf->FB_mean.WBF_frac = 0x63; - - fontBuf->FB_baseAdjust.WBF_int = 0xffff; - fontBuf->FB_baseAdjust.WBF_frac = 0x0; - - fontBuf->FB_baselinePos.WBF_int = 0x0023; - fontBuf->FB_baselinePos.WBF_frac = 0; + ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleFactor ); + //fontBuf->FB_minLSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_minLSB = 0xffff; //hack - fontBuf->FB_descent.WBF_int = 0x0003; - fontBuf->FB_descent.WBF_frac = 0xfb; + ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleFactor ); + fontBuf->FB_maxRSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_extLeading.WBF_int = 0; - fontBuf->FB_extLeading.WBF_frac = 0; + ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleFactor ); + fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_firstChar = fontHeader->FH_firstChar; fontBuf->FB_lastChar = fontHeader->FH_lastChar; fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; - - fontBuf->FB_underPos.WBF_int = 0x0014; - fontBuf->FB_underPos.WBF_frac = 0x70; - - fontBuf->FB_underThickness.WBF_int = 0x0001; - fontBuf->FB_underThickness.WBF_frac = 0xd9; - - fontBuf->FB_strikePos.WBF_int = 0x000c; - fontBuf->FB_strikePos.WBF_frac = 0x5a; - - fontBuf->FB_aboveBox.WBF_int = 0x0001; - fontBuf->FB_aboveBox.WBF_frac = 0; - - fontBuf->FB_belowBox.WBF_int = 0x0001; - fontBuf->FB_belowBox.WBF_frac = 0; - - fontBuf->FB_minTSB = 0x0001; - fontBuf->FB_maxBSB = 0x0001; - fontBuf->FB_maxRSB = 0x000f; - fontBuf->FB_pixHeight = 0x1a; - -} ****/ +} diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 355bce3c9..4a6d6e934 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -46,13 +46,14 @@ typedef struct ***********************************************************************/ MemHandle _pascal TrueType_Gen_Widths( - MemHandle fontHandle, - FontMatrix* fontMatrix, - const FontInfo* fontInfo, - WWFixedAsDWord pointSize, - TextStyle textStyle, - FontWidth fontWidth, - FontWeight fontWeight + MemHandle fontHandle, + FontMatrix* fontMatrix, + WWFixedAsDWord pointSize, + const FontInfo* fontInfo, + const OutlineEntry* headerEntry, + const OutlineEntry* firstEntry, + TextStyle stylesToImplement, + MemHandle varBlock ); diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index b668a41cf..ac83aa7ef 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -62,42 +62,51 @@ TrueTypeGenWidths proc far mov bx, bp .enter - push di ; font handle or 0 + push di ; font handle or 0 - push bx ; send tMatrix ptr + push bx ; send tMatrix ptr push cx + + clr al + movwbf dxah, es:GS_fontAttr.FCA_pointsize + push dx ; pass point size + push ax - ; find font info mov cx, es:GS_fontAttr.FCA_fontID call FontDrFindFontInfo - push ds ; pass font info ptr + push ds ; pass ptr to FontInfo push di - clr al ; pointsize from gstate - movwbf dxah, es:GS_fontAttr.FCA_pointsize - push dx ; pass point size - push ax + mov cx, ds ; save ptr to FontInfo + mov dx, di - clr ah ; text style from gstate + clr ah mov al, es:GS_fontAttr.FCA_textStyle - push ax ; pass text style + mov bx, ODF_HEADER + call FontDrFindOutlineData + push ds ; pass ptr to OutlineEntry + push di - ; font weight from gstate - mov al, es:GS_fontAttr.FCA_weight - push ax ; pass font weight + mov ds, cx + mov di, dx - ; font width from gstate - mov al, es:GS_fontAttr.FCA_width - push ax ; pass font width + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_PART1 + call FontDrFindOutlineData + push ds ; pass ptr to OutlineEntry + push di + push ax ; pass stylesToImplement segmov ds, dgroup, dx + push ds:variableHandle ; pass varBlock call TRUETYPE_GEN_WIDTHS - mov bx, ax ; mov font hdl to bx + mov bx, ax ; mov font hdl to bx call MemDerefDS segmov ax, ds - clc ;indicate no error + clc ;indicate no error .leave ret From cc1ce1537c016b04a402870a06c956783f718622 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 8 May 2023 20:00:59 +0200 Subject: [PATCH 158/246] fix memory leak --- Driver/Font/TrueType/Adapter/ttchars.c | 11 +++++------ Driver/Font/TrueType/Adapter/ttchars.h | 1 - Driver/Font/TrueType/Main/truetypeChars.asm | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index cb1dc990a..2b68a1bf1 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -66,13 +66,11 @@ void _pascal TrueType_Gen_Chars( WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - TextStyle stylesToImplement, MemHandle bitmapHandle ) { FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; - TT_Error error; TT_Face face; TT_Instance instance; TT_Glyph glyph; @@ -100,12 +98,12 @@ void _pascal TrueType_Gen_Chars( ECCheckFileHandle( truetypeFile ); /* open face, create instance and glyph */ - error = TT_Open_Face( truetypeFile, &face ); - if( error ) + if( TT_Open_Face( truetypeFile, &face ) ) goto Fail; TT_New_Glyph( face, &glyph ); TT_New_Instance( face, &instance ); + TT_Set_Instance_Resolutions( instance, 72, 72 ); /* get TT char index */ getCharMap( face, &charMap ); @@ -187,14 +185,14 @@ void _pascal TrueType_Gen_Chars( rasterMap.bitmap = ((byte*)charData) + SIZE_CHAR_HEADER; /* translate outline and render it */ - TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); + //TT_Translate_Outline( &outline, -bbox.xMin, bbox.yMin ); TT_Get_Outline_Bitmap( &outline, &rasterMap ); /* fill header of charData */ ((CharData*)charData)->CD_pictureWidth = width; ((CharData*)charData)->CD_numRows = height; ((CharData*)charData)->CD_xoff = bbox.xMin / 64; - ((CharData*)charData)->CD_yoff = bbox.yMin / 64; + ((CharData*)charData)->CD_yoff = fontBuf->FB_pixHeight - ( bbox.yMax / 64 ); } TT_Done_Glyph( glyph ); @@ -218,6 +216,7 @@ void _pascal TrueType_Gen_Chars( /* cleanup */ MemUnlock( bitmapHandle ); Fail: + TT_Close_Face( face ); FileClose( truetypeFile, FALSE ); FilePopDir(); } diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index 149307482..b87c348ea 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -39,7 +39,6 @@ void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - TextStyle stylesToImplement, MemHandle bitmapBlock ); diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 673a5da0a..d285ce9ac 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -83,7 +83,6 @@ TrueTypeGenChar proc far call FontDrFindOutlineData push ds ; pass ptr to OutlineEntry push di - push ax ; pass stylesToImplement segmov ds, dgroup, ax push ds:bitmapHandle From 6fc414e0f06b869aea890037dc05d2c333b96aed Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 11 May 2023 20:46:45 +0200 Subject: [PATCH 159/246] Positioning on baseline corrected. --- Driver/Font/TrueType/Adapter/ttadapter.h | 1 - Driver/Font/TrueType/Adapter/ttcharmapper.c | 458 ++++++++++---------- Driver/Font/TrueType/Adapter/ttcharmapper.h | 1 - Driver/Font/TrueType/Adapter/ttchars.c | 4 +- Driver/Font/TrueType/Adapter/ttinit.c | 2 - Driver/Font/TrueType/Adapter/ttwidths.c | 9 +- 6 files changed, 235 insertions(+), 240 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 62a079237..7630529df 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -324,7 +324,6 @@ typedef struct sword FH_minTSB; //minimum top side bound sword FH_maxBSB; //maximum bottom side bound sword FH_maxRSB; //maximum right side bound - sword FH_continuitySize; //continuity cutoff } FontHeader; diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 059067e87..b6a3a06e7 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -32,231 +32,231 @@ //TODO: put geosCharMap into movable ressource CharMapEntry geosCharMap[] = { -/* unicode weight flags */ - C_SPACE, 166, 0, - C_EXCLAMATION_MARK, 0, 0, - C_QUOTATION_MARK, 0, 0, - C_NUMBER_SIGN, 0, 0, - C_DOLLAR_SIGN, 0, 0, - C_PERCENT_SIGN, 0, 0, - C_AMPERSAND, 0, 0, - C_APOSTROPHE_QUOTE, 0, 0, - C_OPENING_PARENTHESIS, 0, 0, - C_CLOSING_PARENTHESIS, 0, 0, - C_ASTERISK, 0, 0, - C_PLUS_SIGN, 0, 0, - C_COMMA, 0, 0, - C_HYPHEN_MINUS, 0, 0, - C_PERIOD, 0, 0, - C_SLASH, 0, 0, - C_DIGIT_ZERO, 0, 0, - C_DIGIT_ONE, 0, 0, - C_DIGIT_TWO, 0, 0, - C_DIGIT_THREE, 0, 0, - C_DIGIT_FOUR, 0, 0, - C_DIGIT_FIVE, 0, 0, - C_DIGIT_SIX, 0, 0, - C_DIGIT_SEVEN, 0, 0, - C_DIGIT_EIGHT, 0, 0, - C_DIGIT_NINE, 0, 0, - C_COLON, 0, 0, - C_SEMICOLON, 0, 0, - C_LESS_THAN_SIGN, 0, 0, - C_EQUALS_SIGN, 0, 0, - C_GREATER_THAN_SIGN, 0, 0, - C_QUESTION_MARK, 0, 0, - C_COMMERCIAL_AT, 0, 0, - C_LATIN_CAPITAL_LETTER_A, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_B, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_C, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_D, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_E, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_F, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_G, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_H, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_I, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_J, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_K, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_L, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_M, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_N, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_O, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_P, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_Q, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_R, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_S, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_T, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_U, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_V, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_W, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_X, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_Y, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_Z, 0, CMF_CAP, - C_OPENING_SQUARE_BRACKET, 0, 0, - C_BACKSLASH, 0, 0, - C_CLOSING_SQUARE_BRACKET, 0, 0, - C_SPACING_CIRCUMFLEX, 0, 0, - C_SPACING_UNDERSCORE, 0, 0, - C_SPACING_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_A, 64, CMF_MEAN, - C_LATIN_SMALL_LETTER_B, 14, CMF_ASCENT, - C_LATIN_SMALL_LETTER_C, 27, CMF_MEAN, - C_LATIN_SMALL_LETTER_D, 35, CMF_ASCENT, - C_LATIN_SMALL_LETTER_E, 100, CMF_MEAN, - C_LATIN_SMALL_LETTER_F, 20, CMF_ASCENT, - C_LATIN_SMALL_LETTER_G, 14, CMF_DESCENT, - C_LATIN_SMALL_LETTER_H, 42, CMF_ASCENT, - C_LATIN_SMALL_LETTER_I, 63, CMF_ASCENT, - C_LATIN_SMALL_LETTER_J, 3, CMF_DESCENT, - C_LATIN_SMALL_LETTER_K, 6, CMF_ASCENT, - C_LATIN_SMALL_LETTER_L, 35, CMF_ASCENT, - C_LATIN_SMALL_LETTER_M, 20, CMF_MEAN, - C_LATIN_SMALL_LETTER_N, 56, CMF_MEAN, - C_LATIN_SMALL_LETTER_O, 56, CMF_MEAN, - C_LATIN_SMALL_LETTER_P, 17, CMF_DESCENT, - C_LATIN_SMALL_LETTER_Q, 4, CMF_DESCENT, - C_LATIN_SMALL_LETTER_R, 49, CMF_MEAN, - C_LATIN_SMALL_LETTER_S, 56, CMF_MEAN, - C_LATIN_SMALL_LETTER_T, 71, CMF_ASCENT, - C_LATIN_SMALL_LETTER_U, 31, CMF_MEAN, - C_LATIN_SMALL_LETTER_V, 10, CMF_MEAN, - C_LATIN_SMALL_LETTER_W, 18, CMF_MEAN, - C_LATIN_SMALL_LETTER_X, 3, CMF_MEAN, - C_LATIN_SMALL_LETTER_Y, 18, CMF_DESCENT, - C_LATIN_SMALL_LETTER_Z, 2, CMF_MEAN, - C_OPENING_CURLY_BRACKET, 0, 0, - C_VERTICAL_BAR, 0, 0, - C_CLOSING_CURLY_BRACKET, 0, 0, - C_TILDE, 0, 0, - C_DELETE, 0, 0, - C_LATIN_CAPITAL_LETTER_A_DIAERESIS, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_A_RING, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_C_CEDILLA, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_ACUTE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_N_TILDE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_DIAERESIS, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_DIAERESIS, 0, CMF_ACCENT, - C_LATIN_SMALL_LETTER_A_ACUTE, 0, 0, - C_LATIN_SMALL_LETTER_A_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_A_CIRCUMFLEX, 0, 0, - C_LATIN_SMALL_LETTER_A_DIAERESIS, 0, 0, - C_LATIN_SMALL_LETTER_A_TILDE, 0, 0, - C_LATIN_SMALL_LETTER_A_RING, 0, 0, - C_LATIN_SMALL_LETTER_C_CEDILLA, 0, 0, - C_LATIN_SMALL_LETTER_E_ACUTE, 0, 0, - C_LATIN_SMALL_LETTER_E_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_E_CIRCUMFLEX, 0, 0, - C_LATIN_SMALL_LETTER_E_DIAERESIS, 0, 0, - C_LATIN_SMALL_LETTER_I_ACUTE, 0, 0, - C_LATIN_SMALL_LETTER_I_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_I_CIRCUMFLEX, 0, 0, - C_LATIN_SMALL_LETTER_I_DIAERESIS, 0, 0, - C_LATIN_SMALL_LETTER_N_TILDE, 0, 0, - C_LATIN_SMALL_LETTER_O_ACUTE, 0, 0, - C_LATIN_SMALL_LETTER_O_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_O_CIRCUMFLEX, 0, 0, - C_LATIN_SMALL_LETTER_O_DIAERESIS, 0, 0, - C_LATIN_SMALL_LETTER_O_TILDE, 0, 0, - C_LATIN_SMALL_LETTER_U_ACUTE, 0, 0, - C_LATIN_SMALL_LETTER_U_GRAVE, 0, 0, - C_LATIN_SMALL_LETTER_U_CIRCUMFLEX, 0, 0, - C_LATIN_SMALL_LETTER_U_DIAERESIS, 0, 0, - C_DAGGER, 0, 0, - C_DEGREE_SIGN, 0, 0, - C_CENT_SIGN, 0, 0, - C_POUND_SIGN, 0, 0, - C_SECTION_SIGN, 0, 0, - C_BULLET_OPERATOR, 0, 0, - C_PARAGRAPH_SIGN, 0, 0, - C_LATIN_SMALL_LETTER_SHARP_S, 0, 0, - C_REGISTERED_TRADE_MARK_SIGN, 0, 0, - C_COPYRIGHT_SIGN, 0, 0, - C_TRADEMARK, 0, 0, - C_SPACING_ACUTE, 0, 0, - C_SPACING_DIAERESIS, 0, 0, - C_NOT_EQUAL_TO, 0, 0, - C_LATIN_CAPITAL_LETTER_A_E, 0, CMF_CAP, - C_LATIN_CAPITAL_LETTER_O_SLASH, 0, CMF_CAP, - C_INFINITY, 0, 0, - C_PLUS_OR_MINUS_SIGN, 0, 0, - C_LESS_THAN_OR_EQUAL_TO, 0, 0, - C_GREATER_THAN_OR_EQUAL_TO, 0, 0, - C_YEN_SIGN, 0, 0, - C_MICRO_SIGN, 0, 0, - C_PARTIAL_DIFFERENTIAL, 0, 0, - C_N_ARY_SUMMATION, 0, 0, - C_N_ARY_PRODUCT, 0, 0, - C_GREEK_SMALL_LETTER_PI, 0, 0, - C_INTEGRAL, 0, 0, - C_FEMININE_ORDINAL_INDICATOR, 0, 0, - C_MASCULINE_ORDINAL_INDICATOR, 0, 0, - C_GREEK_CAPITAL_LETTER_OMEGA, 0, 0, - C_LATIN_SMALL_LETTER_A_E, 0, 0, - C_LATIN_SMALL_LETTER_O_SLASH, 0, 0, - C_INVERTED_QUESTION_MARK, 0, 0, - C_INVERTED_EXCLAMATION_MARK, 0, 0, - C_NOT_SIGN, 0, 0, - C_SQUARE_ROOT, 0, 0, - C_LATIN_SMALL_LETTER_SCRIPT_F, 0, 0, - C_ALMOST_EQUAL_TO, 0, 0, - C_GREEK_CAPITAL_LETTER_DELTA, 0, 0, - C_LEFT_POINTING_GUILLEMET, 0, 0, - C_RIGHT_POINTING_GUILLEMET, 0, 0, - C_MIDLINE_HORIZONTAL_ELLIPSIS, 0, 0, - C_NON_BREAKING_SPACE, 0, 0, - C_LATIN_CAPITAL_LETTER_A_GRAVE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_A_TILDE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_TILDE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_E, 0, CMF_ACCENT, - C_LATIN_SMALL_LETTER_O_E, 0, 0, - C_EM_DASH, 0, 0, - C_EN_DASH, 0, 0, - C_DOUBLE_TURNED_COMMA_QUOTATION_MARK, 0, 0, - C_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, - C_SINGLE_TURNED_COMMA_QUOTATION_MARK, 0, 0, - C_SINGLE_COMMA_QUOTATION_MARK, 0, 0, - C_DIVISION_SIGN, 0, 0, - C_BLACK_DIAMOND, 0, 0, - C_LATIN_SMALL_LETTER_Y_DIAERESIS, 0, 0, - C_LATIN_CAPITAL_LETTER_Y_DIAERESIS, 0, CMF_ACCENT, - C_FRACTION_SLASH, 0, 0, - C_EURO_CURRENCY_SIGN, 0, 0, - C_LEFT_POINTING_SINGLE_GUILLEMET, 0, 0, - C_RIGHT_POINTING_SINGLE_GUILLEMET, 0, 0, - C_LATIN_SMALL_LETTER_Y_ACUTE, 0, 0, - C_LATIN_CAPITAL_LETTER_Y_ACUTE, 0, 0, - C_DOUBLE_DAGGER, 0, 0, - C_MIDDLE_DOT, 0, 0, - C_LOW_SINGLE_COMMA_QUOTATION_MARK, 0, 0, - C_LOW_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, - C_PER_MILLE_SIGN, 0, 0, - C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_CIRCUMFLEX, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_A_ACUTE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_DIAERESIS, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_GRAVE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_ACUTE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_CIRCUMFLEX, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_DIAERESIS, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_GRAVE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_ACUTE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_CIRCUMFLEX, 0, CMF_ACCENT, - 0, 0, 0, //no character - C_LATIN_CAPITAL_LETTER_O_GRAVE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_ACUTE, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_CIRCUMFLEX, 0, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_GRAVE, 0, CMF_ACCENT, - C_LATIN_SMALL_LETTER_DOTLESS_I, 0, 0, - C_NON_SPACING_CIRCUMFLEX, 0, 0, - C_NON_SPACING_TILDE, 0, 0, - C_SPACING_MACRON, 0, 0, - C_SPACING_BREVE, 0, 0, - C_SPACING_DOT_ABOVE, 0, 0, - C_SPACING_RING_ABOVE, 0, 0, - C_SPACING_CEDILLA, 0, 0, - C_SPACING_DOUBLE_ACUTE, 0, 0, - C_SPACING_OGONEK, 0, 0, - C_MODIFIER_LETTER_HACEK, 0, 0 +/* unicode flags */ + C_SPACE, 0, + C_EXCLAMATION_MARK, 0, + C_QUOTATION_MARK, 0, + C_NUMBER_SIGN, 0, + C_DOLLAR_SIGN, 0, + C_PERCENT_SIGN, 0, + C_AMPERSAND, 0, + C_APOSTROPHE_QUOTE, 0, + C_OPENING_PARENTHESIS, 0, + C_CLOSING_PARENTHESIS, 0, + C_ASTERISK, 0, + C_PLUS_SIGN, 0, + C_COMMA, 0, + C_HYPHEN_MINUS, 0, + C_PERIOD, 0, + C_SLASH, 0, + C_DIGIT_ZERO, 0, + C_DIGIT_ONE, 0, + C_DIGIT_TWO, 0, + C_DIGIT_THREE, 0, + C_DIGIT_FOUR, 0, + C_DIGIT_FIVE, 0, + C_DIGIT_SIX, 0, + C_DIGIT_SEVEN, 0, + C_DIGIT_EIGHT, 0, + C_DIGIT_NINE, 0, + C_COLON, 0, + C_SEMICOLON, 0, + C_LESS_THAN_SIGN, 0, + C_EQUALS_SIGN, 0, + C_GREATER_THAN_SIGN, 0, + C_QUESTION_MARK, 0, + C_COMMERCIAL_AT, 0, + C_LATIN_CAPITAL_LETTER_A, CMF_CAP, + C_LATIN_CAPITAL_LETTER_B, CMF_CAP, + C_LATIN_CAPITAL_LETTER_C, CMF_CAP, + C_LATIN_CAPITAL_LETTER_D, CMF_CAP, + C_LATIN_CAPITAL_LETTER_E, CMF_CAP, + C_LATIN_CAPITAL_LETTER_F, CMF_CAP, + C_LATIN_CAPITAL_LETTER_G, CMF_CAP, + C_LATIN_CAPITAL_LETTER_H, CMF_CAP, + C_LATIN_CAPITAL_LETTER_I, CMF_CAP, + C_LATIN_CAPITAL_LETTER_J, CMF_CAP, + C_LATIN_CAPITAL_LETTER_K, CMF_CAP, + C_LATIN_CAPITAL_LETTER_L, CMF_CAP, + C_LATIN_CAPITAL_LETTER_M, CMF_CAP, + C_LATIN_CAPITAL_LETTER_N, CMF_CAP, + C_LATIN_CAPITAL_LETTER_O, CMF_CAP, + C_LATIN_CAPITAL_LETTER_P, CMF_CAP, + C_LATIN_CAPITAL_LETTER_Q, CMF_CAP, + C_LATIN_CAPITAL_LETTER_R, CMF_CAP, + C_LATIN_CAPITAL_LETTER_S, CMF_CAP, + C_LATIN_CAPITAL_LETTER_T, CMF_CAP, + C_LATIN_CAPITAL_LETTER_U, CMF_CAP, + C_LATIN_CAPITAL_LETTER_V, CMF_CAP, + C_LATIN_CAPITAL_LETTER_W, CMF_CAP, + C_LATIN_CAPITAL_LETTER_X, CMF_CAP, + C_LATIN_CAPITAL_LETTER_Y, CMF_CAP, + C_LATIN_CAPITAL_LETTER_Z, CMF_CAP, + C_OPENING_SQUARE_BRACKET, 0, + C_BACKSLASH, 0, + C_CLOSING_SQUARE_BRACKET, 0, + C_SPACING_CIRCUMFLEX, 0, + C_SPACING_UNDERSCORE, 0, + C_SPACING_GRAVE, 0, + C_LATIN_SMALL_LETTER_A, CMF_MEAN, + C_LATIN_SMALL_LETTER_B, CMF_ASCENT, + C_LATIN_SMALL_LETTER_C, CMF_MEAN, + C_LATIN_SMALL_LETTER_D, CMF_ASCENT, + C_LATIN_SMALL_LETTER_E, CMF_MEAN, + C_LATIN_SMALL_LETTER_F, CMF_ASCENT, + C_LATIN_SMALL_LETTER_G, CMF_DESCENT, + C_LATIN_SMALL_LETTER_H, CMF_ASCENT, + C_LATIN_SMALL_LETTER_I, CMF_ASCENT, + C_LATIN_SMALL_LETTER_J, CMF_DESCENT, + C_LATIN_SMALL_LETTER_K, CMF_ASCENT, + C_LATIN_SMALL_LETTER_L, CMF_ASCENT, + C_LATIN_SMALL_LETTER_M, CMF_MEAN, + C_LATIN_SMALL_LETTER_N, CMF_MEAN, + C_LATIN_SMALL_LETTER_O, CMF_MEAN, + C_LATIN_SMALL_LETTER_P, CMF_DESCENT, + C_LATIN_SMALL_LETTER_Q, CMF_DESCENT, + C_LATIN_SMALL_LETTER_R, CMF_MEAN, + C_LATIN_SMALL_LETTER_S, CMF_MEAN, + C_LATIN_SMALL_LETTER_T, CMF_ASCENT, + C_LATIN_SMALL_LETTER_U, CMF_MEAN, + C_LATIN_SMALL_LETTER_V, CMF_MEAN, + C_LATIN_SMALL_LETTER_W, CMF_MEAN, + C_LATIN_SMALL_LETTER_X, CMF_MEAN, + C_LATIN_SMALL_LETTER_Y, CMF_DESCENT, + C_LATIN_SMALL_LETTER_Z, CMF_MEAN, + C_OPENING_CURLY_BRACKET, 0, + C_VERTICAL_BAR, 0, + C_CLOSING_CURLY_BRACKET, 0, + C_TILDE, 0, + C_DELETE, 0, + C_LATIN_CAPITAL_LETTER_A_DIAERESIS, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_RING, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_C_CEDILLA, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_ACUTE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_N_TILDE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_DIAERESIS, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_DIAERESIS, CMF_ACCENT, + C_LATIN_SMALL_LETTER_A_ACUTE, 0, + C_LATIN_SMALL_LETTER_A_GRAVE, 0, + C_LATIN_SMALL_LETTER_A_CIRCUMFLEX, 0, + C_LATIN_SMALL_LETTER_A_DIAERESIS, 0, + C_LATIN_SMALL_LETTER_A_TILDE, 0, + C_LATIN_SMALL_LETTER_A_RING, 0, + C_LATIN_SMALL_LETTER_C_CEDILLA, 0, + C_LATIN_SMALL_LETTER_E_ACUTE, 0, + C_LATIN_SMALL_LETTER_E_GRAVE, 0, + C_LATIN_SMALL_LETTER_E_CIRCUMFLEX, 0, + C_LATIN_SMALL_LETTER_E_DIAERESIS, 0, + C_LATIN_SMALL_LETTER_I_ACUTE, 0, + C_LATIN_SMALL_LETTER_I_GRAVE, 0, + C_LATIN_SMALL_LETTER_I_CIRCUMFLEX, 0, + C_LATIN_SMALL_LETTER_I_DIAERESIS, 0, + C_LATIN_SMALL_LETTER_N_TILDE, 0, + C_LATIN_SMALL_LETTER_O_ACUTE, 0, + C_LATIN_SMALL_LETTER_O_GRAVE, 0, + C_LATIN_SMALL_LETTER_O_CIRCUMFLEX, 0, + C_LATIN_SMALL_LETTER_O_DIAERESIS, 0, + C_LATIN_SMALL_LETTER_O_TILDE, 0, + C_LATIN_SMALL_LETTER_U_ACUTE, 0, + C_LATIN_SMALL_LETTER_U_GRAVE, 0, + C_LATIN_SMALL_LETTER_U_CIRCUMFLEX, 0, + C_LATIN_SMALL_LETTER_U_DIAERESIS, 0, + C_DAGGER, 0, + C_DEGREE_SIGN, 0, + C_CENT_SIGN, 0, + C_POUND_SIGN, 0, + C_SECTION_SIGN, 0, + C_BULLET_OPERATOR, 0, + C_PARAGRAPH_SIGN, 0, + C_LATIN_SMALL_LETTER_SHARP_S, 0, + C_REGISTERED_TRADE_MARK_SIGN, 0, + C_COPYRIGHT_SIGN, 0, + C_TRADEMARK, 0, + C_SPACING_ACUTE, 0, + C_SPACING_DIAERESIS, 0, + C_NOT_EQUAL_TO, 0, + C_LATIN_CAPITAL_LETTER_A_E, CMF_CAP, + C_LATIN_CAPITAL_LETTER_O_SLASH, CMF_CAP, + C_INFINITY, 0, + C_PLUS_OR_MINUS_SIGN, 0, + C_LESS_THAN_OR_EQUAL_TO, 0, + C_GREATER_THAN_OR_EQUAL_TO, 0, + C_YEN_SIGN, 0, + C_MICRO_SIGN, 0, + C_PARTIAL_DIFFERENTIAL, 0, + C_N_ARY_SUMMATION, 0, + C_N_ARY_PRODUCT, 0, + C_GREEK_SMALL_LETTER_PI, 0, + C_INTEGRAL, 0, + C_FEMININE_ORDINAL_INDICATOR, 0, + C_MASCULINE_ORDINAL_INDICATOR, 0, + C_GREEK_CAPITAL_LETTER_OMEGA, 0, + C_LATIN_SMALL_LETTER_A_E, 0, + C_LATIN_SMALL_LETTER_O_SLASH, 0, + C_INVERTED_QUESTION_MARK, 0, + C_INVERTED_EXCLAMATION_MARK, 0, + C_NOT_SIGN, 0, + C_SQUARE_ROOT, 0, + C_LATIN_SMALL_LETTER_SCRIPT_F, 0, + C_ALMOST_EQUAL_TO, 0, + C_GREEK_CAPITAL_LETTER_DELTA, 0, + C_LEFT_POINTING_GUILLEMET, 0, + C_RIGHT_POINTING_GUILLEMET, 0, + C_MIDLINE_HORIZONTAL_ELLIPSIS, 0, + C_NON_BREAKING_SPACE, 0, + C_LATIN_CAPITAL_LETTER_A_GRAVE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_TILDE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_TILDE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_E, CMF_ACCENT, + C_LATIN_SMALL_LETTER_O_E, 0, + C_EM_DASH, 0, + C_EN_DASH, 0, + C_DOUBLE_TURNED_COMMA_QUOTATION_MARK, 0, + C_DOUBLE_COMMA_QUOTATION_MARK, 0, + C_SINGLE_TURNED_COMMA_QUOTATION_MARK, 0, + C_SINGLE_COMMA_QUOTATION_MARK, 0, + C_DIVISION_SIGN, 0, + C_BLACK_DIAMOND, 0, + C_LATIN_SMALL_LETTER_Y_DIAERESIS, 0, + C_LATIN_CAPITAL_LETTER_Y_DIAERESIS, CMF_ACCENT, + C_FRACTION_SLASH, 0, + C_EURO_CURRENCY_SIGN, 0, + C_LEFT_POINTING_SINGLE_GUILLEMET, 0, + C_RIGHT_POINTING_SINGLE_GUILLEMET, 0, + C_LATIN_SMALL_LETTER_Y_ACUTE, 0, + C_LATIN_CAPITAL_LETTER_Y_ACUTE, 0, + C_DOUBLE_DAGGER, 0, + C_MIDDLE_DOT, 0, + C_LOW_SINGLE_COMMA_QUOTATION_MARK, 0, + C_LOW_DOUBLE_COMMA_QUOTATION_MARK, 0, + C_PER_MILLE_SIGN, 0, + C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_CIRCUMFLEX, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_A_ACUTE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_DIAERESIS, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_E_GRAVE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_ACUTE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_CIRCUMFLEX, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_DIAERESIS, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_I_GRAVE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_ACUTE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_O_CIRCUMFLEX, CMF_ACCENT, + 0, 0, //no character + C_LATIN_CAPITAL_LETTER_O_GRAVE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_ACUTE, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_CIRCUMFLEX, CMF_ACCENT, + C_LATIN_CAPITAL_LETTER_U_GRAVE, CMF_ACCENT, + C_LATIN_SMALL_LETTER_DOTLESS_I, 0, + C_NON_SPACING_CIRCUMFLEX, 0, + C_NON_SPACING_TILDE, 0, + C_SPACING_MACRON, 0, + C_SPACING_BREVE, 0, + C_SPACING_DOT_ABOVE, 0, + C_SPACING_RING_ABOVE, 0, + C_SPACING_CEDILLA, 0, + C_SPACING_DOUBLE_ACUTE, 0, + C_SPACING_OGONEK, 0, + C_MODIFIER_LETTER_HACEK, 0 }; @@ -277,14 +277,6 @@ CharMapFlags GeosCharMapFlag( word geosChar ) return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].flags; } -byte GeosAvgWidth( word geosChar ) -{ - if( geosChar < MIN_GEOS_CHAR || geosChar > MAX_GEOS_CHAR ) - return 0; - - return geosCharMap[ GEOS_CHAR_INDEX( geosChar ) ].weight; -} - /* * Get microsoft unicode charmap in face. diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 6a8282eda..eeb3409bb 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -38,7 +38,6 @@ typedef ByteFlags CharMapFlags; typedef struct { word unicode; - byte weight; CharMapFlags flags; } CharMapEntry; diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 2b68a1bf1..daa37878b 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -185,14 +185,14 @@ void _pascal TrueType_Gen_Chars( rasterMap.bitmap = ((byte*)charData) + SIZE_CHAR_HEADER; /* translate outline and render it */ - //TT_Translate_Outline( &outline, -bbox.xMin, bbox.yMin ); + TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); TT_Get_Outline_Bitmap( &outline, &rasterMap ); /* fill header of charData */ ((CharData*)charData)->CD_pictureWidth = width; ((CharData*)charData)->CD_numRows = height; ((CharData*)charData)->CD_xoff = bbox.xMin / 64; - ((CharData*)charData)->CD_yoff = fontBuf->FB_pixHeight - ( bbox.yMax / 64 ); + ((CharData*)charData)->CD_yoff = fontBuf->FB_baselinePos.WBF_int - ( bbox.yMax / 64 ); } TT_Done_Glyph( glyph ); diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 8bc398b81..f88f1d8ca 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -903,8 +903,6 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) fontHeader->FH_strikePos = 3 * fontHeader->FH_x_height / 5; else fontHeader->FH_strikePos = 3 * fontHeader->FH_ascent / 5; - - fontHeader->FH_continuitySize = DEFAULT_CONTINUITY_CUTOFF( UNITS_PER_EM ); } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 7c502edfa..b54e75a57 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -58,6 +58,8 @@ static void CalcTransform( FontMatrix* fontMatrix, TextStyle styleToImplement ); +static word round( WWFixedAsDWord toRound ); + /******************************************************************** * TrueType_Gen_Widths @@ -523,7 +525,7 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf->FB_baseAdjust.WBF_frac = 0; ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleFactor ); - fontBuf->FB_baselinePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + fontBuf->FB_baselinePos.WBF_int = round( ttfElement ); fontBuf->FB_baselinePos.WBF_frac = 0; ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleFactor ); @@ -571,3 +573,8 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf->FB_lastChar = fontHeader->FH_lastChar; fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; } + +static word round( WWFixedAsDWord toRound ) +{ + return toRound & 0xffff ? ( toRound >> 16 ) + 1 : toRound >> 16; +} From 4e5d30959c06c0b879f6c60a6736c4406b1e211a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 16 May 2023 22:18:35 +0200 Subject: [PATCH 160/246] Some little corrections. --- Driver/Font/TrueType/Adapter/ttadapter.h | 5 +++ Driver/Font/TrueType/Adapter/ttchars.c | 3 +- Driver/Font/TrueType/Adapter/ttwidths.c | 38 +++++++++++--------- Driver/Font/TrueType/Main/truetypeWidths.asm | 2 +- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 7630529df..f633dbb0f 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -349,6 +349,9 @@ typedef struct /* iterating over glyphs of a font */ word charIndex; word unicode; + + /* scaling */ + WWFixedAsDWord scaleFactor; } TrueTypeVars; @@ -370,6 +373,8 @@ typedef struct #define UNICODE trueTypeVars->unicode #define CHARINDEX trueTypeVars->charIndex +#define SCALE_FACTOR trueTypeVars->scaleFactor + /*********************************************************************** diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index daa37878b..ef9bb8b32 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -86,6 +86,7 @@ void _pascal TrueType_Gen_Chars( ECCheckBounds( (void*)fontBuf ); ECCheckBounds( (void*)fontInfo ); ECCheckBounds( (void*)outlineEntry ); + ECCheckStack(); FilePushDir(); @@ -153,7 +154,7 @@ void _pascal TrueType_Gen_Chars( /* fill header of charData */ ((RegionCharData*)charData)->RCD_xoff = bbox.xMin; - ((RegionCharData*)charData)->RCD_xoff = bbox.yMin; + ((RegionCharData*)charData)->RCD_yoff = bbox.yMin; ((RegionCharData*)charData)->RCD_size = rasterMap.size; ((RegionCharData*)charData)->RCD_bounds.R_left = 0; ((RegionCharData*)charData)->RCD_bounds.R_right = width; diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index b54e75a57..356140e61 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -41,14 +41,13 @@ static WWFixedAsDWord CalcScaleForWidths( word unitsPerEM ); static void ConvertHeader( - WWFixedAsDWord scaleFactor, + WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ); static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, - WWFixedAsDWord scaleFactor, FontBuf* fontBuf ); static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ); @@ -101,15 +100,15 @@ MemHandle _pascal TrueType_Gen_Widths( TrueTypeVars* trueTypeVars; FontHeader* fontHeader; FontBuf* fontBuf; - WWFixedAsDWord scaleFactor; word size; ECCheckMemHandle( fontHandle ); - ECCheckBounds( fontMatrix ); + ECCheckBounds( (void*)fontMatrix ); ECCheckBounds( (void*)fontInfo ); ECCheckBounds( (void*)headerEntry ); ECCheckBounds( (void*)firstEntry ); + ECCheckStack(); // get trueTypeVar block @@ -146,23 +145,23 @@ MemHandle _pascal TrueType_Gen_Widths( &fontHandle ); /* calculate scale factor and transformation matrix */ - scaleFactor = CalcScaleForWidths( pointSize, + SCALE_FACTOR = CalcScaleForWidths( pointSize, stylesToImplement, FACE_PROPERTIES.header->Units_Per_EM ); /* convert FontHeader and fill FontBuf structure */ fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; - ConvertHeader( scaleFactor, fontHeader, fontBuf ); + ConvertHeader( SCALE_FACTOR, fontHeader, fontBuf ); /* fill kerning pairs and kerning values */ ConvertKernPairs( trueTypeVars, fontBuf ); /* convert widths and fill CharTableEntries */ - ConvertWidths( trueTypeVars, fontHeader, scaleFactor, fontBuf ); + ConvertWidths( trueTypeVars, fontHeader, fontBuf ); /* calculate the transformation matrix and copy it into the FontBlock */ - CalcTransform( (TransformMatrix*)((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry ), + CalcTransform( (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )), fontMatrix, stylesToImplement ); @@ -198,7 +197,7 @@ MemHandle _pascal TrueType_Gen_Widths( * 12/02/23 JK Initial Revision *******************************************************************/ -static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, WWFixedAsDWord scaleFactor, FontBuf* fontBuf ) +static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) { char currentChar; CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); @@ -211,6 +210,8 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, WWFixedAsDWord for( currentChar = fontHeader->FH_firstChar; currentChar < fontHeader->FH_lastChar; currentChar++ ) { + ECCheckBounds( (void*)charTableEntry ); + //Unicode to TT ID CHARINDEX = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( currentChar ) ); if ( CHARINDEX == 0 ) @@ -230,7 +231,7 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, WWFixedAsDWord TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); //width berechnen - scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), scaleFactor ); + scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), SCALE_FACTOR ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); @@ -375,6 +376,10 @@ static void CalcTransform( TransformMatrix* transMatrix, { TT_Matrix tempMatrix; + + ECCheckBounds( (void*)transMatrix ); + ECCheckBounds( (void*)fontMatrix ); + /* copy fontMatrix into transMatrix */ tempMatrix.xx = 1L << 16; tempMatrix.xy = 0; @@ -482,7 +487,7 @@ static word AllocFontBlock( void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ) { WWFixedAsDWord ttfElement; - + ECCheckBounds( (void*)fontBuf ); ECCheckBounds( (void*)fontHeader ); @@ -553,15 +558,14 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleFactor ); - //fontBuf->FB_belowBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_belowBox.WBF_int = 1; //hack + fontBuf->FB_belowBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + //fontBuf->FB_belowBox.WBF_int = 1; //hack fontBuf->FB_belowBox.WBF_frac = 0; - //fontBuf->FB_maxBSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_maxBSB = 1; //hack + fontBuf->FB_maxBSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + //fontBuf->FB_maxBSB = 1; //hack ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleFactor ); - //fontBuf->FB_minLSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_minLSB = 0xffff; //hack + fontBuf->FB_minLSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleFactor ); fontBuf->FB_maxRSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index ac83aa7ef..ed31a75b2 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -57,7 +57,7 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TrueTypeGenWidths proc far - uses cx, dx, si, di, ds, es, bp + uses cx, dx, di, ds mov bx, bp .enter From fdb21b41303ff1fe575e826daada268b2eaac2a2 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 18 May 2023 13:53:37 +0200 Subject: [PATCH 161/246] Current status commited. --- Driver/Font/TrueType/Adapter/ttchars.c | 19 ++++++++++++------- Driver/Font/TrueType/Adapter/ttwidths.c | 4 ++-- Driver/Font/TrueType/FreeType/ft_conf.h | 9 +-------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index ef9bb8b32..1fe447e53 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -138,9 +138,14 @@ void _pascal TrueType_Gen_Chars( size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; /* get pointer to bitmapBlock */ - if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) - MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); charData = MemLock( bitmapHandle ); + //TODO: verfügbaren Platz prüfen? + if( charData == NULL ) + { + MemReAlloc( bitmapHandle, /* size */ 1024, HAF_NO_ERR ); + charData = MemLock( bitmapHandle ); + } + memset( charData, 0, size ); /* init rasterMap */ rasterMap.rows = height; @@ -153,8 +158,8 @@ void _pascal TrueType_Gen_Chars( TT_Get_Outline_Region( &outline, &rasterMap ); /* fill header of charData */ - ((RegionCharData*)charData)->RCD_xoff = bbox.xMin; - ((RegionCharData*)charData)->RCD_yoff = bbox.yMin; + ((RegionCharData*)charData)->RCD_xoff = bbox.xMin / 64; + ((RegionCharData*)charData)->RCD_yoff = bbox.yMin / 64; ((RegionCharData*)charData)->RCD_size = rasterMap.size; ((RegionCharData*)charData)->RCD_bounds.R_left = 0; ((RegionCharData*)charData)->RCD_bounds.R_right = width; @@ -169,13 +174,13 @@ void _pascal TrueType_Gen_Chars( /* get pointer to bitmapBlock */ charData = MemLock( bitmapHandle ); + //TODO: verfügbaren Platz prüfen? if( charData == NULL ) { - MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); + MemReAlloc( bitmapHandle, /* size */ 1024, HAF_NO_ERR ); charData = MemLock( bitmapHandle ); } memset( charData, 0, size ); - //if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) /* init rasterMap */ rasterMap.rows = height; @@ -293,7 +298,7 @@ static int FindLRUChar( FontBuf* fontBuf, int numOfChars ) word lru = 0xffff; int indexLRUChar = -1; int i; - CharTableEntry* charTableEntry = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); for( i = 0; i < numOfChars; i++, charTableEntry++ ) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 356140e61..bdf635e26 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -118,6 +118,8 @@ MemHandle _pascal TrueType_Gen_Widths( MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); trueTypeVars = MemLock( varBlock ); } + + ECCheckBounds( (void*)trueTypeVars ); // get filename an load ttf file FilePushDir(); @@ -559,10 +561,8 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleFactor ); fontBuf->FB_belowBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - //fontBuf->FB_belowBox.WBF_int = 1; //hack fontBuf->FB_belowBox.WBF_frac = 0; fontBuf->FB_maxBSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - //fontBuf->FB_maxBSB = 1; //hack ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleFactor ); fontBuf->FB_minLSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); diff --git a/Driver/Font/TrueType/FreeType/ft_conf.h b/Driver/Font/TrueType/FreeType/ft_conf.h index ffdd3f005..e60fe12a5 100644 --- a/Driver/Font/TrueType/FreeType/ft_conf.h +++ b/Driver/Font/TrueType/FreeType/ft_conf.h @@ -18,13 +18,6 @@ #include -/* FreeGEOS specific constants and definitions. */ -#define MAX_LMEM_CHUNKSIZE 32000 - -/* MemHandle to our global memory block under FreeGEOS. In this memory block */ -/* we hold all dynamically allocated FreeType structures we need. */ -extern MemHandle trueTypeHandle; - /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -123,7 +116,7 @@ extern MemHandle trueTypeHandle; /* emerged recently on the FreeType lists. We still do not have Apple's */ /* opinion on the subject and will change this as soon as we have. */ -#undef TT_CONFIG_OPTION_NO_INTERPRETER +#define TT_CONFIG_OPTION_NO_INTERPRETER /*************************************************************************/ From 879762d98f8d9aa361307a18088c7cbf0049833d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 21 May 2023 21:15:54 +0200 Subject: [PATCH 162/246] Add EURO_SIGN. --- CInclude/unicode.h | 1 + Driver/Font/TrueType/Adapter/ttcharmapper.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CInclude/unicode.h b/CInclude/unicode.h index cfc6b616e..cc07704a4 100644 --- a/CInclude/unicode.h +++ b/CInclude/unicode.h @@ -2549,6 +2549,7 @@ typedef word Chars; #define C_NON_SPACING_LONG_VERTICAL_BAR_OVERLAY 0x20d2 #define C_NON_SPACING_RIGHT_HARPOON_ABOVE 0x20d1 #define C_NON_SPACING_LEFT_HARPOON_ABOVE 0x20d0 +#define C_EURO_SIGN 0x20ac #define C_NEW_SHEQEL_SIGN 0x20aa #define C_WON_SIGN 0x20a9 #define C_RUPEE_SIGN 0x20a8 diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index b6a3a06e7..3e2d48709 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -220,7 +220,7 @@ CharMapEntry geosCharMap[] = C_LATIN_SMALL_LETTER_Y_DIAERESIS, 0, C_LATIN_CAPITAL_LETTER_Y_DIAERESIS, CMF_ACCENT, C_FRACTION_SLASH, 0, - C_EURO_CURRENCY_SIGN, 0, + C_EURO_SIGN, 0, C_LEFT_POINTING_SINGLE_GUILLEMET, 0, C_RIGHT_POINTING_SINGLE_GUILLEMET, 0, C_LATIN_SMALL_LETTER_Y_ACUTE, 0, From 79577fc17316995c902a0c8fdb79803bb0a75b7f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 25 May 2023 20:10:29 +0200 Subject: [PATCH 163/246] Some unneeded parts removed. --- Driver/Font/TrueType/Adapter/ttadapter.h | 15 +---- Driver/Font/TrueType/Adapter/ttinit.c | 3 - Driver/Font/TrueType/Adapter/ttinit.h | 10 +-- Driver/Font/TrueType/Adapter/ttmetrics.c | 66 ++++++++++--------- Driver/Font/TrueType/Adapter/ttmetrics.h | 5 +- Driver/Font/TrueType/Adapter/ttwidths.c | 21 +++--- Driver/Font/TrueType/FreeType/freetype.h | 31 ++++----- Driver/Font/TrueType/FreeType/ttapi.c | 42 ++++++------ Driver/Font/TrueType/FreeType/ttload.c | 8 +-- Driver/Font/TrueType/FreeType/ttload.h | 4 +- Driver/Font/TrueType/FreeType/ttobjs.h | 4 +- Driver/Font/TrueType/Main/truetypeMetrics.asm | 1 + 12 files changed, 100 insertions(+), 110 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index f633dbb0f..c70a5d97a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -340,18 +340,12 @@ typedef struct TT_Face face; TT_Face_Properties faceProperties; TT_Instance instance; + TT_Instance_Metrics instanceMetrics; TT_Glyph glyph; TT_Glyph_Metrics glyphMetrics; TT_CharMap charMap; TT_Outline outline; TT_BBox bbox; - - /* iterating over glyphs of a font */ - word charIndex; - word unicode; - - /* scaling */ - WWFixedAsDWord scaleFactor; } TrueTypeVars; @@ -362,6 +356,7 @@ typedef struct #define FACE trueTypeVars->face #define FACE_PROPERTIES trueTypeVars->faceProperties #define INSTANCE trueTypeVars->instance +#define INSTANCE_METRICS trueTypeVars->instanceMetrics #define GLYPH trueTypeVars->glyph #define CHAR_MAP trueTypeVars->charMap #define OUTLINE trueTypeVars->outline @@ -370,12 +365,6 @@ typedef struct #define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM -#define UNICODE trueTypeVars->unicode -#define CHARINDEX trueTypeVars->charIndex - -#define SCALE_FACTOR trueTypeVars->scaleFactor - - /*********************************************************************** * macros diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index f88f1d8ca..ccd5baed3 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -393,9 +393,7 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo /* not found append new outline entry */ trueTypeOutlineChunk = LMemAlloc( fontInfoBlock, sizeof(TrueTypeOutlineEntry) ); if( trueTypeOutlineChunk == NullChunk ) - { goto Fail; - } /* insert OutlineDataEntry behinde fontinfo */ fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); @@ -432,7 +430,6 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo fontInfo = LMemDeref( ConstructOptr(fontInfoBlock, fontInfoChunk) ); fontInfo->FI_outlineEnd += sizeof( OutlineDataEntry ); } - Fail: TT_Close_Face( FACE ); Fin: diff --git a/Driver/Font/TrueType/Adapter/ttinit.h b/Driver/Font/TrueType/Adapter/ttinit.h index 2d5df6a75..54be41240 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.h +++ b/Driver/Font/TrueType/Adapter/ttinit.h @@ -47,7 +47,7 @@ #define ENCODING_ID_MAC_ROMAN 0 #define ENCODING_ID_MS_UNICODE_BMP 1 -#define ENCODING_ID_UNICODE 3 +#define ENCODING_ID_UNICODE 3 #define LANGUAGE_ID_MAC_EN 0 #define LANGUAGE_ID_WIN_EN_US 0x0409 @@ -64,7 +64,6 @@ * macros for calculating values in FontHeader ***********************************************************************/ -#define DEFAULT_CONTINUITY_CUTOFF( value ) ( value / 40 ) // 2.5% of size #define DEFAULT_DEFAULT_CHAR '.' #define BASELINE( value ) ( 3 * value / 4 ) // 75% of size #define DESCENT( value ) ( value / 4 ) // 25% of size @@ -80,13 +79,6 @@ #define MAKE_FONTID( family ) ( FM_TRUETYPE | ( 0x0fff & toHash ( family ))) -/*********************************************************************** - * structues - ***********************************************************************/ - - - - /*********************************************************************** * functions called by driver ***********************************************************************/ diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 9c21eb0fb..1de525fdb 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -41,7 +41,7 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, * result Pointer in wich the result will * stored. * - * RETURNS: TT_Error = FreeType errorcode (see tterrid.h) + * RETURNS: void * * SIDE EFFECTS: none * @@ -53,33 +53,37 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, * 23/12/22 JK Initial Revision * *******************************************************************/ -TT_Error _pascal TrueType_Char_Metrics( +void _pascal TrueType_Char_Metrics( word character, GCM_info info, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, TextStyle stylesToImplement, WWFixedAsDWord pointSize, - dword* result ) + dword* result, + MemHandle varBlock ) { FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; TransformMatrix transMatrix; - TT_Face face; word charIndex; - TT_Outline outline; - TT_Instance instance; - TT_Instance_Metrics instanceMetrics; - TT_CharMap charMap; - TT_Glyph glyph; - TT_Glyph_Metrics glyphMetrics; - TT_Error error; + TrueTypeVars* trueTypeVars; ECCheckBounds( (void*)fontInfo ); ECCheckBounds( (void*)outlineEntry ); + ECCheckMemHandle( varBlock ); + ECCheckStack(); + /* get trueTypeVar block */ + trueTypeVars = MemLock( varBlock ); + if( trueTypeVars == NULL ) + { + MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); + trueTypeVars = MemLock( varBlock ); + } + // get filename an load ttf file FilePushDir(); FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); @@ -91,59 +95,59 @@ TT_Error _pascal TrueType_Char_Metrics( CalcTransformMatrix( stylesToImplement, &transMatrix ); - error = TT_Open_Face( truetypeFile, &face ); - if( error ) + if( TT_Open_Face( truetypeFile, &FACE ) ) goto Fail; // get TT char index - getCharMap( face, &charMap ); + getCharMap( FACE, &CHAR_MAP ); - charIndex = TT_Char_Index( charMap, GeosCharToUnicode( character ) ); + charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); // load glyph - TT_New_Glyph( face, &glyph ); - TT_New_Instance( face, &instance ); + TT_New_Glyph( FACE, &GLYPH ); + TT_New_Instance( FACE, &INSTANCE ); // transform glyphs outline - TT_Get_Glyph_Outline( glyph, &outline ); - TT_Transform_Outline( &outline, &transMatrix.TM_matrix ); - TT_Translate_Outline( &outline, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_shiftY ) ); + TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + TT_Transform_Outline( &OUTLINE, &transMatrix.TM_matrix ); + TT_Translate_Outline( &OUTLINE, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_shiftY ) ); // scale glyph - TT_Set_Instance_CharSize( instance, ( pointSize >> 10 ) ); - TT_Get_Instance_Metrics( instance, &instanceMetrics ); + TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); + TT_Set_Instance_Resolutions( INSTANCE, 72, 72 ); + TT_Get_Instance_Metrics( INSTANCE, &INSTANCE_METRICS ); // get metrics - TT_Get_Glyph_Metrics( glyph, &glyphMetrics ); + TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); switch( info ) { case GCMI_MIN_X: case GCMI_MIN_X_ROUNDED: - *result = SCALE_WORD( glyphMetrics.bbox.xMin, instanceMetrics.x_scale ); + *result = SCALE_WORD( GLYPH_BBOX.xMin, INSTANCE_METRICS.x_scale ); break; case GCMI_MIN_Y: case GCMI_MIN_Y_ROUNDED: - *result = SCALE_WORD( glyphMetrics.bbox.yMin, instanceMetrics.y_scale ); + *result = SCALE_WORD( GLYPH_BBOX.yMin, INSTANCE_METRICS.y_scale ); break; case GCMI_MAX_X: case GCMI_MAX_X_ROUNDED: - *result = SCALE_WORD( glyphMetrics.bbox.xMax, instanceMetrics.x_scale ); + *result = SCALE_WORD( GLYPH_BBOX.xMax, INSTANCE_METRICS.x_scale ); break; case GCMI_MAX_Y: case GCMI_MAX_Y_ROUNDED: - *result = SCALE_WORD( glyphMetrics.bbox.yMax, instanceMetrics.y_scale ); + *result = SCALE_WORD( GLYPH_BBOX.yMax, INSTANCE_METRICS.y_scale ); break; } - TT_Done_Instance( instance ); - TT_Done_Glyph( glyph ); + TT_Done_Instance( INSTANCE ); + TT_Done_Glyph( GLYPH ); Fail: - TT_Close_Face( face ); + TT_Close_Face( FACE ); + MemUnlock( varBlock ); FileClose( truetypeFile, FALSE ); FilePopDir(); - return error; } diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.h b/Driver/Font/TrueType/Adapter/ttmetrics.h index 1c3c93a5f..e82875bce 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.h +++ b/Driver/Font/TrueType/Adapter/ttmetrics.h @@ -21,13 +21,14 @@ #define _TTMETRICS_H_ -TT_Error _pascal TrueType_Char_Metrics( +void _pascal TrueType_Char_Metrics( word character, GCM_info info, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, TextStyle stylesToImplement, WWFixedAsDWord pointSize, - dword* result ); + dword* result, + MemHandle varBlock ); #endif /* _TTMETRICS_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index bdf635e26..8fc7aa42e 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -47,6 +47,7 @@ static void ConvertHeader( static void ConvertWidths( TRUETYPE_VARS, + WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ); @@ -101,6 +102,7 @@ MemHandle _pascal TrueType_Gen_Widths( FontHeader* fontHeader; FontBuf* fontBuf; word size; + WWFixedAsDWord scaleFactor; ECCheckMemHandle( fontHandle ); @@ -147,20 +149,20 @@ MemHandle _pascal TrueType_Gen_Widths( &fontHandle ); /* calculate scale factor and transformation matrix */ - SCALE_FACTOR = CalcScaleForWidths( pointSize, + scaleFactor = CalcScaleForWidths( pointSize, stylesToImplement, FACE_PROPERTIES.header->Units_Per_EM ); /* convert FontHeader and fill FontBuf structure */ fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; - ConvertHeader( SCALE_FACTOR, fontHeader, fontBuf ); + ConvertHeader( scaleFactor, fontHeader, fontBuf ); /* fill kerning pairs and kerning values */ ConvertKernPairs( trueTypeVars, fontBuf ); /* convert widths and fill CharTableEntries */ - ConvertWidths( trueTypeVars, fontHeader, fontBuf ); + ConvertWidths( trueTypeVars, scaleFactor ,fontHeader, fontBuf ); /* calculate the transformation matrix and copy it into the FontBlock */ CalcTransform( (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )), @@ -199,7 +201,7 @@ MemHandle _pascal TrueType_Gen_Widths( * 12/02/23 JK Initial Revision *******************************************************************/ -static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) +static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ) { char currentChar; CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); @@ -212,11 +214,14 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB for( currentChar = fontHeader->FH_firstChar; currentChar < fontHeader->FH_lastChar; currentChar++ ) { + word charIndex; + + ECCheckBounds( (void*)charTableEntry ); //Unicode to TT ID - CHARINDEX = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( currentChar ) ); - if ( CHARINDEX == 0 ) + charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( currentChar ) ); + if ( charIndex == 0 ) { charTableEntry->CTE_flags = CTF_NO_DATA; charTableEntry->CTE_dataOffset = CHAR_NOT_EXIST; @@ -229,11 +234,11 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB } //Glyph laden - TT_Load_Glyph( INSTANCE, GLYPH, CHARINDEX, 0 ); + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); //width berechnen - scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), SCALE_FACTOR ); + scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), scaleFactor ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 4b0abfcd2..ca9ecb0bb 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -697,16 +697,17 @@ /* Set a face object's generic pointer */ +/* EXPORT_DEF TT_Error TT_Set_Face_Pointer( TT_Face face, void* data ); - +*/ /* Get a face object's generic pointer */ - +/* EXPORT_DEF void* TT_Get_Face_Pointer( TT_Face face ); - +*/ /* Close a face's file handle to save system resources. The file */ /* will be re-opened automatically on the next disk access. */ @@ -717,7 +718,7 @@ /* Get a face's glyph metrics expressed in font units. Returns any */ /* number of arrays. Set the fields to NULL if you are not interested */ /* by a given array. */ - +/* EXPORT_DEF TT_Error TT_Get_Face_Metrics( TT_Face face, TT_UShort firstGlyph, @@ -726,7 +727,7 @@ TT_UShort* widths, TT_Short* topBearings, TT_UShort* heights ); - +*/ /* Close a given font object, destroying all associated */ /* instances. */ @@ -736,14 +737,14 @@ /* Get font or table data. */ - +/* EXPORT_DEF TT_Error TT_Get_Font_Data( TT_Face face, TT_ULong tag, TT_Long offset, void* buffer, TT_Long* length ); - +*/ /* A simple macro to build table tags from ASCII chars */ @@ -813,17 +814,17 @@ /* Set an instance's generic pointer. */ - +/* EXPORT_DEF TT_Error TT_Set_Instance_Pointer( TT_Instance instance, void* data ); - +*/ /* Get an instance's generic pointer. */ - +/* EXPORT_DEF void* TT_Get_Instance_Pointer( TT_Instance instance ); - +*/ /* Close a given instance object, destroying all associated data. */ @@ -901,11 +902,11 @@ /* Copy the glyph's big metrics into `metrics'. */ /* Necessary to obtain vertical metrics. */ - +/* EXPORT_DEF TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, TT_Big_Glyph_Metrics* metrics ); - +*/ /* Render the glyph into a bitmap, with given position offsets. */ /* */ @@ -970,10 +971,10 @@ /* Copy an outline into another one. */ - +/* EXPORT_DEF TT_Error TT_Copy_Outline( TT_Outline* source, - TT_Outline* target ); + TT_Outline* target ); */ /* Render an outline into a bitmap. */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index b00d97262..2633795f3 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -292,7 +292,7 @@ extern TEngine_Instance engineInstance; * developers, so it shouldn't be a problem. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Set_Face_Pointer( TT_Face face, void* data ) @@ -307,7 +307,7 @@ extern TEngine_Instance engineInstance; return TT_Err_Ok; } - +*/ /******************************************************************* * @@ -328,7 +328,7 @@ extern TEngine_Instance engineInstance; * developers, so it shouldn't be a problem. * ******************************************************************/ - +/* EXPORT_FUNC void* TT_Get_Face_Pointer( TT_Face face ) { @@ -340,7 +340,7 @@ extern TEngine_Instance engineInstance; else return faze->generic; } - +*/ /******************************************************************* * @@ -396,7 +396,7 @@ extern TEngine_Instance engineInstance; * MT-Note : YES! Reads only permanent data. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Get_Face_Metrics( TT_Face face, TT_UShort firstGlyph, @@ -413,13 +413,13 @@ extern TEngine_Instance engineInstance; if ( !_face ) return TT_Err_Invalid_Face_Handle; - /* Check the glyph range */ + // Check the glyph range if ( lastGlyph >= _face->numGlyphs || firstGlyph > lastGlyph ) return TT_Err_Invalid_Argument; - num = lastGlyph - firstGlyph; /* number of elements-1 in each array */ + num = lastGlyph - firstGlyph; // number of elements-1 in each array - /* store the left side bearings and advance widths first */ + // store the left side bearings and advance widths first { UShort n; Short left_bearing; @@ -436,14 +436,14 @@ extern TEngine_Instance engineInstance; } } - /* check for vertical data if topBearings or heights is non-NULL */ + // check for vertical data if topBearings or heights is non-NULL if ( !topBearings && !heights ) return TT_Err_Ok; if ( !_face->verticalInfo ) return TT_Err_No_Vertical_Data; - /* store the top side bearings */ + // store the top side bearings { UShort n; Short top_bearing; @@ -461,7 +461,7 @@ extern TEngine_Instance engineInstance; return TT_Err_Ok; } - +*/ /******************************************************************* * @@ -877,7 +877,7 @@ extern TEngine_Instance engineInstance; * MT-Note : NO! * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Set_Instance_Pointer( TT_Instance instance, void* data ) @@ -892,7 +892,7 @@ extern TEngine_Instance engineInstance; return TT_Err_Ok; } - +*/ /******************************************************************* * @@ -912,7 +912,7 @@ extern TEngine_Instance engineInstance; * MT-Safe : NO! * ******************************************************************/ - +/* EXPORT_FUNC void* TT_Get_Instance_Pointer( TT_Instance instance ) { @@ -924,7 +924,7 @@ extern TEngine_Instance engineInstance; else return ins->generic; } - +*/ /******************************************************************* * @@ -1158,7 +1158,7 @@ extern TEngine_Instance engineInstance; * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, TT_Big_Glyph_Metrics* metrics ) @@ -1173,7 +1173,7 @@ extern TEngine_Instance engineInstance; return TT_Err_Ok; } - +*/ /******************************************************************* * @@ -1594,7 +1594,7 @@ TT_Error TT_Get_Outline_Region( TT_Outline* outline, * MT-Safe : YES! * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Copy_Outline( TT_Outline* source, TT_Outline* target ) @@ -1619,7 +1619,7 @@ TT_Error TT_Get_Outline_Region( TT_Outline* outline, return TT_Err_Ok; } - +*/ /******************************************************************* * @@ -2072,7 +2072,7 @@ TT_Error TT_Get_Outline_Region( TT_Outline* outline, * MT-Safe : YES! * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Get_Font_Data( TT_Face face, TT_ULong tag, @@ -2088,6 +2088,6 @@ TT_Error TT_Get_Outline_Region( TT_Outline* outline, return Load_TrueType_Any( faze, tag, offset, buffer, length ); } - +*/ /* END */ diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 344a3051b..64074ab89 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -1279,7 +1279,7 @@ * Output : Error condition * ******************************************************************/ - +/* LOCAL_FUNC TT_Error Load_TrueType_Any( PFace face, ULong tag, @@ -1295,7 +1295,7 @@ if ( tag != 0 ) { - /* look for tag in font directory */ + // look for tag in font directory table = TT_LookUp_Table( face, tag ); if ( table < 0 ) return TT_Err_Table_Missing; @@ -1304,7 +1304,7 @@ size = face->dirTables[table].Length; } else - /* tag = 0 -- the use want to access the font file directly */ + // tag = 0 -- the use want to access the font file directly size = TT_Stream_Size( face->stream ); if ( length && *length == 0 ) @@ -1322,6 +1322,6 @@ return error; } - +*/ /* END */ diff --git a/Driver/Font/TrueType/FreeType/ttload.h b/Driver/Font/TrueType/FreeType/ttload.h index 324ddec5c..3538d11b5 100644 --- a/Driver/Font/TrueType/FreeType/ttload.h +++ b/Driver/Font/TrueType/FreeType/ttload.h @@ -49,13 +49,13 @@ LOCAL_DEF TT_Error Load_TrueType_Metrics_Header( PFace face, Bool vertical ); - +/* LOCAL_DEF TT_Error Load_TrueType_Any( PFace face, ULong tag, Long offset, void* buffer, Long* length ); - +*/ LOCAL_DEF TT_Error Free_TrueType_Names( PFace face ); LOCAL_DEF TT_Error Free_TrueType_Hdmx ( PFace face ); diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h index 5257a4da4..29fefa1d8 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.h +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -574,7 +574,7 @@ /* directory to know how to do that. */ /* a generic pointer for client use - see TT_Set/Get_Face_Pointer */ - void* generic; + //void* generic; }; @@ -627,7 +627,7 @@ PExecution_Context context; /* a generic pointer for client use - see TT_Set/Get_Instance_Pointer */ - void* generic; + //void* generic; }; diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index df0a70c3b..08dbb9b71 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -88,6 +88,7 @@ resultAXDX local dword push cx segmov ds, dgroup, cx + push ds:variableHandle call TRUETYPE_CHAR_METRICS mov ax, {word} resultAXDX From bad61e0cb146e94265925f4709c587b8d8fc3cb4 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 27 May 2023 18:08:28 +0200 Subject: [PATCH 164/246] Change type of TT_Error from long to word. --- Driver/Font/TrueType/FreeType/freetype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index ca9ecb0bb..2b7fc8ae2 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -630,7 +630,7 @@ /* Almost all functions return an error code of this type. */ - typedef long TT_Error; + typedef int TT_Error; /* Flags for control path generation for FreeGEOS. */ From 98f9faccf3505b48aa1623aa98c4f6691e89025c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 29 May 2023 21:42:28 +0200 Subject: [PATCH 165/246] Some fixes and optimasations. --- Driver/Font/TrueType/Adapter/ttadapter.h | 2 +- Driver/Font/TrueType/Adapter/ttchars.c | 17 ++++++----- Driver/Font/TrueType/Adapter/ttmetrics.c | 2 +- Driver/Font/TrueType/Adapter/ttwidths.c | 31 ++++++++++---------- Driver/Font/TrueType/FreeType/freetype.h | 4 +-- Driver/Font/TrueType/FreeType/ttapi.c | 6 ++-- Driver/Font/TrueType/FreeType/ttgload.c | 10 +++++-- Driver/Font/TrueType/FreeType/ttobjs.h | 2 +- Driver/Font/TrueType/FreeType/ttraster.c | 4 +-- Driver/Font/TrueType/Main/truetypeWidths.asm | 2 +- 10 files changed, 43 insertions(+), 37 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index c70a5d97a..219d2f2fa 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -53,7 +53,7 @@ extern TEngine_Instance engineInstance; #define SCRIPT_FACTOR 0x00006000 #define SCRIPT_SHIFT_FACTOR 0x00015000 - +#define MAX_BITMAP_SIZE 125 #define MAX_FONTBUF_SIZE 10 * 1024 #define FAMILY_NAME_LENGTH 20 diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 1fe447e53..d2d9f46d9 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -142,10 +142,10 @@ void _pascal TrueType_Gen_Chars( //TODO: verfügbaren Platz prüfen? if( charData == NULL ) { - MemReAlloc( bitmapHandle, /* size */ 1024, HAF_NO_ERR ); + MemReAlloc( bitmapHandle, /* size */ 2048, HAF_NO_ERR ); charData = MemLock( bitmapHandle ); } - memset( charData, 0, size ); + memset( charData, 0, /*size*/ 2048 ); /* init rasterMap */ rasterMap.rows = height; @@ -154,19 +154,20 @@ void _pascal TrueType_Gen_Chars( rasterMap.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; /* translate outline and render it */ - TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); - TT_Get_Outline_Region( &outline, &rasterMap ); + //TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); + TT_Get_Glyph_Region( glyph, &rasterMap, -bbox.xMin, -bbox.yMin ); + //TT_Get_Outline_Region( &outline, &rasterMap ); /* fill header of charData */ ((RegionCharData*)charData)->RCD_xoff = bbox.xMin / 64; - ((RegionCharData*)charData)->RCD_yoff = bbox.yMin / 64; + ((RegionCharData*)charData)->RCD_yoff = fontBuf->FB_baselinePos.WBF_int - ( bbox.yMax / 64 ); ((RegionCharData*)charData)->RCD_size = rasterMap.size; ((RegionCharData*)charData)->RCD_bounds.R_left = 0; ((RegionCharData*)charData)->RCD_bounds.R_right = width; - ((RegionCharData*)charData)->RCD_bounds.R_top = height; - ((RegionCharData*)charData)->RCD_bounds.R_bottom = 0; + ((RegionCharData*)charData)->RCD_bounds.R_top = 0; + ((RegionCharData*)charData)->RCD_bounds.R_bottom = height; - size = rasterMap.size; + size = rasterMap.size + SIZE_REGION_HEADER; } else { diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 1de525fdb..ded922028 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -84,7 +84,7 @@ void _pascal TrueType_Char_Metrics( trueTypeVars = MemLock( varBlock ); } - // get filename an load ttf file + /* get filename an load ttf file */ FilePushDir(); FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 8fc7aa42e..667121462 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -203,7 +203,7 @@ MemHandle _pascal TrueType_Gen_Widths( static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ) { - char currentChar; + word currentChar; CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); WWFixedAsDWord scaledWidth; @@ -212,7 +212,7 @@ static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader TT_New_Instance( FACE, &INSTANCE ); getCharMap( FACE, &CHAR_MAP ); - for( currentChar = fontHeader->FH_firstChar; currentChar < fontHeader->FH_lastChar; currentChar++ ) + for( currentChar = fontHeader->FH_firstChar; currentChar <= fontHeader->FH_lastChar; ++currentChar ) { word charIndex; @@ -229,10 +229,10 @@ static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader charTableEntry->CTE_width.WBF_frac = 0; charTableEntry->CTE_usage = 0; - charTableEntry++; + ++charTableEntry; continue; } - + //Glyph laden TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); @@ -242,7 +242,7 @@ static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); - /* nur TEST */ + // nur TEST charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; charTableEntry->CTE_flags = 0; charTableEntry->CTE_usage = 0; @@ -268,7 +268,7 @@ static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader //second kern } - charTableEntry++; + ++charTableEntry; } TT_Done_Instance( INSTANCE ); @@ -501,13 +501,6 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* /* Fill elements in FontBuf structure. */ - fontBuf->FB_maker = FM_TRUETYPE; - fontBuf->FB_kernPairPtr = 0; - fontBuf->FB_kernValuePtr = 0; - fontBuf->FB_kernCount = 0; - fontBuf->FB_heapCount = 0; - fontBuf->FB_flags = FBF_IS_OUTLINE; - ttfElement = SCALE_WORD( fontHeader->FH_avgwidth, scaleFactor ); fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); @@ -578,9 +571,15 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleFactor ); fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - fontBuf->FB_firstChar = fontHeader->FH_firstChar; - fontBuf->FB_lastChar = fontHeader->FH_lastChar; - fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; + fontBuf->FB_maker = FM_TRUETYPE; + fontBuf->FB_kernPairPtr = 0; + fontBuf->FB_kernValuePtr = 0; + fontBuf->FB_kernCount = 0; + fontBuf->FB_heapCount = 0; + fontBuf->FB_flags = fontBuf->FB_pixHeight < 125 ? FBF_IS_OUTLINE : FBF_IS_REGION; + fontBuf->FB_firstChar = fontHeader->FH_firstChar; + fontBuf->FB_lastChar = fontHeader->FH_lastChar; + fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; } static word round( WWFixedAsDWord toRound ) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 2b7fc8ae2..4828fa910 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -799,12 +799,12 @@ /* This function has been deprecated! Do not use it, as it */ /* doesn't work reliably. You can perfectly control hinting */ /* yourself when loading glyphs, then apply transforms as usual. */ - +/* EXPORT_DEF TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, TT_Bool rotated, TT_Bool stretched ); - +*/ /* Return instance metrics in `metrics'. */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 2633795f3..03e724c70 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -792,7 +792,7 @@ extern TEngine_Instance engineInstance; * instances, so there is no need to protect. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, TT_Bool rotated, @@ -809,7 +809,7 @@ extern TEngine_Instance engineInstance; ins->valid = FALSE; return TT_Err_Ok; - } + }*/ /******************************************************************* @@ -1285,7 +1285,7 @@ extern TEngine_Instance engineInstance; TT_Transform_Outline( &outline, &flipmatrix ); TT_Translate_Outline( &outline, xOffset, yOffset + map->rows * 64 ); error = TT_Get_Outline_Region( &outline, map ); - TT_Translate_Outline( &outline, -xOffset, -yOffset - map->rows * 64 ); + TT_Translate_Outline( &outline, -xOffset, - ( yOffset + map->rows * 64 ) ); TT_Transform_Outline( &outline, &flipmatrix ); return error; diff --git a/Driver/Font/TrueType/FreeType/ttgload.c b/Driver/Font/TrueType/FreeType/ttgload.c index 0c58cf196..069738212 100644 --- a/Driver/Font/TrueType/FreeType/ttgload.c +++ b/Driver/Font/TrueType/FreeType/ttgload.c @@ -199,6 +199,9 @@ TT_F26Dot6 x, y; + ECCheckStack(); + + face = exec->face; /* simple check */ @@ -568,7 +571,7 @@ UShort load_top; Long k, l; UShort new_flags; - Long index; + Short index; UShort u, v; Long glyph_offset, offset; @@ -590,6 +593,9 @@ /* TT_Outline cached_outline; */ + ECCheckStack(); + + /* first of all, check arguments */ if ( !glyph ) return TT_Err_Invalid_Glyph_Handle; @@ -702,7 +708,7 @@ UShort advance_width; - Get_HMetrics( face, (UShort)index, + Get_HMetrics( face, index, !(load_flags & TTLOAD_IGNORE_GLOBAL_ADVANCE_WIDTH), &left_bearing, &advance_width ); diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h index 29fefa1d8..d71e53465 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.h +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -352,7 +352,7 @@ /* subglyph loading record. Used to load composite components */ struct TSubglyph_Record_ { - Long index; /* subglyph index; initialized with -1 */ + Short index; /* subglyph index; initialized with -1 */ Bool is_scaled; /* is the subglyph scaled? */ Bool is_hinted; /* should it be hinted? */ Bool preserve_pps; /* preserve phantom points? */ diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index ac9f59f27..2584ddf97 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -1772,8 +1772,8 @@ *targetLastLine = *target; ras.traceIncr = 0; return; - } - + } + /* move to the next line */ diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index ed31a75b2..2540da7d5 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -61,7 +61,7 @@ TrueTypeGenWidths proc far mov bx, bp .enter - + push di ; font handle or 0 push bx ; send tMatrix ptr From f81f2c799995b9452fc959303d94e7c05f78c176 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 30 May 2023 21:17:43 +0200 Subject: [PATCH 166/246] Regions are rendered. --- Driver/Font/TrueType/Adapter/ttchars.c | 8 +++++--- Driver/Font/TrueType/FreeType/ttapi.c | 1 - Driver/Font/TrueType/FreeType/ttgload.c | 9 --------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index d2d9f46d9..78c2fc585 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -134,6 +134,8 @@ void _pascal TrueType_Gen_Chars( if( fontBuf->FB_flags & FBF_IS_REGION ) { + TT_Matrix flipmatrix = HORIZONTAL_FLIP_MATRIX; + /* We calculate with an average of 4 on/off points, line number and line end code. */ size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; @@ -154,9 +156,9 @@ void _pascal TrueType_Gen_Chars( rasterMap.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; /* translate outline and render it */ - //TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); - TT_Get_Glyph_Region( glyph, &rasterMap, -bbox.xMin, -bbox.yMin ); - //TT_Get_Outline_Region( &outline, &rasterMap ); + TT_Transform_Outline( &outline, &flipmatrix ); + TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin + bbox.yMax ); + TT_Get_Outline_Region( &outline, &rasterMap ); /* fill header of charData */ ((RegionCharData*)charData)->RCD_xoff = bbox.xMin / 64; diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 03e724c70..5b3df0b1e 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -1229,7 +1229,6 @@ extern TEngine_Instance engineInstance; #ifdef __GEOS__ -#define HORIZONTAL_FLIP_MATRIX { ( 1L << 16 ), 0, 0, -1 * ( 1L << 16 ) } /******************************************************************* * diff --git a/Driver/Font/TrueType/FreeType/ttgload.c b/Driver/Font/TrueType/FreeType/ttgload.c index 069738212..7210892e6 100644 --- a/Driver/Font/TrueType/FreeType/ttgload.c +++ b/Driver/Font/TrueType/FreeType/ttgload.c @@ -199,9 +199,6 @@ TT_F26Dot6 x, y; - ECCheckStack(); - - face = exec->face; /* simple check */ @@ -589,12 +586,6 @@ TPhases phase; PByte widths; -/* TT_Glyph_Loader_Callback cacheCb; */ -/* TT_Outline cached_outline; */ - - - ECCheckStack(); - /* first of all, check arguments */ if ( !glyph ) From 27ca0d370e231f723654e0bb7e237af60fd3411f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 1 Jun 2023 21:24:25 +0200 Subject: [PATCH 167/246] Placement of regions on baseline corrected. --- Driver/Font/TrueType/Adapter/ttchars.c | 2 +- Driver/Font/TrueType/FreeType/freetype.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 78c2fc585..edd881008 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -157,7 +157,7 @@ void _pascal TrueType_Gen_Chars( /* translate outline and render it */ TT_Transform_Outline( &outline, &flipmatrix ); - TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin + bbox.yMax ); + TT_Translate_Outline( &outline, -bbox.xMin, bbox.yMin + bbox.yMax ); TT_Get_Outline_Region( &outline, &rasterMap ); /* fill header of charData */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 4828fa910..8afea6e5d 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -1007,6 +1007,9 @@ TT_Matrix* matrix ); +#define HORIZONTAL_FLIP_MATRIX { ( 1L << 16 ), 0, 0, -1 * ( 1L << 16 ) } + + /* Apply a translation to a glyph outline. */ EXPORT_DEF From a326eea1e7bcd684d88419f5598d22fe25e6134e Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 6 Jun 2023 22:17:52 +0200 Subject: [PATCH 168/246] TTF driver further stabilised. --- Driver/Font/TrueType/FreeType/freetype.h | 13 ++++--------- Driver/Font/TrueType/FreeType/ttapi.c | 16 ++++++++-------- Driver/Font/TrueType/FreeType/ttraster.c | 11 +---------- Driver/Font/TrueType/Main/truetypeWidths.asm | 12 +++++++++++- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 8afea6e5d..abbb2a8cf 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -342,13 +342,8 @@ int cols; /* number of columns (bytes) per row */ int width; /* number of pixels per line */ int flow; /* bitmap orientation */ - void* bitmap; /* bit/pixmap buffer */ -#ifndef __GEOS__ - long size; /* bit/pixmap size in bytes */ -#else int size; /* bit/pixmap/region size in bytes */ -#endif /* __GEOS__ */ }; typedef struct TT_Raster_Map_ TT_Raster_Map; @@ -915,12 +910,12 @@ /* (where vertical and horizontal stems aren't grayed). This */ /* means that `xOffset' and `yOffset' must be multiples */ /* of 64! */ - +/* EXPORT_DEF TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, TT_Raster_Map* map, TT_F26Dot6 xOffset, - TT_F26Dot6 yOffset ); + TT_F26Dot6 yOffset );*/ /* Render the glyph into a region, with given position offsets. */ @@ -930,12 +925,12 @@ /* (where vertical and horizontal stems aren't grayed). This */ /* means that `xOffset' and `yOffset' must be multiples */ /* of 64! */ - + /* EXPORT_DEF TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, TT_Raster_Map* map, TT_F26Dot6 xOffset, - TT_F26Dot6 yOffset ); + TT_F26Dot6 yOffset ); */ /* Render the glyph into the passed GEOS regionpath. */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 5b3df0b1e..974f87ee8 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -1195,7 +1195,7 @@ extern TEngine_Instance engineInstance; * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, TT_Raster_Map* map, @@ -1215,8 +1215,8 @@ extern TEngine_Instance engineInstance; _engine = _glyph->face->engine; outline = _glyph->outline; - /* XXX : For now, use only dropout mode 2 */ - /* outline.dropout_mode = _glyph->scan_type; */ + // XXX : For now, use only dropout mode 2 + // outline.dropout_mode = _glyph->scan_type; outline.dropout_mode = 2; TT_Translate_Outline( &outline, xOffset, yOffset ); @@ -1225,7 +1225,7 @@ extern TEngine_Instance engineInstance; return error; } - +*/ #ifdef __GEOS__ @@ -1256,7 +1256,7 @@ extern TEngine_Instance engineInstance; * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Get_Glyph_Region( TT_Glyph glyph, TT_Raster_Map* map, @@ -1277,8 +1277,8 @@ extern TEngine_Instance engineInstance; _engine = _glyph->face->engine; outline = _glyph->outline; - /* XXX : For now, use only dropout mode 2 */ - /* outline.dropout_mode = _glyph->scan_type; */ + // XXX : For now, use only dropout mode 2 + // outline.dropout_mode = _glyph->scan_type; outline.dropout_mode = 2; TT_Transform_Outline( &outline, &flipmatrix ); @@ -1289,7 +1289,7 @@ extern TEngine_Instance engineInstance; return error; } - +*/ /******************************************************************* * diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 2584ddf97..42569d1ec 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -1845,15 +1845,6 @@ } } } -#if 0 - e2 = TRUNC( e2 ); - - if ( e2 >= 0 && e2 < ras.target.rows ) - if ( ras.target.flow == TT_Flow_Down ) - bits[(ras.target.rows-1-e2) * ras.target.cols] |= f1; - else - bits[e2 * ras.target.cols] |= f1; -#endif } @@ -2261,7 +2252,7 @@ { case TT_Flow_Up: InsNew( &draw_left, P ); break; case TT_Flow_Down: InsNew( &draw_right, P ); break; - } + } } P = Q; diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index 2540da7d5..6450e70d7 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -62,7 +62,14 @@ TrueTypeGenWidths proc far mov bx, bp .enter - push di ; font handle or 0 + ;TEST + xchg di, ax + mov di, 800 + call ThreadBorrowStackSpace + push di + + ;push di ; font handle or 0 + push ax push bx ; send tMatrix ptr push cx @@ -106,6 +113,9 @@ TrueTypeGenWidths proc far call MemDerefDS segmov ax, ds + pop di + call ThreadReturnStackSpace + clc ;indicate no error .leave From 90fbae2b0a2ddd976f07bd4b77d0c8c34575f66c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 7 Jun 2023 20:27:54 +0200 Subject: [PATCH 169/246] Code for bitmap orientation removed. --- Driver/Font/TrueType/Adapter/ttchars.c | 4 ++-- Driver/Font/TrueType/FreeType/freetype.h | 2 +- Driver/Font/TrueType/FreeType/ttraster.c | 24 ++++++++++---------- Driver/Font/TrueType/Main/truetypeWidths.asm | 5 +--- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index edd881008..b7849fe09 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -152,7 +152,7 @@ void _pascal TrueType_Gen_Chars( /* init rasterMap */ rasterMap.rows = height; rasterMap.width = width; - rasterMap.flow = TT_Flow_Down; + //rasterMap.flow = TT_Flow_Down; rasterMap.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; /* translate outline and render it */ @@ -190,7 +190,7 @@ void _pascal TrueType_Gen_Chars( rasterMap.width = width; rasterMap.cols = (width + 7) / 8; rasterMap.size = rasterMap.rows * rasterMap.cols; - rasterMap.flow = TT_Flow_Down; + //rasterMap.flow = TT_Flow_Down; rasterMap.bitmap = ((byte*)charData) + SIZE_CHAR_HEADER; /* translate outline and render it */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index abbb2a8cf..8a95cd430 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -341,7 +341,7 @@ int rows; /* number of rows */ int cols; /* number of columns (bytes) per row */ int width; /* number of pixels per line */ - int flow; /* bitmap orientation */ + // int flow; /* bitmap orientation */ void* bitmap; /* bit/pixmap buffer */ int size; /* bit/pixmap/region size in bytes */ }; diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 42569d1ec..913f2121d 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -1499,17 +1499,17 @@ static void Vertical_Sweep_Init( RAS_ARGS Short* min, Short* max ) { - switch ( ras.target.flow ) + /*switch ( ras.target.flow ) { case TT_Flow_Up: ras.traceOfs = *min * ras.target.cols; ras.traceIncr = ras.target.cols; - break; + break;*/ - default: + //default: ras.traceOfs = ( ras.target.rows - 1 - *min ) * ras.target.cols; ras.traceIncr = -ras.target.cols; - } + //} } @@ -1838,9 +1838,9 @@ if ( e1 >= 0 && e1 < ras.target.rows ) { - if ( ras.target.flow == TT_Flow_Down ) + /*if ( ras.target.flow == TT_Flow_Down ) bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1; - else + else*/ bits[e1 * ras.target.cols] |= f1; } } @@ -1903,10 +1903,10 @@ bits = ras.bTarget + (y >> 3); f1 = (Byte)(0x80 >> (y & 7)); - if ( ras.target.flow == TT_Flow_Down ) + //if ( ras.target.flow == TT_Flow_Down ) bits += (ras.target.rows-1-e1) * ras.target.cols; - else - bits += e1 * ras.target.cols; + /*else + bits += e1 * ras.target.cols;*/ if ( e1 >= 0 && e1 < ras.target.rows && @@ -1935,10 +1935,10 @@ if ( e1 >= 0 && e1 < ras.target.rows ) { - if (ras.target.flow==TT_Flow_Down) + //if (ras.target.flow==TT_Flow_Down) bits[(ras.target.rows-1-e1) * ras.target.cols] |= f1; - else - bits[e1 * ras.target.cols] |= f1; + /*else + bits[e1 * ras.target.cols] |= f1;*/ } } diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index 6450e70d7..01692b79e 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -62,15 +62,12 @@ TrueTypeGenWidths proc far mov bx, bp .enter - ;TEST xchg di, ax mov di, 800 call ThreadBorrowStackSpace push di - ;push di ; font handle or 0 - push ax - + push ax ; pass fonthandel push bx ; send tMatrix ptr push cx From 811eecb03e0fe70b9ea0f47475cf5d6653f8796d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 12 Jun 2023 21:57:09 +0200 Subject: [PATCH 170/246] Ensure the bitmapblock is always enough in size. --- Driver/Font/TrueType/Adapter/ttadapter.h | 6 +- Driver/Font/TrueType/Adapter/ttchars.c | 142 +++++++++++--------- Driver/Font/TrueType/Adapter/ttchars.h | 3 +- Driver/Font/TrueType/FreeType/freetype.h | 14 +- Driver/Font/TrueType/FreeType/ttapi.c | 4 +- Driver/Font/TrueType/FreeType/ttraster.c | 33 +---- Driver/Font/TrueType/Main/truetypeChars.asm | 2 +- 7 files changed, 90 insertions(+), 114 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 219d2f2fa..fba041d98 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -55,9 +55,10 @@ extern TEngine_Instance engineInstance; #define MAX_BITMAP_SIZE 125 #define MAX_FONTBUF_SIZE 10 * 1024 +#define BITMAP_BLOCKSIZE 2 * 1024 -#define FAMILY_NAME_LENGTH 20 -#define STYLE_NAME_LENGTH 16 +#define FAMILY_NAME_LENGTH 20 +#define STYLE_NAME_LENGTH 16 /*********************************************************************** @@ -362,6 +363,7 @@ typedef struct #define OUTLINE trueTypeVars->outline #define GLYPH_METRICS trueTypeVars->glyphMetrics #define GLYPH_BBOX trueTypeVars->glyphMetrics.bbox +#define RASTER_MAP trueTypeVars->rasterMap #define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index b7849fe09..2f80d9409 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -33,6 +33,7 @@ static void AdjustPointers( CharTableEntry* charTableEntries, word numOfChars ); static word ShiftCharData( FontBuf* fontBuf, CharData* charData ); static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ); +static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ); /******************************************************************** @@ -66,19 +67,13 @@ void _pascal TrueType_Gen_Chars( WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - MemHandle bitmapHandle - ) + MemHandle bitmapHandle, + MemHandle varBlock ) { FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; - TT_Face face; - TT_Instance instance; - TT_Glyph glyph; - TT_Outline outline; - TT_BBox bbox; - TT_CharMap charMap; TT_UShort charIndex; - TT_Raster_Map rasterMap; + TrueTypeVars* trueTypeVars; void* charData; word width, height, size; @@ -86,7 +81,16 @@ void _pascal TrueType_Gen_Chars( ECCheckBounds( (void*)fontBuf ); ECCheckBounds( (void*)fontInfo ); ECCheckBounds( (void*)outlineEntry ); - ECCheckStack(); + ECCheckMemHandle( bitmapHandle ); + ECCheckMemHandle( varBlock ); + + /* get trueTypeVar block */ + trueTypeVars = MemLock( varBlock ); + if( trueTypeVars == NULL ) + { + MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); + trueTypeVars = MemLock( varBlock ); + } FilePushDir(); @@ -99,38 +103,38 @@ void _pascal TrueType_Gen_Chars( ECCheckFileHandle( truetypeFile ); /* open face, create instance and glyph */ - if( TT_Open_Face( truetypeFile, &face ) ) + if( TT_Open_Face( truetypeFile, &FACE ) ) goto Fail; - TT_New_Glyph( face, &glyph ); - TT_New_Instance( face, &instance ); - TT_Set_Instance_Resolutions( instance, 72, 72 ); + TT_New_Glyph( FACE, &GLYPH ); + TT_New_Instance( FACE, &INSTANCE ); + TT_Set_Instance_Resolutions( INSTANCE, 72, 72 ); /* get TT char index */ - getCharMap( face, &charMap ); - charIndex = TT_Char_Index( charMap, GeosCharToUnicode( character ) ); + getCharMap( FACE, &CHAR_MAP ); + charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); /* set pointsize and get metrics */ - TT_Set_Instance_CharSize( instance, ( pointSize >> 10 ) ); + TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); /* load glyph and load glyphs outline */ - TT_Load_Glyph( instance, glyph, charIndex, TTLOAD_DEFAULT ); + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, TTLOAD_DEFAULT ); // TODO: Transformationsmatrix anwenden - TT_Get_Glyph_Outline( glyph, &outline ); - TT_Get_Outline_BBox( &outline, &bbox ); + TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + TT_Get_Outline_BBox( &OUTLINE, &GLYPH_BBOX ); /* Grid-fit it */ - bbox.xMin &= -64; - bbox.xMax = ( bbox.xMax + 63 ) & -64; - bbox.yMin &= -64; - bbox.yMax = ( bbox.yMax + 63 ) & -64; + GLYPH_BBOX.xMin &= -64; + GLYPH_BBOX.xMax = ( GLYPH_BBOX.xMax + 63 ) & -64; + GLYPH_BBOX.yMin &= -64; + GLYPH_BBOX.yMax = ( GLYPH_BBOX.yMax + 63 ) & -64; /* compute pixel dimensions */ - width = (bbox.xMax - bbox.xMin) / 64; - height = (bbox.yMax - bbox.yMin) / 64; + width = (GLYPH_BBOX.xMax - GLYPH_BBOX.xMin) / 64; + height = (GLYPH_BBOX.yMax - GLYPH_BBOX.yMin) / 64; if( fontBuf->FB_flags & FBF_IS_REGION ) { @@ -140,72 +144,56 @@ void _pascal TrueType_Gen_Chars( size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; /* get pointer to bitmapBlock */ - charData = MemLock( bitmapHandle ); - //TODO: verfügbaren Platz prüfen? - if( charData == NULL ) - { - MemReAlloc( bitmapHandle, /* size */ 2048, HAF_NO_ERR ); - charData = MemLock( bitmapHandle ); - } - memset( charData, 0, /*size*/ 2048 ); + charData = ensureBitmapBlock( bitmapHandle, size ); - /* init rasterMap */ - rasterMap.rows = height; - rasterMap.width = width; - //rasterMap.flow = TT_Flow_Down; - rasterMap.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; + /* init RASTER_MAP */ + RASTER_MAP.rows = height; + RASTER_MAP.width = width; + RASTER_MAP.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; /* translate outline and render it */ - TT_Transform_Outline( &outline, &flipmatrix ); - TT_Translate_Outline( &outline, -bbox.xMin, bbox.yMin + bbox.yMax ); - TT_Get_Outline_Region( &outline, &rasterMap ); + TT_Transform_Outline( &OUTLINE, &flipmatrix ); + TT_Translate_Outline( &OUTLINE, -GLYPH_BBOX.xMin, GLYPH_BBOX.yMin + GLYPH_BBOX.yMax ); + TT_Get_Outline_Region( &OUTLINE, &RASTER_MAP ); /* fill header of charData */ - ((RegionCharData*)charData)->RCD_xoff = bbox.xMin / 64; - ((RegionCharData*)charData)->RCD_yoff = fontBuf->FB_baselinePos.WBF_int - ( bbox.yMax / 64 ); - ((RegionCharData*)charData)->RCD_size = rasterMap.size; + ((RegionCharData*)charData)->RCD_xoff = GLYPH_BBOX.xMin / 64; + ((RegionCharData*)charData)->RCD_yoff = fontBuf->FB_baselinePos.WBF_int - ( GLYPH_BBOX.yMax / 64 ); + ((RegionCharData*)charData)->RCD_size = RASTER_MAP.size; ((RegionCharData*)charData)->RCD_bounds.R_left = 0; ((RegionCharData*)charData)->RCD_bounds.R_right = width; ((RegionCharData*)charData)->RCD_bounds.R_top = 0; ((RegionCharData*)charData)->RCD_bounds.R_bottom = height; - size = rasterMap.size + SIZE_REGION_HEADER; + size = RASTER_MAP.size + SIZE_REGION_HEADER; } else { size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; /* get pointer to bitmapBlock */ - charData = MemLock( bitmapHandle ); - //TODO: verfügbaren Platz prüfen? - if( charData == NULL ) - { - MemReAlloc( bitmapHandle, /* size */ 1024, HAF_NO_ERR ); - charData = MemLock( bitmapHandle ); - } - memset( charData, 0, size ); + charData = ensureBitmapBlock( bitmapHandle, size ); /* init rasterMap */ - rasterMap.rows = height; - rasterMap.width = width; - rasterMap.cols = (width + 7) / 8; - rasterMap.size = rasterMap.rows * rasterMap.cols; - //rasterMap.flow = TT_Flow_Down; - rasterMap.bitmap = ((byte*)charData) + SIZE_CHAR_HEADER; + RASTER_MAP.rows = height; + RASTER_MAP.width = width; + RASTER_MAP.cols = (width + 7) / 8; + RASTER_MAP.size = RASTER_MAP.rows * RASTER_MAP.cols; + RASTER_MAP.bitmap = ((byte*)charData) + SIZE_CHAR_HEADER; /* translate outline and render it */ - TT_Translate_Outline( &outline, -bbox.xMin, -bbox.yMin ); - TT_Get_Outline_Bitmap( &outline, &rasterMap ); + TT_Translate_Outline( &OUTLINE, -GLYPH_BBOX.xMin, -GLYPH_BBOX.yMin ); + TT_Get_Outline_Bitmap( &OUTLINE, &RASTER_MAP ); /* fill header of charData */ ((CharData*)charData)->CD_pictureWidth = width; ((CharData*)charData)->CD_numRows = height; - ((CharData*)charData)->CD_xoff = bbox.xMin / 64; - ((CharData*)charData)->CD_yoff = fontBuf->FB_baselinePos.WBF_int - ( bbox.yMax / 64 ); + ((CharData*)charData)->CD_xoff = GLYPH_BBOX.xMin / 64; + ((CharData*)charData)->CD_yoff = fontBuf->FB_baselinePos.WBF_int - ( GLYPH_BBOX.yMax / 64 ) + 1; } - TT_Done_Glyph( glyph ); - TT_Done_Instance( instance ); + TT_Done_Glyph( GLYPH ); + TT_Done_Instance( INSTANCE ); if( fontBuf->FB_dataSize > MAX_FONTBUF_SIZE ) ShrinkFontBuf( fontBuf ); @@ -225,9 +213,10 @@ void _pascal TrueType_Gen_Chars( /* cleanup */ MemUnlock( bitmapHandle ); Fail: - TT_Close_Face( face ); + TT_Close_Face( FACE ); FileClose( truetypeFile, FALSE ); FilePopDir(); + MemUnlock( varBlock ); } @@ -371,3 +360,22 @@ static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ) return size; } + +static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ) +{ + void* bitmapData = MemLock( bitmapHandle ); + if( bitmapData == NULL ) + { + MemReAlloc( bitmapHandle, MAX( size, 1024 ), HAF_NO_ERR ); + bitmapData = MemLock( bitmapHandle ); + } else { + if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) + { + MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); + bitmapData = MemLock( bitmapHandle ); + } + } + memset( bitmapData, 0, size ); + + return bitmapData; +} diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index b87c348ea..ed4efab25 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -39,7 +39,8 @@ void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - MemHandle bitmapBlock ); + MemHandle bitmapBlock, + MemHandle varBlock ); #endif /* _TTCHARS_H_ */ diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 8a95cd430..e58520bfe 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -320,28 +320,18 @@ /* rows = H */ /* cols = (W+7) / 8 */ /* width = W */ - /* flow = your_choice */ - /* */ - /* - for a WxH pixmap: */ - /* */ - /* rows = H */ - /* cols = (W+3) & ~3 */ - /* width = cols */ - /* flow = your_choice */ /* */ /* - for a WxH region: */ /* */ /* rows = H */ /* cols = W */ /* width = cols */ - /* flow = your_choise */ struct TT_Raster_Map_ { int rows; /* number of rows */ int cols; /* number of columns (bytes) per row */ int width; /* number of pixels per line */ - // int flow; /* bitmap orientation */ void* bitmap; /* bit/pixmap buffer */ int size; /* bit/pixmap/region size in bytes */ }; @@ -706,10 +696,10 @@ /* Close a face's file handle to save system resources. The file */ /* will be re-opened automatically on the next disk access. */ - +/* EXPORT_DEF TT_Error TT_Flush_Face( TT_Face face ); - +*/ /* Get a face's glyph metrics expressed in font units. Returns any */ /* number of arrays. Set the fields to NULL if you are not interested */ /* by a given array. */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 974f87ee8..9af51367f 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -479,7 +479,7 @@ extern TEngine_Instance engineInstance; * MT-Note : YES! (If ttfile is.) * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Flush_Face( TT_Face face ) { @@ -491,7 +491,7 @@ extern TEngine_Instance engineInstance; else return TT_Flush_Stream( &faze->stream ); } - +*/ /******************************************************************* * diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 913f2121d..77e7eb826 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -1499,18 +1499,8 @@ static void Vertical_Sweep_Init( RAS_ARGS Short* min, Short* max ) { - /*switch ( ras.target.flow ) - { - case TT_Flow_Up: - ras.traceOfs = *min * ras.target.cols; - ras.traceIncr = ras.target.cols; - break;*/ - - //default: - ras.traceOfs = ( ras.target.rows - 1 - *min ) * ras.target.cols; - ras.traceIncr = -ras.target.cols; - //} - + ras.traceOfs = ( ras.target.rows - 1 - *min ) * ras.target.cols; + ras.traceIncr = -ras.target.cols; } @@ -1837,12 +1827,7 @@ e1 = TRUNC( e1 ); if ( e1 >= 0 && e1 < ras.target.rows ) - { - /*if ( ras.target.flow == TT_Flow_Down ) - bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1; - else*/ - bits[e1 * ras.target.cols] |= f1; - } + bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1; } } } @@ -1903,10 +1888,7 @@ bits = ras.bTarget + (y >> 3); f1 = (Byte)(0x80 >> (y & 7)); - //if ( ras.target.flow == TT_Flow_Down ) - bits += (ras.target.rows-1-e1) * ras.target.cols; - /*else - bits += e1 * ras.target.cols;*/ + bits += (ras.target.rows-1-e1) * ras.target.cols; if ( e1 >= 0 && e1 < ras.target.rows && @@ -1934,12 +1916,7 @@ e1 = TRUNC( e1 ); if ( e1 >= 0 && e1 < ras.target.rows ) - { - //if (ras.target.flow==TT_Flow_Down) bits[(ras.target.rows-1-e1) * ras.target.cols] |= f1; - /*else - bits[e1 * ras.target.cols] |= f1;*/ - } } @@ -2684,7 +2661,6 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, #ifndef TT_CONFIG_OPTION_STATIC_RASTER FREE( engine->raster_component ); - //GFREE( engine->raster_component ); #endif return TT_Err_Ok; @@ -2702,7 +2678,6 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, ras = engine->raster_component = &cur_ras; #else if ( ALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) - //if ( GALLOC( engine->raster_component, sizeof ( TRaster_Instance ) ) ) return error; ras = (TRaster_Instance*)engine->raster_component; diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index d285ce9ac..0c5485402 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -86,6 +86,7 @@ TrueTypeGenChar proc far segmov ds, dgroup, ax push ds:bitmapHandle + push ds:variableHandle call TRUETYPE_GEN_CHARS ; deref font block (may have moved) @@ -98,4 +99,3 @@ err: ret TrueTypeGenChar endp - From 280a6b6310c039ab3c6e8d530d6ab0e45ba3ad5b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 18 Jun 2023 20:34:15 +0200 Subject: [PATCH 171/246] Begin to implement FontMatix support. --- CInclude/geos.h | 4 ++ Driver/Font/TrueType/Adapter/ttadapter.h | 20 ++++++++ Driver/Font/TrueType/Adapter/ttchars.c | 20 +++++--- Driver/Font/TrueType/Adapter/ttwidths.h | 11 ----- Driver/Font/TrueType/backlog.md | 63 ++++++++---------------- 5 files changed, 57 insertions(+), 61 deletions(-) diff --git a/CInclude/geos.h b/CInclude/geos.h index 1408ff6f0..5c0231408 100644 --- a/CInclude/geos.h +++ b/CInclude/geos.h @@ -372,6 +372,10 @@ typedef struct { sdword DWF_int; } DWFixed; +typedef struct { + dword DDF_frac; + sdword DDF_int; +} DDFixed; typedef WordFlags CPUFlags; #define CPU_OVERFLOW_OFFSET (11) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index fba041d98..578e39c9a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -268,6 +268,26 @@ typedef struct WWFixedAsDWord TM_shiftY; } TransformMatrix; +typedef ByteFlags TransFlags; +#define TF_INV_VALID 0x08 +#define TF_ROTATED 0x04 +#define TF_SCALED 0x02 +#define TF_TRANSLATED 0x01 + +typedef struct +{ + WWFixedAsDWord FM_11; + WWFixedAsDWord FM_12; + WWFixedAsDWord FM_21; + WWFixedAsDWord FM_22; + WWFixedAsDWord FM_31; + WWFixedAsDWord FM_32; + DDFixed FM_xInv; /* inverse translation factor (x coords) */ + DDFixed FM_yInv; /* inverse translation factor (y coords) */ + TransFlags FM_flags; +} FontMatrix; + + /* * drivers CharData structure (see fontDr.def) */ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 2f80d9409..7debb9763 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -71,9 +71,11 @@ void _pascal TrueType_Gen_Chars( MemHandle varBlock ) { FileHandle truetypeFile; + MemHandle fontBufHandle; TrueTypeOutlineEntry* trueTypeOutline; TT_UShort charIndex; TrueTypeVars* trueTypeVars; + TransformMatrix* transformMatrix; void* charData; word width, height, size; @@ -119,11 +121,13 @@ void _pascal TrueType_Gen_Chars( /* load glyph and load glyphs outline */ TT_Load_Glyph( INSTANCE, GLYPH, charIndex, TTLOAD_DEFAULT ); + TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); // TODO: Transformationsmatrix anwenden + transformMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + ( fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1 ) * sizeof( CharTableEntry )); + TT_Transform_Outline( &OUTLINE, &transformMatrix->TM_matrix ); - - TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + /* get glyphs boundig box */ TT_Get_Outline_BBox( &OUTLINE, &GLYPH_BBOX ); /* Grid-fit it */ @@ -149,6 +153,7 @@ void _pascal TrueType_Gen_Chars( /* init RASTER_MAP */ RASTER_MAP.rows = height; RASTER_MAP.width = width; + RASTER_MAP.cols = width; RASTER_MAP.bitmap = ((byte*)charData) + SIZE_REGION_HEADER; /* translate outline and render it */ @@ -199,13 +204,12 @@ void _pascal TrueType_Gen_Chars( ShrinkFontBuf( fontBuf ); /* realloc FontBuf if necessary */ - /* if( MemGetInfo( MemPtrToHandle( fontBuf ), MGIT_SIZE ) < fontBuf->FB_dataSize + size ) + fontBufHandle = MemPtrToHandle( fontBuf ); + if( MemGetInfo( fontBufHandle, MGIT_SIZE ) < fontBuf->FB_dataSize + size ) { - MemReAlloc( PtrToSegment( fontBuf ), - fontBuf->FB_dataSize + size, - HAF_STANDARD_NO_ERR ); - fontBuf = MemDeref( PtrToSegment( fontBuf )); - } */ + MemReAlloc( fontBufHandle, fontBuf->FB_dataSize + size, HAF_STANDARD_NO_ERR ); + fontBuf = MemDeref( fontBufHandle ); + } /* add rendered glyph to fontbuf */ CopyChar( fontBuf, character, charData ,size ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 4a6d6e934..428e81c4f 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -29,17 +29,6 @@ * structues ***********************************************************************/ -/* - * c definition of drivers FontMatrix structure - */ -typedef struct -{ - WWFixedAsDWord FM_11; - WWFixedAsDWord FM_12; - WWFixedAsDWord FM_21; - WWFixedAsDWord FM_22; -} FontMatrix; - /*********************************************************************** * functions called by driver diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md index ba5338d6a..259d46562 100644 --- a/Driver/Font/TrueType/backlog.md +++ b/Driver/Font/TrueType/backlog.md @@ -1,46 +1,25 @@ -## 1 TODOs -- ~~FontHeader füllen und im FontInfoBlock ablegen~~ -- ~~FontBuf auf Basis des FontHeaders füllen (Gen_Widths)~~ -- CharTableEntries füllen (Gen_Widths) -- KernPairs und KernValues füllen (Achtung: sie offene Probleme) -- Transformationsmatrix berechnen und im FontBlock halten (die FakeStyles sind in der Matrix 'enthalten')(Gen_Widths) -- in Gen_Char eine Bitmap erzeugen (notfalls eine Fake Bitmap damit endlich etwas zu sehen ist) - -## 2 Refactorings - -### 2.1 ttinit.c -- Hilfsfunktionen auslagern -- lokale Variablen reduzieren -- das Ermitteln des KernCounts hierhin auslagern -> das macht es in ttwidths.c leichter - -### 2.2 ttwidths.c -- Ermittlung stylesToImplement in ASM-Teil verschieben (Kernel-Routine FontDrFindOutlineData) - -### 2.3 FreeType +# TTF-Treiber für FreeGEOS + +## 1 Fehlende Features +- Support für Kerning +- Handler für GEN_IN_REGION +- Handler für GEN_PATH +- Refactoring des Speichermanagments +- Bytecodeinterpreter aktivieren + +## 2 Bekannte Probleme +- Zeichen mit einer Pointsize > 400 werden oben und/oder unten abgeschnitten +- das Resizing des Fontbuffers ist noch fehlerhaft +- die Fontmatrix wird noch nicht genutzt (Dokument-Zoom, Rotation und Sklaierung gehen deshalb nicht) + +## 3 Performance +Der TrueType-Treiber ist noch sehr träge. Hier einige Ideen wie das verbessert werden kann: +- Fonts (zumindest die, die wir initial in der Distribution mitliefern) auf die 224 Zeichen des GEOS-Zeichensatzes reduzieren +- Caching wie beim Nimbus-Treiber implementieren. D.h. ein Face bleibt im Speicher. Wird beim nächsten Rendern der gleiche Font angefordert wird das Face aus dem Cache genutzt ansonsten wird es verworfen und neu geladen. +- Im FreeType-Code wird an vielen Stellen long-Arithmetik genutzt. Hier gibt es sicher viel Stellen an denen ein word genügt. Siehe auch unter Optimierungen. - FreeType Strukturen zusammenführen (Strukturen die eine 1:1 Kardinalität zu TT_Engine haben in TT_Engine integrieren) +- Wenn das Refactoring des Speichermanagements erfolgt ist, prüfen ober der Render-Cache (derzeit 4096 Bytes) vergrößert werden kann. -### 2.4 Sonstiges -- bessere Lösung für das Mappen GeosChar -> UniCode finden - -## Optimierungen -- prüfen: ob TT_Error in tterrid.h von long auf word reduziert werden kann -- ~~prüfen: ob in ttraster.c traceG, gTarget entfernt werden kann~~ +## 4 Optimierungen - prüfen: ob in ttraster.c in TRasterInstance für lastX, lastY, minX, minY, TraceOfs und TraceOfsLastLine ein word genügt -- ~~in ttobj.h kann in T_Font_Input_ ->fontIndex entfernt werden (Ãœberbleibsel der TTCollections die wir nicht brauchen)~~ - in ttraster.c (Set_Hight_Precision) kann gesteuert werden wie 'genau' ein Glyph gerendert wird; falls wir noch Performanceprobleme haben kann hier auch angesetzt werden (ggf. auch mehrstufig) -- prüfen: kann die AvgWidth aus der OS/2 übernommen werden kann - -## offene Probleme -- klären: der Aufruf von TT_Init_Kerning lässt swat crashen -- das Speichermanagements muss überarbeitet werden, aktuell ist in ttwidths.c Schluss - -## aktuelle Verbräuche - -Speicherbedarf/Blöcke (ohne Code): -| Stand | 10.02.2023 | -|----------------|------------| -|vor ProcessFont | 4896/5 | -|nach ProcessFont| 19232/18 | -|vor Gen_Widths | 19232/18 | -|nach Gen_Widths | n.a. | - From c5164c21f06855680939aee3e6da3f66b69d9f54 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 24 Jun 2023 22:42:26 +0200 Subject: [PATCH 172/246] Unneeded functions revomed. --- Driver/Font/TrueType/Adapter/ttwidths.c | 8 +- Driver/Font/TrueType/FreeType/freetype.h | 34 ------- Driver/Font/TrueType/FreeType/ttapi.c | 115 ----------------------- 3 files changed, 5 insertions(+), 152 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 667121462..2c88e9d4b 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -103,6 +103,7 @@ MemHandle _pascal TrueType_Gen_Widths( FontBuf* fontBuf; word size; WWFixedAsDWord scaleFactor; + TransformMatrix* transMatrix; ECCheckMemHandle( fontHandle ); @@ -165,9 +166,10 @@ MemHandle _pascal TrueType_Gen_Widths( ConvertWidths( trueTypeVars, scaleFactor ,fontHeader, fontBuf ); /* calculate the transformation matrix and copy it into the FontBlock */ - CalcTransform( (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )), - fontMatrix, - stylesToImplement ); + transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); + CalcTransform( transMatrix, fontMatrix, stylesToImplement ); + + //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos Fail: TT_Close_Face( FACE ); diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index e58520bfe..5f6b04d35 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -680,20 +680,6 @@ TT_Face_Properties* properties ); - /* Set a face object's generic pointer */ - -/* - EXPORT_DEF - TT_Error TT_Set_Face_Pointer( TT_Face face, - void* data ); -*/ - - /* Get a face object's generic pointer */ -/* - EXPORT_DEF - void* TT_Get_Face_Pointer( TT_Face face ); -*/ - /* Close a face's file handle to save system resources. The file */ /* will be re-opened automatically on the next disk access. */ /* @@ -798,19 +784,6 @@ TT_Instance_Metrics* metrics ); - /* Set an instance's generic pointer. */ -/* - EXPORT_DEF - TT_Error TT_Set_Instance_Pointer( TT_Instance instance, - void* data ); -*/ - - /* Get an instance's generic pointer. */ -/* - EXPORT_DEF - void* TT_Get_Instance_Pointer( TT_Instance instance ); -*/ - /* Close a given instance object, destroying all associated data. */ EXPORT_DEF @@ -955,13 +928,6 @@ TT_Error TT_Done_Outline( TT_Outline* outline ); - /* Copy an outline into another one. */ -/* - EXPORT_DEF - TT_Error TT_Copy_Outline( TT_Outline* source, - TT_Outline* target ); */ - - /* Render an outline into a bitmap. */ EXPORT_DEF diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 9af51367f..15d7f9a7b 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -273,75 +273,6 @@ extern TEngine_Instance engineInstance; } -/******************************************************************* - * - * Function : TT_Set_Face_Pointer - * - * Description : Each face object has one pointer, which use is - * reserved to client applications. The TrueType - * engine never accesses or uses this field. - * - * This function is used to set the pointer. - * - * Input : face the given face handle - * data the generic pointer value - * - * Output : Error code. - * - * MT-Note : NO! But this function is reserved to "enlightened" - * developers, so it shouldn't be a problem. - * - ******************************************************************/ -/* - EXPORT_FUNC - TT_Error TT_Set_Face_Pointer( TT_Face face, - void* data ) - { - PFace faze = HANDLE_Face( face ); - - - if ( !faze ) - return TT_Err_Invalid_Face_Handle; - else - faze->generic = data; - - return TT_Err_Ok; - } -*/ - -/******************************************************************* - * - * Function : TT_Get_Face_Pointer - * - * Description : Each face object has one pointer, which use is - * reserved to client applications. The TrueType - * engine never access or use this field. - * - * This function is used to read the pointer. - * - * Input : face the given face handle - * data the generic pointer value - * - * Output : Error code. - * - * MT-Note : NO! But this function is reserved to "enlightened" - * developers, so it shouldn't be a problem. - * - ******************************************************************/ -/* - EXPORT_FUNC - void* TT_Get_Face_Pointer( TT_Face face ) - { - PFace faze = HANDLE_Face( face ); - - - if ( !faze ) - return NULL; - else - return faze->generic; - } -*/ - /******************************************************************* * * Function : TT_Get_Face_Metrics @@ -1574,52 +1505,6 @@ TT_Error TT_Get_Outline_Region( TT_Outline* outline, #endif /* __GEOS__ */ -/******************************************************************* - * - * Function : TT_Copy_Outline - * - * Description : Copy an outline into another. The source and - * target outlines must have the same points and - * contours numbers. - * - * Input : source address of source outline - * target address of target outline - * - * Output : Error code - * - * Note : This function doesn't touch the target outline's 'owner' - * field. - * - * MT-Safe : YES! - * - ******************************************************************/ -/* - EXPORT_FUNC - TT_Error TT_Copy_Outline( TT_Outline* source, - TT_Outline* target ) - { - if ( !source || !target || - source->n_points != target->n_points || - source->n_contours != target->n_contours ) - return TT_Err_Invalid_Argument; - - MEM_Copy( target->points, source->points, - source->n_points * 2 * sizeof ( TT_F26Dot6 ) ); - - MEM_Copy( target->flags, source->flags, - source->n_points * sizeof ( Byte ) ); - - MEM_Copy( target->contours, source->contours, - source->n_contours * sizeof ( Short ) ); - - target->high_precision = source->high_precision; - target->second_pass = target->second_pass; - target->dropout_mode = source->dropout_mode; - - return TT_Err_Ok; - } -*/ - /******************************************************************* * * Function : TT_Transform_Outline From 0e4fc0af897170829ff4a4f5c3f6124e59ca4ed6 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 26 Jun 2023 20:40:35 +0200 Subject: [PATCH 173/246] Strikepos corrected. --- Driver/Font/TrueType/Adapter/ttwidths.c | 2 +- Driver/Font/TrueType/FreeType/ttapi.c | 67 ------------------------- 2 files changed, 1 insertion(+), 68 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 2c88e9d4b..83a87987f 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -550,7 +550,7 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf->FB_underThickness.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_underThickness.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_strikePos, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_accent + fontHeader->FH_ascent - fontHeader->FH_strikePos, scaleFactor ); fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 15d7f9a7b..92a2287ad 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -790,73 +790,6 @@ extern TEngine_Instance engineInstance; } -/******************************************************************* - * - * Function : TT_Set_Instance_Pointer - * - * Description : Each instance has one pointer, which use is - * reserved to client applications. The TrueType - * engine never accesses or uses this field. - * - * This function is used to set the pointer. - * - * Input : face the given face handle - * data the generic pointer value - * - * Output : Error code. - * - * MT-Note : NO! - * - ******************************************************************/ -/* - EXPORT_FUNC - TT_Error TT_Set_Instance_Pointer( TT_Instance instance, - void* data ) - { - PInstance ins = HANDLE_Instance( instance ); - - - if ( !ins ) - return TT_Err_Invalid_Instance_Handle; - else - ins->generic = data; - - return TT_Err_Ok; - } -*/ - -/******************************************************************* - * - * Function : TT_Get_Instance_Pointer - * - * Description : Each instance has one pointer, which use is - * reserved to client applications. The TrueType - * engine never accesses or uses this field. - * - * This function is used to read the pointer. - * - * Input : face the given face handle - * data the generic pointer value - * - * Output : Error code. - * - * MT-Safe : NO! - * - ******************************************************************/ -/* - EXPORT_FUNC - void* TT_Get_Instance_Pointer( TT_Instance instance ) - { - PInstance ins = HANDLE_Instance( instance ); - - - if ( !ins ) - return NULL; - else - return ins->generic; - } -*/ - /******************************************************************* * * Function : TT_Done_Instance From 3d54dfcfcef87f449c0c0e0bb24f819c6582ac07 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 1 Jul 2023 20:11:14 +0200 Subject: [PATCH 174/246] Fixing superscript size --- Driver/Font/TrueType/Adapter/ttwidths.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 83a87987f..dca4f5cd6 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -404,7 +404,7 @@ static void CalcTransform( TransformMatrix* transMatrix, tempMatrix.yx = ITALIC_FACTOR; /* fake script style */ - if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) { tempMatrix.xx = GrMulWWFixed( tempMatrix.xx, SCRIPT_FACTOR ); tempMatrix.yy = GrMulWWFixed( tempMatrix.yy, SCRIPT_FACTOR ); From c673e59cead524a7ba58d8449f87d1c4141a46a2 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 2 Jul 2023 20:54:54 +0200 Subject: [PATCH 175/246] Styles to be implemented are passed to ttchars.c. --- Driver/Font/TrueType/Adapter/ttchars.c | 13 ++++++----- Driver/Font/TrueType/Adapter/ttchars.h | 1 + Driver/Font/TrueType/Adapter/ttmetrics.c | 10 ++++---- Driver/Font/TrueType/Adapter/ttwidths.c | 26 ++++++++++----------- Driver/Font/TrueType/Main/truetypeChars.asm | 1 + 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 7debb9763..7f30973aa 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -67,6 +67,7 @@ void _pascal TrueType_Gen_Chars( WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, + TextStyle stylesToImplement, MemHandle bitmapHandle, MemHandle varBlock ) { @@ -80,11 +81,11 @@ void _pascal TrueType_Gen_Chars( word width, height, size; - ECCheckBounds( (void*)fontBuf ); - ECCheckBounds( (void*)fontInfo ); - ECCheckBounds( (void*)outlineEntry ); - ECCheckMemHandle( bitmapHandle ); - ECCheckMemHandle( varBlock ); +EC( ECCheckBounds( (void*)fontBuf ) ); +EC( ECCheckBounds( (void*)fontInfo ) ); +EC( ECCheckBounds( (void*)outlineEntry ) ); +EC( ECCheckMemHandle( bitmapHandle ) ); +EC( ECCheckMemHandle( varBlock ) ); /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); @@ -102,7 +103,7 @@ void _pascal TrueType_Gen_Chars( trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( truetypeFile ); +EC( ECCheckFileHandle( truetypeFile ) ); /* open face, create instance and glyph */ if( TT_Open_Face( truetypeFile, &FACE ) ) diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index ed4efab25..eab865ba0 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -39,6 +39,7 @@ void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, + TextStyle stylesToImplement, MemHandle bitmapBlock, MemHandle varBlock ); diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index ded922028..941d0e197 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -70,10 +70,10 @@ void _pascal TrueType_Char_Metrics( TrueTypeVars* trueTypeVars; - ECCheckBounds( (void*)fontInfo ); - ECCheckBounds( (void*)outlineEntry ); - ECCheckMemHandle( varBlock ); - ECCheckStack(); +EC( ECCheckBounds( (void*)fontInfo ) ); +EC( ECCheckBounds( (void*)outlineEntry ) ); +EC( ECCheckMemHandle( varBlock ) ); +EC( ECCheckStack() ); /* get trueTypeVar block */ @@ -91,7 +91,7 @@ void _pascal TrueType_Char_Metrics( trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( truetypeFile ); +EC( ECCheckFileHandle( truetypeFile ) ); CalcTransformMatrix( stylesToImplement, &transMatrix ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index dca4f5cd6..5c5032c35 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -106,12 +106,12 @@ MemHandle _pascal TrueType_Gen_Widths( TransformMatrix* transMatrix; - ECCheckMemHandle( fontHandle ); - ECCheckBounds( (void*)fontMatrix ); - ECCheckBounds( (void*)fontInfo ); - ECCheckBounds( (void*)headerEntry ); - ECCheckBounds( (void*)firstEntry ); - ECCheckStack(); + EC( ECCheckMemHandle( fontHandle ) ); + EC( ECCheckBounds( (void*)fontMatrix ) ); + EC( ECCheckBounds( (void*)fontInfo ) ); + EC( ECCheckBounds( (void*)headerEntry ) ); + EC( ECCheckBounds( (void*)firstEntry ) ); + EC( ECCheckStack() ); // get trueTypeVar block @@ -122,7 +122,7 @@ MemHandle _pascal TrueType_Gen_Widths( trueTypeVars = MemLock( varBlock ); } - ECCheckBounds( (void*)trueTypeVars ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); // get filename an load ttf file FilePushDir(); @@ -132,7 +132,7 @@ MemHandle _pascal TrueType_Gen_Widths( trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), headerEntry->OE_handle ); truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( truetypeFile ); +EC( ECCheckFileHandle( truetypeFile ) ); // get pointer to FontHeader fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), firstEntry->OE_handle ); @@ -219,7 +219,7 @@ static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader word charIndex; - ECCheckBounds( (void*)charTableEntry ); +EC( ECCheckBounds( (void*)charTableEntry ) ); //Unicode to TT ID charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( currentChar ) ); @@ -386,8 +386,8 @@ static void CalcTransform( TransformMatrix* transMatrix, TT_Matrix tempMatrix; - ECCheckBounds( (void*)transMatrix ); - ECCheckBounds( (void*)fontMatrix ); +EC( ECCheckBounds( (void*)transMatrix ) ); +EC( ECCheckBounds( (void*)fontMatrix ) ); /* copy fontMatrix into transMatrix */ tempMatrix.xx = 1L << 16; @@ -498,8 +498,8 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* WWFixedAsDWord ttfElement; - ECCheckBounds( (void*)fontBuf ); - ECCheckBounds( (void*)fontHeader ); + EC( ECCheckBounds( (void*)fontBuf ) ); + EC( ECCheckBounds( (void*)fontHeader ) ); /* Fill elements in FontBuf structure. */ diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 0c5485402..1a6f6c1be 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -83,6 +83,7 @@ TrueTypeGenChar proc far call FontDrFindOutlineData push ds ; pass ptr to OutlineEntry push di + push ax ; pass styles to implement segmov ds, dgroup, ax push ds:bitmapHandle From f5731eed366a3b44f37edd22f9ae1e3af367a9b7 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 10 Jul 2023 21:44:53 +0200 Subject: [PATCH 176/246] Fix italic fake style. --- Driver/Font/TrueType/Adapter/ttadapter.h | 12 +- Driver/Font/TrueType/Adapter/ttchars.c | 4 + Driver/Font/TrueType/Adapter/ttwidths.c | 187 ++++++++++------------- 3 files changed, 99 insertions(+), 104 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 578e39c9a..8d399abb6 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -50,9 +50,13 @@ extern TEngine_Instance engineInstance; #define ITALIC_FACTOR 0x0000366A #define BOLD_FACTOR 0x00012000 -#define SCRIPT_FACTOR 0x00006000 +#define SCRIPT_FACTOR 0x00008000 #define SCRIPT_SHIFT_FACTOR 0x00015000 +#define SUPERSCRIPT_OFFSET 0x00006000 +#define SUBSCRIPT_OFFSET 0x00001a00 + + #define MAX_BITMAP_SIZE 125 #define MAX_FONTBUF_SIZE 10 * 1024 #define BITMAP_BLOCKSIZE 2 * 1024 @@ -354,6 +358,10 @@ typedef struct char familyName[FID_NAME_LEN]; char styleName[STYLE_NAME_LENGTH]; + /* scaling */ + WWFixedAsDWord scaleHeight; + WWFixedAsDWord scaleWidth; + /* render glyphs */ TT_Raster_Map rasterMap; @@ -384,6 +392,8 @@ typedef struct #define GLYPH_METRICS trueTypeVars->glyphMetrics #define GLYPH_BBOX trueTypeVars->glyphMetrics.bbox #define RASTER_MAP trueTypeVars->rasterMap +#define SCALE_HEIGHT trueTypeVars->scaleHeight +#define SCALE_WIDTH trueTypeVars->scaleWidth #define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 7f30973aa..a2c7296c7 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -196,6 +196,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); ((CharData*)charData)->CD_numRows = height; ((CharData*)charData)->CD_xoff = GLYPH_BBOX.xMin / 64; ((CharData*)charData)->CD_yoff = fontBuf->FB_baselinePos.WBF_int - ( GLYPH_BBOX.yMax / 64 ) + 1; + + /* shift if subscript style */ + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) + ((CharData*)charData)->CD_yoff += ( transformMatrix->TM_shiftY >> 16 ); } TT_Done_Glyph( GLYPH ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 5c5032c35..1fbce6b0a 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -29,34 +29,26 @@ #include "../FreeType/ftxkern.h" -static word AllocFontBlock( - word additionalSpace, - word numOfCharacters, - word numOfKernPairs, - MemHandle* fontHandle ); - -static WWFixedAsDWord CalcScaleForWidths( - WWFixedAsDWord pointSize, - TextStyle stylesToImplement, - word unitsPerEM ); - -static void ConvertHeader( - WWFixedAsDWord scaleFactor, - FontHeader* fontHeader, - FontBuf* fontBuf ); - -static void ConvertWidths( - TRUETYPE_VARS, - WWFixedAsDWord scaleFactor, - FontHeader* fontHeader, - FontBuf* fontBuf ); +static word AllocFontBlock( word additionalSpace, + word numOfCharacters, + word numOfKernPairs, + MemHandle* fontHandle ); + +static void ConvertHeader( TRUETYPE_VARS, + FontHeader* fontHeader, + FontBuf* fontBuf ); + +static void ConvertWidths( TRUETYPE_VARS, + FontHeader* fontHeader, + FontBuf* fontBuf ); static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ); -static void CalcTransform( - TransformMatrix* transMatrix, - FontMatrix* fontMatrix, - TextStyle styleToImplement ); +static void CalcTransform( TransformMatrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle styleToImplement ); + +static void AdjustFontBuf( TransformMatrix* transMatrix, FontBuf* fontBuf ); static word round( WWFixedAsDWord toRound ); @@ -102,7 +94,6 @@ MemHandle _pascal TrueType_Gen_Widths( FontHeader* fontHeader; FontBuf* fontBuf; word size; - WWFixedAsDWord scaleFactor; TransformMatrix* transMatrix; @@ -114,7 +105,7 @@ MemHandle _pascal TrueType_Gen_Widths( EC( ECCheckStack() ); - // get trueTypeVar block + /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); if( trueTypeVars == NULL ) { @@ -149,27 +140,51 @@ EC( ECCheckFileHandle( truetypeFile ) ); CountKernPairsWithGeosChars( FACE ), &fontHandle ); - /* calculate scale factor and transformation matrix */ - scaleFactor = CalcScaleForWidths( pointSize, - stylesToImplement, - FACE_PROPERTIES.header->Units_Per_EM ); - - /* convert FontHeader and fill FontBuf structure */ + /* deref FontBuf */ fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; - ConvertHeader( scaleFactor, fontHeader, fontBuf ); + + /* calculate the transformation matrix and copy it into the FontBlock */ + transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); + CalcTransform( transMatrix, fontMatrix, stylesToImplement ); + + /* calculate scale factor for width and height */ + SCALE_HEIGHT = GrUDivWWFixed( pointSize, MakeWWFixed( FACE_PROPERTIES.header->Units_Per_EM ) ); + SCALE_WIDTH = SCALE_HEIGHT; + + if( stylesToImplement & TS_BOLD ) + SCALE_WIDTH = GrMulWWFixed( SCALE_HEIGHT, WWFIXED_1_POINR_1 ); + + if( stylesToImplement & TS_SUBSCRIPT ) + { + SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); + transMatrix->TM_shiftY = GrMulWWFixed(SUBSCRIPT_OFFSET, + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ); + } + + if( stylesToImplement & TS_SUPERSCRIPT ) + { + SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); + transMatrix->TM_shiftY = GrMulWWFixed( SUPERSCRIPT_OFFSET, + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) - + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos ) - + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ); + } + + /* convert FontHeader and fill FontBuf structure */ + + ConvertHeader( trueTypeVars, fontHeader, fontBuf ); /* fill kerning pairs and kerning values */ ConvertKernPairs( trueTypeVars, fontBuf ); /* convert widths and fill CharTableEntries */ - ConvertWidths( trueTypeVars, scaleFactor ,fontHeader, fontBuf ); - - /* calculate the transformation matrix and copy it into the FontBlock */ - transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); - CalcTransform( transMatrix, fontMatrix, stylesToImplement ); + ConvertWidths( trueTypeVars, fontHeader, fontBuf ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos + AdjustFontBuf( transMatrix, fontBuf ); Fail: TT_Close_Face( FACE ); @@ -203,7 +218,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); * 12/02/23 JK Initial Revision *******************************************************************/ -static void ConvertWidths( TRUETYPE_VARS, WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ) +static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) { word currentChar; CharTableEntry* charTableEntry = (CharTableEntry*) (((byte*)fontBuf) + sizeof( FontBuf )); @@ -240,7 +255,7 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); //width berechnen - scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), scaleFactor ); + scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), SCALE_WIDTH ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); @@ -278,44 +293,6 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); } -/******************************************************************** - * CalcScaleForWidths - ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: - * - * RETURNS: - * - * SIDE EFFECTS: none - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 12/02/23 JK Initial Revision - *******************************************************************/ - -static WWFixedAsDWord CalcScaleForWidths( - WWFixedAsDWord pointSize, - TextStyle stylesToImplement, - word unitsPerEM ) -{ - WWFixedAsDWord scaleWidth = GrUDivWWFixed( pointSize, MakeWWFixed( unitsPerEM ) ); - - /* do bold need to be added? */ - if( stylesToImplement & TS_BOLD ) - scaleWidth = GrMulWWFixed( scaleWidth, WWFIXED_1_POINR_1 ); - - /* do subscript or superscript to be added? */ - if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) - scaleWidth = GrMulWWFixed( scaleWidth, WWFIXED_0_POINT_5 ); - - return scaleWidth; -} - - /******************************************************************** * ConvertKernPairs ******************************************************************** @@ -401,18 +378,13 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); /* fake italic style */ if( stylesToImplement & TS_ITALIC ) - tempMatrix.yx = ITALIC_FACTOR; + tempMatrix.xy = ITALIC_FACTOR;//tempMatrix.yx = ITALIC_FACTOR; /* fake script style */ if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) { tempMatrix.xx = GrMulWWFixed( tempMatrix.xx, SCRIPT_FACTOR ); tempMatrix.yy = GrMulWWFixed( tempMatrix.yy, SCRIPT_FACTOR ); - - if( stylesToImplement & TS_SUBSCRIPT ) - transMatrix->TM_shiftY = -SCRIPT_SHIFT_FACTOR; - else - transMatrix->TM_shiftY = SCRIPT_SHIFT_FACTOR; } /* integrate fontMatrix */ @@ -493,9 +465,11 @@ static word AllocFontBlock( * 11/12/22 JK Initial Revision *******************************************************************/ -void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf ) +void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) { WWFixedAsDWord ttfElement; + WWFixedAsDWord scaleWidth = SCALE_WIDTH; + WWFixedAsDWord scaleHeight = SCALE_HEIGHT; EC( ECCheckBounds( (void*)fontBuf ) ); @@ -503,74 +477,74 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* /* Fill elements in FontBuf structure. */ - ttfElement = SCALE_WORD( fontHeader->FH_avgwidth, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_avgwidth, scaleWidth ); fontBuf->FB_avgwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_avgwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_maxwidth, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_maxwidth, scaleWidth ); fontBuf->FB_maxwidth.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_maxwidth.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleHeight ); fontBuf->FB_heightAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_heightAdjust.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_height, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_height, scaleHeight ); fontBuf->FB_height.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_height.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_accent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_accent, scaleHeight ); fontBuf->FB_accent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_accent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_x_height, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_x_height, scaleHeight ); fontBuf->FB_mean.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_mean.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_baseAdjust, scaleHeight ); fontBuf->FB_baseAdjust.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_baseAdjust.WBF_frac = 0; - ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleHeight ); fontBuf->FB_baselinePos.WBF_int = round( ttfElement ); fontBuf->FB_baselinePos.WBF_frac = 0; - ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleHeight ); fontBuf->FB_descent.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_descent.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_extLeading.WBF_int = 0; fontBuf->FB_extLeading.WBF_frac = 0; - ttfElement = SCALE_WORD( fontHeader->FH_underPos, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_underPos, scaleHeight ); fontBuf->FB_underPos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_underPos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_underThick, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_underThick, scaleHeight ); fontBuf->FB_underThickness.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_underThickness.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_accent + fontHeader->FH_ascent - fontHeader->FH_strikePos, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_accent + fontHeader->FH_ascent - fontHeader->FH_strikePos, scaleHeight ); fontBuf->FB_strikePos.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_strikePos.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_minTSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_minTSB, scaleHeight ); fontBuf->FB_aboveBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_aboveBox.WBF_frac = 0; fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_maxBSB, scaleHeight ); fontBuf->FB_belowBox.WBF_int = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_belowBox.WBF_frac = 0; fontBuf->FB_maxBSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_minLSB, scaleWidth ); fontBuf->FB_minLSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleWidth ); fontBuf->FB_maxRSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleFactor ); + ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleHeight ); fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); fontBuf->FB_maker = FM_TRUETYPE; @@ -584,6 +558,13 @@ void ConvertHeader( WWFixedAsDWord scaleFactor, FontHeader* fontHeader, FontBuf* fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; } + +static void AdjustFontBuf( TransformMatrix* transMatrix, FontBuf* fontBuf ) +{ + //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos +} + + static word round( WWFixedAsDWord toRound ) { return toRound & 0xffff ? ( toRound >> 16 ) + 1 : toRound >> 16; From e52c401b9b69534ca15fb6a052811a6265a937cc Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 13 Jul 2023 20:01:52 +0200 Subject: [PATCH 177/246] Support for systems font matrix implemented. --- Driver/Font/TrueType/Adapter/ttwidths.c | 31 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 1fbce6b0a..e5e07b7f8 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -48,7 +48,8 @@ static void CalcTransform( TransformMatrix* transMatrix, FontMatrix* fontMatrix, TextStyle styleToImplement ); -static void AdjustFontBuf( TransformMatrix* transMatrix, FontBuf* fontBuf ); +static void AdjustFontBuf( TransformMatrix* transMatrix, + FontMatrix* fontMatrix, FontBuf* fontBuf ); static word round( WWFixedAsDWord toRound ); @@ -184,7 +185,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); ConvertWidths( trueTypeVars, fontHeader, fontBuf ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos - AdjustFontBuf( transMatrix, fontBuf ); + AdjustFontBuf( transMatrix, fontMatrix, fontBuf ); Fail: TT_Close_Face( FACE ); @@ -374,11 +375,14 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); /* fake bold style */ if( stylesToImplement & TS_BOLD ) + { tempMatrix.xx = BOLD_FACTOR; + tempMatrix.yy = BOLD_FACTOR; + } /* fake italic style */ if( stylesToImplement & TS_ITALIC ) - tempMatrix.xy = ITALIC_FACTOR;//tempMatrix.yx = ITALIC_FACTOR; + tempMatrix.xy = ITALIC_FACTOR; /* fake script style */ if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) @@ -559,9 +563,28 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) } -static void AdjustFontBuf( TransformMatrix* transMatrix, FontBuf* fontBuf ) +static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) { //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos + + //FBF_IS_COMPLEX setzen + //tempMatrix = transMatrix + + //FB_pixHeight = truncate( FB_height * TM_22 ) + //FB_minTSB = truncate( FB_minTSB * TM_22 ) + //FB_pixHeight = FB_pixHeight + FB_minTSB + + //height_Y = FB_baselinePos * TM_22 + //script_Y = script_Y * TM_22 + + + fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ), fontMatrix->FM_22 ) ); + fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( MakeWWFixed( fontBuf->FB_minTSB ), fontMatrix->FM_22 ) ); + fontBuf->FB_pixHeight += fontBuf->FB_minTSB; + + fontBuf->FB_flags |= FBF_IS_COMPLEX; + + } From 68d521ced56d7f7b731355c48b386831da9fad7f Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Sat, 15 Jul 2023 18:20:58 +0200 Subject: [PATCH 178/246] Use ROOT_DIR environment variable in path examples --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a1952685b..d6bdac5c3 100644 --- a/README.md +++ b/README.md @@ -35,19 +35,19 @@ Document is work in progress.... stay tuned! ## Building PC/GEOS SDK Build pmake tool: -- `cd pcgeos/Tools/pmake/pmake` +- `cd %ROOT_DIR%/Tools/pmake/pmake` - `wmake install` Build all the other SDK Tools: -- `cd pcgeos/Installed/Tools` +- `cd %ROOT_DIR%/Installed/Tools` - `pmake install` Build all PC/GEOS (target) components: -- `cd pcgeos/Installed` +- `cd %ROOT_DIR%/Installed` - `pmake` Build the target environment: -- `cd pcgeos/Tools/build/product/bbxensem/Scripts` +- `cd %ROOT_DIR%/Tools/build/product/bbxensem/Scripts` - `perl -I. buildbbx.pl` - the answers to the questions from the above perl-script are: - nt (for the platform) @@ -60,7 +60,7 @@ Build the target environment: Launch the target environment in dosbox: - make sure dosbox is added to your path variable, or [pcgeos-basebox](https://github.com/bluewaysw/pcgeos-basebox/tags) is installed and configured using BASEBOX environmental variable -- `cd pcgeos` +- `cd %ROOT_DIR%` - `bin/target` - the "swat" debugger stops immediately after the first stage of the boot process - enter `quit` at the "=>" prompt to detach the debugger and launch PC/GEOS stand-alone From aa8fe9706e78e71b114eb5a2b0b4d218d151407c Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Mon, 17 Jul 2023 23:24:10 +0200 Subject: [PATCH 179/246] First draft of persistent font information --- Driver/Font/TrueType/Adapter/ttadapter.c | 153 ++++++++++++++++++ Driver/Font/TrueType/Adapter/ttadapter.h | 15 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 13 +- Driver/Font/TrueType/Adapter/ttcharmapper.h | 5 +- Driver/Font/TrueType/Adapter/ttchars.c | 22 +-- Driver/Font/TrueType/Adapter/ttinit.c | 4 +- Driver/Font/TrueType/Adapter/ttmetrics.c | 26 +-- Driver/Font/TrueType/Adapter/ttwidths.c | 27 +--- Driver/Font/TrueType/Main/truetypeInit.asm | 5 +- Installed/Driver/Font/TrueType/Makefile | 42 ++--- .../Driver/Font/TrueType/dependencies.mk | 13 ++ 11 files changed, 226 insertions(+), 99 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttadapter.c diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c new file mode 100644 index 000000000..6dcea431b --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -0,0 +1,153 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttadapter.c + * + * AUTHOR: Marcus Groeber: July 16 2023 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial version + * + * DESCRIPTION: + * Common functions used by TrueType Adapter. + ***********************************************************************/ + +#include "ttadapter.h" +#include +#include + +static int strcmp( const char* s1, const char* s2 ); + + +/******************************************************************** + * TrueType_Lock_Face + ******************************************************************** + * SYNOPSIS: Active a particular face. + * + * PARAMETERS: *trueTypeVars + * *entry Ptr to font entry. + * + * RETURNS: TT_Error + * + * STRATEGY: - check if face is already loaded + * - if not, open file with face + * - load face from file + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial Revision + * + *******************************************************************/ + +Boolean TrueType_Lock_Face(TRUETYPE_VARS, TrueTypeOutlineEntry* entry) +{ + Boolean failure = TRUE; + + if( strcmp( entry->TTOE_fontFileName, trueTypeVars->entry.TTOE_fontFileName )==0 ) + { + failure = FALSE; + goto Fin; + } + + TrueType_Free_Face( trueTypeVars ); + + FilePushDir(); + FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); + + /* get filename and load ttf file */ + TTFILE = FileOpen( entry->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); + /* change owner to ourselves, to make handle persist if application closes */ + HandleModifyOwner( (MemHandle)TTFILE, GeodeGetCodeProcessHandle() ); + FilePopDir(); + + if( TT_Open_Face( TTFILE, &FACE ) ) + goto Fin; + if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) + goto Fail; + if ( getCharMap( trueTypeVars, &CHAR_MAP ) ) + goto Fail; + + /* font has been fully loaded */ + trueTypeVars->entry = *entry; + failure = FALSE; +Fin: + return failure; +Fail: + TT_Close_Face( FACE ); + goto Fin; +} + + +/******************************************************************** + * TrueType_Unlock_Face + ******************************************************************** + * SYNOPSIS: Deactivate the currently active face. + * + * PARAMETERS: *trueTypeVars + * + * RETURNS: TT_Error + * + * STRATEGY: - free resources used by face + * - close file + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial Revision + * + *******************************************************************/ + +void TrueType_Unlock_Face(TRUETYPE_VARS) +{ + /* Will be used for unlocking moveable font resources */ + (void)trueTypeVars; +} + +/******************************************************************** + * TrueType_Free_Face + ******************************************************************** + * SYNOPSIS: Close the currently active face. + * + * PARAMETERS: *trueTypeVars + * + * RETURNS: TT_Error + * + * STRATEGY: - free resources used by face + * - close file + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial Revision + * + *******************************************************************/ + +void TrueType_Free_Face(TRUETYPE_VARS) +{ + if ( trueTypeVars->entry.TTOE_fontFileName[0] ) + { + TT_Close_Face( FACE ); + trueTypeVars->entry.TTOE_fontFileName[0] = 0; + } + if ( TTFILE ) + { + FileClose( TTFILE, FALSE ); + TTFILE = NullHandle; + } +} + +static int strcmp( const char* s1, const char* s2 ) +{ + while ( *s1 && ( *s1 == *s2 ) ) + { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 8d399abb6..54fda74da 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -375,6 +375,10 @@ typedef struct TT_CharMap charMap; TT_Outline outline; TT_BBox bbox; + + /* currently open face */ + FileHandle ttfile; + TrueTypeOutlineEntry entry; } TrueTypeVars; @@ -393,7 +397,8 @@ typedef struct #define GLYPH_BBOX trueTypeVars->glyphMetrics.bbox #define RASTER_MAP trueTypeVars->rasterMap #define SCALE_HEIGHT trueTypeVars->scaleHeight -#define SCALE_WIDTH trueTypeVars->scaleWidth +#define SCALE_WIDTH trueTypeVars->scaleWidth +#define TTFILE trueTypeVars->ttfile #define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM @@ -463,4 +468,12 @@ typedef struct ( ( (long)value.WBF_int << 16 ) | ( value.WBF_frac << 8 ) ) +/*********************************************************************** + * functions + ***********************************************************************/ + +Boolean TrueType_Lock_Face(TRUETYPE_VARS, TrueTypeOutlineEntry* entry); +void TrueType_Unlock_Face(TRUETYPE_VARS); +void TrueType_Free_Face(TRUETYPE_VARS); + #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 3e2d48709..4f19d114e 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -281,27 +281,26 @@ CharMapFlags GeosCharMapFlag( word geosChar ) /* * Get microsoft unicode charmap in face. */ -TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) +TT_Error getCharMap( TRUETYPE_VARS, TT_CharMap* charMap ) { - TT_Face_Properties face_Properties; TT_UShort platform; TT_UShort encoding; int map; - TT_Get_Face_Properties( face, &face_Properties ); + TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ); - for ( map = 0; map < face_Properties.num_CharMaps; ++map ) + for ( map = 0; map < FACE_PROPERTIES.num_CharMaps; ++map ) { - TT_Get_CharMap_ID( face, map, &platform, &encoding ); + TT_Get_CharMap_ID( FACE, map, &platform, &encoding ); if ( platform == TT_PLATFORM_MICROSOFT && encoding == TT_MS_ID_UNICODE_CS ) { - TT_Get_CharMap(face, map, charMap); + TT_Get_CharMap(FACE, map, charMap); break; } } - if ( map == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; + if ( map == FACE_PROPERTIES.num_CharMaps ) return TT_Err_CMap_Table_Missing; else return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index eeb3409bb..5438476d8 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -22,6 +22,7 @@ #include #include +#include "ttadapter.h" typedef ByteFlags CharMapFlags; @@ -46,11 +47,13 @@ typedef struct * internal functions ***********************************************************************/ +word GeosCharToUnicode( word geosChar ); + word InitGeosCharsInCharMap( TT_CharMap map, char* firstChar, char* lastChar ); word CountKernPairsWithGeosChars( TT_Face face ); -TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); +TT_Error getCharMap( TRUETYPE_VARS, TT_CharMap* charMap ); CharMapFlags GeosCharMapFlag( word geosChar ); diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index a2c7296c7..c9fe0f12a 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -71,7 +71,6 @@ void _pascal TrueType_Gen_Chars( MemHandle bitmapHandle, MemHandle varBlock ) { - FileHandle truetypeFile; MemHandle fontBufHandle; TrueTypeOutlineEntry* trueTypeOutline; TT_UShort charIndex; @@ -89,24 +88,12 @@ EC( ECCheckMemHandle( varBlock ) ); /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); - if( trueTypeVars == NULL ) - { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); - trueTypeVars = MemLock( varBlock ); - } - - - FilePushDir(); - FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); - // get filename an load ttf file trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); - truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - -EC( ECCheckFileHandle( truetypeFile ) ); /* open face, create instance and glyph */ - if( TT_Open_Face( truetypeFile, &FACE ) ) + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; TT_New_Glyph( FACE, &GLYPH ); @@ -114,7 +101,6 @@ EC( ECCheckFileHandle( truetypeFile ) ); TT_Set_Instance_Resolutions( INSTANCE, 72, 72 ); /* get TT char index */ - getCharMap( FACE, &CHAR_MAP ); charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); /* set pointsize and get metrics */ @@ -221,10 +207,8 @@ EC( ECCheckFileHandle( truetypeFile ) ); /* cleanup */ MemUnlock( bitmapHandle ); + TrueType_Unlock_Face( trueTypeVars ); Fail: - TT_Close_Face( FACE ); - FileClose( truetypeFile, FALSE ); - FilePopDir(); MemUnlock( varBlock ); } diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index ccd5baed3..b0341e37a 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -164,7 +164,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ) trueTypeVars = MemLock( varBlock ); if( trueTypeVars == NULL ) { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); + MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR | HAF_ZERO_INIT ); trueTypeVars = MemLock( varBlock ); } @@ -281,7 +281,7 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) goto Fail; - if ( getCharMap( FACE, &CHAR_MAP ) ) + if ( getCharMap( trueTypeVars, &CHAR_MAP ) ) goto Fail; if ( getNameFromNameTable( trueTypeVars, FAMILY_NAME, FAMILY_NAME_ID ) == 0 ) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 941d0e197..aad50b927 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -63,7 +63,6 @@ void _pascal TrueType_Char_Metrics( dword* result, MemHandle varBlock ) { - FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; TransformMatrix transMatrix; word charIndex; @@ -78,29 +77,16 @@ EC( ECCheckStack() ); /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); - if( trueTypeVars == NULL ) - { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); - trueTypeVars = MemLock( varBlock ); - } - - /* get filename an load ttf file */ - FilePushDir(); - FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); - truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - -EC( ECCheckFileHandle( truetypeFile ) ); - - CalcTransformMatrix( stylesToImplement, &transMatrix ); - if( TT_Open_Face( truetypeFile, &FACE ) ) + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; - // get TT char index - getCharMap( FACE, &CHAR_MAP ); + CalcTransformMatrix( stylesToImplement, &transMatrix ); + // get TT char index charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); // load glyph @@ -142,12 +128,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); TT_Done_Instance( INSTANCE ); TT_Done_Glyph( GLYPH ); + TrueType_Unlock_Face( trueTypeVars ); Fail: - TT_Close_Face( FACE ); MemUnlock( varBlock ); - FileClose( truetypeFile, FALSE ); - FilePopDir(); } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index e5e07b7f8..db8d48a92 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -89,7 +89,6 @@ MemHandle _pascal TrueType_Gen_Widths( TextStyle stylesToImplement, MemHandle varBlock ) { - FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; TrueTypeVars* trueTypeVars; FontHeader* fontHeader; @@ -108,31 +107,15 @@ MemHandle _pascal TrueType_Gen_Widths( /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); - if( trueTypeVars == NULL ) - { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); - trueTypeVars = MemLock( varBlock ); - } - EC( ECCheckBounds( (void*)trueTypeVars ) ); - // get filename an load ttf file - FilePushDir(); - FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - // get filename an load ttf file trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), headerEntry->OE_handle ); - truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - -EC( ECCheckFileHandle( truetypeFile ) ); // get pointer to FontHeader fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), firstEntry->OE_handle ); - if ( TT_Open_Face( truetypeFile, &FACE ) ) - goto Fin; - - if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ @@ -187,12 +170,9 @@ EC( ECCheckFileHandle( truetypeFile ) ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos AdjustFontBuf( transMatrix, fontMatrix, fontBuf ); -Fail: - TT_Close_Face( FACE ); -Fin: - FileClose( truetypeFile, FALSE ); + TrueType_Unlock_Face( trueTypeVars ); +Fail: MemUnlock( varBlock ); - FilePopDir(); return fontHandle; } @@ -228,7 +208,6 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB TT_New_Glyph( FACE, &GLYPH ); TT_New_Instance( FACE, &INSTANCE ); - getCharMap( FACE, &CHAR_MAP ); for( currentChar = fontHeader->FH_firstChar; currentChar <= fontHeader->FH_lastChar; ++currentChar ) { diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index c6c87e78b..301d99df4 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -76,10 +76,9 @@ TrueTypeInit proc far ; We also need a block to use for variables. We don't ; need it yet, either. ; - mov ax, size TrueTypeVars ;ax <- size of block + mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block mov bx, handle 0 ;bx <- make TrueType owner - mov cx, mask HF_DISCARDABLE \ - or mask HF_SWAPABLE \ + mov cx, mask HF_SWAPABLE \ or mask HF_SHARABLE \ or mask HF_DISCARDED \ or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 4640e06f7..1131663f1 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,31 +4,31 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ - truetypeWidths.asm ansic_memory.asm truetypeMetrics.asm\ - truetypeInit.asm truetypeEC.asm truetypeChars.asm\ - truetypePath.asm truetypeMacros.def truetypeVariable.def\ - truetypeConstant.def -ADAPTER = ttchars.c ttinit.c ttmetrics.c ttcharmapper.c ttwidths.c\ - ttpath.c ttcharmapper.h ttwidths.h ttinit.h ttmetrics.h\ - ttadapter.h -FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ - ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h ttinterp.h\ - ttload.h tttables.h ttobjs.h fterrid.h ttraster.h\ - ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ - ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h +ADAPTER = ttadapter.c ttcharmapper.c ttchars.c ttinit.c ttmetrics.c\ + ttpath.c ttwidths.c ttadapter.h ttcharmapper.h ttchars.h\ + ttinit.h ttmetrics.h ttwidths.h +FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttextend.c\ + ttfile.c ttgload.c ttinterp.c ttload.c ttmemory.c\ + ttmutex.c ttobjs.c ttraster.c freetype.h fterrid.h\ + ftnameid.h ftxkern.h ft_conf.h ttcache.h ttcalc.h\ + ttcmap.h ttconfig.h ttengine.h ttextend.h ttfile.h\ + ttgload.h ttinterp.h ttload.h ttmemory.h ttmutex.h\ + ttobjs.h ttraster.h tttables.h tttags.h tttypes.h +MAIN = ansic_memory.asm ansic_runtime.asm mainManager.asm\ + truetypeChars.asm truetypeEC.asm truetypeEscape.asm\ + truetypeInit.asm truetypeMetrics.asm truetypePath.asm\ + truetypeWidths.asm truetypeConstant.def\ + truetypeMacros.def truetypeVariable.def UI_TO_RDFS = -OBJS = ttchars.obj ttinit.obj ttmetrics.obj ttcharmapper.obj\ - ttwidths.obj ttpath.obj ttcache.obj ttraster.obj\ - ttmutex.obj ttgload.obj ttextend.obj ttcalc.obj ttapi.obj\ - ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ - ttobjs.obj ttmemory.obj +OBJS = ttadapter.obj ttcharmapper.obj ttchars.obj ttinit.obj\ + ttmetrics.obj ttpath.obj ttwidths.obj ftxkern.obj\ + ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj ttextend.obj\ + ttfile.obj ttgload.obj ttinterp.obj ttload.obj\ + ttmemory.obj ttmutex.obj ttobjs.obj ttraster.obj COMMON = MODULES = Main CMODULES = Adapter FreeType -SRCS = $(MAIN) $(ADAPTER) $(FREETYPE) $(COMMON) +SRCS = $(ADAPTER) $(FREETYPE) $(MAIN) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index 24b484802..40dee37eb 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -13,6 +13,18 @@ Main.eobj: Main/mainManager.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm +ttadapter.obj \ +ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ + Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h ttchars.obj \ ttchars.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/freetype.h \ @@ -50,6 +62,7 @@ ttmetrics.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h ttcharmapper.obj \ ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ + Adapter/ttadapter.h \ FreeType/fterrid.h FreeType/ftnameid.h unicode.h ttwidths.obj \ ttwidths.eobj: geos.h ec.h unicode.h graphics.h fontID.h font.h color.h \ From 01d2c2ecafd61b0d8bca71dbbacd43a91075371f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 18 Jul 2023 21:43:29 +0200 Subject: [PATCH 180/246] Move calculation of heightX, heightY, scriptX and scriptY from ttchars.c to ttwidths.c --- Driver/Font/TrueType/Adapter/ttadapter.h | 5 ++- Driver/Font/TrueType/Adapter/ttchars.c | 16 ++++----- Driver/Font/TrueType/Adapter/ttmetrics.c | 8 ++--- Driver/Font/TrueType/Adapter/ttwidths.c | 42 +++++++++++------------- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 8d399abb6..d55b09679 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -269,7 +269,10 @@ typedef struct typedef struct { TT_Matrix TM_matrix; - WWFixedAsDWord TM_shiftY; + sword TM_scriptX; + sword TM_heightX; + sword TM_scriptY; + sword TM_heightY; } TransformMatrix; typedef ByteFlags TransFlags; diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index a2c7296c7..bde2609b8 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -163,8 +163,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); TT_Get_Outline_Region( &OUTLINE, &RASTER_MAP ); /* fill header of charData */ - ((RegionCharData*)charData)->RCD_xoff = GLYPH_BBOX.xMin / 64; - ((RegionCharData*)charData)->RCD_yoff = fontBuf->FB_baselinePos.WBF_int - ( GLYPH_BBOX.yMax / 64 ); + ((RegionCharData*)charData)->RCD_xoff = transformMatrix->TM_scriptX + + transformMatrix->TM_heightX + GLYPH_BBOX.xMin / 64; + ((RegionCharData*)charData)->RCD_yoff = transformMatrix->TM_scriptY + + transformMatrix->TM_heightY - GLYPH_BBOX.yMax / 64; ((RegionCharData*)charData)->RCD_size = RASTER_MAP.size; ((RegionCharData*)charData)->RCD_bounds.R_left = 0; ((RegionCharData*)charData)->RCD_bounds.R_right = width; @@ -194,12 +196,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); /* fill header of charData */ ((CharData*)charData)->CD_pictureWidth = width; ((CharData*)charData)->CD_numRows = height; - ((CharData*)charData)->CD_xoff = GLYPH_BBOX.xMin / 64; - ((CharData*)charData)->CD_yoff = fontBuf->FB_baselinePos.WBF_int - ( GLYPH_BBOX.yMax / 64 ) + 1; - - /* shift if subscript style */ - if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) - ((CharData*)charData)->CD_yoff += ( transformMatrix->TM_shiftY >> 16 ); + ((CharData*)charData)->CD_xoff = transformMatrix->TM_scriptX + + transformMatrix->TM_heightX + GLYPH_BBOX.xMin / 64; + ((CharData*)charData)->CD_yoff = transformMatrix->TM_scriptY + + transformMatrix->TM_heightY - GLYPH_BBOX.yMax / 64; } TT_Done_Glyph( GLYPH ); diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 941d0e197..17c1f3e15 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -110,7 +110,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); // transform glyphs outline TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); TT_Transform_Outline( &OUTLINE, &transMatrix.TM_matrix ); - TT_Translate_Outline( &OUTLINE, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_shiftY ) ); + TT_Translate_Outline( &OUTLINE, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_scriptY ) ); // scale glyph TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); @@ -159,7 +159,7 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, transMatrix->TM_matrix.xy = 0; transMatrix->TM_matrix.yx = 0; transMatrix->TM_matrix.yy = 1L << 16; - transMatrix->TM_shiftY = 0; + transMatrix->TM_scriptY = 0; /* fake bold style */ if( stylesToImplement & TS_BOLD ) @@ -176,8 +176,8 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, transMatrix->TM_matrix.yy = GrMulWWFixed( transMatrix->TM_matrix.yy, SCRIPT_FACTOR ); if( stylesToImplement & TS_SUBSCRIPT ) - transMatrix->TM_shiftY = -SCRIPT_SHIFT_FACTOR; + transMatrix->TM_scriptY = -SCRIPT_SHIFT_FACTOR; else - transMatrix->TM_shiftY = SCRIPT_SHIFT_FACTOR; + transMatrix->TM_scriptY = SCRIPT_SHIFT_FACTOR; } } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index e5e07b7f8..5b28bc605 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -159,19 +159,19 @@ EC( ECCheckFileHandle( truetypeFile ) ); if( stylesToImplement & TS_SUBSCRIPT ) { SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); - transMatrix->TM_shiftY = GrMulWWFixed(SUBSCRIPT_OFFSET, + transMatrix->TM_scriptY = GrMulWWFixed(SUBSCRIPT_OFFSET, WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ); + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) >> 16; } if( stylesToImplement & TS_SUPERSCRIPT ) { SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); - transMatrix->TM_shiftY = GrMulWWFixed( SUPERSCRIPT_OFFSET, + transMatrix->TM_scriptY = ( GrMulWWFixed( SUPERSCRIPT_OFFSET, WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos ) - - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ); + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ) ) >> 16; } /* convert FontHeader and fill FontBuf structure */ @@ -400,6 +400,10 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); GrMulWWFixed( tempMatrix.yy, fontMatrix->FM_21 ); transMatrix->TM_matrix.yy = GrMulWWFixed( tempMatrix.yx, fontMatrix->FM_12 ) + GrMulWWFixed( tempMatrix.yy, fontMatrix->FM_22 ); + transMatrix->TM_heightX = 0; + transMatrix->TM_scriptX = 0; + transMatrix->TM_heightY = 0; + transMatrix->TM_scriptY = 0; } @@ -548,8 +552,9 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleWidth ); fontBuf->FB_maxRSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleHeight ); - fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); + //ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleHeight ); + ttfElement = SCALE_WORD( fontHeader->FH_height, scaleHeight ); + fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement );// + fontBuf->FB_minTSB; fontBuf->FB_maker = FM_TRUETYPE; fontBuf->FB_kernPairPtr = 0; @@ -565,26 +570,17 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) { - //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos - - //FBF_IS_COMPLEX setzen - //tempMatrix = transMatrix - - //FB_pixHeight = truncate( FB_height * TM_22 ) - //FB_minTSB = truncate( FB_minTSB * TM_22 ) - //FB_pixHeight = FB_pixHeight + FB_minTSB - - //height_Y = FB_baselinePos * TM_22 - //script_Y = script_Y * TM_22 + //adjust FB_pixHeight, FB_minTSB, heightY + fontBuf->FB_flags |= FBF_IS_COMPLEX; - fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ), fontMatrix->FM_22 ) ); - fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( MakeWWFixed( fontBuf->FB_minTSB ), fontMatrix->FM_22 ) ); - fontBuf->FB_pixHeight += fontBuf->FB_minTSB; - - fontBuf->FB_flags |= FBF_IS_COMPLEX; - + //TODO: das ist nur eine provisorische Lösung --> + transMatrix->TM_heightY = fontBuf->FB_baselinePos.WBF_int + 1; + if( fontMatrix->FM_flags & TF_ROTATED ) + { + //adjust scriptX, heightX + } } From bf287d5df77d154b515a7f2c8edf3ab9e7cc3a3b Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Wed, 19 Jul 2023 23:02:08 +0200 Subject: [PATCH 181/246] Add Font readme to DDK and format as Markdown --- .../Markdown/Ddk/ddkfont.md | 368 +++++++++--------- TechDocs/Markdown/ddk.md | 7 + 2 files changed, 181 insertions(+), 194 deletions(-) rename Driver/Font/FontCom/README.font => TechDocs/Markdown/Ddk/ddkfont.md (63%) diff --git a/Driver/Font/FontCom/README.font b/TechDocs/Markdown/Ddk/ddkfont.md similarity index 63% rename from Driver/Font/FontCom/README.font rename to TechDocs/Markdown/Ddk/ddkfont.md index 6b63e4590..6733df0db 100644 --- a/Driver/Font/FontCom/README.font +++ b/TechDocs/Markdown/Ddk/ddkfont.md @@ -1,26 +1,13 @@ +## 4 Font Driver -FILE: README.fontDr -DESC: This document describes the interface and interactions of font - drivers in PC/GEOS -AUTHOR: Gene Anderson -DATE: 01/21/91 +AUTHOR: Gene Anderson (01/21/91) - $Id: README.font,v 1.4.25.1 97/03/29 07:08:03 canavese Exp $ +This document describes the interface and interactions of font drivers in +PC/GEOS. ------------------------------------------------------------------------------- - CONTENTS ------------------------------------------------------------------------------- - Overview - Initialization Routines - Data Routines - Metrics Routines - Debugging Tips +### 4.1 Overview ------------------------------------------------------------------------------- - Overview ------------------------------------------------------------------------------- - - In PC/GEOS, outline font drivers play a vital role in the +In PC/GEOS, outline font drivers play a vital role in the WYSIWYG rendering engine. They are called to generate the metrics for a font at any pointsize, rotation or scale factor that a program may request, making this information transparently available. When the @@ -28,7 +15,7 @@ font is actually drawn to the screen (or to memory for printing), the font drivers are called to generate bitmaps for the actual images of the characters. - A program will normally specify a particular typeface +A program will normally specify a particular typeface (FontIDs) and pointsize (WBFixed) using GrSetFont(). Additional styles (TextStyles) may be specified using GrSetTextStyle(). Some programs, such as GeoDraw, may also specify an angle of rotation using @@ -38,7 +25,7 @@ printing or rendering to a different device, using window routines similar to the graphics transformation routines above. All these elements combine to specify a unique 'font' to the system. - A typeface is referred to by a 16-bit ID (FontIDs). Part of +A typeface is referred to by a 16-bit ID (FontIDs). Part of the PC/GEOS kernel is a Font Manager, and it tracks the requests and usage of fonts in the system via these IDs and other font attributes. It maintains an array of structures (FontsAvailEntry) for each font in @@ -48,7 +35,7 @@ display. Each of these entries has a corresponding chunk of data (FontInfo), which specifies more information about the typeface, such as the ASCII name, and which styles are available as direct outlines. - When a routine needs a particular piece of font information, +When a routine needs a particular piece of font information, it asks the Font Manager to get the font in question. This may be accomplished simply if the font has a hand-tuned bitmap that is appropriate. If no bitmap exists, however, the font driver will be @@ -58,47 +45,45 @@ metrics information, and references to each character in the font indicating whether it exists or not, and whether a bitmap for it has been built. - When the video driver renders text on screen, it checks to see +When the video driver renders text on screen, it checks to see if a bitmap for the character it is about to draw exists or not. If not, it asks the Font Manager to get a bitmap for the character. The Font Manager in turn calls the appropriate font driver and requests the bitmap using the function DR_FONT_GEN_CHAR. - This process goes on as the system runs. Eventually, the font +This process goes on as the system runs. Eventually, the font may be unused for such a time period as to cause the data block to be discarded by the Heap Manager. If the font is requested again, the Font Manager will call the font driver with DR_FONT_GEN_WIDTHS, and the whole process starts over. - In addition to the process of requesting font metrics and +In addition to the process of requesting font metrics and corresponding character bitmaps, programs may request metrics about a particular character in which case the Font Manager calls the font driver with DR_FONT_CHAR_METRICS. Alternatively, a program may request the outline data for a particular character, in which case the font driver is called with DR_FONT_GEN_PATH. - There are also a number of initialization routines that the +There are also a number of initialization routines that the font driver must support. These are used to start and stop the font driver, as well as give it a chance to initialize any of its own fonts. - Finally, there are a number of driver 'escape functions', +Finally, there are a number of driver 'escape functions', which the font driver may choose to support or not, as is appropriate. These include functions such as adding or deleting a font from the system. ------------------------------------------------------------------------------- - Initialization Routines ------------------------------------------------------------------------------- +### 4.2 Initialization Routines -DR_INIT +*DR_INIT* - DR_INIT is called for all drivers. This should be used to +DR_INIT is called for all drivers. This should be used to initialize any necessary data structures and memory. However, care should be taken to keep memory usage at this stage at an absolute minimum as the driver may never get called again during this session. - For example, the Nimbus driver allocates handles for a variety +For example, the Nimbus driver allocates handles for a variety of blocks it uses (one for variables, one for the generated bitmap), but without allocating the associated memory (ie. HF_DISCARDED). They are also marked as discardable (ie. HF_DISCARDABLE), so the first @@ -108,87 +93,85 @@ two handles are used. If the Nimbus driver is unused for a long period of time, these blocks may eventually be discarded as well. -DR_EXIT +*DR_EXIT* - DR_EXIT is also called for all drivers, and is the counterpart +DR_EXIT is also called for all drivers, and is the counterpart of DR_INIT. This function should clean up any memory or resources that have been allocated by the driver, generally things that were allocated in DR_INIT. -DR_FONT_INIT_FONTS +*DR_FONT_INIT_FONTS* - DR_FONT_INIT_FONTS is intended to allow the font driver to +DR_FONT_INIT_FONTS is intended to allow the font driver to inform the system of any additional fonts it may have. The PC/GEOS kernel searches the disk for any fonts in it's format, but by definition most font drivers will be dealing with non-PC/GEOS fonts. - To add a font to the system, two structures must be modified +To add a font to the system, two structures must be modified or created. Both of these structures reside in the font manager's information block, which is passed to the various font driver functions. - First, a FontsAvailEntry must be added, which specifies to the +First, a FontsAvailEntry must be added, which specifies to the system that this particular FontIDs value is available, and where additional information about the font is stored. - The additional information is a separate chunk in the font +The additional information is a separate chunk in the font manager's block. It consists of a FontInfo structure, followed by as many PointSizeEntry structures (for bitmap fonts) and OutlineDataEntry structures (for outline fonts) as is appropriate. - "As many is appropriate" for bitmap fonts constitutes one +"As many is appropriate" for bitmap fonts constitutes one PointSizeEntry for each pointsize/style/weight combination. If there are no bitmaps for the FontIDs value in question, FI_pointSizeTab is zero (0) and there are no PointSizeEntry structures. - "As many is appropriate" for outline fonts constitutes one +"As many is appropriate" for outline fonts constitutes one OutlineDataEntry for each style/weight combination (note this does not include pointsize, as that is irrelevant for outline fonts). If there are no outlines for the FontIDs value in question, FI_outlineTab is zero (0) and there are no OutlineDataEntry structures. ------------------------------------------------------------------------------- - Data Routines ------------------------------------------------------------------------------- +### 4.3 Data Routines -DR_FONT_GEN_WIDTHS +*DR_FONT_GEN_WIDTHS* - DR_FONT_GEN_WIDTHS is called to generate the metrics and basic +DR_FONT_GEN_WIDTHS is called to generate the metrics and basic information for one font. In PC/GEOS, a different font is constituted by: - typeface (FontIDs) - pointsize (WBFixed) - style (TextStyle) - weight (FontWeight) - width (FontWidth) - transformation (TMatrix) - - What the system expects back from this routine is a buffer +* typeface (FontIDs) +* pointsize (WBFixed) +* style (TextStyle) +* weight (FontWeight) +* width (FontWidth) +* transformation (TMatrix) + +What the system expects back from this routine is a buffer containing the following: - FontBuf - font header and metrics information - + - CharTableEntry #1 - CharTableEntry #2 - [...] - CharTableEntry #n - + - [optional cached data] - + - [optional KernPair[1..m]] - [optional BBFixed[1..m]] - - Each CharTableEntry contains the pen width of the character, + FontBuf - font header and metrics information + + + CharTableEntry #1 + CharTableEntry #2 + [...] + CharTableEntry #n + + + [optional cached data] + + + [optional KernPair[1..m]] + [optional BBFixed[1..m]] + +Each CharTableEntry contains the pen width of the character, flags about the size and shape of the character, and the offset to the actual bitmap data for the character if it is built (or a flag indicating it hasn't yet been built). - Given this structure, the system will call the font driver +Given this structure, the system will call the font driver back for each character when it is needed, via the DR_FONT_GEN_CHAR routine. - The kerning information is a pair of matched tables. +The kerning information is a pair of matched tables. FB_kernCount contains the number of kerning pairs. FB_kernPairPtr points to an array of KernPair structures, which are left char / right char combinations that specify each kerning pair. FB_kernValuePtr @@ -197,7 +180,7 @@ specifying the adjustment for the corresponding character pair. Negative values mean move the characters closer; positive values mean move them further apart. - A note about DR_FONT_GEN_WIDTHS: outlines for all styles and +A note about DR_FONT_GEN_WIDTHS: outlines for all styles and all style combinations are generally not available. Underline and strikethrough are rendered by the kernel, and so need not be worried about. Some fonts have plain, bold, italic, and bold-italic @@ -206,7 +189,7 @@ the best case, this leaves superscript and subscript or any combination involving them unaccounted for. In the worst case, this may leave every combination of TextStyles except plain unaccounted for! - In the case a direct outline is not available, the font driver +In the case a direct outline is not available, the font driver is expected to "do its best". This involves tricks like scaling and translating for superscript and subscript, and obliquing for creating italic. To this end, a kernel routine (XXX: not yet written) is @@ -216,7 +199,7 @@ Superscript', and 'Plain' and 'Bold' outlines are available, the best thing to do is to select the 'Bold' outline and scale and translate it to simulate the 'Superscript' attribute. - The "optional cached data" is just that: data that the font +The "optional cached data" is just that: data that the font driver may choose to store in the font. There is no explicit reference to this data, but it can quickly be found by adding the size of the FontBuf plus the appropriate number of CharTableEntry @@ -228,58 +211,59 @@ font, and a reference to which set of routines will be used for rasterizing the bitmap or region data. -DR_FONT_GEN_CHAR +*DR_FONT_GEN_CHAR* - DR_FONT_GEN_CHAR is called to generate the bitmap for a single +DR_FONT_GEN_CHAR is called to generate the bitmap for a single character. The resulting data should be added to the FontBuf block returned by DR_FONT_GEN_WIDTHS after it has been resized appropriately. The system supports two varieties of character data, one simple and the other compacted. - The first format is simple bitmap data, comprised of a header +The first format is simple bitmap data, comprised of a header (CharData) containing the bounds and offset of the bitmap (in device coordinates) for where it should drawn relative to the top of the nominal font box. - This is followed by the data bytes. The data should be +This is followed by the data bytes. The data should be byte-padded, and the in the data, ones are 'on' and zeroes are 'off'. Shown below is an example of the letter 'i': - byte 6 ;width (CD_pictureWidth) - byte 10 ;height (CD_numRows) - byte 3 ;y offset (CD_yoff) - byte 2 ;x offset (CD_xoff) - byte 00110000b ;(CD_data) - byte 00110000b - byte 00000000b - byte 11110000b - byte 00110000b - byte 00110000b - byte 00110000b - byte 00110000b - byte 00110000b - byte 11111100b - - (0,0) - | - | - | - +--* (2,3) - (CD_xoff, CD_yoff) - +----------+ - | ## | - | ## | - | | - | #### | - | ## | - | ## | - | ## | - | ## | - | ## | - | ###### | - +----------+ - - The second format is storing the character as a region. This + + byte 6 ;width (CD_pictureWidth) + byte 10 ;height (CD_numRows) + byte 3 ;y offset (CD_yoff) + byte 2 ;x offset (CD_xoff) + byte 00110000b ;(CD_data) + byte 00110000b + byte 00000000b + byte 11110000b + byte 00110000b + byte 00110000b + byte 00110000b + byte 00110000b + byte 00110000b + byte 11111100b + + (0,0) + | + | + | + +--* (2,3) + (CD_xoff, CD_yoff) + +----------+ + | ## | + | ## | + | | + | #### | + | ## | + | ## | + | ## | + | ## | + | ## | + | ###### | + +----------+ + +The second format is storing the character as a region. This amounts to a scanline compression format, and works quite well for characters at 0, 90, 180 and 270 degree rotations. It works reasonably well for characters at an arbitrary angle of rotation, and @@ -288,15 +272,15 @@ in a script font like Shattuck Avenue. The cutoff point between storing characters as bitmaps and as regions is 125 lines high (eg. 125 point at 72 DPI, 30 point at 300 DPI, etc.) - There is a header (RegionCharData) similar to the header for +There is a header (RegionCharData) similar to the header for bitmap characters. There are two additional pieces of information: the size of the data for the region (in bytes), and the full bounds of the region data, which are used for drawing the region. - More details about the region format can be found in the +More details about the region format can be found in the documentation about the graphics system. - A note about DR_FONT_GEN_CHAR: characters are requested on an +A note about DR_FONT_GEN_CHAR: characters are requested on an as-needed basis. The means the font will start with the FontBuf+CharTableEntry+KernPair+BBFixed information in the block. As characters are added, the font driver will be adding data to this @@ -308,7 +292,7 @@ individual FontBuf blocks below 10K in size. This may not be possible at very large pointsizes, but is a general goal of the system to improve performance. - To this end, the font driver should use information which is +To this end, the font driver should use information which is maintained in the CharTableEntry for each character and the FontBuf. FB_heapCount is the current usage counter for the font. CTE_usage is the current usage counter for that character. Given these values, it @@ -318,73 +302,71 @@ delete this LRU character, thereby freeing up space for additional character(s) in the FontBuf block. A kernel routine (XXX: not written) is provided to do this. - After DR_FONT_GEN_WIDTHS is called, then DR_FONT_GEN_CHAR +After DR_FONT_GEN_WIDTHS is called, then DR_FONT_GEN_CHAR is called several times, the results will be something like what is below. The FontBuf block will have been expanded to include the character bitmap/region data, although because of the LRU caching scheme, the characters may not be in any particular order. - FontBuf - font header and metrics information - + - CharTableEntry #1 - CharTableEntry #2 - [...] - CharTableEntry #n - + - [optional cached data] - + - [optional KernPair[1..m]] - [optional BBFixed[1..m]] - + - Region/CharData #a - Region/CharData #b - [...] - Region/CharData #c - ------------------------------------------------------------------------------- - Metrics Routines ------------------------------------------------------------------------------- - -DR_FONT_CHAR_METRICS - - DR_FONT_CHAR_METRICS is called to return metrics information + FontBuf - font header and metrics information + + + CharTableEntry #1 + CharTableEntry #2 + [...] + CharTableEntry #n + + + [optional cached data] + + + [optional KernPair[1..m]] + [optional BBFixed[1..m]] + + + Region/CharData #a + Region/CharData #b + [...] + Region/CharData #c + +### 4.4 Metrics Routines + +*DR_FONT_CHAR_METRICS* + +DR_FONT_CHAR_METRICS is called to return metrics information about a particular character in a font. The information is in document coordinates, which is to say it is not affected by scaling, rotation, etc. that modifies the way the document is viewed, but simply by the pointsize and font attributes requested. - There are currently four pieces of information returned: min +There are currently four pieces of information returned: min x, min y, max x and max y. These values are relative to (0,0) at the baseline/starting pen position: -(xmin,ymax) (xmax,ymax) - +------+ - | ##| - | ##| - | | - | ####| - | ##| - | ##| - | ##| - | ##| - | ##| - | ##| - (0,0)+----##+ - | ##| - | ###| - |#### | - +------+ -(xmin,ymin) (xmax,ymin) - - Note that any of the values can be negative. Normally, the + (xmin,ymax) (xmax,ymax) + +------+ + | ##| + | ##| + | | + | ####| + | ##| + | ##| + | ##| + | ##| + | ##| + | ##| + (0,0)+----##+ + | ##| + | ###| + |#### | + +------+ + (xmin,ymin) (xmax,ymin) + +Note that any of the values can be negative. Normally, the data will be returned as a WBFixed, but there is an optional flag which may be passed, indicating the data should be rounded and returned as a word. -DR_FONT_GEN_PATH +*DR_FONT_GEN_PATH* - DR_FONT_GEN_PATH is called to return an outline description of +DR_FONT_GEN_PATH is called to return an outline description of a character at a particular pointsize, rotation, etc. It is used by things like the Postscript(tm) printer driver for building Adobe Type 3 fonts to download to printers when the font is not resident in the @@ -392,33 +374,33 @@ printer. For example, Shattuck Avenue (aka Park Avenue) is generally not in Postscript printers, and so a Type 3 font would be built and downloaded for it. - This outline description should be comprised of lines, Bezier +This outline description should be comprised of lines, Bezier curves, pen moves, and in some cases, a translation. Composite characters, such as accented letters, can be rendered by rendering the accent character, translating, and then rendering the unaccented letter. - The use for generating Postscript fonts is strong enough that +The use for generating Postscript fonts is strong enough that there is a special FGPF_POSTSCRIPT flag which can be passed to the function. The font driver is expected to rotate and scale the outlines such that (0,0) is the baseline/starting pen position, and the data is sized for a 1000 unit em-square. - If the FGPF_POSTSCRIPT flag is passed, the font driver is also +If the FGPF_POSTSCRIPT flag is passed, the font driver is also expected to emit a comment at the start of the graphics string which contains information for the Postscript "setcachedevice" command. This information is the pen width and bounding box information, in the order: width(x),width(y),ll(x),ll(y),ur(x),ur(y). -DR_FONT_GEN_IN_REGION +*DR_FONT_GEN_IN_REGION* - DR_FONT_GEN_IN_REGION is called to add the definition of a +DR_FONT_GEN_IN_REGION is called to add the definition of a character to a passed RegionPath. It is used by the graphics path code for filling and/or creating clip paths that contain text strings & characters. - The outline description of a font is normally comprised of +The outline description of a font is normally comprised of lines, Bezier curves & pen moves. At large point sizes (for the Nimbus font driver, above 500 points), this data is "played" into a RegionPath, and then handed to the video driver which draws the region @@ -426,7 +408,7 @@ on the screen. For paths, characters are always generated using regions, regardless of point size, and use this routine as the method for incorporating text into a path. - An implementation of this call should be careful to include +An implementation of this call should be careful to include the transformations contained in both the GState & Window (ie. use the W_curTMatrix) for generating the font, and the font must be carefully drawn into the correct location (GS_penPos in the GState) in the @@ -435,39 +417,37 @@ code might normally do). Finally, one may not assume that this will be the only routine called to add data to the RegionPath, so the integrity of RegionPath data must be ensured. - ------------------------------------------------------------------------------- - Debugging Tips ------------------------------------------------------------------------------- - To assist in debugging font drivers and their interaction with +### 4.5 Debugging Tips + +To assist in debugging font drivers and their interaction with the Font Manager, there are a number of useful TCL commands available: -fonts - print various items about fonts and font drivers in the system -pfontinfo - print the FontInfo structure for a font -pfont - print the FontBuf structure for a font and any bitmaps that - have been built for it -pchar - print the bitmap for a character in a font, if it has been - built -pusage - print the usage values for all characters that have been - built, and which of them will be discarded next +* fonts - print various items about fonts and font drivers in the system +* pfontinfo - print the FontInfo structure for a font +* pfont - print the FontBuf structure for a font and any bitmaps that + have been built for it +* pchar - print the bitmap for a character in a font, if it has been + built +* pusage - print the usage values for all characters that have been + built, and which of them will be discarded next A typical series of commands might be something like: -(geos:0) 1 => fonts -d ;show the available font drivers -(geos:0) 2 => fonts -a ;show the available fonts -(geos:0) 3 => pfontinfo FONT_URW_ROMAN ;show FontInfo for URW Roman + (geos:0) 1 => fonts -d ;show the available font drivers + (geos:0) 2 => fonts -a ;show the available fonts + (geos:0) 3 => pfontinfo FONT_URW_ROMAN ;show FontInfo for URW Roman - <...call GEN_WIDTHS here...> ;now we've got a FontBuf... + <...call GEN_WIDTHS here...> ;now we've got a FontBuf... -(geos:0) 4 => fonts -u FONT_URW_ROMAN ;show sizes of URW Roman in use -(geos:0) 5 => pfont ^h1ab0h ;print the FontBuf for a font + (geos:0) 4 => fonts -u FONT_URW_ROMAN ;show sizes of URW Roman in use + (geos:0) 5 => pfont ^h1ab0h ;print the FontBuf for a font - <...call GEN_CHAR here...> ;now we've got a bitmap... + <...call GEN_CHAR here...> ;now we've got a bitmap... -(geos:0) 6 => pchar C_CAP_A ^h1ab0h ;print the bitmap for 'A' + (geos:0) 6 => pchar C_CAP_A ^h1ab0h ;print the bitmap for 'A' - <...call GEN_CHAR here...> ;now we've got two bitmaps... + <...call GEN_CHAR here...> ;now we've got two bitmaps... -(geos:0) 7 => pusage ^h1ab0h ;print the LRU information + (geos:0) 7 => pusage ^h1ab0h ;print the LRU information diff --git a/TechDocs/Markdown/ddk.md b/TechDocs/Markdown/ddk.md index 529403480..af6168168 100644 --- a/TechDocs/Markdown/ddk.md +++ b/TechDocs/Markdown/ddk.md @@ -25,3 +25,10 @@ [3.2 PCMCIA Library Functions](Ddk/ddkpcmcia.md#32-PCMCIA-Library-Functions) [3.3 CardServices Functions](Ddk/ddkpcmcia.md#33-CardServices-Functions) [3.4 CardServices Events](Ddk/ddkpcmcia.md#34-CardServices-Events) + +**[4 Font Driver](Ddk/ddkfont.md#4-font-driver)** + [4.1 Overview](Ddk/ddkfont.md#41-Overview) + [4.2 Initialization Routines](Ddk/ddkfont.md#42-Initialization-Routines) + [4.3 Data Routines](Ddk/ddkfont.md#43-Data-Routines) + [4.4 Metrics Routines](Ddk/ddkfont.md#44-Metrics-Routines) + [4.5 Debugging Tips](Ddk/ddkfont.md#45-Debugging-Tips) From 6948b9ef43b033075f78b4adea85c0a4b0b380d1 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 21 Jul 2023 10:44:07 +0200 Subject: [PATCH 182/246] Fixing supscript and superscript --- Driver/Font/TrueType/Adapter/ttadapter.h | 7 +- Driver/Font/TrueType/Adapter/ttchars.c | 5 + Driver/Font/TrueType/Adapter/ttwidths.c | 121 ++++++++++++++--------- 3 files changed, 84 insertions(+), 49 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index d55b09679..1db2ed092 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -457,13 +457,10 @@ typedef struct ( (byte) ( (WWFixedAsDWord)value >> 8 ) ) /* - * convert value (WBFixed) to TT_F26DOT6 + * convert value (WBFixed) to WWFixedAsDWord */ -#define WBFIXED_TO_FIXED26DOT6( value ) \ - ( ( ( (long)value.WBF_int ) * 1024 ) | value.WBF_frac >> 2 ) - #define WBFIXED_TO_WWFIXEDASDWORD( value ) \ - ( ( (long)value.WBF_int << 16 ) | ( value.WBF_frac << 8 ) ) + ( (long) ( ( (long)(value.WBF_int) ) * 0x00010000 ) | ( ( (long)value.WBF_frac) << 8 ) ) #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index bde2609b8..18b03d002 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -80,6 +80,8 @@ void _pascal TrueType_Gen_Chars( void* charData; word width, height, size; + int s, h; + EC( ECCheckBounds( (void*)fontBuf ) ); EC( ECCheckBounds( (void*)fontInfo ) ); @@ -128,6 +130,9 @@ EC( ECCheckFileHandle( truetypeFile ) ); transformMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + ( fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1 ) * sizeof( CharTableEntry )); TT_Transform_Outline( &OUTLINE, &transformMatrix->TM_matrix ); + s = transformMatrix->TM_scriptY; + h = transformMatrix->TM_heightY; + /* get glyphs boundig box */ TT_Get_Outline_BBox( &OUTLINE, &GLYPH_BBOX ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 5b28bc605..4fae086de 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -44,10 +44,16 @@ static void ConvertWidths( TRUETYPE_VARS, static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ); -static void CalcTransform( TransformMatrix* transMatrix, - FontMatrix* fontMatrix, +static void CalcScaleForWidths( TRUETYPE_VARS, + WWFixedAsDWord pointSize, TextStyle styleToImplement ); +static void CalcTransform( TRUETYPE_VARS, + TransformMatrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle stylesToImplement, + FontBuf* fontBuf ); + static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ); @@ -145,37 +151,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; - /* calculate the transformation matrix and copy it into the FontBlock */ - transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); - CalcTransform( transMatrix, fontMatrix, stylesToImplement ); - - /* calculate scale factor for width and height */ - SCALE_HEIGHT = GrUDivWWFixed( pointSize, MakeWWFixed( FACE_PROPERTIES.header->Units_Per_EM ) ); - SCALE_WIDTH = SCALE_HEIGHT; - - if( stylesToImplement & TS_BOLD ) - SCALE_WIDTH = GrMulWWFixed( SCALE_HEIGHT, WWFIXED_1_POINR_1 ); - - if( stylesToImplement & TS_SUBSCRIPT ) - { - SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); - transMatrix->TM_scriptY = GrMulWWFixed(SUBSCRIPT_OFFSET, - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) >> 16; - } - - if( stylesToImplement & TS_SUPERSCRIPT ) - { - SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); - transMatrix->TM_scriptY = ( GrMulWWFixed( SUPERSCRIPT_OFFSET, - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) - - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos ) - - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ) ) >> 16; - } + /* calculate scale factor */ + CalcScaleForWidths( trueTypeVars, pointSize, stylesToImplement ); /* convert FontHeader and fill FontBuf structure */ - ConvertHeader( trueTypeVars, fontHeader, fontBuf ); /* fill kerning pairs and kerning values */ @@ -184,6 +163,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); /* convert widths and fill CharTableEntries */ ConvertWidths( trueTypeVars, fontHeader, fontBuf ); + /* calculate the transformation matrix and copy it into the FontBlock */ + transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); + CalcTransform( trueTypeVars, transMatrix, fontMatrix, stylesToImplement, fontBuf ); + //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos AdjustFontBuf( transMatrix, fontMatrix, fontBuf ); @@ -336,6 +319,39 @@ static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) fontBuf->FB_kernPairPtr = NULL; } +/******************************************************************** + * CalcScaleForWidths + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: TRUETYPE_VARS + * pointSize + * styleToImplement + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/07/23 JK Initial Revision + *******************************************************************/ + +static void CalcScaleForWidths( TRUETYPE_VARS, + WWFixedAsDWord pointSize, + TextStyle stylesToImplement ) +{ + SCALE_HEIGHT = GrUDivWWFixed( pointSize, MakeWWFixed( FACE_PROPERTIES.header->Units_Per_EM ) ); + SCALE_WIDTH = SCALE_HEIGHT; + + if( stylesToImplement & ( TS_BOLD ) ) + SCALE_WIDTH = GrMulWWFixed( SCALE_HEIGHT, WWFIXED_1_POINR_1 ); + + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) + SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); +} + /******************************************************************** * CalcTransform @@ -357,21 +373,28 @@ static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) * 20/12/22 JK Initial Revision *******************************************************************/ -static void CalcTransform( TransformMatrix* transMatrix, +static void CalcTransform( TRUETYPE_VARS, + TransformMatrix* transMatrix, FontMatrix* fontMatrix, - TextStyle stylesToImplement ) + TextStyle stylesToImplement, + FontBuf* fontBuf ) { TT_Matrix tempMatrix; - + EC( ECCheckBounds( (void*)transMatrix ) ); EC( ECCheckBounds( (void*)fontMatrix ) ); /* copy fontMatrix into transMatrix */ - tempMatrix.xx = 1L << 16; - tempMatrix.xy = 0; - tempMatrix.yx = 0; - tempMatrix.yy = 1L << 16; + tempMatrix.xx = 1L << 16; + tempMatrix.xy = 0; + tempMatrix.yx = 0; + tempMatrix.yy = 1L << 16; + + transMatrix->TM_heightX = 0; + transMatrix->TM_scriptX = 0; + transMatrix->TM_heightY = 0; + transMatrix->TM_scriptY = 0; /* fake bold style */ if( stylesToImplement & TS_BOLD ) @@ -389,6 +412,21 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); { tempMatrix.xx = GrMulWWFixed( tempMatrix.xx, SCRIPT_FACTOR ); tempMatrix.yy = GrMulWWFixed( tempMatrix.yy, SCRIPT_FACTOR ); + + if( stylesToImplement & TS_SUBSCRIPT ) + { + transMatrix->TM_scriptY = GrMulWWFixed( SUBSCRIPT_OFFSET, + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) >> 16; + } + else + { + transMatrix->TM_scriptY = GrMulWWFixed( SUPERSCRIPT_OFFSET, + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) - + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos ) - + WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ) >> 16; + } } /* integrate fontMatrix */ @@ -400,10 +438,6 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); GrMulWWFixed( tempMatrix.yy, fontMatrix->FM_21 ); transMatrix->TM_matrix.yy = GrMulWWFixed( tempMatrix.yx, fontMatrix->FM_12 ) + GrMulWWFixed( tempMatrix.yy, fontMatrix->FM_22 ); - transMatrix->TM_heightX = 0; - transMatrix->TM_scriptX = 0; - transMatrix->TM_heightY = 0; - transMatrix->TM_scriptY = 0; } @@ -570,11 +604,10 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) { - //adjust FB_pixHeight, FB_minTSB, heightY fontBuf->FB_flags |= FBF_IS_COMPLEX; - //TODO: das ist nur eine provisorische Lösung --> + //TODO: Das ist nur eine provisorische Lösung: transMatrix->TM_heightY = fontBuf->FB_baselinePos.WBF_int + 1; if( fontMatrix->FM_flags & TF_ROTATED ) From 75a11a7c0ee884f6a771d907ef322da1b8f37e89 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 21 Jul 2023 10:50:07 +0200 Subject: [PATCH 183/246] Testcode removed. --- Driver/Font/TrueType/Adapter/ttchars.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 18b03d002..bde2609b8 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -80,8 +80,6 @@ void _pascal TrueType_Gen_Chars( void* charData; word width, height, size; - int s, h; - EC( ECCheckBounds( (void*)fontBuf ) ); EC( ECCheckBounds( (void*)fontInfo ) ); @@ -130,9 +128,6 @@ EC( ECCheckFileHandle( truetypeFile ) ); transformMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + ( fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1 ) * sizeof( CharTableEntry )); TT_Transform_Outline( &OUTLINE, &transformMatrix->TM_matrix ); - s = transformMatrix->TM_scriptY; - h = transformMatrix->TM_heightY; - /* get glyphs boundig box */ TT_Get_Outline_BBox( &OUTLINE, &GLYPH_BBOX ); From 6495708b88cf0dcef6d10628b2daad4e6dcb41cb Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Sat, 15 Jul 2023 18:20:58 +0200 Subject: [PATCH 184/246] Use ROOT_DIR environment variable in path examples --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a1952685b..d6bdac5c3 100644 --- a/README.md +++ b/README.md @@ -35,19 +35,19 @@ Document is work in progress.... stay tuned! ## Building PC/GEOS SDK Build pmake tool: -- `cd pcgeos/Tools/pmake/pmake` +- `cd %ROOT_DIR%/Tools/pmake/pmake` - `wmake install` Build all the other SDK Tools: -- `cd pcgeos/Installed/Tools` +- `cd %ROOT_DIR%/Installed/Tools` - `pmake install` Build all PC/GEOS (target) components: -- `cd pcgeos/Installed` +- `cd %ROOT_DIR%/Installed` - `pmake` Build the target environment: -- `cd pcgeos/Tools/build/product/bbxensem/Scripts` +- `cd %ROOT_DIR%/Tools/build/product/bbxensem/Scripts` - `perl -I. buildbbx.pl` - the answers to the questions from the above perl-script are: - nt (for the platform) @@ -60,7 +60,7 @@ Build the target environment: Launch the target environment in dosbox: - make sure dosbox is added to your path variable, or [pcgeos-basebox](https://github.com/bluewaysw/pcgeos-basebox/tags) is installed and configured using BASEBOX environmental variable -- `cd pcgeos` +- `cd %ROOT_DIR%` - `bin/target` - the "swat" debugger stops immediately after the first stage of the boot process - enter `quit` at the "=>" prompt to detach the debugger and launch PC/GEOS stand-alone From 6513f948c9c9f24c8290ff49aa9e0fcd1f6d56bd Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Mon, 17 Jul 2023 23:24:10 +0200 Subject: [PATCH 185/246] First draft of persistent font information --- Driver/Font/TrueType/Adapter/ttadapter.c | 153 ++++++++++++++++++ Driver/Font/TrueType/Adapter/ttadapter.h | 15 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 13 +- Driver/Font/TrueType/Adapter/ttcharmapper.h | 5 +- Driver/Font/TrueType/Adapter/ttchars.c | 22 +-- Driver/Font/TrueType/Adapter/ttinit.c | 4 +- Driver/Font/TrueType/Adapter/ttmetrics.c | 26 +-- Driver/Font/TrueType/Adapter/ttwidths.c | 27 +--- Driver/Font/TrueType/Main/truetypeInit.asm | 5 +- Installed/Driver/Font/TrueType/Makefile | 42 ++--- .../Driver/Font/TrueType/dependencies.mk | 13 ++ 11 files changed, 226 insertions(+), 99 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttadapter.c diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c new file mode 100644 index 000000000..6dcea431b --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -0,0 +1,153 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttadapter.c + * + * AUTHOR: Marcus Groeber: July 16 2023 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial version + * + * DESCRIPTION: + * Common functions used by TrueType Adapter. + ***********************************************************************/ + +#include "ttadapter.h" +#include +#include + +static int strcmp( const char* s1, const char* s2 ); + + +/******************************************************************** + * TrueType_Lock_Face + ******************************************************************** + * SYNOPSIS: Active a particular face. + * + * PARAMETERS: *trueTypeVars + * *entry Ptr to font entry. + * + * RETURNS: TT_Error + * + * STRATEGY: - check if face is already loaded + * - if not, open file with face + * - load face from file + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial Revision + * + *******************************************************************/ + +Boolean TrueType_Lock_Face(TRUETYPE_VARS, TrueTypeOutlineEntry* entry) +{ + Boolean failure = TRUE; + + if( strcmp( entry->TTOE_fontFileName, trueTypeVars->entry.TTOE_fontFileName )==0 ) + { + failure = FALSE; + goto Fin; + } + + TrueType_Free_Face( trueTypeVars ); + + FilePushDir(); + FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); + + /* get filename and load ttf file */ + TTFILE = FileOpen( entry->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); + /* change owner to ourselves, to make handle persist if application closes */ + HandleModifyOwner( (MemHandle)TTFILE, GeodeGetCodeProcessHandle() ); + FilePopDir(); + + if( TT_Open_Face( TTFILE, &FACE ) ) + goto Fin; + if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) + goto Fail; + if ( getCharMap( trueTypeVars, &CHAR_MAP ) ) + goto Fail; + + /* font has been fully loaded */ + trueTypeVars->entry = *entry; + failure = FALSE; +Fin: + return failure; +Fail: + TT_Close_Face( FACE ); + goto Fin; +} + + +/******************************************************************** + * TrueType_Unlock_Face + ******************************************************************** + * SYNOPSIS: Deactivate the currently active face. + * + * PARAMETERS: *trueTypeVars + * + * RETURNS: TT_Error + * + * STRATEGY: - free resources used by face + * - close file + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial Revision + * + *******************************************************************/ + +void TrueType_Unlock_Face(TRUETYPE_VARS) +{ + /* Will be used for unlocking moveable font resources */ + (void)trueTypeVars; +} + +/******************************************************************** + * TrueType_Free_Face + ******************************************************************** + * SYNOPSIS: Close the currently active face. + * + * PARAMETERS: *trueTypeVars + * + * RETURNS: TT_Error + * + * STRATEGY: - free resources used by face + * - close file + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 16/07/23 MG Initial Revision + * + *******************************************************************/ + +void TrueType_Free_Face(TRUETYPE_VARS) +{ + if ( trueTypeVars->entry.TTOE_fontFileName[0] ) + { + TT_Close_Face( FACE ); + trueTypeVars->entry.TTOE_fontFileName[0] = 0; + } + if ( TTFILE ) + { + FileClose( TTFILE, FALSE ); + TTFILE = NullHandle; + } +} + +static int strcmp( const char* s1, const char* s2 ) +{ + while ( *s1 && ( *s1 == *s2 ) ) + { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 1db2ed092..1fcb99f0d 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -378,6 +378,10 @@ typedef struct TT_CharMap charMap; TT_Outline outline; TT_BBox bbox; + + /* currently open face */ + FileHandle ttfile; + TrueTypeOutlineEntry entry; } TrueTypeVars; @@ -396,7 +400,8 @@ typedef struct #define GLYPH_BBOX trueTypeVars->glyphMetrics.bbox #define RASTER_MAP trueTypeVars->rasterMap #define SCALE_HEIGHT trueTypeVars->scaleHeight -#define SCALE_WIDTH trueTypeVars->scaleWidth +#define SCALE_WIDTH trueTypeVars->scaleWidth +#define TTFILE trueTypeVars->ttfile #define UNITS_PER_EM FACE_PROPERTIES.header->Units_Per_EM @@ -463,4 +468,12 @@ typedef struct ( (long) ( ( (long)(value.WBF_int) ) * 0x00010000 ) | ( ( (long)value.WBF_frac) << 8 ) ) +/*********************************************************************** + * functions + ***********************************************************************/ + +Boolean TrueType_Lock_Face(TRUETYPE_VARS, TrueTypeOutlineEntry* entry); +void TrueType_Unlock_Face(TRUETYPE_VARS); +void TrueType_Free_Face(TRUETYPE_VARS); + #endif /* _TTADAPTER_H_ */ diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 3e2d48709..4f19d114e 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -281,27 +281,26 @@ CharMapFlags GeosCharMapFlag( word geosChar ) /* * Get microsoft unicode charmap in face. */ -TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ) +TT_Error getCharMap( TRUETYPE_VARS, TT_CharMap* charMap ) { - TT_Face_Properties face_Properties; TT_UShort platform; TT_UShort encoding; int map; - TT_Get_Face_Properties( face, &face_Properties ); + TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ); - for ( map = 0; map < face_Properties.num_CharMaps; ++map ) + for ( map = 0; map < FACE_PROPERTIES.num_CharMaps; ++map ) { - TT_Get_CharMap_ID( face, map, &platform, &encoding ); + TT_Get_CharMap_ID( FACE, map, &platform, &encoding ); if ( platform == TT_PLATFORM_MICROSOFT && encoding == TT_MS_ID_UNICODE_CS ) { - TT_Get_CharMap(face, map, charMap); + TT_Get_CharMap(FACE, map, charMap); break; } } - if ( map == face_Properties.num_CharMaps ) return TT_Err_CMap_Table_Missing; + if ( map == FACE_PROPERTIES.num_CharMaps ) return TT_Err_CMap_Table_Missing; else return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index eeb3409bb..5438476d8 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -22,6 +22,7 @@ #include #include +#include "ttadapter.h" typedef ByteFlags CharMapFlags; @@ -46,11 +47,13 @@ typedef struct * internal functions ***********************************************************************/ +word GeosCharToUnicode( word geosChar ); + word InitGeosCharsInCharMap( TT_CharMap map, char* firstChar, char* lastChar ); word CountKernPairsWithGeosChars( TT_Face face ); -TT_Error getCharMap( TT_Face face, TT_CharMap* charMap ); +TT_Error getCharMap( TRUETYPE_VARS, TT_CharMap* charMap ); CharMapFlags GeosCharMapFlag( word geosChar ); diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index bde2609b8..cdc9fb93f 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -71,7 +71,6 @@ void _pascal TrueType_Gen_Chars( MemHandle bitmapHandle, MemHandle varBlock ) { - FileHandle truetypeFile; MemHandle fontBufHandle; TrueTypeOutlineEntry* trueTypeOutline; TT_UShort charIndex; @@ -89,24 +88,12 @@ EC( ECCheckMemHandle( varBlock ) ); /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); - if( trueTypeVars == NULL ) - { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); - trueTypeVars = MemLock( varBlock ); - } - - - FilePushDir(); - FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); - // get filename an load ttf file trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); - truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - -EC( ECCheckFileHandle( truetypeFile ) ); /* open face, create instance and glyph */ - if( TT_Open_Face( truetypeFile, &FACE ) ) + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; TT_New_Glyph( FACE, &GLYPH ); @@ -114,7 +101,6 @@ EC( ECCheckFileHandle( truetypeFile ) ); TT_Set_Instance_Resolutions( INSTANCE, 72, 72 ); /* get TT char index */ - getCharMap( FACE, &CHAR_MAP ); charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); /* set pointsize and get metrics */ @@ -221,10 +207,8 @@ EC( ECCheckFileHandle( truetypeFile ) ); /* cleanup */ MemUnlock( bitmapHandle ); + TrueType_Unlock_Face( trueTypeVars ); Fail: - TT_Close_Face( FACE ); - FileClose( truetypeFile, FALSE ); - FilePopDir(); MemUnlock( varBlock ); } diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index ccd5baed3..b0341e37a 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -164,7 +164,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ) trueTypeVars = MemLock( varBlock ); if( trueTypeVars == NULL ) { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); + MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR | HAF_ZERO_INIT ); trueTypeVars = MemLock( varBlock ); } @@ -281,7 +281,7 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) goto Fail; - if ( getCharMap( FACE, &CHAR_MAP ) ) + if ( getCharMap( trueTypeVars, &CHAR_MAP ) ) goto Fail; if ( getNameFromNameTable( trueTypeVars, FAMILY_NAME, FAMILY_NAME_ID ) == 0 ) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 17c1f3e15..265c20fe7 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -63,7 +63,6 @@ void _pascal TrueType_Char_Metrics( dword* result, MemHandle varBlock ) { - FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; TransformMatrix transMatrix; word charIndex; @@ -78,29 +77,16 @@ EC( ECCheckStack() ); /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); - if( trueTypeVars == NULL ) - { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); - trueTypeVars = MemLock( varBlock ); - } - - /* get filename an load ttf file */ - FilePushDir(); - FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); - truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - -EC( ECCheckFileHandle( truetypeFile ) ); - - CalcTransformMatrix( stylesToImplement, &transMatrix ); - if( TT_Open_Face( truetypeFile, &FACE ) ) + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; - // get TT char index - getCharMap( FACE, &CHAR_MAP ); + CalcTransformMatrix( stylesToImplement, &transMatrix ); + // get TT char index charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); // load glyph @@ -142,12 +128,10 @@ EC( ECCheckFileHandle( truetypeFile ) ); TT_Done_Instance( INSTANCE ); TT_Done_Glyph( GLYPH ); + TrueType_Unlock_Face( trueTypeVars ); Fail: - TT_Close_Face( FACE ); MemUnlock( varBlock ); - FileClose( truetypeFile, FALSE ); - FilePopDir(); } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 4fae086de..72bcc647e 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -95,7 +95,6 @@ MemHandle _pascal TrueType_Gen_Widths( TextStyle stylesToImplement, MemHandle varBlock ) { - FileHandle truetypeFile; TrueTypeOutlineEntry* trueTypeOutline; TrueTypeVars* trueTypeVars; FontHeader* fontHeader; @@ -114,31 +113,15 @@ MemHandle _pascal TrueType_Gen_Widths( /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); - if( trueTypeVars == NULL ) - { - MemReAlloc( varBlock, sizeof( TrueTypeVars ), HAF_NO_ERR ); - trueTypeVars = MemLock( varBlock ); - } - EC( ECCheckBounds( (void*)trueTypeVars ) ); - // get filename an load ttf file - FilePushDir(); - FileSetCurrentPath( SP_FONT, TTF_DIRECTORY ); - // get filename an load ttf file trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), headerEntry->OE_handle ); - truetypeFile = FileOpen( trueTypeOutline->TTOE_fontFileName, FILE_ACCESS_R | FILE_DENY_W ); - -EC( ECCheckFileHandle( truetypeFile ) ); // get pointer to FontHeader fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), firstEntry->OE_handle ); - if ( TT_Open_Face( truetypeFile, &FACE ) ) - goto Fin; - - if ( TT_Get_Face_Properties( FACE, &FACE_PROPERTIES ) ) + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ @@ -170,12 +153,9 @@ EC( ECCheckFileHandle( truetypeFile ) ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos AdjustFontBuf( transMatrix, fontMatrix, fontBuf ); -Fail: - TT_Close_Face( FACE ); -Fin: - FileClose( truetypeFile, FALSE ); + TrueType_Unlock_Face( trueTypeVars ); +Fail: MemUnlock( varBlock ); - FilePopDir(); return fontHandle; } @@ -211,7 +191,6 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB TT_New_Glyph( FACE, &GLYPH ); TT_New_Instance( FACE, &INSTANCE ); - getCharMap( FACE, &CHAR_MAP ); for( currentChar = fontHeader->FH_firstChar; currentChar <= fontHeader->FH_lastChar; ++currentChar ) { diff --git a/Driver/Font/TrueType/Main/truetypeInit.asm b/Driver/Font/TrueType/Main/truetypeInit.asm index c6c87e78b..301d99df4 100644 --- a/Driver/Font/TrueType/Main/truetypeInit.asm +++ b/Driver/Font/TrueType/Main/truetypeInit.asm @@ -76,10 +76,9 @@ TrueTypeInit proc far ; We also need a block to use for variables. We don't ; need it yet, either. ; - mov ax, size TrueTypeVars ;ax <- size of block + mov ax, TRUETYPE_BLOCK_SIZE ;ax <- size of block mov bx, handle 0 ;bx <- make TrueType owner - mov cx, mask HF_DISCARDABLE \ - or mask HF_SWAPABLE \ + mov cx, mask HF_SWAPABLE \ or mask HF_SHARABLE \ or mask HF_DISCARDED \ or (mask HAF_NO_ERR shl 8) ;cl, ch <- alloc flags diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 4640e06f7..1131663f1 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -4,31 +4,31 @@ # If you edit it, you will lose your changes, should it be regenerated. # GEODE = truetype -MAIN = truetypeEscape.asm ansic_runtime.asm mainManager.asm\ - truetypeWidths.asm ansic_memory.asm truetypeMetrics.asm\ - truetypeInit.asm truetypeEC.asm truetypeChars.asm\ - truetypePath.asm truetypeMacros.def truetypeVariable.def\ - truetypeConstant.def -ADAPTER = ttchars.c ttinit.c ttmetrics.c ttcharmapper.c ttwidths.c\ - ttpath.c ttcharmapper.h ttwidths.h ttinit.h ttmetrics.h\ - ttadapter.h -FREETYPE = ttcache.c ttraster.c ttmutex.c ttgload.c ttextend.c\ - ttcalc.c ttapi.c ftxkern.c ttinterp.c ttload.c ttfile.c\ - ttcmap.c ttobjs.c ttmemory.c ttcache.h ttcmap.h\ - ttconfig.h freetype.h ttgload.h ttfile.h ttinterp.h\ - ttload.h tttables.h ttobjs.h fterrid.h ttraster.h\ - ttengine.h tttypes.h ttmutex.h ft_conf.h ttextend.h\ - ftnameid.h ttcalc.h ftxkern.h ttmemory.h tttags.h +ADAPTER = ttadapter.c ttcharmapper.c ttchars.c ttinit.c ttmetrics.c\ + ttpath.c ttwidths.c ttadapter.h ttcharmapper.h ttchars.h\ + ttinit.h ttmetrics.h ttwidths.h +FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttextend.c\ + ttfile.c ttgload.c ttinterp.c ttload.c ttmemory.c\ + ttmutex.c ttobjs.c ttraster.c freetype.h fterrid.h\ + ftnameid.h ftxkern.h ft_conf.h ttcache.h ttcalc.h\ + ttcmap.h ttconfig.h ttengine.h ttextend.h ttfile.h\ + ttgload.h ttinterp.h ttload.h ttmemory.h ttmutex.h\ + ttobjs.h ttraster.h tttables.h tttags.h tttypes.h +MAIN = ansic_memory.asm ansic_runtime.asm mainManager.asm\ + truetypeChars.asm truetypeEC.asm truetypeEscape.asm\ + truetypeInit.asm truetypeMetrics.asm truetypePath.asm\ + truetypeWidths.asm truetypeConstant.def\ + truetypeMacros.def truetypeVariable.def UI_TO_RDFS = -OBJS = ttchars.obj ttinit.obj ttmetrics.obj ttcharmapper.obj\ - ttwidths.obj ttpath.obj ttcache.obj ttraster.obj\ - ttmutex.obj ttgload.obj ttextend.obj ttcalc.obj ttapi.obj\ - ftxkern.obj ttinterp.obj ttload.obj ttfile.obj ttcmap.obj\ - ttobjs.obj ttmemory.obj +OBJS = ttadapter.obj ttcharmapper.obj ttchars.obj ttinit.obj\ + ttmetrics.obj ttpath.obj ttwidths.obj ftxkern.obj\ + ttapi.obj ttcache.obj ttcalc.obj ttcmap.obj ttextend.obj\ + ttfile.obj ttgload.obj ttinterp.obj ttload.obj\ + ttmemory.obj ttmutex.obj ttobjs.obj ttraster.obj COMMON = MODULES = Main CMODULES = Adapter FreeType -SRCS = $(MAIN) $(ADAPTER) $(FREETYPE) $(COMMON) +SRCS = $(ADAPTER) $(FREETYPE) $(MAIN) $(COMMON) LOBJS = SYSMAKEFILE = geode.mk diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index 24b484802..40dee37eb 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -13,6 +13,18 @@ Main.eobj: Main/mainManager.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ truetypeEC.asm ansic_runtime.asm ansic_memory.asm +ttadapter.obj \ +ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ + Adapter/../FreeType/freetype.h \ + Adapter/../FreeType/fterrid.h \ + Adapter/../FreeType/ftnameid.h \ + Adapter/../FreeType/ttengine.h \ + Adapter/../FreeType/tttypes.h \ + Adapter/../FreeType/ttconfig.h \ + Adapter/../FreeType/ft_conf.h resource.h graphics.h \ + font.h color.h heap.h lmem.h Ansi/stdlib.h \ + Adapter/../FreeType/ttmutex.h \ + Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h ttchars.obj \ ttchars.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/freetype.h \ @@ -50,6 +62,7 @@ ttmetrics.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/ttcalc.h Adapter/ttmetrics.h ttcharmapper.obj \ ttcharmapper.eobj: Adapter/ttcharmapper.h geos.h FreeType/freetype.h \ + Adapter/ttadapter.h \ FreeType/fterrid.h FreeType/ftnameid.h unicode.h ttwidths.obj \ ttwidths.eobj: geos.h ec.h unicode.h graphics.h fontID.h font.h color.h \ From e8a4fe1f34d301539c03465e1edb5199d0dd509a Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Wed, 19 Jul 2023 23:02:08 +0200 Subject: [PATCH 186/246] Add Font readme to DDK and format as Markdown --- .../Markdown/Ddk/ddkfont.md | 368 +++++++++--------- TechDocs/Markdown/ddk.md | 7 + 2 files changed, 181 insertions(+), 194 deletions(-) rename Driver/Font/FontCom/README.font => TechDocs/Markdown/Ddk/ddkfont.md (63%) diff --git a/Driver/Font/FontCom/README.font b/TechDocs/Markdown/Ddk/ddkfont.md similarity index 63% rename from Driver/Font/FontCom/README.font rename to TechDocs/Markdown/Ddk/ddkfont.md index 6b63e4590..6733df0db 100644 --- a/Driver/Font/FontCom/README.font +++ b/TechDocs/Markdown/Ddk/ddkfont.md @@ -1,26 +1,13 @@ +## 4 Font Driver -FILE: README.fontDr -DESC: This document describes the interface and interactions of font - drivers in PC/GEOS -AUTHOR: Gene Anderson -DATE: 01/21/91 +AUTHOR: Gene Anderson (01/21/91) - $Id: README.font,v 1.4.25.1 97/03/29 07:08:03 canavese Exp $ +This document describes the interface and interactions of font drivers in +PC/GEOS. ------------------------------------------------------------------------------- - CONTENTS ------------------------------------------------------------------------------- - Overview - Initialization Routines - Data Routines - Metrics Routines - Debugging Tips +### 4.1 Overview ------------------------------------------------------------------------------- - Overview ------------------------------------------------------------------------------- - - In PC/GEOS, outline font drivers play a vital role in the +In PC/GEOS, outline font drivers play a vital role in the WYSIWYG rendering engine. They are called to generate the metrics for a font at any pointsize, rotation or scale factor that a program may request, making this information transparently available. When the @@ -28,7 +15,7 @@ font is actually drawn to the screen (or to memory for printing), the font drivers are called to generate bitmaps for the actual images of the characters. - A program will normally specify a particular typeface +A program will normally specify a particular typeface (FontIDs) and pointsize (WBFixed) using GrSetFont(). Additional styles (TextStyles) may be specified using GrSetTextStyle(). Some programs, such as GeoDraw, may also specify an angle of rotation using @@ -38,7 +25,7 @@ printing or rendering to a different device, using window routines similar to the graphics transformation routines above. All these elements combine to specify a unique 'font' to the system. - A typeface is referred to by a 16-bit ID (FontIDs). Part of +A typeface is referred to by a 16-bit ID (FontIDs). Part of the PC/GEOS kernel is a Font Manager, and it tracks the requests and usage of fonts in the system via these IDs and other font attributes. It maintains an array of structures (FontsAvailEntry) for each font in @@ -48,7 +35,7 @@ display. Each of these entries has a corresponding chunk of data (FontInfo), which specifies more information about the typeface, such as the ASCII name, and which styles are available as direct outlines. - When a routine needs a particular piece of font information, +When a routine needs a particular piece of font information, it asks the Font Manager to get the font in question. This may be accomplished simply if the font has a hand-tuned bitmap that is appropriate. If no bitmap exists, however, the font driver will be @@ -58,47 +45,45 @@ metrics information, and references to each character in the font indicating whether it exists or not, and whether a bitmap for it has been built. - When the video driver renders text on screen, it checks to see +When the video driver renders text on screen, it checks to see if a bitmap for the character it is about to draw exists or not. If not, it asks the Font Manager to get a bitmap for the character. The Font Manager in turn calls the appropriate font driver and requests the bitmap using the function DR_FONT_GEN_CHAR. - This process goes on as the system runs. Eventually, the font +This process goes on as the system runs. Eventually, the font may be unused for such a time period as to cause the data block to be discarded by the Heap Manager. If the font is requested again, the Font Manager will call the font driver with DR_FONT_GEN_WIDTHS, and the whole process starts over. - In addition to the process of requesting font metrics and +In addition to the process of requesting font metrics and corresponding character bitmaps, programs may request metrics about a particular character in which case the Font Manager calls the font driver with DR_FONT_CHAR_METRICS. Alternatively, a program may request the outline data for a particular character, in which case the font driver is called with DR_FONT_GEN_PATH. - There are also a number of initialization routines that the +There are also a number of initialization routines that the font driver must support. These are used to start and stop the font driver, as well as give it a chance to initialize any of its own fonts. - Finally, there are a number of driver 'escape functions', +Finally, there are a number of driver 'escape functions', which the font driver may choose to support or not, as is appropriate. These include functions such as adding or deleting a font from the system. ------------------------------------------------------------------------------- - Initialization Routines ------------------------------------------------------------------------------- +### 4.2 Initialization Routines -DR_INIT +*DR_INIT* - DR_INIT is called for all drivers. This should be used to +DR_INIT is called for all drivers. This should be used to initialize any necessary data structures and memory. However, care should be taken to keep memory usage at this stage at an absolute minimum as the driver may never get called again during this session. - For example, the Nimbus driver allocates handles for a variety +For example, the Nimbus driver allocates handles for a variety of blocks it uses (one for variables, one for the generated bitmap), but without allocating the associated memory (ie. HF_DISCARDED). They are also marked as discardable (ie. HF_DISCARDABLE), so the first @@ -108,87 +93,85 @@ two handles are used. If the Nimbus driver is unused for a long period of time, these blocks may eventually be discarded as well. -DR_EXIT +*DR_EXIT* - DR_EXIT is also called for all drivers, and is the counterpart +DR_EXIT is also called for all drivers, and is the counterpart of DR_INIT. This function should clean up any memory or resources that have been allocated by the driver, generally things that were allocated in DR_INIT. -DR_FONT_INIT_FONTS +*DR_FONT_INIT_FONTS* - DR_FONT_INIT_FONTS is intended to allow the font driver to +DR_FONT_INIT_FONTS is intended to allow the font driver to inform the system of any additional fonts it may have. The PC/GEOS kernel searches the disk for any fonts in it's format, but by definition most font drivers will be dealing with non-PC/GEOS fonts. - To add a font to the system, two structures must be modified +To add a font to the system, two structures must be modified or created. Both of these structures reside in the font manager's information block, which is passed to the various font driver functions. - First, a FontsAvailEntry must be added, which specifies to the +First, a FontsAvailEntry must be added, which specifies to the system that this particular FontIDs value is available, and where additional information about the font is stored. - The additional information is a separate chunk in the font +The additional information is a separate chunk in the font manager's block. It consists of a FontInfo structure, followed by as many PointSizeEntry structures (for bitmap fonts) and OutlineDataEntry structures (for outline fonts) as is appropriate. - "As many is appropriate" for bitmap fonts constitutes one +"As many is appropriate" for bitmap fonts constitutes one PointSizeEntry for each pointsize/style/weight combination. If there are no bitmaps for the FontIDs value in question, FI_pointSizeTab is zero (0) and there are no PointSizeEntry structures. - "As many is appropriate" for outline fonts constitutes one +"As many is appropriate" for outline fonts constitutes one OutlineDataEntry for each style/weight combination (note this does not include pointsize, as that is irrelevant for outline fonts). If there are no outlines for the FontIDs value in question, FI_outlineTab is zero (0) and there are no OutlineDataEntry structures. ------------------------------------------------------------------------------- - Data Routines ------------------------------------------------------------------------------- +### 4.3 Data Routines -DR_FONT_GEN_WIDTHS +*DR_FONT_GEN_WIDTHS* - DR_FONT_GEN_WIDTHS is called to generate the metrics and basic +DR_FONT_GEN_WIDTHS is called to generate the metrics and basic information for one font. In PC/GEOS, a different font is constituted by: - typeface (FontIDs) - pointsize (WBFixed) - style (TextStyle) - weight (FontWeight) - width (FontWidth) - transformation (TMatrix) - - What the system expects back from this routine is a buffer +* typeface (FontIDs) +* pointsize (WBFixed) +* style (TextStyle) +* weight (FontWeight) +* width (FontWidth) +* transformation (TMatrix) + +What the system expects back from this routine is a buffer containing the following: - FontBuf - font header and metrics information - + - CharTableEntry #1 - CharTableEntry #2 - [...] - CharTableEntry #n - + - [optional cached data] - + - [optional KernPair[1..m]] - [optional BBFixed[1..m]] - - Each CharTableEntry contains the pen width of the character, + FontBuf - font header and metrics information + + + CharTableEntry #1 + CharTableEntry #2 + [...] + CharTableEntry #n + + + [optional cached data] + + + [optional KernPair[1..m]] + [optional BBFixed[1..m]] + +Each CharTableEntry contains the pen width of the character, flags about the size and shape of the character, and the offset to the actual bitmap data for the character if it is built (or a flag indicating it hasn't yet been built). - Given this structure, the system will call the font driver +Given this structure, the system will call the font driver back for each character when it is needed, via the DR_FONT_GEN_CHAR routine. - The kerning information is a pair of matched tables. +The kerning information is a pair of matched tables. FB_kernCount contains the number of kerning pairs. FB_kernPairPtr points to an array of KernPair structures, which are left char / right char combinations that specify each kerning pair. FB_kernValuePtr @@ -197,7 +180,7 @@ specifying the adjustment for the corresponding character pair. Negative values mean move the characters closer; positive values mean move them further apart. - A note about DR_FONT_GEN_WIDTHS: outlines for all styles and +A note about DR_FONT_GEN_WIDTHS: outlines for all styles and all style combinations are generally not available. Underline and strikethrough are rendered by the kernel, and so need not be worried about. Some fonts have plain, bold, italic, and bold-italic @@ -206,7 +189,7 @@ the best case, this leaves superscript and subscript or any combination involving them unaccounted for. In the worst case, this may leave every combination of TextStyles except plain unaccounted for! - In the case a direct outline is not available, the font driver +In the case a direct outline is not available, the font driver is expected to "do its best". This involves tricks like scaling and translating for superscript and subscript, and obliquing for creating italic. To this end, a kernel routine (XXX: not yet written) is @@ -216,7 +199,7 @@ Superscript', and 'Plain' and 'Bold' outlines are available, the best thing to do is to select the 'Bold' outline and scale and translate it to simulate the 'Superscript' attribute. - The "optional cached data" is just that: data that the font +The "optional cached data" is just that: data that the font driver may choose to store in the font. There is no explicit reference to this data, but it can quickly be found by adding the size of the FontBuf plus the appropriate number of CharTableEntry @@ -228,58 +211,59 @@ font, and a reference to which set of routines will be used for rasterizing the bitmap or region data. -DR_FONT_GEN_CHAR +*DR_FONT_GEN_CHAR* - DR_FONT_GEN_CHAR is called to generate the bitmap for a single +DR_FONT_GEN_CHAR is called to generate the bitmap for a single character. The resulting data should be added to the FontBuf block returned by DR_FONT_GEN_WIDTHS after it has been resized appropriately. The system supports two varieties of character data, one simple and the other compacted. - The first format is simple bitmap data, comprised of a header +The first format is simple bitmap data, comprised of a header (CharData) containing the bounds and offset of the bitmap (in device coordinates) for where it should drawn relative to the top of the nominal font box. - This is followed by the data bytes. The data should be +This is followed by the data bytes. The data should be byte-padded, and the in the data, ones are 'on' and zeroes are 'off'. Shown below is an example of the letter 'i': - byte 6 ;width (CD_pictureWidth) - byte 10 ;height (CD_numRows) - byte 3 ;y offset (CD_yoff) - byte 2 ;x offset (CD_xoff) - byte 00110000b ;(CD_data) - byte 00110000b - byte 00000000b - byte 11110000b - byte 00110000b - byte 00110000b - byte 00110000b - byte 00110000b - byte 00110000b - byte 11111100b - - (0,0) - | - | - | - +--* (2,3) - (CD_xoff, CD_yoff) - +----------+ - | ## | - | ## | - | | - | #### | - | ## | - | ## | - | ## | - | ## | - | ## | - | ###### | - +----------+ - - The second format is storing the character as a region. This + + byte 6 ;width (CD_pictureWidth) + byte 10 ;height (CD_numRows) + byte 3 ;y offset (CD_yoff) + byte 2 ;x offset (CD_xoff) + byte 00110000b ;(CD_data) + byte 00110000b + byte 00000000b + byte 11110000b + byte 00110000b + byte 00110000b + byte 00110000b + byte 00110000b + byte 00110000b + byte 11111100b + + (0,0) + | + | + | + +--* (2,3) + (CD_xoff, CD_yoff) + +----------+ + | ## | + | ## | + | | + | #### | + | ## | + | ## | + | ## | + | ## | + | ## | + | ###### | + +----------+ + +The second format is storing the character as a region. This amounts to a scanline compression format, and works quite well for characters at 0, 90, 180 and 270 degree rotations. It works reasonably well for characters at an arbitrary angle of rotation, and @@ -288,15 +272,15 @@ in a script font like Shattuck Avenue. The cutoff point between storing characters as bitmaps and as regions is 125 lines high (eg. 125 point at 72 DPI, 30 point at 300 DPI, etc.) - There is a header (RegionCharData) similar to the header for +There is a header (RegionCharData) similar to the header for bitmap characters. There are two additional pieces of information: the size of the data for the region (in bytes), and the full bounds of the region data, which are used for drawing the region. - More details about the region format can be found in the +More details about the region format can be found in the documentation about the graphics system. - A note about DR_FONT_GEN_CHAR: characters are requested on an +A note about DR_FONT_GEN_CHAR: characters are requested on an as-needed basis. The means the font will start with the FontBuf+CharTableEntry+KernPair+BBFixed information in the block. As characters are added, the font driver will be adding data to this @@ -308,7 +292,7 @@ individual FontBuf blocks below 10K in size. This may not be possible at very large pointsizes, but is a general goal of the system to improve performance. - To this end, the font driver should use information which is +To this end, the font driver should use information which is maintained in the CharTableEntry for each character and the FontBuf. FB_heapCount is the current usage counter for the font. CTE_usage is the current usage counter for that character. Given these values, it @@ -318,73 +302,71 @@ delete this LRU character, thereby freeing up space for additional character(s) in the FontBuf block. A kernel routine (XXX: not written) is provided to do this. - After DR_FONT_GEN_WIDTHS is called, then DR_FONT_GEN_CHAR +After DR_FONT_GEN_WIDTHS is called, then DR_FONT_GEN_CHAR is called several times, the results will be something like what is below. The FontBuf block will have been expanded to include the character bitmap/region data, although because of the LRU caching scheme, the characters may not be in any particular order. - FontBuf - font header and metrics information - + - CharTableEntry #1 - CharTableEntry #2 - [...] - CharTableEntry #n - + - [optional cached data] - + - [optional KernPair[1..m]] - [optional BBFixed[1..m]] - + - Region/CharData #a - Region/CharData #b - [...] - Region/CharData #c - ------------------------------------------------------------------------------- - Metrics Routines ------------------------------------------------------------------------------- - -DR_FONT_CHAR_METRICS - - DR_FONT_CHAR_METRICS is called to return metrics information + FontBuf - font header and metrics information + + + CharTableEntry #1 + CharTableEntry #2 + [...] + CharTableEntry #n + + + [optional cached data] + + + [optional KernPair[1..m]] + [optional BBFixed[1..m]] + + + Region/CharData #a + Region/CharData #b + [...] + Region/CharData #c + +### 4.4 Metrics Routines + +*DR_FONT_CHAR_METRICS* + +DR_FONT_CHAR_METRICS is called to return metrics information about a particular character in a font. The information is in document coordinates, which is to say it is not affected by scaling, rotation, etc. that modifies the way the document is viewed, but simply by the pointsize and font attributes requested. - There are currently four pieces of information returned: min +There are currently four pieces of information returned: min x, min y, max x and max y. These values are relative to (0,0) at the baseline/starting pen position: -(xmin,ymax) (xmax,ymax) - +------+ - | ##| - | ##| - | | - | ####| - | ##| - | ##| - | ##| - | ##| - | ##| - | ##| - (0,0)+----##+ - | ##| - | ###| - |#### | - +------+ -(xmin,ymin) (xmax,ymin) - - Note that any of the values can be negative. Normally, the + (xmin,ymax) (xmax,ymax) + +------+ + | ##| + | ##| + | | + | ####| + | ##| + | ##| + | ##| + | ##| + | ##| + | ##| + (0,0)+----##+ + | ##| + | ###| + |#### | + +------+ + (xmin,ymin) (xmax,ymin) + +Note that any of the values can be negative. Normally, the data will be returned as a WBFixed, but there is an optional flag which may be passed, indicating the data should be rounded and returned as a word. -DR_FONT_GEN_PATH +*DR_FONT_GEN_PATH* - DR_FONT_GEN_PATH is called to return an outline description of +DR_FONT_GEN_PATH is called to return an outline description of a character at a particular pointsize, rotation, etc. It is used by things like the Postscript(tm) printer driver for building Adobe Type 3 fonts to download to printers when the font is not resident in the @@ -392,33 +374,33 @@ printer. For example, Shattuck Avenue (aka Park Avenue) is generally not in Postscript printers, and so a Type 3 font would be built and downloaded for it. - This outline description should be comprised of lines, Bezier +This outline description should be comprised of lines, Bezier curves, pen moves, and in some cases, a translation. Composite characters, such as accented letters, can be rendered by rendering the accent character, translating, and then rendering the unaccented letter. - The use for generating Postscript fonts is strong enough that +The use for generating Postscript fonts is strong enough that there is a special FGPF_POSTSCRIPT flag which can be passed to the function. The font driver is expected to rotate and scale the outlines such that (0,0) is the baseline/starting pen position, and the data is sized for a 1000 unit em-square. - If the FGPF_POSTSCRIPT flag is passed, the font driver is also +If the FGPF_POSTSCRIPT flag is passed, the font driver is also expected to emit a comment at the start of the graphics string which contains information for the Postscript "setcachedevice" command. This information is the pen width and bounding box information, in the order: width(x),width(y),ll(x),ll(y),ur(x),ur(y). -DR_FONT_GEN_IN_REGION +*DR_FONT_GEN_IN_REGION* - DR_FONT_GEN_IN_REGION is called to add the definition of a +DR_FONT_GEN_IN_REGION is called to add the definition of a character to a passed RegionPath. It is used by the graphics path code for filling and/or creating clip paths that contain text strings & characters. - The outline description of a font is normally comprised of +The outline description of a font is normally comprised of lines, Bezier curves & pen moves. At large point sizes (for the Nimbus font driver, above 500 points), this data is "played" into a RegionPath, and then handed to the video driver which draws the region @@ -426,7 +408,7 @@ on the screen. For paths, characters are always generated using regions, regardless of point size, and use this routine as the method for incorporating text into a path. - An implementation of this call should be careful to include +An implementation of this call should be careful to include the transformations contained in both the GState & Window (ie. use the W_curTMatrix) for generating the font, and the font must be carefully drawn into the correct location (GS_penPos in the GState) in the @@ -435,39 +417,37 @@ code might normally do). Finally, one may not assume that this will be the only routine called to add data to the RegionPath, so the integrity of RegionPath data must be ensured. - ------------------------------------------------------------------------------- - Debugging Tips ------------------------------------------------------------------------------- - To assist in debugging font drivers and their interaction with +### 4.5 Debugging Tips + +To assist in debugging font drivers and their interaction with the Font Manager, there are a number of useful TCL commands available: -fonts - print various items about fonts and font drivers in the system -pfontinfo - print the FontInfo structure for a font -pfont - print the FontBuf structure for a font and any bitmaps that - have been built for it -pchar - print the bitmap for a character in a font, if it has been - built -pusage - print the usage values for all characters that have been - built, and which of them will be discarded next +* fonts - print various items about fonts and font drivers in the system +* pfontinfo - print the FontInfo structure for a font +* pfont - print the FontBuf structure for a font and any bitmaps that + have been built for it +* pchar - print the bitmap for a character in a font, if it has been + built +* pusage - print the usage values for all characters that have been + built, and which of them will be discarded next A typical series of commands might be something like: -(geos:0) 1 => fonts -d ;show the available font drivers -(geos:0) 2 => fonts -a ;show the available fonts -(geos:0) 3 => pfontinfo FONT_URW_ROMAN ;show FontInfo for URW Roman + (geos:0) 1 => fonts -d ;show the available font drivers + (geos:0) 2 => fonts -a ;show the available fonts + (geos:0) 3 => pfontinfo FONT_URW_ROMAN ;show FontInfo for URW Roman - <...call GEN_WIDTHS here...> ;now we've got a FontBuf... + <...call GEN_WIDTHS here...> ;now we've got a FontBuf... -(geos:0) 4 => fonts -u FONT_URW_ROMAN ;show sizes of URW Roman in use -(geos:0) 5 => pfont ^h1ab0h ;print the FontBuf for a font + (geos:0) 4 => fonts -u FONT_URW_ROMAN ;show sizes of URW Roman in use + (geos:0) 5 => pfont ^h1ab0h ;print the FontBuf for a font - <...call GEN_CHAR here...> ;now we've got a bitmap... + <...call GEN_CHAR here...> ;now we've got a bitmap... -(geos:0) 6 => pchar C_CAP_A ^h1ab0h ;print the bitmap for 'A' + (geos:0) 6 => pchar C_CAP_A ^h1ab0h ;print the bitmap for 'A' - <...call GEN_CHAR here...> ;now we've got two bitmaps... + <...call GEN_CHAR here...> ;now we've got two bitmaps... -(geos:0) 7 => pusage ^h1ab0h ;print the LRU information + (geos:0) 7 => pusage ^h1ab0h ;print the LRU information diff --git a/TechDocs/Markdown/ddk.md b/TechDocs/Markdown/ddk.md index 529403480..af6168168 100644 --- a/TechDocs/Markdown/ddk.md +++ b/TechDocs/Markdown/ddk.md @@ -25,3 +25,10 @@ [3.2 PCMCIA Library Functions](Ddk/ddkpcmcia.md#32-PCMCIA-Library-Functions) [3.3 CardServices Functions](Ddk/ddkpcmcia.md#33-CardServices-Functions) [3.4 CardServices Events](Ddk/ddkpcmcia.md#34-CardServices-Events) + +**[4 Font Driver](Ddk/ddkfont.md#4-font-driver)** + [4.1 Overview](Ddk/ddkfont.md#41-Overview) + [4.2 Initialization Routines](Ddk/ddkfont.md#42-Initialization-Routines) + [4.3 Data Routines](Ddk/ddkfont.md#43-Data-Routines) + [4.4 Metrics Routines](Ddk/ddkfont.md#44-Metrics-Routines) + [4.5 Debugging Tips](Ddk/ddkfont.md#45-Debugging-Tips) From e14b802dbd0fbef836510a98d8d2fb56316d58e8 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Fri, 21 Jul 2023 23:03:54 +0200 Subject: [PATCH 187/246] Example for directly launching target from anywhere --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index d6bdac5c3..e0e19ef18 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,7 @@ Build the target environment: Launch the target environment in dosbox: - make sure dosbox is added to your path variable, or [pcgeos-basebox](https://github.com/bluewaysw/pcgeos-basebox/tags) is installed and configured using BASEBOX environmental variable -- `cd %ROOT_DIR%` -- `bin/target` +- `%ROOT_DIR%/bin/target` - the "swat" debugger stops immediately after the first stage of the boot process - enter `quit` at the "=>" prompt to detach the debugger and launch PC/GEOS stand-alone - or: enter `c` to launch with the debugger running in the background (slower) From 5823cb2f350e48f5a2328c6c158132b252562f0e Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 22 Jul 2023 18:33:46 +0200 Subject: [PATCH 188/246] Shrinking FontBuf fixed. --- Driver/Font/TrueType/Adapter/ttchars.c | 14 +++++++------- Driver/Font/TrueType/FreeType/ttraster.c | 5 ----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index bde2609b8..f3c2d1b0c 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -257,14 +257,14 @@ static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word char static void ShrinkFontBuf( FontBuf* fontBuf ) { word numOfChars = fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1; - CharTableEntry* charTableEntries = (CharTableEntry*) ((byte*)fontBuf) + sizeof( FontBuf ); + CharTableEntry* charTableEntries = (CharTableEntry*) ( ( (byte*)fontBuf ) + sizeof( FontBuf ) ); word sizeCharData; /* shrink fontBuf if necessary */ while( fontBuf->FB_dataSize > MAX_FONTBUF_SIZE ) { - word indexLRUChar = FindLRUChar( fontBuf, numOfChars ); + int indexLRUChar = FindLRUChar( fontBuf, numOfChars ); void* charData = ((byte*)fontBuf) + charTableEntries[indexLRUChar].CTE_dataOffset; /* ensure that we have a char to remove */ @@ -305,7 +305,7 @@ static int FindLRUChar( FontBuf* fontBuf, int numOfChars ) for( i = 0; i < numOfChars; i++, charTableEntry++ ) { /* if no data, go to next char */ - if( charTableEntry->CTE_dataOffset < CHAR_MISSING ) + if( charTableEntry->CTE_dataOffset <= CHAR_MISSING ) continue; if( charTableEntry->CTE_usage < lru ) @@ -343,12 +343,12 @@ static void AdjustPointers( CharTableEntry* charTableEntries, *******************************************************************/ static word ShiftCharData( FontBuf* fontBuf, CharData* charData ) { - word size = charData->CD_pictureWidth * charData->CD_numRows + SIZE_CHAR_HEADER; - + word size = charData->CD_pictureWidth * + ( ( charData->CD_numRows + 7 ) / 8 ) + SIZE_CHAR_HEADER; memmove( charData, ((byte*)charData) + size, - ((byte*)charData) - ((byte*)fontBuf) + fontBuf->FB_dataSize ); + (((byte*)fontBuf) + fontBuf->FB_dataSize) - ((byte*)charData) + size ); return size; } @@ -365,7 +365,7 @@ static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ) memmove( charData, ((byte*)charData) + size, - ((byte*)charData) - ((byte*)fontBuf) + fontBuf->FB_dataSize ); + (((byte*)fontBuf) + fontBuf->FB_dataSize) - ((byte*)charData) + size ); return size; } diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 77e7eb826..2e243023a 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -2435,10 +2435,6 @@ Scan_DropOuts : /* sub-banding */ -#ifdef DEBUG_RASTER - ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) ); -#endif - i = ras.band_stack[ras.band_top].y_min; j = ras.band_stack[ras.band_top].y_max; @@ -2453,7 +2449,6 @@ Scan_DropOuts : ras.band_stack[ras.band_top+1].y_min = k; ras.band_stack[ras.band_top+1].y_max = j; - ras.band_stack[ras.band_top].y_max = k - 1; ras.band_top++; From bb509c0f705f3d22c2df1e6c8acd255b0ba6ce78 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 23 Jul 2023 12:35:05 +0200 Subject: [PATCH 189/246] Settig of FBF_IS_REGION flag fixed. --- Driver/Font/TrueType/Adapter/ttwidths.c | 55 ++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 4fae086de..d696a0815 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -57,6 +57,9 @@ static void CalcTransform( TRUETYPE_VARS, static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ); +static Boolean IsRegionNeeded( TransformMatrix* transMatrix, + FontMatrix* fontMatrix, FontBuf* fontBuf ); + static word round( WWFixedAsDWord toRound ); @@ -170,6 +173,12 @@ EC( ECCheckFileHandle( truetypeFile ) ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos AdjustFontBuf( transMatrix, fontMatrix, fontBuf ); + /* Are the glyphs rendered as regions? */ + if( IsRegionNeeded( transMatrix, fontMatrix, fontBuf ) ) + fontBuf->FB_flags |= FBF_IS_REGION; + else + fontBuf->FB_flags &= ~FBF_IS_REGION; + Fail: TT_Close_Face( FACE ); Fin: @@ -595,7 +604,6 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) fontBuf->FB_kernValuePtr = 0; fontBuf->FB_kernCount = 0; fontBuf->FB_heapCount = 0; - fontBuf->FB_flags = fontBuf->FB_pixHeight < 125 ? FBF_IS_OUTLINE : FBF_IS_REGION; fontBuf->FB_firstChar = fontHeader->FH_firstChar; fontBuf->FB_lastChar = fontHeader->FH_lastChar; fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; @@ -617,6 +625,51 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, } +/******************************************************************** + * IsRegionNeeded + ******************************************************************** + * SYNOPSIS: Determines whether glyphs should be rendered as + * bitmap or as region. + * + * PARAMETERS: *transMatrix Ptr to tranfomation matrix. + * *fontMatrix Ptr to systems font matrix. + * *fontBuf Ptr to FontBuf structure. + * + * RETURNS: Boolean + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 22/07/23 JK Initial Revision + *******************************************************************/ +static Boolean IsRegionNeeded( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) +{ + word param1; + word param2; + + + param1 = ABS( GrMulWWFixed( fontMatrix->FM_11, WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ) ) >> 16 ); + param2 = ABS( GrMulWWFixed( fontMatrix->FM_21, WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ) ) >> 16 ); + if( param1 + param2 > MAX_BITMAP_SIZE ) + return TRUE; + + param1 = ABS( GrMulWWFixed( fontMatrix->FM_12, WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ) ) >> 16 ); + param2 = ABS( GrMulWWFixed( fontMatrix->FM_22, WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ) ) >> 16 ); + if( param1 + param2 > MAX_BITMAP_SIZE ) + return TRUE; + + if( transMatrix->TM_heightX + transMatrix->TM_scriptX > MAX_BITMAP_SIZE ) + return TRUE; + + if( transMatrix->TM_heightY + transMatrix->TM_scriptY > MAX_BITMAP_SIZE ) + return TRUE; + + return FALSE; +} + + static word round( WWFixedAsDWord toRound ) { return toRound & 0xffff ? ( toRound >> 16 ) + 1 : toRound >> 16; From f0b4af7f8854719b6af35121c7f951c8a05537ab Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 23 Jul 2023 15:54:05 +0200 Subject: [PATCH 190/246] Rotation and stretched flag in FreeType removed. --- Driver/Font/TrueType/FreeType/ttobjs.c | 4 ++-- Driver/Font/TrueType/FreeType/ttobjs.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index 609d8c7c8..5ad6746da 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -739,8 +739,8 @@ metrics->x_ppem = 0; metrics->y_ppem = 0; - metrics->rotated = FALSE; - metrics->stretched = FALSE; + // metrics->rotated = FALSE; + // metrics->stretched = FALSE; /* set default compensation ( all 0 ) */ for ( i = 0; i < 4; i++ ) diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h index d71e53465..e37e36fa3 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.h +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -460,8 +460,8 @@ TT_F26Dot6 compensations[4]; /* device-specific compensations */ - Bool rotated; /* `is the glyph rotated?'-flag */ - Bool stretched; /* `is the glyph stretched?'-flag */ + //Bool rotated; /* `is the glyph rotated?'-flag */ + //Bool stretched; /* `is the glyph stretched?'-flag */ }; typedef struct TIns_Metrics_ TIns_Metrics; From 0b51d0283ff1bf3ba99e5684cce67a453ce7a823 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Fri, 21 Jul 2023 23:03:54 +0200 Subject: [PATCH 191/246] Example for directly launching target from anywhere --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index d6bdac5c3..e0e19ef18 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,7 @@ Build the target environment: Launch the target environment in dosbox: - make sure dosbox is added to your path variable, or [pcgeos-basebox](https://github.com/bluewaysw/pcgeos-basebox/tags) is installed and configured using BASEBOX environmental variable -- `cd %ROOT_DIR%` -- `bin/target` +- `%ROOT_DIR%/bin/target` - the "swat" debugger stops immediately after the first stage of the boot process - enter `quit` at the "=>" prompt to detach the debugger and launch PC/GEOS stand-alone - or: enter `c` to launch with the debugger running in the background (slower) From 0bb6488ecf905d55ce7c22ddbb71acd1e101579b Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Sun, 23 Jul 2023 21:29:01 +0200 Subject: [PATCH 192/246] Use near calls for local functions within rasterizer --- Driver/Font/TrueType/FreeType/ttraster.c | 106 +++++++++-------------- 1 file changed, 39 insertions(+), 67 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 77e7eb826..fb8f19f54 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -275,11 +275,11 @@ /* dispatch variables */ - Function_Sweep_Init* Proc_Sweep_Init; - Function_Sweep_Span* Proc_Sweep_Span; - Function_Sweep_Span* Proc_Sweep_Drop; - Function_Sweep_Step* Proc_Sweep_Step; - Function_Sweep_Finish* Proc_Sweep_Finish; + Function_Sweep_Init _near * Proc_Sweep_Init; + Function_Sweep_Span _near * Proc_Sweep_Span; + Function_Sweep_Span _near * Proc_Sweep_Drop; + Function_Sweep_Step _near * Proc_Sweep_Step; + Function_Sweep_Finish _near * Proc_Sweep_Finish; TT_Vector* coords; @@ -320,7 +320,7 @@ /* */ /************************************************************************/ - static void Set_High_Precision( RAS_ARGS Bool High ) + static void _near Set_High_Precision( RAS_ARGS Bool High ) { if ( High ) { @@ -354,7 +354,7 @@ /* */ /****************************************************************************/ - static Bool New_Profile( RAS_ARGS TStates aState ) + static Bool _near New_Profile( RAS_ARGS TStates aState ) { if ( !ras.fProfile ) { @@ -414,7 +414,7 @@ /* */ /****************************************************************************/ - static Bool End_Profile( RAS_ARG ) + static Bool _near End_Profile( RAS_ARG ) { Long h; PProfile oldProfile; @@ -585,7 +585,7 @@ /* */ /****************************************************************************/ - static void Split_Bezier( TPoint* base ) + static void _near Split_Bezier( TPoint* base ) { Long a, b; @@ -619,7 +619,7 @@ /* */ /****************************************************************************/ - static void Push_Bezier( RAS_ARGS Long x1, Long y1, + static void _near Push_Bezier( RAS_ARGS Long x1, Long y1, Long x2, Long y2, Long x3, Long y3 ) { @@ -644,7 +644,7 @@ /* */ /****************************************************************************/ - static Bool Line_Up( RAS_ARGS Long x1, Long y1, + static Bool _near Line_Up( RAS_ARGS Long x1, Long y1, Long x2, Long y2, Long miny, Long maxy ) { @@ -755,7 +755,7 @@ } - static Bool Line_Down( RAS_ARGS Long x1, Long y1, + static Bool _near Line_Down( RAS_ARGS Long x1, Long y1, Long x2, Long y2, Long miny, Long maxy ) { @@ -787,7 +787,7 @@ /* */ /****************************************************************************/ - static Bool Bezier_Up( RAS_ARGS Long miny, Long maxy ) + static Bool _near Bezier_Up( RAS_ARGS Long miny, Long maxy ) { Long y1, y2, e, e2, e0; Short f1; @@ -916,7 +916,7 @@ /* */ /****************************************************************************/ - static Bool Bezier_Down( RAS_ARGS Long miny, Long maxy ) + static Bool _near Bezier_Down( RAS_ARGS Long miny, Long maxy ) { TPoint* arc = ras.arc; Bool result, fresh; @@ -951,7 +951,7 @@ /* */ /****************************************************************************/ - static Bool Line_To( RAS_ARGS Long x, Long y ) + static Bool _near Line_To( RAS_ARGS Long x, Long y ) { /* First, detect a change of direction */ @@ -1030,7 +1030,7 @@ /* */ /****************************************************************************/ - static Bool Bezier_To( RAS_ARGS Long x, + static Bool _near Bezier_To( RAS_ARGS Long x, Long y, Long cx, Long cy ) @@ -1144,7 +1144,7 @@ #undef SWAP_ #define SWAP_(x,y) { Long swap = x; x = y; y = swap; } - static Bool Decompose_Curve( RAS_ARGS UShort first, + static Bool _near Decompose_Curve( RAS_ARGS UShort first, UShort last, Bool flipped ) { @@ -1276,7 +1276,7 @@ /* */ /****************************************************************************/ - static Bool Convert_Glyph( RAS_ARGS int flipped ) + static Bool _near Convert_Glyph( RAS_ARGS int flipped ) { Short i; UShort start; @@ -1340,7 +1340,7 @@ /* */ /************************************************/ - static void Init_Linked( TProfileList* l ) + static void _near Init_Linked( TProfileList* l ) { *l = NULL; } @@ -1354,7 +1354,7 @@ /* */ /************************************************/ - static void InsNew( PProfileList list, + static void _near InsNew( PProfileList list, PProfile profile ) { PProfile *old, current; @@ -1386,7 +1386,7 @@ /* */ /*************************************************/ - static void DelOld( PProfileList list, + static void _near DelOld( PProfileList list, PProfile profile ) { PProfile *old, current; @@ -1420,7 +1420,7 @@ /* */ /************************************************/ - static void Update( PProfile first ) + static void _near Update( PProfile first ) { PProfile current = first; @@ -1446,7 +1446,7 @@ /* */ /************************************************/ - static void Sort( PProfileList list ) + static void _near Sort( PProfileList list ) { PProfile *old, current, next; @@ -1497,14 +1497,14 @@ /* */ /***********************************************************************/ - static void Vertical_Sweep_Init( RAS_ARGS Short* min, Short* max ) + static void _near Vertical_Sweep_Init( RAS_ARGS Short* min, Short* max ) { ras.traceOfs = ( ras.target.rows - 1 - *min ) * ras.target.cols; ras.traceIncr = -ras.target.cols; } - static void Vertical_Sweep_Span( RAS_ARGS Short y, + static void _near Vertical_Sweep_Span( RAS_ARGS Short y, TT_F26Dot6 x1, TT_F26Dot6 x2, PProfile left, @@ -1553,7 +1553,7 @@ } - static void Vertical_Sweep_Drop( RAS_ARGS Short y, + static void _near Vertical_Sweep_Drop( RAS_ARGS Short y, TT_F26Dot6 x1, TT_F26Dot6 x2, PProfile left, @@ -1658,13 +1658,13 @@ } - static void Vertical_Sweep_Step( RAS_ARGS Short y ) + static void _near Vertical_Sweep_Step( RAS_ARGS Short y ) { ras.traceOfs += ras.traceIncr; } - static void Vertical_Sweep_Finish( RAS_ARG ) + static void _near Vertical_Sweep_Finish( RAS_ARG ) { /* nothing to do */ } @@ -1681,7 +1681,7 @@ /* */ /***********************************************************************/ - static void Vertical_Region_Sweep_Init( RAS_ARGS + static void _near Vertical_Region_Sweep_Init( RAS_ARGS Short* min, Short* max ) { @@ -1690,7 +1690,7 @@ ras.traceOfsLastLine = -1; } - static void Vertical_Region_Sweep_Span( RAS_ARGS Short y, + static void _near Vertical_Region_Sweep_Span( RAS_ARGS Short y, TT_F26Dot6 x1, TT_F26Dot6 x2, PProfile left, @@ -1724,7 +1724,7 @@ } } - static void Vertical_Region_Sweep_Drop( RAS_ARGS Short y, + static void _near Vertical_Region_Sweep_Drop( RAS_ARGS Short y, TT_F26Dot6 x1, TT_F26Dot6 x2, PProfile left, @@ -1733,7 +1733,7 @@ /* nothing to do */ } - static void Vertical_Region_Sweep_Step( RAS_ARGS Short y ) + static void _near Vertical_Region_Sweep_Step( RAS_ARGS Short y ) { Short* target; Short* targetLastLine; @@ -1772,7 +1772,7 @@ ras.traceIncr = 0; } - static void Vertical_Region_Sweep_Finish( RAS_ARG ) + static void _near Vertical_Region_Sweep_Finish( RAS_ARG ) { Short* target; @@ -1797,13 +1797,13 @@ /* */ /***********************************************************************/ - static void Horizontal_Sweep_Init( RAS_ARGS Short* min, Short* max ) + static void _near Horizontal_Sweep_Init( RAS_ARGS Short* min, Short* max ) { /* nothing, really */ } - static void Horizontal_Sweep_Span( RAS_ARGS Short y, + static void _near Horizontal_Sweep_Span( RAS_ARGS Short y, TT_F26Dot6 x1, TT_F26Dot6 x2, PProfile left, @@ -1833,7 +1833,7 @@ } - static void Horizontal_Sweep_Drop( RAS_ARGS Short y, + static void _near Horizontal_Sweep_Drop( RAS_ARGS Short y, TT_F26Dot6 x1, TT_F26Dot6 x2, PProfile left, @@ -1920,12 +1920,12 @@ } - static void Horizontal_Sweep_Step( RAS_ARGS Short y ) + static void _near Horizontal_Sweep_Step( RAS_ARGS Short y ) { /* Nothing, really */ } - static void Horizontal_Sweep_Finish( RAS_ARG ) + static void _near Horizontal_Sweep_Finish( RAS_ARG ) { /* nothing to do */ } @@ -2134,7 +2134,7 @@ /* */ /********************************************************************/ - static Bool Draw_Sweep( RAS_ARG ) + static Bool _near Draw_Sweep( RAS_ARG ) { Short y, y_change, y_height; @@ -2186,11 +2186,7 @@ /* Now inits the sweep */ -#ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Init, RAS_VARS &min_Y, &max_Y ); -#else ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); -#endif /* __GEOS__ */ /* Then compute the distance of each profile from min_Y */ @@ -2286,11 +2282,7 @@ } } -#ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Span, RAS_VARS y, x1, x2, P_Left, P_Right ); -#else ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right ); -#endif /* __GEOS__ */ Skip_To_Next: @@ -2306,11 +2298,7 @@ Next_Line: -#ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); -#else ras.Proc_Sweep_Step( RAS_VARS y ); -#endif /* __GEOS__ */ y++; @@ -2351,19 +2339,11 @@ /* for gray-scaling, flushes the bitmap scanline cache */ while ( y <= max_Y ) { -#ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Step, RAS_VARS y ); -#else ras.Proc_Sweep_Step( RAS_VARS y ); -#endif /* __GEOS__ */ y++; } -#ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Finish, RAS_VAR ); -#else ras.Proc_Sweep_Finish( RAS_VAR ); -#endif return SUCCESS; Scan_DropOuts : @@ -2377,19 +2357,11 @@ Scan_DropOuts : { P_Left->countL = 0; /* dropouts--; -- this is useful when debugging only */ -#ifdef __GEOS__ - ProcCallFixedOrMovable_cdecl( ras.Proc_Sweep_Drop, RAS_VARS y, - P_Left->X, - P_Right->X, - P_Left, - P_Right ); -#else ras.Proc_Sweep_Drop( RAS_VARS y, P_Left->X, P_Right->X, P_Left, P_Right ); -#endif /* __GEOS__ */ } P_Left = P_Left->link; From 6361f1e979ffc2fd58c2bed1965f901a74f29be1 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 24 Jul 2023 18:34:59 +0200 Subject: [PATCH 193/246] Regression fixed. --- Driver/Font/TrueType/Adapter/ttinit.c | 14 ++--- Driver/Font/TrueType/Adapter/ttwidths.c | 80 +++++++++++++++++-------- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index ccd5baed3..abdca8d8a 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -156,8 +156,8 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ) TrueTypeVars* trueTypeVars; - ECCheckMemHandle( fontInfoBlock ); - ECCheckMemHandle( varBlock ); +EC( ECCheckMemHandle( fontInfoBlock ) ); +EC( ECCheckMemHandle( varBlock ) ); /* get trueTypeVar block */ @@ -174,7 +174,7 @@ void _pascal TrueType_InitFonts( MemHandle fontInfoBlock, MemHandle varBlock ) /* detect all filenames in current directory */ numFiles = DetectFontFiles( &fileEnumBlock ); - ECCheckMemHandle( fileEnumBlock ); +EC( ECCheckMemHandle( fileEnumBlock ) ); if( numFiles == 0 ) goto Fin; @@ -268,12 +268,12 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo sword availIndex; - ECCheckBounds( (void*)fileName ); - ECCheckBounds( (void*)trueTypeVars ); +EC( ECCheckBounds( (void*)fileName ) ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); truetypeFile = FileOpen( fileName, FILE_ACCESS_R | FILE_DENY_W ); - ECCheckFileHandle( truetypeFile ); +EC( ECCheckFileHandle( truetypeFile ) ); if ( TT_Open_Face( truetypeFile, &FACE ) ) goto Fin; @@ -791,7 +791,7 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ) word geosChar; - ECCheckBounds( (void*)fontHeader ); +EC( ECCheckBounds( (void*)fontHeader ) ); /* initialize min, max and avg values in fontHeader */ fontHeader->FH_minLSB = 9999; diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index d696a0815..a99b47adf 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -60,6 +60,9 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, static Boolean IsRegionNeeded( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ); + +#define ROUND_WWFIXED( value ) ( value & 0xffff ? ( value >> 16 ) + 1 : value >> 16 ) + static word round( WWFixedAsDWord toRound ); @@ -70,10 +73,14 @@ static word round( WWFixedAsDWord toRound ); * in a given pointsize and style. * * PARAMETERS: fontHandle Memory handle to font block. - * *fontMatrix Pointer to tranformation matrix. + * *fontMatrix Ptr. to tranformation matrix. * pointSize Desired point size. - * *fontInfo Pointer to font info structure. - * textStyle Desired text style. + * *fontInfo Ptr. to font info structure. + * *headerEntry Ptr. to outline entry containing + * TrueTypeOutlineEntry. + * *firstEntry Ptr. to outline entry containing + * FontHeader. + * stylesToImplement Desired text style. * MemHandle Memory handle to var block. * * RETURNS: MemHandle Memory handle to font block. @@ -176,8 +183,6 @@ EC( ECCheckFileHandle( truetypeFile ) ); /* Are the glyphs rendered as regions? */ if( IsRegionNeeded( transMatrix, fontMatrix, fontBuf ) ) fontBuf->FB_flags |= FBF_IS_REGION; - else - fontBuf->FB_flags &= ~FBF_IS_REGION; Fail: TT_Close_Face( FACE ); @@ -195,11 +200,9 @@ EC( ECCheckFileHandle( truetypeFile ) ); * SYNOPSIS: Converts the information from the FontHeader and * fills FontBuf with it. * - * PARAMETERS: face TrueType face of font file. - * *fontHeader Pointer to FontHeader structure. - * scaleFactor Factor by which the chars width - * must be scaled. - * *fontBuf Pointer to FontBuf structure. + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. + * *fontHeader Ptr. to FontHeader structure. + * *fontBuf Ptr. to FontBuf structure. * * RETURNS: void * @@ -289,11 +292,12 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); /******************************************************************** * ConvertKernPairs ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Fills FontBuf with kerning information. * - * PARAMETERS: + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. + * *fontBuf Ptr. to FontBuf structure. * - * RETURNS: + * RETURNS: void * * SIDE EFFECTS: none * @@ -331,11 +335,12 @@ static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) /******************************************************************** * CalcScaleForWidths ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Fills scale factors in chached variables for calculating + * FontBuf and ChatTableEntries. * - * PARAMETERS: TRUETYPE_VARS - * pointSize - * styleToImplement + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. + * pointSize Desired point size. + * stylesToImplement Desired text style. * * RETURNS: void * @@ -368,9 +373,11 @@ static void CalcScaleForWidths( TRUETYPE_VARS, * SYNOPSIS: Calculates the transformation matrix for missing * style attributes and weights. * - * PARAMETERS: *transMatrix Pointer to TransformMatrix. + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. + * *transMatrix Pointer to TransformMatrix. * *fontMatrix Systems transformation matrix. * styleToImplement Styles that must be added. + * *fontBuf Ptr. to FontBuf structure. * * RETURNS: void * @@ -470,11 +477,11 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); * ---- ---- ----------- * 14/01/23 JK Initial Revision *******************************************************************/ -static word AllocFontBlock( - word additionalSpace, - word numOfCharacters, - word numOfKernPairs, - MemHandle* fontHandle ) + +static word AllocFontBlock( word additionalSpace, + word numOfCharacters, + word numOfKernPairs, + MemHandle* fontHandle ) { word size = sizeof( FontBuf ) + numOfCharacters * sizeof( CharTableEntry ) + numOfKernPairs * ( sizeof( KernPair ) + sizeof( WBFixed ) ) + @@ -502,7 +509,7 @@ static word AllocFontBlock( ******************************************************************** * SYNOPSIS: Converts FontInfo and fill FontBuf structure. * - * PARAMETERS: pointSize Current pointsize. + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. * *fontHeader Ptr to FontHeader structure. * *fontBuf Ptr to FontBuf structure. * @@ -516,7 +523,7 @@ static word AllocFontBlock( * 11/12/22 JK Initial Revision *******************************************************************/ -void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) +static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) { WWFixedAsDWord ttfElement; WWFixedAsDWord scaleWidth = SCALE_WIDTH; @@ -600,6 +607,7 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement );// + fontBuf->FB_minTSB; fontBuf->FB_maker = FM_TRUETYPE; + fontBuf->FB_flags = FBF_IS_OUTLINE; fontBuf->FB_kernPairPtr = 0; fontBuf->FB_kernValuePtr = 0; fontBuf->FB_kernCount = 0; @@ -610,6 +618,25 @@ void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontBuf ) } +/******************************************************************** + * AdjustFontBuf + ******************************************************************** + * SYNOPSIS: Adjust fields in FontBuf to reflect rotating and scaling. + * + * PARAMETERS: *transMatrix Ptr to tranfomation matrix. + * *fontMatrix Ptr to systems font matrix. + * *fontBuf Ptr to FontBuf structure. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 22/07/23 JK Initial Revision + *******************************************************************/ + static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) { //adjust FB_pixHeight, FB_minTSB, heightY @@ -629,7 +656,7 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, * IsRegionNeeded ******************************************************************** * SYNOPSIS: Determines whether glyphs should be rendered as - * bitmap or as region. + * region. * * PARAMETERS: *transMatrix Ptr to tranfomation matrix. * *fontMatrix Ptr to systems font matrix. @@ -644,6 +671,7 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, * ---- ---- ----------- * 22/07/23 JK Initial Revision *******************************************************************/ + static Boolean IsRegionNeeded( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) { word param1; From c28c447f1f2da62c5a63a7bba9cf3751df2faecc Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 24 Jul 2023 22:23:09 +0200 Subject: [PATCH 194/246] Fix: large glyphs are not cut off. --- Driver/Font/TrueType/Adapter/ttchars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index f3c2d1b0c..7501bf3e0 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -159,7 +159,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); /* translate outline and render it */ TT_Transform_Outline( &OUTLINE, &flipmatrix ); - TT_Translate_Outline( &OUTLINE, -GLYPH_BBOX.xMin, GLYPH_BBOX.yMin + GLYPH_BBOX.yMax ); + TT_Translate_Outline( &OUTLINE, -GLYPH_BBOX.xMin, GLYPH_BBOX.yMax ); TT_Get_Outline_Region( &OUTLINE, &RASTER_MAP ); /* fill header of charData */ From 0b571694931ec955490f0e5e210b6e0edc4b2f84 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 25 Jul 2023 20:48:19 +0200 Subject: [PATCH 195/246] Set default resulution to 72dpi. --- Driver/Font/TrueType/Adapter/ttadapter.h | 2 ++ Driver/Font/TrueType/Adapter/ttchars.c | 1 - Driver/Font/TrueType/Adapter/ttwidths.c | 15 ++++++++++++--- Driver/Font/TrueType/FreeType/ttobjs.c | 7 ++----- Driver/Font/TrueType/FreeType/ttobjs.h | 3 --- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 1db2ed092..a4924b9a9 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -281,6 +281,8 @@ typedef ByteFlags TransFlags; #define TF_SCALED 0x02 #define TF_TRANSLATED 0x01 +#define TF_COMPLEX ( TF_ROTATED | TF_SCALED | TF_TRANSLATED ) + typedef struct { WWFixedAsDWord FM_11; diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 7501bf3e0..588a856fa 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -111,7 +111,6 @@ EC( ECCheckFileHandle( truetypeFile ) ); TT_New_Glyph( FACE, &GLYPH ); TT_New_Instance( FACE, &INSTANCE ); - TT_Set_Instance_Resolutions( INSTANCE, 72, 72 ); /* get TT char index */ getCharMap( FACE, &CHAR_MAP ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index a99b47adf..db401c4ea 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -639,11 +639,20 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) { + /* set height */ + transMatrix->TM_heightY = fontBuf->FB_baselinePos.WBF_int + 1; + + if( fontMatrix->FM_flags & TF_COMPLEX ) + { + fontBuf->FB_flags |= FBF_IS_COMPLEX; + + + + } + //adjust FB_pixHeight, FB_minTSB, heightY - fontBuf->FB_flags |= FBF_IS_COMPLEX; - //TODO: Das ist nur eine provisorische Lösung: - transMatrix->TM_heightY = fontBuf->FB_baselinePos.WBF_int + 1; + if( fontMatrix->FM_flags & TF_ROTATED ) { diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index 5ad6746da..a437bed9f 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -733,15 +733,12 @@ metrics->pointSize = 10 * 64; /* default pointsize = 10pts */ - metrics->x_resolution = 96; /* default resolution = 96dpi */ - metrics->y_resolution = 96; + metrics->x_resolution = 72; /* default resolution = 72dpi */ + metrics->y_resolution = 72; metrics->x_ppem = 0; metrics->y_ppem = 0; - // metrics->rotated = FALSE; - // metrics->stretched = FALSE; - /* set default compensation ( all 0 ) */ for ( i = 0; i < 4; i++ ) metrics->compensations[i] = 0; diff --git a/Driver/Font/TrueType/FreeType/ttobjs.h b/Driver/Font/TrueType/FreeType/ttobjs.h index e37e36fa3..38a15fa64 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.h +++ b/Driver/Font/TrueType/FreeType/ttobjs.h @@ -459,9 +459,6 @@ Long scale2; /* scale for ppem */ TT_F26Dot6 compensations[4]; /* device-specific compensations */ - - //Bool rotated; /* `is the glyph rotated?'-flag */ - //Bool stretched; /* `is the glyph stretched?'-flag */ }; typedef struct TIns_Metrics_ TIns_Metrics; From dfc81efefe05ae5702f3c08e79ed1939a5172a46 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 31 Jul 2023 20:32:38 +0200 Subject: [PATCH 196/246] Implement systems font matrix --- Driver/Font/TrueType/Adapter/ttadapter.h | 6 +-- Driver/Font/TrueType/Adapter/ttinit.c | 1 - Driver/Font/TrueType/Adapter/ttwidths.c | 64 +++++++++++++++++------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index a4924b9a9..f67325c1f 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -281,7 +281,7 @@ typedef ByteFlags TransFlags; #define TF_SCALED 0x02 #define TF_TRANSLATED 0x01 -#define TF_COMPLEX ( TF_ROTATED | TF_SCALED | TF_TRANSLATED ) +#define TF_COMPLEX ( TF_ROTATED | TF_SCALED ) typedef struct { @@ -289,8 +289,8 @@ typedef struct WWFixedAsDWord FM_12; WWFixedAsDWord FM_21; WWFixedAsDWord FM_22; - WWFixedAsDWord FM_31; - WWFixedAsDWord FM_32; + DWFixed FM_31; + DWFixed FM_32; DDFixed FM_xInv; /* inverse translation factor (x coords) */ DDFixed FM_yInv; /* inverse translation factor (y coords) */ TransFlags FM_flags; diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index abdca8d8a..0f12564df 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -798,7 +798,6 @@ EC( ECCheckBounds( (void*)fontHeader ) ); fontHeader->FH_maxBSB = -9999; fontHeader->FH_minTSB = -9999; fontHeader->FH_maxRSB = -9999; - fontHeader->FH_avgwidth = 0; fontHeader->FH_maxwidth = 0; fontHeader->FH_descent = 9999; fontHeader->FH_accent = 0; diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index db401c4ea..8f8541ea6 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -54,8 +54,10 @@ static void CalcTransform( TRUETYPE_VARS, TextStyle stylesToImplement, FontBuf* fontBuf ); -static void AdjustFontBuf( TransformMatrix* transMatrix, - FontMatrix* fontMatrix, FontBuf* fontBuf ); +static void AdjustFontBuf( TransformMatrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle stylesToImplement, + FontBuf* fontBuf ); static Boolean IsRegionNeeded( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ); @@ -63,6 +65,8 @@ static Boolean IsRegionNeeded( TransformMatrix* transMatrix, #define ROUND_WWFIXED( value ) ( value & 0xffff ? ( value >> 16 ) + 1 : value >> 16 ) +#define ROUND_WBFIXED( value ) ( value.WBF_frac ? ( value.WBF_int + 1 ) : value.WBF_int ) + static word round( WWFixedAsDWord toRound ); @@ -178,7 +182,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); CalcTransform( trueTypeVars, transMatrix, fontMatrix, stylesToImplement, fontBuf ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos - AdjustFontBuf( transMatrix, fontMatrix, fontBuf ); + AdjustFontBuf( transMatrix, fontMatrix, stylesToImplement, fontBuf ); /* Are the glyphs rendered as regions? */ if( IsRegionNeeded( transMatrix, fontMatrix, fontBuf ) ) @@ -414,10 +418,7 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); /* fake bold style */ if( stylesToImplement & TS_BOLD ) - { tempMatrix.xx = BOLD_FACTOR; - tempMatrix.yy = BOLD_FACTOR; - } /* fake italic style */ if( stylesToImplement & TS_ITALIC ) @@ -602,9 +603,8 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB ttfElement = SCALE_WORD( fontHeader->FH_maxRSB, scaleWidth ); fontBuf->FB_maxRSB = INTEGER_OF_WWFIXEDASDWORD( ttfElement ); - //ttfElement = SCALE_WORD( fontHeader->FH_height + fontHeader->FH_accent, scaleHeight ); ttfElement = SCALE_WORD( fontHeader->FH_height, scaleHeight ); - fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement );// + fontBuf->FB_minTSB; + fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement ) + fontBuf->FB_minTSB; fontBuf->FB_maker = FM_TRUETYPE; fontBuf->FB_flags = FBF_IS_OUTLINE; @@ -625,6 +625,7 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB * * PARAMETERS: *transMatrix Ptr to tranfomation matrix. * *fontMatrix Ptr to systems font matrix. + * stylesToImplement * *fontBuf Ptr to FontBuf structure. * * RETURNS: void @@ -637,27 +638,52 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB * 22/07/23 JK Initial Revision *******************************************************************/ -static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, FontBuf* fontBuf ) +static void AdjustFontBuf( TransformMatrix* transMatrix, + FontMatrix* fontMatrix, + TextStyle stylesToImplement, + FontBuf* fontBuf ) { - /* set height */ - transMatrix->TM_heightY = fontBuf->FB_baselinePos.WBF_int + 1; + transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), fontMatrix->FM_22 ) ) + 1; if( fontMatrix->FM_flags & TF_COMPLEX ) { fontBuf->FB_flags |= FBF_IS_COMPLEX; + /* adjust FB_pixHeight, FB_minTSB */ + fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ), fontMatrix->FM_22 ) ); + fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_minTSB ), fontMatrix->FM_22 ) ); + fontBuf->FB_pixHeight += fontBuf->FB_minTSB; - } - - //adjust FB_pixHeight, FB_minTSB, heightY - - + if( fontMatrix->FM_flags & TF_ROTATED ) + { + sword savedHeightY = transMatrix->TM_heightY; + + /* adjust FB_pixHeight, FB_minTSB */ + fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ), transMatrix->TM_matrix.yy ) ); + fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_minTSB ), transMatrix->TM_matrix.yy ) ); + fontBuf->FB_pixHeight += fontBuf->FB_minTSB; + + /* adjust script and height */ + transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( transMatrix->TM_heightY ), transMatrix->TM_matrix.yy ) ); + transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( transMatrix->TM_scriptY ), transMatrix->TM_matrix.yy ) ); + + transMatrix->TM_heightX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yx ) ); + transMatrix->TM_scriptX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yx ) ); + } - if( fontMatrix->FM_flags & TF_ROTATED ) - { - //adjust scriptX, heightX + fontMatrix->FM_12 = -fontMatrix->FM_12; + fontMatrix->FM_21 = -fontMatrix->FM_21; } + } From bb9571e5817aeb76302d0aa12be92dcfa51e79ca Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 31 Jul 2023 21:33:53 +0200 Subject: [PATCH 197/246] Start to optimize fontprocessing. --- Driver/Font/TrueType/Adapter/ttinit.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 0f12564df..b706fbd25 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -798,7 +798,6 @@ EC( ECCheckBounds( (void*)fontHeader ) ); fontHeader->FH_maxBSB = -9999; fontHeader->FH_minTSB = -9999; fontHeader->FH_maxRSB = -9999; - fontHeader->FH_maxwidth = 0; fontHeader->FH_descent = 9999; fontHeader->FH_accent = 0; fontHeader->FH_ascent = 0; @@ -839,10 +838,6 @@ EC( ECCheckBounds( (void*)fontHeader ) ); //descender -> check if ( unicode == C_LATIN_SMALL_LETTER_P ) fontHeader->FH_descender = GLYPH_BBOX.yMin; - - //width -> check - if ( fontHeader->FH_maxwidth < GLYPH_METRICS.advance ) - fontHeader->FH_maxwidth = GLYPH_METRICS.advance; /* scan xMin -> check */ if( fontHeader->FH_minLSB > GLYPH_BBOX.xMin ) @@ -880,6 +875,8 @@ EC( ECCheckBounds( (void*)fontHeader ) ); TT_Done_Instance( INSTANCE ); fontHeader->FH_avgwidth = FACE_PROPERTIES.os2->xAvgCharWidth; + fontHeader->FH_maxwidth = FACE_PROPERTIES.horizontal->advance_Width_Max; + fontHeader->FH_accent = fontHeader->FH_accent - fontHeader->FH_ascent; fontHeader->FH_baseAdjust = BASELINE( UNITS_PER_EM ) - fontHeader->FH_ascent - fontHeader->FH_accent; fontHeader->FH_height = fontHeader->FH_maxBSB + fontHeader->FH_ascent + DESCENT( UNITS_PER_EM ) - SAFETY( UNITS_PER_EM ); From 9c9171fb7511180a36d1635b36f9aa976ebb6eae Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Mon, 31 Jul 2023 22:17:33 +0200 Subject: [PATCH 198/246] Initial assembly implementation of TT memory --- Driver/Font/TrueType/FreeType/ttmemory.c | 3 + Driver/Font/TrueType/Main/mainManager.asm | 4 + .../Font/TrueType/Main/truetypeConstant.def | 6 + .../Font/TrueType/Main/truetypeVariable.def | 3 + Driver/Font/TrueType/Main/ttmemory_asm.asm | 659 ++++++++++++++++++ Installed/Driver/Font/TrueType/Makefile | 1 + .../Driver/Font/TrueType/dependencies.mk | 3 +- 7 files changed, 678 insertions(+), 1 deletion(-) create mode 100644 Driver/Font/TrueType/Main/ttmemory_asm.asm diff --git a/Driver/Font/TrueType/FreeType/ttmemory.c b/Driver/Font/TrueType/FreeType/ttmemory.c index 843069ea6..8253a7bdb 100644 --- a/Driver/Font/TrueType/FreeType/ttmemory.c +++ b/Driver/Font/TrueType/FreeType/ttmemory.c @@ -31,6 +31,7 @@ #include #include +#ifndef __GEOS__ /******************************************************************* * @@ -140,3 +141,5 @@ { return TT_Err_Ok; } + +#endif diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index bc9018af7..fee63fe36 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -117,6 +117,9 @@ global bitmapHandle:hptr global bitmapSize:word global engineInstance:TrueTypeEngineInstance +global smallListHandle: word +global largeListHandle: word + MetricsMod segment resource include truetypeMetrics.asm include truetypePath.asm @@ -131,6 +134,7 @@ InitMod ends include truetypeEC.asm include ansic_runtime.asm include ansic_memory.asm +include ttmemory_asm.asm Resident segment resource ;MODULE_FIXED diff --git a/Driver/Font/TrueType/Main/truetypeConstant.def b/Driver/Font/TrueType/Main/truetypeConstant.def index 2b58e8a71..049ffe726 100644 --- a/Driver/Font/TrueType/Main/truetypeConstant.def +++ b/Driver/Font/TrueType/Main/truetypeConstant.def @@ -103,5 +103,11 @@ FONT_BAD_ROUTINE enum FatalErrors TRUETYPE_INTERNAL_ERROR enum FatalErrors +HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS enum FatalErrors +FREE_CALLED_BEFORE_MALLOC enum FatalErrors +COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT enum FatalErrors +NULL_PTR_PASSED_TO_GEO_FREE enum FatalErrors +MORE_THAN_ONE_FREE_MALLOC_BLOCK enum FatalErrors + endif diff --git a/Driver/Font/TrueType/Main/truetypeVariable.def b/Driver/Font/TrueType/Main/truetypeVariable.def index b18e41e92..174a939f0 100644 --- a/Driver/Font/TrueType/Main/truetypeVariable.def +++ b/Driver/Font/TrueType/Main/truetypeVariable.def @@ -120,6 +120,9 @@ variableHandle hptr ;handle of our variable block ;This structure is later moved to the variable block. engineInstance TrueTypeEngineInstance <> +smallListHandle word ;handle of small block list +largeListHandle word ;handle of large block list + udata ends diff --git a/Driver/Font/TrueType/Main/ttmemory_asm.asm b/Driver/Font/TrueType/Main/ttmemory_asm.asm new file mode 100644 index 000000000..c64e499a4 --- /dev/null +++ b/Driver/Font/TrueType/Main/ttmemory_asm.asm @@ -0,0 +1,659 @@ +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved + +PROJECT: PC/GEOS +MODULE: Font Driver +FILE: ttmemory_asm.asm + +AUTHOR: Andrew Wilson, Sep 17, 1991 + +ROUTINES: + Name Description + ---- ----------- + _Malloc allocs fixed memory + _Free frees fixed memory + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/17/91 Initial revision + schoon 6/11/92 Revised for ANSI C standards + marcusg 7/29/23 Adapted for TrueType driver + +DESCRIPTION: + This file contains the PC/GEOS implementations of the C routines + TT_Alloc(), TT_Free(), TTMemory_Init(), TTMemory_Done(), to avoid + the need to link to the ansic library. + +NOTES: + There are 2 allocation strategies used by this code. If the block size + is below MALLOC_LARGE_THRESHOLD, then it is allocated in one of the + fixed LMem heaps kept for this purpose. If the block size is above + the threshold, then the memory is allocated in a global memory block + by itself. Since the pointer to memory returned by the "large" strategy + is below any of the valid pointers returned by the "small" strategy + (due to the fact that the small blocks all lie beyond the + LMemBlockHeader at the start of the lmem blocks, while the large + blocks all lie at LARGE_BLOCK_OFFSET, which is less than the + LMemBlockHeader), we are able to tell which type of block it is just + by looking at the address. + + When we free these blocks, we have a different strategy for each. + When we free a large block, we just call MemFree on the block. If + it is a small block, we free the chunk, and then check to see if that + LMem block is now empty. If it isn't, we just exit. If it is, we scan + through the list of lmem blocks to see if it is the only lmem block. + if it isn't, we free it up (so we have at most one empty lmem block + hanging around per geode). + + In the GeodePrivData for each geode we keep 2 words - the first one + is the handle of a block containing a list of handles of lmem blocks + used for the small allocation scheme. The second one is the handle + of a block containing a list of handles of global memory blocks + containing blocks allocated via the large allocation scheme. + The format of these blocks is as follows: + + word numberOfEntriesInList ;This includes any empty slots + word entry1 + word entry2 + word entry3 + . + . + . + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +ttmemory_TEXT segment public 'CODE' + +.model medium, c + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + AddHandleToMallocList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Adds a handle to the associated list of handles. + +CALLED BY: GLOBAL +PASS: ds:[LMBH_handle] - handle to add + cx - handle of block containing list of blocks +RETURN: carry set if error +DESTROYED: bx, cx, dx, di, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +SLOT_INCREMENT equ 8 +AddHandleToMallocList proc near uses ds, es, bp, ax + .enter + +; Read in the handle of the block containing the list of blocks + + mov dx, ds:[LMBH_handle] + jcxz doMalloc ;If no block, allocate a new one + +; Scan through the block looking for an empty slot to store the new +; handle. + + mov bx, cx + call MemLock + mov es, ax +scanTop: + mov di, 2 + mov cx, es:[0] ;CX <- # items in block + clr ax + repne scasw ;Look for an empty spot + jne reAlloc ;Branch if no empty slots found + + mov es:[di][-2], dx ;Save handle in empty slot + clc ;Signify no errors +unlockExit: + call MemUnlock ;Unlock the block +exit: + .leave + ret +reAlloc: + +; No empty slots found, so reallocate the block bigger (create some). + + mov ax, es:[0] + inc ax ;AX <- # words in block currently + shl ax, 1 ;AX <- # bytes in block + add ax, SLOT_INCREMENT*2 ;Add room for 8 more slots + mov ch, mask HAF_ZERO_INIT + call MemReAlloc + jc unlockExit ;If error reallocing, branch + mov es, ax + add {word} es:[0], SLOT_INCREMENT ; + jmp scanTop +doMalloc: + +; ALLOCATE A NEW BLOCK TO HOLD DATA + + mov bx, handle 0 ;current Geode + mov ax, SLOT_INCREMENT*2 ; + mov cx, ALLOC_DYNAMIC_LOCK or mask HF_SHARABLE or (mask HAF_ZERO_INIT shl 8) + call MemAllocSetOwner + jc exit ;If we could not allocate the block, + ; branch. + mov es, ax ; + mov {word} es:[0], SLOT_INCREMENT-1; + push ds +NOFXIP< segmov ds, , cx > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov ds:[di], bx ; + pop ds + jnc scanTop ;If no error, branch + call MemFree ;Else, free up this block and exit. + stc + jmp exit +AddHandleToMallocList endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + RemoveHandleFromMallocList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Removes a handle from the associated list of handles. + +CALLED BY: GLOBAL +PASS: ds:[LMBH_handle] - handle to remove + cx - handle of block containing list of blocks +RETURN: nothing +DESTROYED: ax, bx, cx, dx, di, si + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +RemoveHandleFromMallocList proc near uses es, ds + .enter + + mov dx, ds:[LMBH_handle] +EC < jcxz nullError ;If no block, fail > + +; Scan through the block looking for the passed handle. + + mov bx, cx + call MemLock + mov es, ax + mov di, 2 + mov cx, es:[0] ;CX <- # items in block + mov ax, dx + repne scasw ;Look for an empty spot +EC < ERROR_NZ HANDLE_NOT_FOUND_IN_LIST_OF_MALLOC_BLOCKS > + + mov {word} es:[di][-2], 0 ;Nuke handle + call MemUnlock + .leave + ret +EC +EC < ERROR FREE_CALLED_BEFORE_MALLOC > +RemoveHandleFromMallocList endp + + +if ERROR_CHECK +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ECCountFreeBlocksOnMallocList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Counts total number of malloc heaps with no items + +CALLED BY: _Free +PASS: cx - handle of block containing list of blocks +RETURN: dx - # free blocks +DESTROYED: ax, bx, di, ds + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +ECCountFreeBlocksOnMallocList proc near + uses cx, si, es + .enter + +; Read in the handle of the block containing the list of blocks + + jcxz nullError ;If no block, fail + +; Traverse the block counting the # empty blocks + + mov bx, cx + call MemLock + push bx + mov ds, ax + mov si, 2 + mov cx, ds:[0] ;CX <- # items in block + clr dx +findNext: + lodsw + tst ax + jz next + xchg ax, bx + call MemDerefES + cmp es:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader + jne next ;If not empty, branch + inc dx ;Else, increment count of empty blocks +next: + loop findNext + pop bx + call MemUnlock ; + .leave + ret +nullError: + ERROR FREE_CALLED_BEFORE_MALLOC +ECCountFreeBlocksOnMallocList endp +endif + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + AllocInSmallList +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Traverses the list of lmem blocks and tries to allocate + the passed # bytes in each one until it is successful + +CALLED BY: GLOBAL +PASS: cx - # bytes to allocate +RETURN: ds:ax <- pointer to block allocated + carry set if unsuccessful +DESTROYED: ax, bx, cx, di, si, ds + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +AllocInSmallList proc near + .enter + +; Read in the handle of the block containing the list of blocks + + mov dx, cx ;DX <- size + push ds +NOFXIP< segmov ds, dgroup, di > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov cx, ds:[smallListHandle] ; + pop ds + stc + jcxz exit ;If no blocks allocated, exit + +; Traverse the block and attempt to allocate in each one (ignoring +; empty slots). + + mov bx, cx + mov cx, dx ;CX <- # bytes to allocate + push bx + call MemLock + mov ds, ax + mov si, 2 + mov dx, ds:[0] ;CX <- # items in block +findNext: + lodsw + tst ax + jz next ;If handle is null, branch (empty slot) + mov di, ds ;. + xchg ax, bx ;BX <- handle of this lmem block + call MemDerefDS ;DS <- segment of this lmem block + call LMemAlloc ;Try to allocate here + jnc success ;Branch if no error allocating + mov ds, di ; +next: + dec dx ;Decrement # handles to try + jnz findNext ; + stc ;Unsuccessful, so unlock and exit w/carry set +success: + pop bx ;Unlock list of blocks + call MemUnlock ; +exit: + .leave + ret +AllocInSmallList endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + MemAllocFixed +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Just a front end to MemAlloc + +CALLED BY: GLOBAL +PASS: ax - size of block to alloc + bx - owner of block +RETURN: ds - segment of block + + rest of MemAlloc return values +DESTROYED: cx + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +MemAllocFixed proc near + mov cx, mask HF_FIXED or mask HF_SHARABLE + call MemAllocSetOwner ;Try to allocate memory + mov ds, ax + ret +MemAllocFixed endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _TT_Alloc +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: This routine allocates fixed memory for C programs to use. + +C DECLARATION: TT_Error TT_Alloc(word blockSize, void**p); + +NOTES: geodeHan can be 0, if you just want to use the current process' + malloc heap. + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/17/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +MALLOC_LARGE_THRESHOLD equ 511 +MALLOC_SMALL_BLOCK_SIZE equ 1024 +LARGE_BLOCK_OFFSET equ size hptr +global _TT_Alloc:far +_TT_Alloc proc far blockSize:word, p:fptr + uses ds, di, si + .enter + mov cx, blockSize + + tst cx + jz zeroAlloc ;zero-sized allocs are valid + +; Mallocs of over MALLOC_LARGE_THRESHOLD should be put in their own +; fixed block. + + cmp cx, MALLOC_LARGE_THRESHOLD + ja largeAlloc + +; Scan through the list of fixed lmem blocks to allocate this +; small block. + + call AllocInSmallList ;Try to allocate in various blocks + ; in small list (returns pointer in + ; DS:AX). + jnc zinitAndExit ;Branch if successful + +; Could not allocate in already existing lmem block, so allocate a new +; lmem block and allocate in it. + + mov ax, MALLOC_SMALL_BLOCK_SIZE + mov bx, handle 0 ;current Geode + call MemAllocFixed ;Try to allocate new lmem block. + jc errRet ;If unsuccessful, branch to exit. + mov ax, LMEM_TYPE_GENERAL + mov dx, size LMemBlockHeader + mov di, mask LMF_NO_HANDLES or mask LMF_NO_ENLARGE or mask LMF_RETURN_ERRORS + push bp + clr bp + call LMemInitHeap + pop bp + +; Allocate a new chunk on the just-allocated lmem heap. + + mov cx, blockSize + call LMemAlloc +EC < ERROR_C COULD_NOT_ALLOC_BLOCK_WHEN_THERE_SHOULD_BE_ROOM_FOR_IT > + mov di, offset smallListHandle + jmp mallocCommon ;Branch to add block to list, and + ; to return pointer to block + +largeAlloc: + +; Allocate a fixed block on the heap with the handle of the block at the +; start, and the remainder of the block to be returned for use by the +; caller. + + add cx, LARGE_BLOCK_OFFSET ;These blocks have the handle of the + xchg ax, cx ; block at the start. Put size in AX. + mov bx, handle 0 ;current Geode + call MemAllocFixed ; + jc errRet ;If we couldn't, branch + mov dx, bx ;DX <- handle of new block + mov ds:[0], bx ;Save handle of block + + mov di, offset largeListHandle + ;DI <- offset to handle of block + ; containing list of large data blocks + ; (in the GeodePrivData area reserved + ; for the malloc routines). + mov ax, LARGE_BLOCK_OFFSET ;DS:AX <- pointer to data just alloc'd + +mallocCommon: +; Get the handle to the block list indicated by DI + + push ds +NOFXIP< segmov ds, , bx > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov cx, ds:[di] ; + pop ds + call AddHandleToMallocList ;Add handle at DS:0 to malloc list + jc freeError ;If couldn't add to list, branch and + ; exit. +zinitAndExit: ; + mov dx, ds ;DX:AX <- pointer to data + push es + push ax + mov es, dx ;ES:DI <- pointer to block + xchg di, ax + clr ax + mov cx, blockSize + shr cx, 1 + jnc 80$ + stosb +80$: + rep stosw + pop ax ;DX:AX <- pointer to block +exitWithPtr: + les di, p + mov es:[di].low, ax + mov es:[di].high, dx + pop es + mov ax, 0 ;TT_Err_Ok +exit: + .leave + ret + +freeError: + mov bx, dx ;Free up the block + call MemFree +errRet: + mov ax, 100h ;TT_Err_Out_Of_Memory + jmp exit + +zeroAlloc: + clr ax ;Return zero pointer + clr dx + push es + jmp exitWithPtr +_TT_Alloc endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _TT_Free +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: Frees up a block previously returned from _TT_Alloc. + +CALLED BY: GLOBAL + +C DECLARATION: TT_Error _Free(void **p); + +PSEUDO CODE/STRATEGY: + Accepts p or *p being NULL. + If the block is freed, *p is set to NULL. + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + atw 9/18/91 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ +global _TT_Free:far +_TT_Free proc far p:fptr + uses es, ds, di, si + .enter + tst p.high ;no pointer passed + jz exit ;nothing to do + les si, p + tst es:[si].high ;pointer is already NULL? + jz exitZero ;nothing to do + + cmp es:[si].low, LARGE_BLOCK_OFFSET + jne smallBlockFree + +; The free block was large (allocated as a single block on the global +; heap). Remove the block from the list, and free it up. + +NOFXIP< segmov ds, , di > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov cx, ds:[largeListHandle] ;cx <- handle of large + ; block list +freeAndRemoveBlock: + mov ds, es:[si+2] + call RemoveHandleFromMallocList ; + mov bx, ds:[LMBH_handle] + call MemFree ;Free up the handle + jmp exit +smallBlockFree: + lds ax, es:[si] ;If small block, just free + call LMemFree ; up the chunk. We never + ; return this memory to the + ; global heap. + +; If the block is now empty, free it. + + cmp ds:[LMBH_totalFree], MALLOC_SMALL_BLOCK_SIZE - size LMemBlockHeader + jne exitZero ; Branch if block is non-empty + +NOFXIP< segmov ds, , di > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + mov cx, ds:[smallListHandle] ;cx <- handle of small + +EC < call ECCountFreeBlocksOnMallocList ; > +EC < cmp dx, 2 ; > +EC < ERROR_A MORE_THAN_ONE_FREE_MALLOC_BLOCK > + jmp freeAndRemoveBlock +exitZero: + clr ax + mov es:[si], ax + mov es:[si+2], ax +exit: + mov ax, 0 ;TT_Err_Ok + .leave + ret +_TT_Free endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _TTMemory_Init +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: This routine initializes the heap. + +C DECLARATION: + +TT_Error TTMemory_Init() + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + marcusg 7/29/23 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +global _TTMemory_Init:far +_TTMemory_Init proc far + uses ds, di, bx + .enter +NOFXIP< segmov ds, , di > +FXIP < mov bx, handle dgroup > +FXIP < call MemDerefDS ; ds = dgroup > + clr bx + mov ds:[smallListHandle], bx ;initialize: no lists yet + mov ds:[largeListHandle], bx + mov ax, 0 ; TT_Err_Ok + .leave + ret +_TTMemory_Init endp + + +COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + _TTMemory_Done +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +SYNOPSIS: This routine should deinitialize the heap if needed. + +C DECLARATION: + +TT_Error TTMemory_Done() + +PSEUDO CODE/STRATEGY: + +KNOWN BUGS/SIDE EFFECTS/IDEAS: + +REVISION HISTORY: + Name Date Description + ---- ---- ----------- + marcusg 7/29/23 Initial version + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ + +global _TTMemory_Done:far +_TTMemory_Done proc far + mov ax, 0 ; TT_Err_Ok + ret +_TTMemory_Done endp + +ttmemory_TEXT ends diff --git a/Installed/Driver/Font/TrueType/Makefile b/Installed/Driver/Font/TrueType/Makefile index 1131663f1..cec9f900f 100644 --- a/Installed/Driver/Font/TrueType/Makefile +++ b/Installed/Driver/Font/TrueType/Makefile @@ -15,6 +15,7 @@ FREETYPE = ftxkern.c ttapi.c ttcache.c ttcalc.c ttcmap.c ttextend.c\ ttgload.h ttinterp.h ttload.h ttmemory.h ttmutex.h\ ttobjs.h ttraster.h tttables.h tttags.h tttypes.h MAIN = ansic_memory.asm ansic_runtime.asm mainManager.asm\ + ttmemory_asm.asm\ truetypeChars.asm truetypeEC.asm truetypeEscape.asm\ truetypeInit.asm truetypeMetrics.asm truetypePath.asm\ truetypeWidths.asm truetypeConstant.def\ diff --git a/Installed/Driver/Font/TrueType/dependencies.mk b/Installed/Driver/Font/TrueType/dependencies.mk index 40dee37eb..24434160d 100644 --- a/Installed/Driver/Font/TrueType/dependencies.mk +++ b/Installed/Driver/Font/TrueType/dependencies.mk @@ -12,7 +12,8 @@ Main.eobj: Main/mainManager.asm \ ../FontCom/fontcomUtils.asm truetypeChars.asm \ truetypeMetrics.asm truetypePath.asm truetypeInit.asm \ truetypeEscape.asm ../FontCom/fontcomEscape.asm \ - truetypeEC.asm ansic_runtime.asm ansic_memory.asm + truetypeEC.asm ansic_runtime.asm ansic_memory.asm \ + ttmemory_asm.asm ttadapter.obj \ ttadapter.eobj: Adapter/ttadapter.h geos.h ec.h fontID.h file.h \ Adapter/../FreeType/freetype.h \ From 3a0542036a51a64b13ff8f23ee71402e230ad3c6 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 2 Aug 2023 19:47:24 +0200 Subject: [PATCH 199/246] fix: space glyph is correctly rendered as region --- Driver/Font/TrueType/FreeType/ttraster.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index 365e773ff..e715f321b 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -2548,7 +2548,10 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, TT_Error error; if ( glyph->n_points == 0 || glyph->n_contours <= 0 ) + { + Render_Region_Empty_Glyph( raster ); return TT_Err_Ok; + } if ( !ras.buff ) { @@ -2600,6 +2603,19 @@ TT_Error Render_Region_Glyph( RAS_ARGS TT_Outline* glyph, return TT_Err_Ok; } + +static void Render_Region_Empty_Glyph( RAS_ARG ) +{ + Short* target = ras.rTarget; + + + /* complete a region */ + + target[0] = EOREGREC; + target[1] = EOREGREC; + ras.target.size = 2 * sizeof( Short ); +} + #endif /* __GEOS__ */ From d51119e3eeee70755ff0e7b7b5f116a61e44f533 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Wed, 2 Aug 2023 23:25:51 +0200 Subject: [PATCH 200/246] Merge WCC_TEXT segment into ttcalc_TEXT to reduce inter-segment calls for 32-bit arithmetic --- Driver/Font/TrueType/Main/ansic_runtime.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/Main/ansic_runtime.asm b/Driver/Font/TrueType/Main/ansic_runtime.asm index 70704657a..00a93bce7 100644 --- a/Driver/Font/TrueType/Main/ansic_runtime.asm +++ b/Driver/Font/TrueType/Main/ansic_runtime.asm @@ -13,8 +13,8 @@ ; limitations under the License. -WCC_TEXT SEGMENT BYTE PUBLIC 'CODE' - ASSUME CS:WCC_TEXT +ttcalc_TEXT SEGMENT BYTE PUBLIC 'CODE' + ASSUME CS:ttcalc_TEXT public __U4M public __U4D @@ -147,4 +147,4 @@ WCC_TEXT SEGMENT BYTE PUBLIC 'CODE' __I4D endp -WCC_TEXT ENDS +ttcalc_TEXT ENDS From ec94230fb2c609660c78e02f50cad293982801d3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 4 Aug 2023 21:16:32 +0200 Subject: [PATCH 201/246] some cleanup --- Driver/Font/TrueType/Adapter/ttmetrics.c | 1 - Driver/Font/TrueType/Adapter/ttwidths.c | 27 ++++++++---------------- Driver/Font/TrueType/FreeType/ttfile.h | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 265c20fe7..eefc23fec 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -100,7 +100,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); // scale glyph TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); - TT_Set_Instance_Resolutions( INSTANCE, 72, 72 ); TT_Get_Instance_Metrics( INSTANCE, &INSTANCE_METRICS ); // get metrics diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 11a803e18..46dc779d6 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -67,8 +67,6 @@ static Boolean IsRegionNeeded( TransformMatrix* transMatrix, #define ROUND_WBFIXED( value ) ( value.WBF_frac ? ( value.WBF_int + 1 ) : value.WBF_int ) -static word round( WWFixedAsDWord toRound ); - /******************************************************************** * TrueType_Gen_Widths @@ -85,7 +83,7 @@ static word round( WWFixedAsDWord toRound ); * *firstEntry Ptr. to outline entry containing * FontHeader. * stylesToImplement Desired text style. - * MemHandle Memory handle to var block. + * varBlock Memory handle to var block. * * RETURNS: MemHandle Memory handle to font block. * @@ -117,12 +115,12 @@ MemHandle _pascal TrueType_Gen_Widths( TransformMatrix* transMatrix; - EC( ECCheckMemHandle( fontHandle ) ); - EC( ECCheckBounds( (void*)fontMatrix ) ); - EC( ECCheckBounds( (void*)fontInfo ) ); - EC( ECCheckBounds( (void*)headerEntry ) ); - EC( ECCheckBounds( (void*)firstEntry ) ); - EC( ECCheckStack() ); +EC( ECCheckMemHandle( fontHandle ) ); +EC( ECCheckBounds( (void*)fontMatrix ) ); +EC( ECCheckBounds( (void*)fontInfo ) ); +EC( ECCheckBounds( (void*)headerEntry ) ); +EC( ECCheckBounds( (void*)firstEntry ) ); +EC( ECCheckStack() ); /* get trueTypeVar block */ @@ -335,8 +333,7 @@ static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) * 20/07/23 JK Initial Revision *******************************************************************/ -static void CalcScaleForWidths( TRUETYPE_VARS, - WWFixedAsDWord pointSize, +static void CalcScaleForWidths( TRUETYPE_VARS, WWFixedAsDWord pointSize, TextStyle stylesToImplement ) { SCALE_HEIGHT = GrUDivWWFixed( pointSize, MakeWWFixed( FACE_PROPERTIES.header->Units_Per_EM ) ); @@ -544,7 +541,7 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB fontBuf->FB_baseAdjust.WBF_frac = 0; ttfElement = SCALE_WORD( fontHeader->FH_ascent + fontHeader->FH_accent, scaleHeight ); - fontBuf->FB_baselinePos.WBF_int = round( ttfElement ); + fontBuf->FB_baselinePos.WBF_int = ROUND_WWFIXED( ttfElement ); fontBuf->FB_baselinePos.WBF_frac = 0; ttfElement = SCALE_WORD( fontHeader->FH_descent, scaleHeight ); @@ -710,9 +707,3 @@ static Boolean IsRegionNeeded( TransformMatrix* transMatrix, FontMatrix* fontMat return FALSE; } - - -static word round( WWFixedAsDWord toRound ) -{ - return toRound & 0xffff ? ( toRound >> 16 ) + 1 : toRound >> 16; -} diff --git a/Driver/Font/TrueType/FreeType/ttfile.h b/Driver/Font/TrueType/FreeType/ttfile.h index 0c47ffc22..bf4295312 100644 --- a/Driver/Font/TrueType/FreeType/ttfile.h +++ b/Driver/Font/TrueType/FreeType/ttfile.h @@ -199,7 +199,7 @@ } -#define CHECK_FILE( _handle_ ) ECCheckFileHandle( _handle_ ) +#define CHECK_FILE( _handle_ ) EC( ECCheckFileHandle( _handle_ ) ) /* The macros FRAME_ARGS and FRAME_ARG let us build a thread-safe */ From 3e02073233f6c1e8d39257e4bc781f6da74ba741 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 4 Aug 2023 21:45:34 +0200 Subject: [PATCH 202/246] remove unneeded parameter --- Driver/Font/TrueType/Adapter/ttchars.c | 10 ++++++---- Driver/Font/TrueType/Adapter/ttchars.h | 1 - Driver/Font/TrueType/Main/truetypeChars.asm | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 8313797f2..95de1f66e 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -42,11 +42,14 @@ static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ); * SYNOPSIS: Generate one character for a font. * * PARAMETERS: character Character to build (Chars). - * pointsize * *fontBuf Ptr to font data structure. + * pointsize Desired point size. * *fontInfo Pointer to FontInfo structure. - * *outlineEntry Handle to current gstate. - * stylesToImplement + * *outlineEntry Ptr. to outline entry containing + * TrueTypeOutlineEntry. + * bitmapHandle Memory handle to bitmapblock. + * varBlock Memory handle to var block. + * * * RETURNS: void * @@ -67,7 +70,6 @@ void _pascal TrueType_Gen_Chars( WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - TextStyle stylesToImplement, MemHandle bitmapHandle, MemHandle varBlock ) { diff --git a/Driver/Font/TrueType/Adapter/ttchars.h b/Driver/Font/TrueType/Adapter/ttchars.h index eab865ba0..ed4efab25 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.h +++ b/Driver/Font/TrueType/Adapter/ttchars.h @@ -39,7 +39,6 @@ void _pascal TrueType_Gen_Chars( word character, WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, - TextStyle stylesToImplement, MemHandle bitmapBlock, MemHandle varBlock ); diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 1a6f6c1be..0c5485402 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -83,7 +83,6 @@ TrueTypeGenChar proc far call FontDrFindOutlineData push ds ; pass ptr to OutlineEntry push di - push ax ; pass styles to implement segmov ds, dgroup, ax push ds:bitmapHandle From 4a67641d4c068706e20dbfe19de2ed7cab5796f6 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 6 Aug 2023 11:24:14 +0200 Subject: [PATCH 203/246] Short is enough for index of ttf tables. --- Driver/Font/TrueType/Adapter/ttwidths.c | 14 ++++------- Driver/Font/TrueType/FreeType/ftxkern.c | 2 +- Driver/Font/TrueType/FreeType/ttgload.c | 2 +- Driver/Font/TrueType/FreeType/ttload.c | 31 +++++++++++++------------ Driver/Font/TrueType/FreeType/ttload.h | 2 +- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 46dc779d6..6353701a1 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -213,7 +213,7 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB EC( ECCheckBounds( (void*)charTableEntry ) ); - //Unicode to TT ID + /* get glyph index of currentChar */ charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( currentChar ) ); if ( charIndex == 0 ) { @@ -227,30 +227,26 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); continue; } - //Glyph laden + /* load glyph and metrics */ TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); - //width berechnen + /* fill CharTableEntry */ scaledWidth = GrMulWWFixed( MakeWWFixed( GLYPH_METRICS.advance), SCALE_WIDTH ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); - - // nur TEST charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; charTableEntry->CTE_flags = 0; charTableEntry->CTE_usage = 0; - // set flags in CTE_flags if needed + /* set flags in CTE_flags if needed */ if( GLYPH_BBOX.xMin < 0 ) charTableEntry->CTE_flags |= CTF_NEGATIVE_LSB; - - //below descent + if( -GLYPH_BBOX.yMin > fontHeader->FH_descent ) charTableEntry->CTE_flags |= CTF_BELOW_DESCENT; - //above ascent if( GLYPH_BBOX.yMax > fontHeader->FH_ascent ) charTableEntry->CTE_flags |= CTF_ABOVE_ASCENT; diff --git a/Driver/Font/TrueType/FreeType/ftxkern.c b/Driver/Font/TrueType/FreeType/ftxkern.c index 0225d4ffd..e519c3869 100644 --- a/Driver/Font/TrueType/FreeType/ftxkern.c +++ b/Driver/Font/TrueType/FreeType/ftxkern.c @@ -285,7 +285,7 @@ extern TEngine_Instance engineInstance; TT_Kerning* kern = (TT_Kerning*)ext; UShort num_tables; - Long table; + Short table; TT_Kern_Subtable* sub; diff --git a/Driver/Font/TrueType/FreeType/ttgload.c b/Driver/Font/TrueType/FreeType/ttgload.c index 7210892e6..1e3fda50a 100644 --- a/Driver/Font/TrueType/FreeType/ttgload.c +++ b/Driver/Font/TrueType/FreeType/ttgload.c @@ -564,7 +564,7 @@ Short left_contours; UShort num_elem_points; - Long table; + Short table; UShort load_top; Long k, l; UShort new_flags; diff --git a/Driver/Font/TrueType/FreeType/ttload.c b/Driver/Font/TrueType/FreeType/ttload.c index 64074ab89..998592499 100644 --- a/Driver/Font/TrueType/FreeType/ttload.c +++ b/Driver/Font/TrueType/FreeType/ttload.c @@ -49,7 +49,7 @@ ******************************************************************/ EXPORT_FUNC - Long TT_LookUp_Table( PFace face, + Short TT_LookUp_Table( PFace face, ULong tag ) { UShort i; @@ -154,7 +154,7 @@ { DEFINE_LOCALS; - Long i; + Short i; PMaxProfile maxProfile = &face->maxProfile; @@ -240,7 +240,7 @@ { DEFINE_LOCALS; - Long i; + Short i; UShort j; TGasp* gas; GaspRange* gaspranges; @@ -300,7 +300,7 @@ { DEFINE_LOCALS; - Long i; + Short i; TT_Header* header; @@ -366,7 +366,8 @@ { DEFINE_LOCALS; - Long n, num_shorts, num_shorts_checked, num_longs; + Short n; + UShort num_shorts, num_shorts_checked, num_longs; PLongMetrics* longs; PShortMetrics* shorts; @@ -484,7 +485,7 @@ { DEFINE_LOCALS; - Long i; + Short i; TT_Horizontal_Header* header; @@ -570,7 +571,7 @@ { DEFINE_LOCALS; - Long n, limit; + Short n, limit; Short LongOffsets; @@ -644,7 +645,7 @@ DEFINE_LOCALS; UShort i, bytes; - Long n; + Short n; PByte storage; TName_Table* names; @@ -787,7 +788,7 @@ { DEFINE_LOCALS; - Long n, limit; + Short n, limit; if ( ( n = TT_LookUp_Table( face, TTAG_cvt ) ) < 0 ) @@ -837,8 +838,8 @@ { DEFINE_LOCALS; - Long off, table_start; - Long n, limit; + Long off, table_start; + Short n, limit; TCMapDir cmap_dir; TCMapDirEntry entry_; @@ -926,7 +927,7 @@ { DEFINE_LOCALS_WO_FRAME; - Long n; + Short n; /* The font program is optional */ @@ -985,7 +986,7 @@ { DEFINE_LOCALS; - Long i; + Short i; TT_OS2* os2; @@ -1083,7 +1084,7 @@ { DEFINE_LOCALS; - Long i; + Short i; TT_Postscript* post = &face->postscript; @@ -1135,7 +1136,7 @@ TT_Hdmx_Record* rec; TT_Hdmx hdmx; - Long table; + Short table; UShort n, num_glyphs; Long record_size; diff --git a/Driver/Font/TrueType/FreeType/ttload.h b/Driver/Font/TrueType/FreeType/ttload.h index 3538d11b5..429799c35 100644 --- a/Driver/Font/TrueType/FreeType/ttload.h +++ b/Driver/Font/TrueType/FreeType/ttload.h @@ -32,7 +32,7 @@ #endif EXPORT_DEF - Long TT_LookUp_Table( PFace face, ULong tag ); + Short TT_LookUp_Table( PFace face, ULong tag ); LOCAL_DEF TT_Error Load_TrueType_Directory ( PFace face ); LOCAL_DEF TT_Error Load_TrueType_MaxProfile ( PFace face ); From a298dc7e48110198a2e84703bfe69cead0704392 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 6 Aug 2023 17:54:32 +0200 Subject: [PATCH 204/246] activate kerning extension --- Driver/Font/TrueType/Adapter/ttinit.c | 3 +-- Driver/Font/TrueType/FreeType/ttextend.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index ea3123a3f..69214626d 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -93,8 +93,7 @@ TT_Error _pascal Init_FreeType() if ( error != TT_Err_Ok ) return error; - //commented out because it freezes swat - //TT_Init_Kerning() + TT_Init_Kerning_Extension(); return TT_Err_Ok; } diff --git a/Driver/Font/TrueType/FreeType/ttextend.c b/Driver/Font/TrueType/FreeType/ttextend.c index 0c66c29d9..427b7ba91 100644 --- a/Driver/Font/TrueType/FreeType/ttextend.c +++ b/Driver/Font/TrueType/FreeType/ttextend.c @@ -160,8 +160,12 @@ ext = (PByte)face->extension + clazz->offset; /* the destructor is optional */ - if ( clazz->destroy ) + if ( clazz->destroy ) +#ifdef __GEOS__ + ProcCallFixedOrMovable_cdecl( clazz->destroy, (void*)ext, face ); +#else clazz->destroy( (void*)ext, face ); +#endif } /* destroy the face's extension block too */ @@ -196,7 +200,13 @@ { clazz = registry->classes + n; ext = (PByte)face->extension + clazz->offset; + +#ifdef __GEOS__ + error = ProcCallFixedOrMovable_cdecl( clazz->build, (void*)ext, face ); +#else error = clazz->build( (void*)ext, face ); +#endif + if ( error ) goto Fail; } From fe339aa44b9c25ff48345ed1c878da1e5de2ce26 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 7 Aug 2023 23:00:39 +0200 Subject: [PATCH 205/246] add instance to persistent font information --- Driver/Font/TrueType/Adapter/ttadapter.c | 7 +++++-- Driver/Font/TrueType/Adapter/ttchars.c | 2 -- Driver/Font/TrueType/Adapter/ttwidths.c | 7 +++---- Driver/Font/TrueType/FreeType/freetype.h | 4 ++-- Driver/Font/TrueType/FreeType/ttapi.c | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.c b/Driver/Font/TrueType/Adapter/ttadapter.c index 6dcea431b..d3a6fc6fe 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.c +++ b/Driver/Font/TrueType/Adapter/ttadapter.c @@ -35,7 +35,7 @@ static int strcmp( const char* s1, const char* s2 ); * RETURNS: TT_Error * * STRATEGY: - check if face is already loaded - * - if not, open file with face + * - if not, open file with face and instance * - load face from file * * REVISION HISTORY: @@ -72,6 +72,8 @@ Boolean TrueType_Lock_Face(TRUETYPE_VARS, TrueTypeOutlineEntry* entry) goto Fail; if ( getCharMap( trueTypeVars, &CHAR_MAP ) ) goto Fail; + if ( TT_New_Instance( FACE, &INSTANCE ) ) + goto Fail; /* font has been fully loaded */ trueTypeVars->entry = *entry; @@ -118,7 +120,7 @@ void TrueType_Unlock_Face(TRUETYPE_VARS) * * RETURNS: TT_Error * - * STRATEGY: - free resources used by face + * STRATEGY: - free resources used by instance and face * - close file * * REVISION HISTORY: @@ -132,6 +134,7 @@ void TrueType_Free_Face(TRUETYPE_VARS) { if ( trueTypeVars->entry.TTOE_fontFileName[0] ) { + TT_Done_Instance( INSTANCE ); TT_Close_Face( FACE ); trueTypeVars->entry.TTOE_fontFileName[0] = 0; } diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 95de1f66e..861e679dd 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -99,7 +99,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); goto Fail; TT_New_Glyph( FACE, &GLYPH ); - TT_New_Instance( FACE, &INSTANCE ); /* get TT char index */ charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); @@ -190,7 +189,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); } TT_Done_Glyph( GLYPH ); - TT_Done_Instance( INSTANCE ); if( fontBuf->FB_dataSize > MAX_FONTBUF_SIZE ) ShrinkFontBuf( fontBuf ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 6353701a1..f63e4b7af 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -26,6 +26,7 @@ #include "ttcharmapper.h" #include "ttinit.h" #include "freetype.h" +#include "ftxkern.h" #include "../FreeType/ftxkern.h" @@ -204,7 +205,6 @@ static void ConvertWidths( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB TT_New_Glyph( FACE, &GLYPH ); - TT_New_Instance( FACE, &INSTANCE ); for( currentChar = fontHeader->FH_firstChar; currentChar <= fontHeader->FH_lastChar; ++currentChar ) { @@ -261,7 +261,6 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); ++charTableEntry; } - TT_Done_Instance( INSTANCE ); TT_Done_Glyph( GLYPH ); } @@ -305,8 +304,8 @@ static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) // KernCounter hochzählen fontBuf->FB_kernCount = 0; - fontBuf->FB_kernValuePtr = NULL; - fontBuf->FB_kernPairPtr = NULL; + fontBuf->FB_kernValuePtr = 0; + fontBuf->FB_kernPairPtr = 0; } /******************************************************************** diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index 5f6b04d35..c7b64aef9 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -739,11 +739,11 @@ /* Set device resolution for a given instance. The values are */ /* given in dpi (Dots Per Inch). Default is 96 in both directions. */ - +/* EXPORT_DEF TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, TT_UShort xResolution, - TT_UShort yResolution ); + TT_UShort yResolution ); */ /* Set the pointsize for a given instance. Default is 10pt. */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 92a2287ad..a95feb29e 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -531,7 +531,7 @@ extern TEngine_Instance engineInstance; * Happily, 99.99% will do just that :-) * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, TT_UShort xResolution, @@ -545,7 +545,7 @@ extern TEngine_Instance engineInstance; ins->metrics.x_resolution = xResolution; ins->metrics.y_resolution = yResolution; - ins->valid = FALSE; + ins->valid = FALSE; */ /* In the case of a thread-safe implementation, we immediately */ /* call Instance_Reset in order to change the instance's variable */ @@ -554,8 +554,8 @@ extern TEngine_Instance engineInstance; /* flag to FALSE, which will force the instance's resetting at */ /* the next glyph loading */ - return TT_Err_Ok; - } +/* return TT_Err_Ok; + } */ /******************************************************************* From e737d4c5bf2941bf1f85e08d5bab1000154f94d3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 11 Aug 2023 23:29:56 +0200 Subject: [PATCH 206/246] first steps implementation kerning --- Driver/Font/TrueType/Adapter/ttadapter.h | 3 + Driver/Font/TrueType/Adapter/ttcharmapper.c | 469 ++++++++++---------- Driver/Font/TrueType/Adapter/ttcharmapper.h | 3 +- Driver/Font/TrueType/Adapter/ttinit.c | 55 ++- Driver/Font/TrueType/Adapter/ttmetrics.c | 2 - Driver/Font/TrueType/Adapter/ttwidths.c | 3 +- 6 files changed, 298 insertions(+), 237 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index e66f7a998..28afd9b2a 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -64,6 +64,8 @@ extern TEngine_Instance engineInstance; #define FAMILY_NAME_LENGTH 20 #define STYLE_NAME_LENGTH 16 +#define MAX_KERN_TABLE_LENGTH 6000 + /*********************************************************************** * structures @@ -354,6 +356,7 @@ typedef struct sword FH_minTSB; //minimum top side bound sword FH_maxBSB; //maximum bottom side bound sword FH_maxRSB; //maximum right side bound + word FH_kernCount; //num of kerning pairs } FontHeader; diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index 4f19d114e..d02b36263 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -32,231 +32,231 @@ //TODO: put geosCharMap into movable ressource CharMapEntry geosCharMap[] = { -/* unicode flags */ - C_SPACE, 0, - C_EXCLAMATION_MARK, 0, - C_QUOTATION_MARK, 0, - C_NUMBER_SIGN, 0, - C_DOLLAR_SIGN, 0, - C_PERCENT_SIGN, 0, - C_AMPERSAND, 0, - C_APOSTROPHE_QUOTE, 0, - C_OPENING_PARENTHESIS, 0, - C_CLOSING_PARENTHESIS, 0, - C_ASTERISK, 0, - C_PLUS_SIGN, 0, - C_COMMA, 0, - C_HYPHEN_MINUS, 0, - C_PERIOD, 0, - C_SLASH, 0, - C_DIGIT_ZERO, 0, - C_DIGIT_ONE, 0, - C_DIGIT_TWO, 0, - C_DIGIT_THREE, 0, - C_DIGIT_FOUR, 0, - C_DIGIT_FIVE, 0, - C_DIGIT_SIX, 0, - C_DIGIT_SEVEN, 0, - C_DIGIT_EIGHT, 0, - C_DIGIT_NINE, 0, - C_COLON, 0, - C_SEMICOLON, 0, - C_LESS_THAN_SIGN, 0, - C_EQUALS_SIGN, 0, - C_GREATER_THAN_SIGN, 0, - C_QUESTION_MARK, 0, - C_COMMERCIAL_AT, 0, - C_LATIN_CAPITAL_LETTER_A, CMF_CAP, - C_LATIN_CAPITAL_LETTER_B, CMF_CAP, - C_LATIN_CAPITAL_LETTER_C, CMF_CAP, - C_LATIN_CAPITAL_LETTER_D, CMF_CAP, - C_LATIN_CAPITAL_LETTER_E, CMF_CAP, - C_LATIN_CAPITAL_LETTER_F, CMF_CAP, - C_LATIN_CAPITAL_LETTER_G, CMF_CAP, - C_LATIN_CAPITAL_LETTER_H, CMF_CAP, - C_LATIN_CAPITAL_LETTER_I, CMF_CAP, - C_LATIN_CAPITAL_LETTER_J, CMF_CAP, - C_LATIN_CAPITAL_LETTER_K, CMF_CAP, - C_LATIN_CAPITAL_LETTER_L, CMF_CAP, - C_LATIN_CAPITAL_LETTER_M, CMF_CAP, - C_LATIN_CAPITAL_LETTER_N, CMF_CAP, - C_LATIN_CAPITAL_LETTER_O, CMF_CAP, - C_LATIN_CAPITAL_LETTER_P, CMF_CAP, - C_LATIN_CAPITAL_LETTER_Q, CMF_CAP, - C_LATIN_CAPITAL_LETTER_R, CMF_CAP, - C_LATIN_CAPITAL_LETTER_S, CMF_CAP, - C_LATIN_CAPITAL_LETTER_T, CMF_CAP, - C_LATIN_CAPITAL_LETTER_U, CMF_CAP, - C_LATIN_CAPITAL_LETTER_V, CMF_CAP, - C_LATIN_CAPITAL_LETTER_W, CMF_CAP, - C_LATIN_CAPITAL_LETTER_X, CMF_CAP, - C_LATIN_CAPITAL_LETTER_Y, CMF_CAP, - C_LATIN_CAPITAL_LETTER_Z, CMF_CAP, - C_OPENING_SQUARE_BRACKET, 0, - C_BACKSLASH, 0, - C_CLOSING_SQUARE_BRACKET, 0, - C_SPACING_CIRCUMFLEX, 0, - C_SPACING_UNDERSCORE, 0, - C_SPACING_GRAVE, 0, - C_LATIN_SMALL_LETTER_A, CMF_MEAN, - C_LATIN_SMALL_LETTER_B, CMF_ASCENT, - C_LATIN_SMALL_LETTER_C, CMF_MEAN, - C_LATIN_SMALL_LETTER_D, CMF_ASCENT, - C_LATIN_SMALL_LETTER_E, CMF_MEAN, - C_LATIN_SMALL_LETTER_F, CMF_ASCENT, - C_LATIN_SMALL_LETTER_G, CMF_DESCENT, - C_LATIN_SMALL_LETTER_H, CMF_ASCENT, - C_LATIN_SMALL_LETTER_I, CMF_ASCENT, - C_LATIN_SMALL_LETTER_J, CMF_DESCENT, - C_LATIN_SMALL_LETTER_K, CMF_ASCENT, - C_LATIN_SMALL_LETTER_L, CMF_ASCENT, - C_LATIN_SMALL_LETTER_M, CMF_MEAN, - C_LATIN_SMALL_LETTER_N, CMF_MEAN, - C_LATIN_SMALL_LETTER_O, CMF_MEAN, - C_LATIN_SMALL_LETTER_P, CMF_DESCENT, - C_LATIN_SMALL_LETTER_Q, CMF_DESCENT, - C_LATIN_SMALL_LETTER_R, CMF_MEAN, - C_LATIN_SMALL_LETTER_S, CMF_MEAN, - C_LATIN_SMALL_LETTER_T, CMF_ASCENT, - C_LATIN_SMALL_LETTER_U, CMF_MEAN, - C_LATIN_SMALL_LETTER_V, CMF_MEAN, - C_LATIN_SMALL_LETTER_W, CMF_MEAN, - C_LATIN_SMALL_LETTER_X, CMF_MEAN, - C_LATIN_SMALL_LETTER_Y, CMF_DESCENT, - C_LATIN_SMALL_LETTER_Z, CMF_MEAN, - C_OPENING_CURLY_BRACKET, 0, - C_VERTICAL_BAR, 0, - C_CLOSING_CURLY_BRACKET, 0, - C_TILDE, 0, - C_DELETE, 0, - C_LATIN_CAPITAL_LETTER_A_DIAERESIS, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_A_RING, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_C_CEDILLA, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_ACUTE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_N_TILDE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_DIAERESIS, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_DIAERESIS, CMF_ACCENT, - C_LATIN_SMALL_LETTER_A_ACUTE, 0, - C_LATIN_SMALL_LETTER_A_GRAVE, 0, - C_LATIN_SMALL_LETTER_A_CIRCUMFLEX, 0, - C_LATIN_SMALL_LETTER_A_DIAERESIS, 0, - C_LATIN_SMALL_LETTER_A_TILDE, 0, - C_LATIN_SMALL_LETTER_A_RING, 0, - C_LATIN_SMALL_LETTER_C_CEDILLA, 0, - C_LATIN_SMALL_LETTER_E_ACUTE, 0, - C_LATIN_SMALL_LETTER_E_GRAVE, 0, - C_LATIN_SMALL_LETTER_E_CIRCUMFLEX, 0, - C_LATIN_SMALL_LETTER_E_DIAERESIS, 0, - C_LATIN_SMALL_LETTER_I_ACUTE, 0, - C_LATIN_SMALL_LETTER_I_GRAVE, 0, - C_LATIN_SMALL_LETTER_I_CIRCUMFLEX, 0, - C_LATIN_SMALL_LETTER_I_DIAERESIS, 0, - C_LATIN_SMALL_LETTER_N_TILDE, 0, - C_LATIN_SMALL_LETTER_O_ACUTE, 0, - C_LATIN_SMALL_LETTER_O_GRAVE, 0, - C_LATIN_SMALL_LETTER_O_CIRCUMFLEX, 0, - C_LATIN_SMALL_LETTER_O_DIAERESIS, 0, - C_LATIN_SMALL_LETTER_O_TILDE, 0, - C_LATIN_SMALL_LETTER_U_ACUTE, 0, - C_LATIN_SMALL_LETTER_U_GRAVE, 0, - C_LATIN_SMALL_LETTER_U_CIRCUMFLEX, 0, - C_LATIN_SMALL_LETTER_U_DIAERESIS, 0, - C_DAGGER, 0, - C_DEGREE_SIGN, 0, - C_CENT_SIGN, 0, - C_POUND_SIGN, 0, - C_SECTION_SIGN, 0, - C_BULLET_OPERATOR, 0, - C_PARAGRAPH_SIGN, 0, - C_LATIN_SMALL_LETTER_SHARP_S, 0, - C_REGISTERED_TRADE_MARK_SIGN, 0, - C_COPYRIGHT_SIGN, 0, - C_TRADEMARK, 0, - C_SPACING_ACUTE, 0, - C_SPACING_DIAERESIS, 0, - C_NOT_EQUAL_TO, 0, - C_LATIN_CAPITAL_LETTER_A_E, CMF_CAP, - C_LATIN_CAPITAL_LETTER_O_SLASH, CMF_CAP, - C_INFINITY, 0, - C_PLUS_OR_MINUS_SIGN, 0, - C_LESS_THAN_OR_EQUAL_TO, 0, - C_GREATER_THAN_OR_EQUAL_TO, 0, - C_YEN_SIGN, 0, - C_MICRO_SIGN, 0, - C_PARTIAL_DIFFERENTIAL, 0, - C_N_ARY_SUMMATION, 0, - C_N_ARY_PRODUCT, 0, - C_GREEK_SMALL_LETTER_PI, 0, - C_INTEGRAL, 0, - C_FEMININE_ORDINAL_INDICATOR, 0, - C_MASCULINE_ORDINAL_INDICATOR, 0, - C_GREEK_CAPITAL_LETTER_OMEGA, 0, - C_LATIN_SMALL_LETTER_A_E, 0, - C_LATIN_SMALL_LETTER_O_SLASH, 0, - C_INVERTED_QUESTION_MARK, 0, - C_INVERTED_EXCLAMATION_MARK, 0, - C_NOT_SIGN, 0, - C_SQUARE_ROOT, 0, - C_LATIN_SMALL_LETTER_SCRIPT_F, 0, - C_ALMOST_EQUAL_TO, 0, - C_GREEK_CAPITAL_LETTER_DELTA, 0, - C_LEFT_POINTING_GUILLEMET, 0, - C_RIGHT_POINTING_GUILLEMET, 0, - C_MIDLINE_HORIZONTAL_ELLIPSIS, 0, - C_NON_BREAKING_SPACE, 0, - C_LATIN_CAPITAL_LETTER_A_GRAVE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_A_TILDE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_TILDE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_E, CMF_ACCENT, - C_LATIN_SMALL_LETTER_O_E, 0, - C_EM_DASH, 0, - C_EN_DASH, 0, - C_DOUBLE_TURNED_COMMA_QUOTATION_MARK, 0, - C_DOUBLE_COMMA_QUOTATION_MARK, 0, - C_SINGLE_TURNED_COMMA_QUOTATION_MARK, 0, - C_SINGLE_COMMA_QUOTATION_MARK, 0, - C_DIVISION_SIGN, 0, - C_BLACK_DIAMOND, 0, - C_LATIN_SMALL_LETTER_Y_DIAERESIS, 0, - C_LATIN_CAPITAL_LETTER_Y_DIAERESIS, CMF_ACCENT, - C_FRACTION_SLASH, 0, - C_EURO_SIGN, 0, - C_LEFT_POINTING_SINGLE_GUILLEMET, 0, - C_RIGHT_POINTING_SINGLE_GUILLEMET, 0, - C_LATIN_SMALL_LETTER_Y_ACUTE, 0, - C_LATIN_CAPITAL_LETTER_Y_ACUTE, 0, - C_DOUBLE_DAGGER, 0, - C_MIDDLE_DOT, 0, - C_LOW_SINGLE_COMMA_QUOTATION_MARK, 0, - C_LOW_DOUBLE_COMMA_QUOTATION_MARK, 0, - C_PER_MILLE_SIGN, 0, - C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_CIRCUMFLEX, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_A_ACUTE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_DIAERESIS, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_E_GRAVE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_ACUTE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_CIRCUMFLEX, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_DIAERESIS, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_I_GRAVE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_ACUTE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_O_CIRCUMFLEX, CMF_ACCENT, - 0, 0, //no character - C_LATIN_CAPITAL_LETTER_O_GRAVE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_ACUTE, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_CIRCUMFLEX, CMF_ACCENT, - C_LATIN_CAPITAL_LETTER_U_GRAVE, CMF_ACCENT, - C_LATIN_SMALL_LETTER_DOTLESS_I, 0, - C_NON_SPACING_CIRCUMFLEX, 0, - C_NON_SPACING_TILDE, 0, - C_SPACING_MACRON, 0, - C_SPACING_BREVE, 0, - C_SPACING_DOT_ABOVE, 0, - C_SPACING_RING_ABOVE, 0, - C_SPACING_CEDILLA, 0, - C_SPACING_DOUBLE_ACUTE, 0, - C_SPACING_OGONEK, 0, - C_MODIFIER_LETTER_HACEK, 0 +/* unicode flags ttIndex */ + C_SPACE, 0, 0, + C_EXCLAMATION_MARK, 0, 0, + C_QUOTATION_MARK, 0, 0, + C_NUMBER_SIGN, 0, 0, + C_DOLLAR_SIGN, 0, 0, + C_PERCENT_SIGN, 0, 0, + C_AMPERSAND, 0, 0, + C_APOSTROPHE_QUOTE, 0, 0, + C_OPENING_PARENTHESIS, 0, 0, + C_CLOSING_PARENTHESIS, 0, 0, + C_ASTERISK, 0, 0, + C_PLUS_SIGN, 0, 0, + C_COMMA, 0, 0, + C_HYPHEN_MINUS, 0, 0, + C_PERIOD, 0, 0, + C_SLASH, 0, 0, + C_DIGIT_ZERO, 0, 0, + C_DIGIT_ONE, 0, 0, + C_DIGIT_TWO, 0, 0, + C_DIGIT_THREE, 0, 0, + C_DIGIT_FOUR, 0, 0, + C_DIGIT_FIVE, 0, 0, + C_DIGIT_SIX, 0, 0, + C_DIGIT_SEVEN, 0, 0, + C_DIGIT_EIGHT, 0, 0, + C_DIGIT_NINE, 0, 0, + C_COLON, 0, 0, + C_SEMICOLON, 0, 0, + C_LESS_THAN_SIGN, 0, 0, + C_EQUALS_SIGN, 0, 0, + C_GREATER_THAN_SIGN, 0, 0, + C_QUESTION_MARK, 0, 0, + C_COMMERCIAL_AT, 0, 0, + C_LATIN_CAPITAL_LETTER_A, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_B, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_C, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_D, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_E, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_F, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_G, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_H, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_I, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_J, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_K, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_L, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_M, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_N, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_O, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_P, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_Q, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_R, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_S, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_T, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_U, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_V, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_W, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_X, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_Y, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_Z, CMF_CAP, 0, + C_OPENING_SQUARE_BRACKET, 0, 0, + C_BACKSLASH, 0, 0, + C_CLOSING_SQUARE_BRACKET, 0, 0, + C_SPACING_CIRCUMFLEX, 0, 0, + C_SPACING_UNDERSCORE, 0, 0, + C_SPACING_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_A, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_B, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_C, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_D, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_E, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_F, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_G, CMF_DESCENT, 0, + C_LATIN_SMALL_LETTER_H, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_I, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_J, CMF_DESCENT, 0, + C_LATIN_SMALL_LETTER_K, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_L, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_M, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_N, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_O, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_P, CMF_DESCENT, 0, + C_LATIN_SMALL_LETTER_Q, CMF_DESCENT, 0, + C_LATIN_SMALL_LETTER_R, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_S, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_T, CMF_ASCENT, 0, + C_LATIN_SMALL_LETTER_U, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_V, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_W, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_X, CMF_MEAN, 0, + C_LATIN_SMALL_LETTER_Y, CMF_DESCENT, 0, + C_LATIN_SMALL_LETTER_Z, CMF_MEAN, 0, + C_OPENING_CURLY_BRACKET, 0, 0, + C_VERTICAL_BAR, 0, 0, + C_CLOSING_CURLY_BRACKET, 0, 0, + C_TILDE, 0, 0, + C_DELETE, 0, 0, + C_LATIN_CAPITAL_LETTER_A_DIAERESIS, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_A_RING, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_C_CEDILLA, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_E_ACUTE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_N_TILDE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_O_DIAERESIS, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_U_DIAERESIS, CMF_ACCENT, 0, + C_LATIN_SMALL_LETTER_A_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_A_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_A_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_A_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_A_TILDE, 0, 0, + C_LATIN_SMALL_LETTER_A_RING, 0, 0, + C_LATIN_SMALL_LETTER_C_CEDILLA, 0, 0, + C_LATIN_SMALL_LETTER_E_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_E_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_E_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_E_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_I_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_I_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_I_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_I_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_N_TILDE, 0, 0, + C_LATIN_SMALL_LETTER_O_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_O_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_O_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_O_DIAERESIS, 0, 0, + C_LATIN_SMALL_LETTER_O_TILDE, 0, 0, + C_LATIN_SMALL_LETTER_U_ACUTE, 0, 0, + C_LATIN_SMALL_LETTER_U_GRAVE, 0, 0, + C_LATIN_SMALL_LETTER_U_CIRCUMFLEX, 0, 0, + C_LATIN_SMALL_LETTER_U_DIAERESIS, 0, 0, + C_DAGGER, 0, 0, + C_DEGREE_SIGN, 0, 0, + C_CENT_SIGN, 0, 0, + C_POUND_SIGN, 0, 0, + C_SECTION_SIGN, 0, 0, + C_BULLET_OPERATOR, 0, 0, + C_PARAGRAPH_SIGN, 0, 0, + C_LATIN_SMALL_LETTER_SHARP_S, 0, 0, + C_REGISTERED_TRADE_MARK_SIGN, 0, 0, + C_COPYRIGHT_SIGN, 0, 0, + C_TRADEMARK, 0, 0, + C_SPACING_ACUTE, 0, 0, + C_SPACING_DIAERESIS, 0, 0, + C_NOT_EQUAL_TO, 0, 0, + C_LATIN_CAPITAL_LETTER_A_E, CMF_CAP, 0, + C_LATIN_CAPITAL_LETTER_O_SLASH, CMF_CAP, 0, + C_INFINITY, 0, 0, + C_PLUS_OR_MINUS_SIGN, 0, 0, + C_LESS_THAN_OR_EQUAL_TO, 0, 0, + C_GREATER_THAN_OR_EQUAL_TO, 0, 0, + C_YEN_SIGN, 0, 0, + C_MICRO_SIGN, 0, 0, + C_PARTIAL_DIFFERENTIAL, 0, 0, + C_N_ARY_SUMMATION, 0, 0, + C_N_ARY_PRODUCT, 0, 0, + C_GREEK_SMALL_LETTER_PI, 0, 0, + C_INTEGRAL, 0, 0, + C_FEMININE_ORDINAL_INDICATOR, 0, 0, + C_MASCULINE_ORDINAL_INDICATOR, 0, 0, + C_GREEK_CAPITAL_LETTER_OMEGA, 0, 0, + C_LATIN_SMALL_LETTER_A_E, 0, 0, + C_LATIN_SMALL_LETTER_O_SLASH, 0, 0, + C_INVERTED_QUESTION_MARK, 0, 0, + C_INVERTED_EXCLAMATION_MARK, 0, 0, + C_NOT_SIGN, 0, 0, + C_SQUARE_ROOT, 0, 0, + C_LATIN_SMALL_LETTER_SCRIPT_F, 0, 0, + C_ALMOST_EQUAL_TO, 0, 0, + C_GREEK_CAPITAL_LETTER_DELTA, 0, 0, + C_LEFT_POINTING_GUILLEMET, 0, 0, + C_RIGHT_POINTING_GUILLEMET, 0, 0, + C_MIDLINE_HORIZONTAL_ELLIPSIS, 0, 0, + C_NON_BREAKING_SPACE, 0, 0, + C_LATIN_CAPITAL_LETTER_A_GRAVE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_A_TILDE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_O_TILDE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_O_E, CMF_ACCENT, 0, + C_LATIN_SMALL_LETTER_O_E, 0, 0, + C_EM_DASH, 0, 0, + C_EN_DASH, 0, 0, + C_DOUBLE_TURNED_COMMA_QUOTATION_MARK, 0, 0, + C_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, + C_SINGLE_TURNED_COMMA_QUOTATION_MARK, 0, 0, + C_SINGLE_COMMA_QUOTATION_MARK, 0, 0, + C_DIVISION_SIGN, 0, 0, + C_BLACK_DIAMOND, 0, 0, + C_LATIN_SMALL_LETTER_Y_DIAERESIS, 0, 0, + C_LATIN_CAPITAL_LETTER_Y_DIAERESIS, CMF_ACCENT, 0, + C_FRACTION_SLASH, 0, 0, + C_EURO_SIGN, 0, 0, + C_LEFT_POINTING_SINGLE_GUILLEMET, 0, 0, + C_RIGHT_POINTING_SINGLE_GUILLEMET, 0, 0, + C_LATIN_SMALL_LETTER_Y_ACUTE, 0, 0, + C_LATIN_CAPITAL_LETTER_Y_ACUTE, 0, 0, + C_DOUBLE_DAGGER, 0, 0, + C_MIDDLE_DOT, 0, 0, + C_LOW_SINGLE_COMMA_QUOTATION_MARK, 0, 0, + C_LOW_DOUBLE_COMMA_QUOTATION_MARK, 0, 0, + C_PER_MILLE_SIGN, 0, 0, + C_LATIN_CAPITAL_LETTER_A_CIRCUMFLEX, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_E_CIRCUMFLEX, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_A_ACUTE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_E_DIAERESIS, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_E_GRAVE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_I_ACUTE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_I_CIRCUMFLEX, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_I_DIAERESIS, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_I_GRAVE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_O_ACUTE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_O_CIRCUMFLEX, CMF_ACCENT, 0, + 0, 0, 0, //no character + C_LATIN_CAPITAL_LETTER_O_GRAVE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_U_ACUTE, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_U_CIRCUMFLEX, CMF_ACCENT, 0, + C_LATIN_CAPITAL_LETTER_U_GRAVE, CMF_ACCENT, 0, + C_LATIN_SMALL_LETTER_DOTLESS_I, 0, 0, + C_NON_SPACING_CIRCUMFLEX, 0, 0, + C_NON_SPACING_TILDE, 0, 0, + C_SPACING_MACRON, 0, 0, + C_SPACING_BREVE, 0, 0, + C_SPACING_DOT_ABOVE, 0, 0, + C_SPACING_RING_ABOVE, 0, 0, + C_SPACING_CEDILLA, 0, 0, + C_SPACING_DOUBLE_ACUTE, 0, 0, + C_SPACING_OGONEK, 0, 0, + C_MODIFIER_LETTER_HACEK, 0, 0 }; @@ -311,6 +311,7 @@ TT_Error getCharMap( TRUETYPE_VARS, TT_CharMap* charMap ) word InitGeosCharsInCharMap( TT_CharMap map, char *firstChar, char *lastChar ) { word charIndex; + word truetypeIndex; *firstChar = 255; @@ -318,18 +319,24 @@ word InitGeosCharsInCharMap( TT_CharMap map, char *firstChar, char *lastChar ) for( charIndex = 0; charIndex < NUM_CHARMAPENTRIES; ++charIndex ) { - if( TT_Char_Index( map, geosCharMap[ charIndex ].unicode ) ) + if( truetypeIndex = TT_Char_Index( map, geosCharMap[ charIndex ].unicode ) ) { - if ( *firstChar > ( charIndex + C_SPACE ) ) *firstChar = charIndex + C_SPACE; - if ( *lastChar < ( charIndex + C_SPACE ) ) *lastChar = charIndex + C_SPACE; + geosCharMap[ charIndex ].ttIndex = truetypeIndex; + if ( firstChar != NULL && *firstChar > ( charIndex + C_SPACE ) ) *firstChar = charIndex + C_SPACE; + if ( lastChar != NULL && *lastChar < ( charIndex + C_SPACE ) ) *lastChar = charIndex + C_SPACE; } } return 1 + ( *lastChar - *firstChar ); } - -word CountKernPairsWithGeosChars( TT_Face face ) +char getGeosCharForIndex( word ttIndex ) { - return 0; + word charIndex; + + for( charIndex = 0; charIndex < NUM_CHARMAPENTRIES; ++charIndex ) + if( ttIndex == geosCharMap[charIndex].ttIndex ) + return charIndex + C_SPACE; + + return 0; } diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.h b/Driver/Font/TrueType/Adapter/ttcharmapper.h index 5438476d8..5ce6442bd 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.h +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.h @@ -40,6 +40,7 @@ typedef struct { word unicode; CharMapFlags flags; + word ttIndex; } CharMapEntry; @@ -51,8 +52,6 @@ word GeosCharToUnicode( word geosChar ); word InitGeosCharsInCharMap( TT_CharMap map, char* firstChar, char* lastChar ); -word CountKernPairsWithGeosChars( TT_Face face ); - TT_Error getCharMap( TRUETYPE_VARS, TT_CharMap* charMap ); CharMapFlags GeosCharMapFlag( word geosChar ); diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 69214626d..444e2c1bc 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -20,6 +20,7 @@ #include "ttinit.h" #include "ttadapter.h" #include "ttcharmapper.h" +#include "ftxkern.h" #include #include #include @@ -56,12 +57,16 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader ); static char GetDefaultChar( TRUETYPE_VARS, char firstChar ); +static word GetKernCount( TRUETYPE_VARS ); + static word toHash( const char* str ); static int strlen( const char* str ); static void strcpy( char* dest, const char* source ); +static int strcmp( const char* s1, const char* s2 ); + /******************************************************************** * Init_FreeType @@ -674,7 +679,7 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) sword element; /* set fontsAvailEntrys to first Element after LMemBlockHeader */ - fontsAvailEntrys = ( (byte*)LMemDeref( + fontsAvailEntrys = ( (FontsAvailEntry*)LMemDeref( ConstructOptr( fontInfoBlock, sizeof(LMemBlockHeader))) ); elements = LMemGetChunkSizePtr( fontsAvailEntrys ) / sizeof( FontsAvailEntry ); @@ -805,6 +810,7 @@ EC( ECCheckBounds( (void*)fontHeader ) ); &fontHeader->FH_firstChar, &fontHeader->FH_lastChar ); fontHeader->FH_defaultChar = GetDefaultChar( trueTypeVars, fontHeader->FH_firstChar ); + fontHeader->FH_kernCount = GetKernCount( trueTypeVars ); TT_New_Instance( FACE, &INSTANCE ); TT_New_Glyph( FACE, &GLYPH ); @@ -932,6 +938,53 @@ static char GetDefaultChar( TRUETYPE_VARS, char firstChar ) } +/******************************************************************** + * GetKernCount + ******************************************************************** + * SYNOPSIS: Returns the number of kernpairs with chars from + * FreeGEOS char set. + * + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * + * RETURNS: word + * + * SIDE EFFECTS: none + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 11/08/23 JK Initial Revision + *******************************************************************/ + +static word GetKernCount( TRUETYPE_VARS ) +{ + TT_Kerning kerningDir; + word table; + + if( TT_Get_Kerning_Directory( FACE, &kerningDir ) ) + goto Fail; + + /* search for format 0 subtable */ + for( table = 0; table < kerningDir.nTables; table++ ) + { + if( TT_Load_Kerning_Table( FACE, table ) ) + goto Fail; + + if( kerningDir.tables->format != 0 ) + continue; + } + + //TODO: return only number of pairs with FreeGEOS chars + return kerningDir.tables->length <= MAX_KERN_TABLE_LENGTH ? + kerningDir.tables->t.kern0.nPairs : 0; + +Fail: + return 0; +} + + /*******************************************************************/ /* We cannot use functions from the Ansic library, which causes a */ /* cycle. Therefore, the required functions are reimplemented here.*/ diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index eefc23fec..c668ef315 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -91,7 +91,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); // load glyph TT_New_Glyph( FACE, &GLYPH ); - TT_New_Instance( FACE, &INSTANCE ); // transform glyphs outline TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); @@ -125,7 +124,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); break; } - TT_Done_Instance( INSTANCE ); TT_Done_Glyph( GLYPH ); TrueType_Unlock_Face( trueTypeVars ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index f63e4b7af..fc4b02bd9 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -140,12 +140,13 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* alloc Block for FontBuf, CharTableEntries, KernPairs and kerning values */ size = AllocFontBlock( sizeof( TransformMatrix ), fontHeader->FH_numChars, - CountKernPairsWithGeosChars( FACE ), + fontHeader->FH_kernCount, &fontHandle ); /* deref FontBuf */ fontBuf = (FontBuf*)MemDeref( fontHandle ); fontBuf->FB_dataSize = size; + fontBuf->FB_kernCount = fontHeader->FH_kernCount; /* calculate scale factor */ CalcScaleForWidths( trueTypeVars, pointSize, stylesToImplement ); From e65ebb228ed53402eb21ad4e8de5e522f7c216fb Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 14 Aug 2023 22:24:59 +0200 Subject: [PATCH 207/246] kerning implemented --- Driver/Font/TrueType/Adapter/ttadapter.h | 8 +- Driver/Font/TrueType/Adapter/ttcharmapper.c | 21 ++++ Driver/Font/TrueType/Adapter/ttchars.c | 2 +- Driver/Font/TrueType/Adapter/ttinit.c | 22 ++-- Driver/Font/TrueType/Adapter/ttwidths.c | 115 ++++++++++++++------ Driver/Font/TrueType/backlog.md | 25 ----- 6 files changed, 119 insertions(+), 74 deletions(-) delete mode 100644 Driver/Font/TrueType/backlog.md diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 28afd9b2a..7e6a892d4 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -189,8 +189,8 @@ typedef struct WBFixed FB_descent; WBFixed FB_extLeading; word FB_kernCount; - word FB_kernPairPtr; //offset to kerning pair table - word FB_kernValuePtr; //offset to kerning value table + word FB_kernPairs; //offset to kerning pair table + word FB_kernValues; //offset to kerning value table #ifdef DBCS_PCGEOS wchar FB_firstChar; wchar FB_lastChar; @@ -261,8 +261,8 @@ typedef struct */ typedef struct { - char KB_char1; - char KB_char2; + char KP_charRight; + char KP_charLeft; } KernPair; /* diff --git a/Driver/Font/TrueType/Adapter/ttcharmapper.c b/Driver/Font/TrueType/Adapter/ttcharmapper.c index d02b36263..b509d2ad7 100644 --- a/Driver/Font/TrueType/Adapter/ttcharmapper.c +++ b/Driver/Font/TrueType/Adapter/ttcharmapper.c @@ -330,6 +330,27 @@ word InitGeosCharsInCharMap( TT_CharMap map, char *firstChar, char *lastChar ) return 1 + ( *lastChar - *firstChar ); } + +Boolean isGeosCharPair( word ttIndex_1, word ttIndex_2 ) +{ + word charIndex; + word hits = 0; + + for( charIndex = 0; charIndex < NUM_CHARMAPENTRIES; ++charIndex ) + { + if( geosCharMap[charIndex].ttIndex == ttIndex_1 || + geosCharMap[charIndex].ttIndex == ttIndex_2 ) + ++hits; + + if( hits == 2 ) + return TRUE; + + } + + return FALSE; +} + + char getGeosCharForIndex( word ttIndex ) { word charIndex; diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 861e679dd..f15c277c7 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -358,7 +358,7 @@ static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ) void* bitmapData = MemLock( bitmapHandle ); if( bitmapData == NULL ) { - MemReAlloc( bitmapHandle, MAX( size, 1024 ), HAF_NO_ERR ); + MemReAlloc( bitmapHandle, MAX( size, 2048 ), HAF_NO_ERR ); bitmapData = MemLock( bitmapHandle ); } else { if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 444e2c1bc..6b3ba448b 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -927,11 +927,7 @@ EC( ECCheckBounds( (void*)fontHeader ) ); *******************************************************************/ static char GetDefaultChar( TRUETYPE_VARS, char firstChar ) { - word unicode = GeosCharToUnicode( DEFAULT_DEFAULT_CHAR ); - word charIndex = TT_Char_Index( CHAR_MAP, unicode ); - - - if ( charIndex == 0 ) + if ( !TT_Char_Index( CHAR_MAP, GeosCharToUnicode( DEFAULT_DEFAULT_CHAR ) ) ) return firstChar; return DEFAULT_DEFAULT_CHAR; @@ -962,6 +958,7 @@ static word GetKernCount( TRUETYPE_VARS ) { TT_Kerning kerningDir; word table; + word numGeosKernPairs = 0; if( TT_Get_Kerning_Directory( FACE, &kerningDir ) ) goto Fail; @@ -969,19 +966,24 @@ static word GetKernCount( TRUETYPE_VARS ) /* search for format 0 subtable */ for( table = 0; table < kerningDir.nTables; table++ ) { + word i; + if( TT_Load_Kerning_Table( FACE, table ) ) goto Fail; if( kerningDir.tables->format != 0 ) continue; - } - //TODO: return only number of pairs with FreeGEOS chars - return kerningDir.tables->length <= MAX_KERN_TABLE_LENGTH ? - kerningDir.tables->t.kern0.nPairs : 0; + for( i = 0; i < kerningDir.tables->t.kern0.nPairs; i++ ) + { + if( isGeosCharPair( kerningDir.tables->t.kern0.pairs[i].left, + kerningDir.tables->t.kern0.pairs[i].right ) ) + numGeosKernPairs++; + } + } Fail: - return 0; + return numGeosKernPairs; } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index fc4b02bd9..cfa1cb992 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -68,6 +68,16 @@ static Boolean IsRegionNeeded( TransformMatrix* transMatrix, #define ROUND_WBFIXED( value ) ( value.WBF_frac ? ( value.WBF_int + 1 ) : value.WBF_int ) +#define OFFSET_KERN_PAIRS ( sizeof(FontBuf) + \ + fontHeader->FH_numChars * sizeof( CharTableEntry) + \ + sizeof( TransformMatrix ) ) + + +#define OFFSET_KERN_VALUES ( sizeof(FontBuf) + \ + fontHeader->FH_numChars * sizeof( CharTableEntry) + \ + sizeof( TransformMatrix ) + \ + fontHeader->FH_kernCount * sizeof( KernPair ) ) + /******************************************************************** * TrueType_Gen_Widths @@ -142,11 +152,21 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); fontHeader->FH_numChars, fontHeader->FH_kernCount, &fontHandle ); - - /* deref FontBuf */ fontBuf = (FontBuf*)MemDeref( fontHandle ); - fontBuf->FB_dataSize = size; - fontBuf->FB_kernCount = fontHeader->FH_kernCount; + + /* initialize fields in FontBuf that do not have to be scaled */ + fontBuf->FB_dataSize = size; + fontBuf->FB_maker = FM_TRUETYPE; + fontBuf->FB_flags = FBF_IS_OUTLINE; + fontBuf->FB_heapCount = 0; + + fontBuf->FB_firstChar = fontHeader->FH_firstChar; + fontBuf->FB_lastChar = fontHeader->FH_lastChar; + fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; + + fontBuf->FB_kernCount = fontHeader->FH_kernCount; + fontBuf->FB_kernPairs = fontHeader->FH_kernCount ? OFFSET_KERN_PAIRS : 0; + fontBuf->FB_kernValues = fontHeader->FH_kernCount ? OFFSET_KERN_VALUES : 0; /* calculate scale factor */ CalcScaleForWidths( trueTypeVars, pointSize, stylesToImplement ); @@ -237,7 +257,6 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); charTableEntry->CTE_width.WBF_int = INTEGER_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_width.WBF_frac = FRACTION_OF_WWFIXEDASDWORD( scaledWidth ); charTableEntry->CTE_dataOffset = CHAR_NOT_BUILT; - charTableEntry->CTE_flags = 0; charTableEntry->CTE_usage = 0; @@ -252,11 +271,22 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); charTableEntry->CTE_flags |= CTF_ABOVE_ASCENT; - if( fontBuf->FB_kernCount > 0 ) + if( fontBuf->FB_kernCount ) { - //first kern - - //second kern + word i; + KernPair* kernPair = (KernPair*) ( ( (byte*)fontBuf ) + fontBuf->FB_kernPairs ); + + for( i = 0; i < fontBuf->FB_kernCount; ++i ) + { + if( currentChar == kernPair->KP_charRight ) + charTableEntry->CTE_flags |= CTF_IS_FIRST_KERN; + else if ( currentChar == kernPair->KP_charLeft ) + charTableEntry->CTE_flags |= CTF_IS_SECOND_KERN; + + if( charTableEntry->CTE_flags && CTF_IS_FIRST_KERN & + charTableEntry->CTE_flags && CTF_IS_SECOND_KERN ) + break; + } } ++charTableEntry; @@ -269,7 +299,8 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); /******************************************************************** * ConvertKernPairs ******************************************************************** - * SYNOPSIS: Fills FontBuf with kerning information. + * SYNOPSIS: Fills kern pairs and kern values in FontBuf with + * kerning information. * * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. * *fontBuf Ptr. to FontBuf structure. @@ -288,25 +319,51 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) { - KernPair* kernPair; - WBFixed* wbFixed; + TT_Kerning kerningDir; + word table; + + KernPair* kernPair = (KernPair*) ( ( (byte*)fontBuf ) + fontBuf->FB_kernPairs ); + BBFixed* kernValue = (BBFixed*) ( ( (byte*)fontBuf ) + fontBuf->FB_kernValues ); + - //lade TT_Kern Tabelle + /* load kerning directory */ + if( TT_Get_Kerning_Directory( FACE, &kerningDir ) ) + return; - //iteriere über den FreeGEOS Zeichensatz + /* search for format 0 subtable */ + for( table = 0; table < kerningDir.nTables; ++table ) + { + word i; + + if( TT_Load_Kerning_Table( FACE, table ) ) + return; + + if( kerningDir.tables->format != 0 ) + continue; - //wandle das akt. Zeichen in den TT Index + for( i = 0; i < kerningDir.tables->t.kern0.nPairs; ++i ) + { + char left = getGeosCharForIndex( kerningDir.tables->t.kern0.pairs[i].left ); + char right = getGeosCharForIndex( kerningDir.tables->t.kern0.pairs[i].right ); + + if( left && right ) + { + WWFixedAsDWord scaledKernValue; - //suche den Index in der TT Kern Tabelle - // wenn gefunden: ist das zweite Zeichen auch ein GEOS Zeichen? - // ja: Kernpair in den FontBuf eintragen - // Kernvalue in den FontBuf eintragen - // KernCounter hochzählen + kernPair->KP_charLeft = left; + kernPair->KP_charRight = right; - fontBuf->FB_kernCount = 0; - fontBuf->FB_kernValuePtr = 0; - fontBuf->FB_kernPairPtr = 0; + /* save scaled kerning value */ + scaledKernValue = SCALE_WORD( kerningDir.tables->t.kern0.pairs[i].value, SCALE_WIDTH ); + kernValue->BBF_int = IntegerOf( scaledKernValue ); + kernValue->BBF_frac = FractionOf( scaledKernValue ) >> 8; + + ++kernPair; + ++kernValue; + } + } + } } /******************************************************************** @@ -465,7 +522,7 @@ static word AllocFontBlock( word additionalSpace, { *fontHandle = MemAllocSetOwner( FONT_MAN_ID, MAX_FONTBUF_SIZE, HF_SWAPABLE | HF_SHARABLE | HF_DISCARDABLE, - HAF_NO_ERR | HAF_LOCK ); + HAF_NO_ERR | HAF_LOCK | HAF_ZERO_INIT ); HandleP( *fontHandle ); } else @@ -577,16 +634,6 @@ static void ConvertHeader( TRUETYPE_VARS, FontHeader* fontHeader, FontBuf* fontB ttfElement = SCALE_WORD( fontHeader->FH_height, scaleHeight ); fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( ttfElement ) + fontBuf->FB_minTSB; - - fontBuf->FB_maker = FM_TRUETYPE; - fontBuf->FB_flags = FBF_IS_OUTLINE; - fontBuf->FB_kernPairPtr = 0; - fontBuf->FB_kernValuePtr = 0; - fontBuf->FB_kernCount = 0; - fontBuf->FB_heapCount = 0; - fontBuf->FB_firstChar = fontHeader->FH_firstChar; - fontBuf->FB_lastChar = fontHeader->FH_lastChar; - fontBuf->FB_defaultChar = fontHeader->FH_defaultChar; } diff --git a/Driver/Font/TrueType/backlog.md b/Driver/Font/TrueType/backlog.md deleted file mode 100644 index 259d46562..000000000 --- a/Driver/Font/TrueType/backlog.md +++ /dev/null @@ -1,25 +0,0 @@ -# TTF-Treiber für FreeGEOS - -## 1 Fehlende Features -- Support für Kerning -- Handler für GEN_IN_REGION -- Handler für GEN_PATH -- Refactoring des Speichermanagments -- Bytecodeinterpreter aktivieren - -## 2 Bekannte Probleme -- Zeichen mit einer Pointsize > 400 werden oben und/oder unten abgeschnitten -- das Resizing des Fontbuffers ist noch fehlerhaft -- die Fontmatrix wird noch nicht genutzt (Dokument-Zoom, Rotation und Sklaierung gehen deshalb nicht) - -## 3 Performance -Der TrueType-Treiber ist noch sehr träge. Hier einige Ideen wie das verbessert werden kann: -- Fonts (zumindest die, die wir initial in der Distribution mitliefern) auf die 224 Zeichen des GEOS-Zeichensatzes reduzieren -- Caching wie beim Nimbus-Treiber implementieren. D.h. ein Face bleibt im Speicher. Wird beim nächsten Rendern der gleiche Font angefordert wird das Face aus dem Cache genutzt ansonsten wird es verworfen und neu geladen. -- Im FreeType-Code wird an vielen Stellen long-Arithmetik genutzt. Hier gibt es sicher viel Stellen an denen ein word genügt. Siehe auch unter Optimierungen. -- FreeType Strukturen zusammenführen (Strukturen die eine 1:1 Kardinalität zu TT_Engine haben in TT_Engine integrieren) -- Wenn das Refactoring des Speichermanagements erfolgt ist, prüfen ober der Render-Cache (derzeit 4096 Bytes) vergrößert werden kann. - -## 4 Optimierungen -- prüfen: ob in ttraster.c in TRasterInstance für lastX, lastY, minX, minY, TraceOfs und TraceOfsLastLine ein word genügt -- in ttraster.c (Set_Hight_Precision) kann gesteuert werden wie 'genau' ein Glyph gerendert wird; falls wir noch Performanceprobleme haben kann hier auch angesetzt werden (ggf. auch mehrstufig) From e02a49118d6528d946170ca3fab628993c1b497b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 16 Aug 2023 20:48:02 +0200 Subject: [PATCH 208/246] Fixing cursor position for fonts with kerning. --- Driver/Font/TrueType/Adapter/ttinit.c | 4 ++++ Driver/Font/TrueType/Adapter/ttwidths.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 6b3ba448b..b1ba40c4e 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -974,6 +974,10 @@ static word GetKernCount( TRUETYPE_VARS ) if( kerningDir.tables->format != 0 ) continue; + /* We only support decreasing the character spacing.*/ + if( kerningDir.tables->t.kern0.pairs[i].value > 0 ) + continue; + for( i = 0; i < kerningDir.tables->t.kern0.nPairs; i++ ) { if( isGeosCharPair( kerningDir.tables->t.kern0.pairs[i].left, diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index cfa1cb992..563799d32 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -346,11 +346,15 @@ static void ConvertKernPairs( TRUETYPE_VARS, FontBuf* fontBuf ) char left = getGeosCharForIndex( kerningDir.tables->t.kern0.pairs[i].left ); char right = getGeosCharForIndex( kerningDir.tables->t.kern0.pairs[i].right ); + + /* We only support decreasing the character spacing.*/ + if( kerningDir.tables->t.kern0.pairs[i].value > 0 ) + continue; + if( left && right ) { WWFixedAsDWord scaledKernValue; - kernPair->KP_charLeft = left; kernPair->KP_charRight = right; From 50ba057f6478759f97b7d8d8f7efd43b1c7a89ef Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 20 Aug 2023 13:19:52 +0200 Subject: [PATCH 209/246] faster font processing --- Driver/Font/TrueType/Adapter/ttinit.c | 28 +++++++++++++++---------- Driver/Font/TrueType/Adapter/ttwidths.c | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index b1ba40c4e..985298fe7 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -243,7 +243,8 @@ static word DetectFontFiles( MemHandle* fileEnumBlock ) ******************************************************************** * SYNOPSIS: Registers a font with its styles as an available font. * - * PARAMETERS: fileName Name of font file. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * fileName Name of font file. * fontInfoBlock Handle to memory block with all * infos about aviable fonts. * @@ -672,6 +673,7 @@ static FontID getFontID( const char* familyName ) * ---- ---- ----------- * 21/01/23 JK Initial Revision *******************************************************************/ + static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) { FontsAvailEntry* fontsAvailEntrys; @@ -697,11 +699,11 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ) * SYNOPSIS: Searches the font's name tables for the given NameID * and returns its content. * - * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. - * name* Pointer to result string. - * nameID ID to be searched. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * name* Pointer to result string. + * nameID ID to be searched. * - * RETURNS: word Length of the table entry found. + * RETURNS: word Length of the table entry found. * * SIDE EFFECTS: none * @@ -773,9 +775,9 @@ static word getNameFromNameTable( TRUETYPE_VARS, char* name, TT_UShort nameID ) * SYNOPSIS: Converts information from a TrueType font into a * FreeGEOS FontHeader. * - * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. - * fontHeader* Pointer to FontInfo in which the - * converted information is to be stored. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * fontHeader* Pointer to FontInfo in which the + * converted information is to be stored. * * RETURNS: void * @@ -820,6 +822,9 @@ EC( ECCheckBounds( (void*)fontHeader ) ); word unicode = GeosCharToUnicode( geosChar ); + if( !GeosCharMapFlag( geosChar ) ) + continue; + charIndex = TT_Char_Index( CHAR_MAP, unicode ); if ( charIndex == 0 ) continue; @@ -911,8 +916,8 @@ EC( ECCheckBounds( (void*)fontHeader ) ); * in the face, the first GEOS character in the font is * the default character. * - * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. - * firstChar First GEOS char in face. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * firstChar First GEOS char in face. * * RETURNS: char * @@ -925,6 +930,7 @@ EC( ECCheckBounds( (void*)fontHeader ) ); * ---- ---- ----------- * 23/04/23 JK Initial Revision *******************************************************************/ + static char GetDefaultChar( TRUETYPE_VARS, char firstChar ) { if ( !TT_Char_Index( CHAR_MAP, GeosCharToUnicode( DEFAULT_DEFAULT_CHAR ) ) ) @@ -940,7 +946,7 @@ static char GetDefaultChar( TRUETYPE_VARS, char firstChar ) * SYNOPSIS: Returns the number of kernpairs with chars from * FreeGEOS char set. * - * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. + * PARAMETERS: TRUETYPE_VARS Pointer to truetypevar block. * * RETURNS: word * diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 563799d32..adb96eee2 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -278,11 +278,13 @@ EC( ECCheckBounds( (void*)charTableEntry ) ); for( i = 0; i < fontBuf->FB_kernCount; ++i ) { + /* If currentChar is right or left char in a kernpair set corresponding flags. */ if( currentChar == kernPair->KP_charRight ) charTableEntry->CTE_flags |= CTF_IS_FIRST_KERN; else if ( currentChar == kernPair->KP_charLeft ) charTableEntry->CTE_flags |= CTF_IS_SECOND_KERN; + /* If currentChar is right and left char in a kernpair, it can be aborted. */ if( charTableEntry->CTE_flags && CTF_IS_FIRST_KERN & charTableEntry->CTE_flags && CTF_IS_SECOND_KERN ) break; From 4da56d378722bd55e5cf7feffe429a38e52c3e94 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Sun, 20 Aug 2023 22:04:46 +0200 Subject: [PATCH 210/246] Reduce number of inter-resource calls by avoiding 32-bit division and performing MulDiv on entire vector at once. --- Driver/Font/TrueType/FreeType/ttcalc.c | 12 ++++++++++++ Driver/Font/TrueType/FreeType/ttcalc.h | 2 ++ Driver/Font/TrueType/FreeType/ttobjs.c | 8 ++++---- Driver/Font/TrueType/FreeType/ttraster.c | 12 ++++++------ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttcalc.c b/Driver/Font/TrueType/FreeType/ttcalc.c index 98b6acff9..70f3ac3e1 100644 --- a/Driver/Font/TrueType/FreeType/ttcalc.c +++ b/Driver/Font/TrueType/FreeType/ttcalc.c @@ -398,5 +398,17 @@ #endif /* LONG64 */ +/* This convenience function applies TT_MulDiv to a vector. */ +/* Its main purpose is to reduce the number of inter-module calls in GEOS. */ + +LOCAL_FUNC +void MulDivVector( TT_Long* a, ULong n, TT_Long b, TT_Long c ) +{ + ULong i; + + for ( i = 0; i < n; i++ ) + a[i] = TT_MulDiv( a[i], b, c ); +} + /* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcalc.h b/Driver/Font/TrueType/FreeType/ttcalc.h index 0aec33850..663991dd0 100644 --- a/Driver/Font/TrueType/FreeType/ttcalc.h +++ b/Driver/Font/TrueType/FreeType/ttcalc.h @@ -20,6 +20,7 @@ #include "ttconfig.h" #include "freetype.h" +#include "tttypes.h" #ifdef __cplusplus @@ -78,6 +79,7 @@ /* TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ); */ /* TT_Long TT_MulFix( TT_Long a, TT_Long b ); */ +LOCAL_DEF void MulDivVector( TT_Long* a, ULong n, TT_Long b, TT_Long c ); #define INT_TO_F26DOT6( x ) ( (Long)(x) << 6 ) #define INT_TO_F2DOT14( x ) ( (Long)(x) << 14 ) diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index a437bed9f..25a24b5e0 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -934,10 +934,10 @@ /* Scale the cvt values to the new ppem. */ /* We use by default the y ppem to scale the CVT. */ - for ( i = 0; i < ins->cvtSize; i++ ) - ins->cvt[i] = TT_MulDiv( face->cvt[i], - ins->metrics.scale1, - ins->metrics.scale2 ); + MulDivVector( ins->cvt, + ins->cvtSize, + ins->metrics.scale1, + ins->metrics.scale2 ); /* All twilight points are originally zero */ for ( j = 0; j < ins->twilight.n_points; j++ ) diff --git a/Driver/Font/TrueType/FreeType/ttraster.c b/Driver/Font/TrueType/FreeType/ttraster.c index e715f321b..9237684dc 100644 --- a/Driver/Font/TrueType/FreeType/ttraster.c +++ b/Driver/Font/TrueType/FreeType/ttraster.c @@ -592,15 +592,15 @@ base[4].x = base[2].x; b = base[1].x; - a = base[3].x = ( base[2].x + b ) / 2; - b = base[1].x = ( base[0].x + b ) / 2; - base[2].x = ( a + b ) / 2; + a = base[3].x = ( base[2].x + b ) >> 1; + b = base[1].x = ( base[0].x + b ) >> 1; + base[2].x = ( a + b ) >> 1; base[4].y = base[2].y; b = base[1].y; - a = base[3].y = ( base[2].y + b ) / 2; - b = base[1].y = ( base[0].y + b ) / 2; - base[2].y = ( a + b ) / 2; + a = base[3].y = ( base[2].y + b ) >> 1; + b = base[1].y = ( base[0].y + b ) >> 1; + base[2].y = ( a + b ) >> 1; /* hand optimized. gcc doesn't seem too good at common expression */ /* substitution and instruction scheduling ;-) */ From 1882601eb62f0131c7e00ac11e82691ae93bfece Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Mon, 21 Aug 2023 23:05:26 +0200 Subject: [PATCH 211/246] Inline versions of GET_Byte/Char/UShort/Short --- Driver/Font/TrueType/FreeType/ttload.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttload.h b/Driver/Font/TrueType/FreeType/ttload.h index 429799c35..0eb9034ff 100644 --- a/Driver/Font/TrueType/FreeType/ttload.h +++ b/Driver/Font/TrueType/FreeType/ttload.h @@ -123,10 +123,26 @@ #define FORGET_Frame() \ ( (void)TT_Forget_Frame( &frame ) ) -#define GET_Byte() TT_Get_Byte ( &frame ) -#define GET_Char() TT_Get_Char ( &frame ) -#define GET_UShort() TT_Get_UShort( &frame ) -#define GET_Short() TT_Get_Short ( &frame ) +#if defined(__GEOS__) && !DEBUG_FILE + + #define GET_Byte() (Byte) (*frame.cursor++) + #define GET_Char() (Char) (*frame.cursor++) + #define GET_UShort() (UShort)(frame.cursor += 2, \ + (frame.cursor[-2] << 8) | \ + frame.cursor[-1]) + #define GET_Short() (Short) (frame.cursor += 2, \ + (frame.cursor[-2] << 8) | \ + frame.cursor[-1]) + +#else + + #define GET_Byte() TT_Get_Byte ( &frame ) + #define GET_Char() TT_Get_Char ( &frame ) + #define GET_UShort() TT_Get_UShort( &frame ) + #define GET_Short() TT_Get_Short ( &frame ) + +#endif + #define GET_Long() TT_Get_Long ( &frame ) #define GET_ULong() TT_Get_ULong ( &frame ) #define GET_Tag4() TT_Get_ULong ( &frame ) From 1665bf234f10ebf05f72b3f5ab0e075bd9763140 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 24 Aug 2023 21:40:39 +0200 Subject: [PATCH 212/246] Avoid some integer arithmetic. --- Driver/Font/TrueType/Adapter/ttchars.c | 14 +++++++------- Driver/Font/TrueType/FreeType/freetype.h | 3 ++- Driver/Font/TrueType/FreeType/ttapi.c | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index f15c277c7..5ba950a1e 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -124,8 +124,8 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); GLYPH_BBOX.yMax = ( GLYPH_BBOX.yMax + 63 ) & -64; /* compute pixel dimensions */ - width = (GLYPH_BBOX.xMax - GLYPH_BBOX.xMin) / 64; - height = (GLYPH_BBOX.yMax - GLYPH_BBOX.yMin) / 64; + width = (GLYPH_BBOX.xMax - GLYPH_BBOX.xMin) >> 6; + height = (GLYPH_BBOX.yMax - GLYPH_BBOX.yMin) >> 6; if( fontBuf->FB_flags & FBF_IS_REGION ) { @@ -150,9 +150,9 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* fill header of charData */ ((RegionCharData*)charData)->RCD_xoff = transformMatrix->TM_scriptX + - transformMatrix->TM_heightX + GLYPH_BBOX.xMin / 64; + transformMatrix->TM_heightX + ( GLYPH_BBOX.xMin >> 6 ); ((RegionCharData*)charData)->RCD_yoff = transformMatrix->TM_scriptY + - transformMatrix->TM_heightY - GLYPH_BBOX.yMax / 64; + transformMatrix->TM_heightY - ( GLYPH_BBOX.yMax >> 6 ); ((RegionCharData*)charData)->RCD_size = RASTER_MAP.size; ((RegionCharData*)charData)->RCD_bounds.R_left = 0; ((RegionCharData*)charData)->RCD_bounds.R_right = width; @@ -183,9 +183,9 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); ((CharData*)charData)->CD_pictureWidth = width; ((CharData*)charData)->CD_numRows = height; ((CharData*)charData)->CD_xoff = transformMatrix->TM_scriptX + - transformMatrix->TM_heightX + GLYPH_BBOX.xMin / 64; + transformMatrix->TM_heightX + ( GLYPH_BBOX.xMin >> 6 ); ((CharData*)charData)->CD_yoff = transformMatrix->TM_scriptY + - transformMatrix->TM_heightY - GLYPH_BBOX.yMax / 64; + transformMatrix->TM_heightY - ( GLYPH_BBOX.yMax >> 6 ); } TT_Done_Glyph( GLYPH ); @@ -358,7 +358,7 @@ static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ) void* bitmapData = MemLock( bitmapHandle ); if( bitmapData == NULL ) { - MemReAlloc( bitmapHandle, MAX( size, 2048 ), HAF_NO_ERR ); + MemReAlloc( bitmapHandle, MAX( size, BITMAP_BLOCKSIZE ), HAF_NO_ERR ); bitmapData = MemLock( bitmapHandle ); } else { if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index c7b64aef9..a86b4be7a 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -760,12 +760,13 @@ #define TT_Set_Instance_PointSize( ins, ptsize ) \ TT_Set_Instance_CharSize( ins, ptsize*64L ) +/* EXPORT_DEF TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, TT_UShort pixelWidth, TT_UShort pixelHeight, TT_F26Dot6 pointSize ); - +*/ /* This function has been deprecated! Do not use it, as it */ /* doesn't work reliably. You can perfectly control hinting */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index a95feb29e..a3dc78811 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -608,8 +608,8 @@ extern TEngine_Instance engineInstance; ins->metrics.y_scale1 = (ins->metrics.y_scale1+32) & -64; } - ins->metrics.x_ppem = ins->metrics.x_scale1 / 64; - ins->metrics.y_ppem = ins->metrics.y_scale1 / 64; + ins->metrics.x_ppem = ins->metrics.x_scale1 >> 6; + ins->metrics.y_ppem = ins->metrics.y_scale1 >> 6; if ( charWidth > charHeight ) ins->metrics.pointSize = charWidth; @@ -670,7 +670,7 @@ extern TEngine_Instance engineInstance; * instances, so there is no need to protect. * ******************************************************************/ - + /* EXPORT_FUNC TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, TT_UShort pixelWidth, @@ -698,7 +698,7 @@ extern TEngine_Instance engineInstance; return Instance_Reset( ins ); } - +*/ /******************************************************************* * From ba7b5568507dee00945b8e1966d2a3a6f8d1f2a0 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 25 Aug 2023 19:37:10 +0200 Subject: [PATCH 213/246] Better solution for calculation superscript and subscript position. --- Driver/Font/TrueType/Adapter/ttwidths.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index adb96eee2..ee9f35e07 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -52,6 +52,7 @@ static void CalcScaleForWidths( TRUETYPE_VARS, static void CalcTransform( TRUETYPE_VARS, TransformMatrix* transMatrix, FontMatrix* fontMatrix, + WWFixedAsDWord pointSize, TextStyle stylesToImplement, FontBuf* fontBuf ); @@ -75,7 +76,7 @@ static Boolean IsRegionNeeded( TransformMatrix* transMatrix, #define OFFSET_KERN_VALUES ( sizeof(FontBuf) + \ fontHeader->FH_numChars * sizeof( CharTableEntry) + \ - sizeof( TransformMatrix ) + \ + sizeof( TransformMatrix ) + \ fontHeader->FH_kernCount * sizeof( KernPair ) ) @@ -182,7 +183,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* calculate the transformation matrix and copy it into the FontBlock */ transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); - CalcTransform( trueTypeVars, transMatrix, fontMatrix, stylesToImplement, fontBuf ); + CalcTransform( trueTypeVars, transMatrix, fontMatrix, pointSize, stylesToImplement, fontBuf ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos AdjustFontBuf( transMatrix, fontMatrix, stylesToImplement, fontBuf ); @@ -431,6 +432,7 @@ static void CalcScaleForWidths( TRUETYPE_VARS, WWFixedAsDWord pointSize, static void CalcTransform( TRUETYPE_VARS, TransformMatrix* transMatrix, FontMatrix* fontMatrix, + WWFixedAsDWord pointSize, TextStyle stylesToImplement, FontBuf* fontBuf ) { @@ -467,15 +469,13 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); if( stylesToImplement & TS_SUBSCRIPT ) { - transMatrix->TM_scriptY = GrMulWWFixed( SUBSCRIPT_OFFSET, - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) >> 16; + transMatrix->TM_scriptY = GrMulWWFixed( + SUBSCRIPT_OFFSET, pointSize ) >> 16; } else { - transMatrix->TM_scriptY = GrMulWWFixed( SUPERSCRIPT_OFFSET, - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_height ) + - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_heightAdjust ) ) - + transMatrix->TM_scriptY = GrMulWWFixed( + SUPERSCRIPT_OFFSET, pointSize ) - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos ) - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ) >> 16; } From dac83dda223a8c8ddf17012a19ba8c6b94146d45 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Tue, 29 Aug 2023 21:37:42 +0200 Subject: [PATCH 214/246] Optimize calls in vector transformations with matrix --- Driver/Font/TrueType/FreeType/ttapi.c | 19 +------------ Driver/Font/TrueType/FreeType/ttcalc.c | 26 ++++++++++++++++-- Driver/Font/TrueType/FreeType/ttcalc.h | 3 ++- Driver/Font/TrueType/FreeType/ttgload.c | 36 +++++++------------------ Driver/Font/TrueType/FreeType/ttobjs.c | 8 +++--- 5 files changed, 40 insertions(+), 52 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index a3dc78811..47b3eae7b 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -1460,24 +1460,7 @@ TT_Error TT_Get_Outline_Region( TT_Outline* outline, void TT_Transform_Outline( TT_Outline* outline, TT_Matrix* matrix ) { - UShort n; - TT_F26Dot6 x, y; - TT_Vector* vec; - - - vec = outline->points; - for ( n = 0; n < outline->n_points; n++ ) - { - x = TT_MulFix( vec->x, matrix->xx ) + - TT_MulFix( vec->y, matrix->xy ); - - y = TT_MulFix( vec->x, matrix->yx ) + - TT_MulFix( vec->y, matrix->yy ); - - vec->x = x; - vec->y = y; - vec++; - } + TransVecList( outline->points, outline->n_points, matrix ); } diff --git a/Driver/Font/TrueType/FreeType/ttcalc.c b/Driver/Font/TrueType/FreeType/ttcalc.c index 70f3ac3e1..ac556446f 100644 --- a/Driver/Font/TrueType/FreeType/ttcalc.c +++ b/Driver/Font/TrueType/FreeType/ttcalc.c @@ -398,11 +398,11 @@ #endif /* LONG64 */ -/* This convenience function applies TT_MulDiv to a vector. */ +/* This convenience function applies TT_MulDiv to a list. */ /* Its main purpose is to reduce the number of inter-module calls in GEOS. */ LOCAL_FUNC -void MulDivVector( TT_Long* a, ULong n, TT_Long b, TT_Long c ) +void MulDivList( TT_Long* a, ULong n, TT_Long b, TT_Long c ) { ULong i; @@ -410,5 +410,27 @@ void MulDivVector( TT_Long* a, ULong n, TT_Long b, TT_Long c ) a[i] = TT_MulDiv( a[i], b, c ); } +/* This convenience function applies a matrix to a list of vectors. */ +/* Its main purpose is to reduce the number of inter-module calls in GEOS. */ + +LOCAL_FUNC +void TransVecList( TT_Vector* vec, ULong n, TT_Matrix* matrix ) +{ + ULong i; + TT_F26Dot6 x, y; + + for ( i = 0; i < n; i++ ) + { + x = TT_MulFix( vec->x, matrix->xx ) + + TT_MulFix( vec->y, matrix->xy ); + + y = TT_MulFix( vec->x, matrix->yx ) + + TT_MulFix( vec->y, matrix->yy ); + + vec->x = x; + vec->y = y; + vec++; + } +} /* END */ diff --git a/Driver/Font/TrueType/FreeType/ttcalc.h b/Driver/Font/TrueType/FreeType/ttcalc.h index 663991dd0..33266e2af 100644 --- a/Driver/Font/TrueType/FreeType/ttcalc.h +++ b/Driver/Font/TrueType/FreeType/ttcalc.h @@ -79,7 +79,8 @@ /* TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ); */ /* TT_Long TT_MulFix( TT_Long a, TT_Long b ); */ -LOCAL_DEF void MulDivVector( TT_Long* a, ULong n, TT_Long b, TT_Long c ); +LOCAL_DEF void MulDivList( TT_Long* a, ULong n, TT_Long b, TT_Long c ); +LOCAL_DEF void TransVecList( TT_Vector* vec, ULong n, TT_Matrix* matrix ); #define INT_TO_F26DOT6( x ) ( (Long)(x) << 6 ) #define INT_TO_F2DOT14( x ) ( (Long)(x) << 14 ) diff --git a/Driver/Font/TrueType/FreeType/ttgload.c b/Driver/Font/TrueType/FreeType/ttgload.c index 1e3fda50a..d97316f06 100644 --- a/Driver/Font/TrueType/FreeType/ttgload.c +++ b/Driver/Font/TrueType/FreeType/ttgload.c @@ -573,7 +573,7 @@ Long glyph_offset, offset; - TT_F26Dot6 x, y, nx, ny; + TT_F26Dot6 x, y; Fixed xx, xy, yx, yy; @@ -984,32 +984,14 @@ if ( subglyph2->is_scaled ) { - TT_Vector* cur = subglyph2->zone.cur; - TT_Vector* org = subglyph2->zone.org; - - for ( u = 0; u < num_points; u++ ) - { - nx = TT_MulFix( cur->x, subglyph->transform.xx ) + - TT_MulFix( cur->y, subglyph->transform.yx ); - - ny = TT_MulFix( cur->x, subglyph->transform.xy ) + - TT_MulFix( cur->y, subglyph->transform.yy ); - - cur->x = nx; - cur->y = ny; - - nx = TT_MulFix( org->x, subglyph->transform.xx ) + - TT_MulFix( org->y, subglyph->transform.yx ); - - ny = TT_MulFix( org->x, subglyph->transform.xy ) + - TT_MulFix( org->y, subglyph->transform.yy ); - - org->x = nx; - org->y = ny; - - cur++; - org++; - } + TT_Matrix matrix; + matrix.xx = subglyph->transform.xx; + matrix.xy = subglyph->transform.xy; + matrix.yx = subglyph->transform.yx; + matrix.yy = subglyph->transform.yy; + + TransVecList( subglyph2->zone.cur, num_points, &matrix ); + TransVecList( subglyph2->zone.org, num_points, &matrix ); } /* adjust counts */ diff --git a/Driver/Font/TrueType/FreeType/ttobjs.c b/Driver/Font/TrueType/FreeType/ttobjs.c index 25a24b5e0..cb7e2c61a 100644 --- a/Driver/Font/TrueType/FreeType/ttobjs.c +++ b/Driver/Font/TrueType/FreeType/ttobjs.c @@ -934,10 +934,10 @@ /* Scale the cvt values to the new ppem. */ /* We use by default the y ppem to scale the CVT. */ - MulDivVector( ins->cvt, - ins->cvtSize, - ins->metrics.scale1, - ins->metrics.scale2 ); + MulDivList( ins->cvt, + ins->cvtSize, + ins->metrics.scale1, + ins->metrics.scale2 ); /* All twilight points are originally zero */ for ( j = 0; j < ins->twilight.n_points; j++ ) From 89e322246aefd015f384b46d6bb8e6675e684336 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 2 Sep 2023 21:41:24 +0200 Subject: [PATCH 215/246] Rendering problems in FontMagick and Banner partially fixed. --- Driver/Font/TrueType/Adapter/ttmetrics.c | 42 +++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index c668ef315..553f3b506 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -28,6 +28,10 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, TransformMatrix* transMatrix ); +static void CalcScaleForWidths( TRUETYPE_VARS, + WWFixedAsDWord pointSize, + TextStyle stylesToImplement ); + /******************************************************************** * TrueType_Char_Metrics ******************************************************************** @@ -35,11 +39,14 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, * * PARAMETERS: character Character to get metrics of. * info Info to return (GCM_info). - * *fontInfo - * *outlineData - * stylesToImplement + * *fontInfo Ptr. to font info structure. + * *outlineEntry Ptr. to outline entry containing + * TrueTypeOutlineEntry. + * stylesToImplement Desired text style. + * pointSize Desired point size. * result Pointer in wich the result will * stored. + * varBlock Memory handle to var block. * * RETURNS: void * @@ -51,7 +58,6 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, * Date Name Description * ---- ---- ----------- * 23/12/22 JK Initial Revision - * *******************************************************************/ void _pascal TrueType_Char_Metrics( word character, @@ -84,6 +90,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; + CalcScaleForWidths( trueTypeVars, pointSize, stylesToImplement ); CalcTransformMatrix( stylesToImplement, &transMatrix ); // get TT char index @@ -97,30 +104,27 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); TT_Transform_Outline( &OUTLINE, &transMatrix.TM_matrix ); TT_Translate_Outline( &OUTLINE, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_scriptY ) ); - // scale glyph - TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); - TT_Get_Instance_Metrics( INSTANCE, &INSTANCE_METRICS ); - // get metrics + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); switch( info ) { case GCMI_MIN_X: case GCMI_MIN_X_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.xMin, INSTANCE_METRICS.x_scale ); + *result = SCALE_WORD( GLYPH_BBOX.xMin, trueTypeVars->scaleWidth ); break; case GCMI_MIN_Y: case GCMI_MIN_Y_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.yMin, INSTANCE_METRICS.y_scale ); + *result = SCALE_WORD( GLYPH_BBOX.yMin, trueTypeVars->scaleHeight ); break; case GCMI_MAX_X: case GCMI_MAX_X_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.xMax, INSTANCE_METRICS.x_scale ); + *result = SCALE_WORD( GLYPH_BBOX.xMax, trueTypeVars->scaleWidth ); break; case GCMI_MAX_Y: case GCMI_MAX_Y_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.yMax, INSTANCE_METRICS.y_scale ); + *result = SCALE_WORD( GLYPH_BBOX.yMax, trueTypeVars->scaleHeight ); break; } @@ -132,6 +136,20 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); } +static void CalcScaleForWidths( TRUETYPE_VARS, WWFixedAsDWord pointSize, + TextStyle stylesToImplement ) +{ + SCALE_HEIGHT = GrUDivWWFixed( pointSize, MakeWWFixed( FACE_PROPERTIES.header->Units_Per_EM ) ); + SCALE_WIDTH = SCALE_HEIGHT; + + if( stylesToImplement & ( TS_BOLD ) ) + SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_1_POINR_1 ); + + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) + SCALE_WIDTH = GrMulWWFixed( SCALE_WIDTH, WWFIXED_0_POINT_5 ); +} + + static void CalcTransformMatrix( TextStyle stylesToImplement, TransformMatrix* transMatrix ) { From fab69fb78724e7ad3241364bd247365f0857f428 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Sun, 3 Sep 2023 17:48:21 +0200 Subject: [PATCH 216/246] Generate name for block scopes with empty names (fixes issue #225) --- Tools/glue/codeview32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/glue/codeview32.c b/Tools/glue/codeview32.c index 38a932c4d..297b8de55 100644 --- a/Tools/glue/codeview32.c +++ b/Tools/glue/codeview32.c @@ -2968,7 +2968,7 @@ CV32ProcessSymbols(const char *file) /* Object file name (for errors) */ &lastLocal, &symBase); os->flags = 0; MSObj_GetWord(blockSeg, bp); - if (bp < base + len) { + if (bp < base + len && *bp != 0) { os->name = ST_Enter(symbols, strings, (char *)bp + 1, *bp); } else { From bdf0e76b51cb2fa1b51cf4a80b63b030f900532e Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 6 Sep 2023 20:16:46 +0200 Subject: [PATCH 217/246] Building FontID of mapped font fixed. --- Driver/Font/TrueType/Adapter/ttinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 985298fe7..2c3de9083 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -645,7 +645,7 @@ static FontID getFontID( const char* familyName ) FontID fontID; if( !InitFileReadInteger( FONTMAPPING_CATEGORY, familyName, &fontID ) ) - return FM_TRUETYPE || (fontID && 0x0fff); + return FM_TRUETYPE | (fontID & 0x0fff); return MAKE_FONTID( familyName ); } From 354eb988102c0ebab03b0898decc252ff4f523c4 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 9 Sep 2023 18:47:05 +0200 Subject: [PATCH 218/246] Medium is a synonym for Regular in some fonts. --- Driver/Font/TrueType/Adapter/ttinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 2c3de9083..950c790c5 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -603,7 +603,7 @@ static AdjustedWeight mapFontWeight( TT_Short weightClass ) static TextStyle mapTextStyle( const char* subfamily ) { - if ( strcmp( subfamily, "Regular" ) == 0 ) + if ( strcmp( subfamily, "Regular" ) == 0 || strcmp( subfamily, "Medium" ) == 0 ) return 0x00; if ( strcmp( subfamily, "Bold" ) == 0 ) return TS_BOLD; From 91e370dada07eb8bee348691c2ae5d36209735db Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 9 Sep 2023 20:10:35 +0200 Subject: [PATCH 219/246] Filling of FI_family in FontInfo struct corrected. --- Driver/Font/TrueType/Adapter/ttinit.c | 88 +++++---------------------- 1 file changed, 14 insertions(+), 74 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index 950c790c5..db52c5c28 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -40,9 +40,8 @@ static sword getFontIDAvailIndex( FontID fontID, MemHandle fontInfoBlock ); -static FontID getFontID( const char* familiyName ); - -static FontAttrs mapFamilyClass( TT_Short familyClass ); +static Boolean getFontID( const char* familiyName, + FontID* fontID ); static FontWeight mapFontWeight( TT_Short weightClass ); @@ -270,6 +269,7 @@ static void ProcessFont( TRUETYPE_VARS, const char* fileName, MemHandle fontInfo FontInfo* fontInfo; TrueTypeOutlineEntry* trueTypeOutlineEntry; FontID fontID; + Boolean mappedFont; sword availIndex; @@ -295,7 +295,8 @@ EC( ECCheckFileHandle( truetypeFile ) ); if ( getNameFromNameTable( trueTypeVars, STYLE_NAME, STYLE_NAME_ID ) == 0 ) goto Fail; - fontID = getFontID( FAMILY_NAME ); + //fontID = getFontID( FAMILY_NAME ); + mappedFont = getFontID( FAMILY_NAME, &fontID ); availIndex = getFontIDAvailIndex( fontID, fontInfoBlock ); /* if we have an new font FontAvailEntry, FontInfo and Outline must be created */ @@ -328,7 +329,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); strcpy( fontInfo->FI_faceName, FAMILY_NAME ); fontInfo->FI_fileHandle = NullHandle; fontInfo->FI_fontID = fontID; - fontInfo->FI_family = mapFamilyClass( FACE_PROPERTIES.os2->sFamilyClass ); + fontInfo->FI_family = FA_USEFUL | FA_OUTLINE | ( mappedFont ? FA_FAMILY : 0 ); // family;//mapFamilyClass( FACE_PROPERTIES.os2->sFamilyClass ); fontInfo->FI_maker = FM_TRUETYPE; fontInfo->FI_pointSizeTab = 0; fontInfo->FI_pointSizeEnd = 0; @@ -473,69 +474,6 @@ static word toHash( const char* str ) } -/******************************************************************** - * mapFamiliClass - ******************************************************************** - * SYNOPSIS: Maps the TrueType family class to FreeGEOS FontAttrs. - * - * PARAMETERS: familyClass TrueType family class. - * - * RETURNS: FontAttrs FreeGEOS FontAttrs. - * - * SIDE EFFECTS: none - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 21/01/23 JK Initial Revision - *******************************************************************/ - -static FontAttrs mapFamilyClass( TT_Short familyClass ) -{ - byte class = familyClass >> 8; - byte subclass = (byte) familyClass & 0x00ff; - FontFamily family; - - switch ( class ) - { - case 1: //old style serifs - case 2: //transitional serifs - case 3: //modern serifs - family = FF_SERIF; - break; - case 4: //clarendon serifs - family = subclass == 6 ? FF_MONO : FF_SERIF; - break; - case 5: //slab serifs - family = subclass == 1 ? FF_MONO : FF_SERIF; - break; - //6 = reserved - case 7: //freeform serfis - family = FF_SERIF; - break; - case 8: //sans serif - family = FF_SANS_SERIF; - break; - case 9: //ornamentals - family = FF_ORNAMENT; - break; - case 10: //scripts - family = FF_SCRIPT; - break; - //11 = reserved - case 12: //symbolic - family = FF_SYMBOL; - break; - default: - family = FF_NON_PORTABLE; - } - - return FA_USEFUL | FA_OUTLINE | family; -} - - /******************************************************************** * mapFontWeight ******************************************************************** @@ -640,14 +578,16 @@ static TextStyle mapTextStyle( const char* subfamily ) * 21/01/23 JK Initial Revision *******************************************************************/ -static FontID getFontID( const char* familyName ) +static Boolean getFontID( const char* familyName, FontID* fontID ) { - FontID fontID; - - if( !InitFileReadInteger( FONTMAPPING_CATEGORY, familyName, &fontID ) ) - return FM_TRUETYPE | (fontID & 0x0fff); + if( !InitFileReadInteger( FONTMAPPING_CATEGORY, familyName, fontID ) ) + { + *fontID = ( FM_TRUETYPE | (*fontID & 0x0fff) ); + return TRUE; + } - return MAKE_FONTID( familyName ); + *fontID = MAKE_FONTID( familyName ); + return FALSE; } From faca5812b694ada8eaeebd28f7ca099c114c835a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 14 Sep 2023 20:55:31 +0200 Subject: [PATCH 220/246] Better solution for rotation implemented. --- Driver/Font/TrueType/Adapter/ttinit.c | 3 +-- Driver/Font/TrueType/Adapter/ttwidths.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttinit.c b/Driver/Font/TrueType/Adapter/ttinit.c index db52c5c28..7e6970b85 100644 --- a/Driver/Font/TrueType/Adapter/ttinit.c +++ b/Driver/Font/TrueType/Adapter/ttinit.c @@ -295,7 +295,6 @@ EC( ECCheckFileHandle( truetypeFile ) ); if ( getNameFromNameTable( trueTypeVars, STYLE_NAME, STYLE_NAME_ID ) == 0 ) goto Fail; - //fontID = getFontID( FAMILY_NAME ); mappedFont = getFontID( FAMILY_NAME, &fontID ); availIndex = getFontIDAvailIndex( fontID, fontInfoBlock ); @@ -329,7 +328,7 @@ EC( ECCheckFileHandle( truetypeFile ) ); strcpy( fontInfo->FI_faceName, FAMILY_NAME ); fontInfo->FI_fileHandle = NullHandle; fontInfo->FI_fontID = fontID; - fontInfo->FI_family = FA_USEFUL | FA_OUTLINE | ( mappedFont ? FA_FAMILY : 0 ); // family;//mapFamilyClass( FACE_PROPERTIES.os2->sFamilyClass ); + fontInfo->FI_family = FA_USEFUL | FA_OUTLINE | ( mappedFont ? FA_FAMILY : 0 ); fontInfo->FI_maker = FM_TRUETYPE; fontInfo->FI_pointSizeTab = 0; fontInfo->FI_pointSizeEnd = 0; diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index ee9f35e07..4cd6c208f 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -679,8 +679,6 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ), fontMatrix->FM_22 ) ); fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_minTSB ), fontMatrix->FM_22 ) ); - fontBuf->FB_pixHeight += fontBuf->FB_minTSB; - if( fontMatrix->FM_flags & TF_ROTATED ) { @@ -688,21 +686,20 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, /* adjust FB_pixHeight, FB_minTSB */ fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( fontBuf->FB_pixHeight ), transMatrix->TM_matrix.yy ) ); + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_height.WBF_int ), transMatrix->TM_matrix.yy ) ); fontBuf->FB_minTSB = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( fontBuf->FB_minTSB ), transMatrix->TM_matrix.yy ) ); - fontBuf->FB_pixHeight += fontBuf->FB_minTSB; + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_minTSB ), transMatrix->TM_matrix.xy ) ); /* adjust script and height */ transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( transMatrix->TM_heightY ), transMatrix->TM_matrix.yy ) ); + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yy ) ); transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( transMatrix->TM_scriptY ), transMatrix->TM_matrix.yy ) ); + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yy ) ); - transMatrix->TM_heightX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yx ) ); + transMatrix->TM_heightX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.xy ) ); transMatrix->TM_scriptX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yx ) ); + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) ); } fontMatrix->FM_12 = -fontMatrix->FM_12; From 564d8be263fd291d83fe186a736578fb972f4a8e Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 17 Sep 2023 18:49:38 +0200 Subject: [PATCH 221/246] Some fixes in TrueType_Char_Metrics. --- Driver/Font/TrueType/Adapter/ttmetrics.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 553f3b506..9941891be 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -98,6 +98,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); // load glyph TT_New_Glyph( FACE, &GLYPH ); + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); // transform glyphs outline TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); @@ -105,26 +106,25 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); TT_Translate_Outline( &OUTLINE, 0, WWFIXEDASDWORD_TO_FIXED26DOT6( transMatrix.TM_scriptY ) ); // get metrics - TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); switch( info ) { case GCMI_MIN_X: case GCMI_MIN_X_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.xMin, trueTypeVars->scaleWidth ); + *result = SCALE_WORD( GLYPH_BBOX.xMin, SCALE_WIDTH ); break; case GCMI_MIN_Y: case GCMI_MIN_Y_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.yMin, trueTypeVars->scaleHeight ); + *result = SCALE_WORD( GLYPH_BBOX.yMin, SCALE_HEIGHT ); break; case GCMI_MAX_X: case GCMI_MAX_X_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.xMax, trueTypeVars->scaleWidth ); + *result = SCALE_WORD( GLYPH_BBOX.xMax, SCALE_WIDTH ); break; case GCMI_MAX_Y: case GCMI_MAX_Y_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.yMax, trueTypeVars->scaleHeight ); + *result = SCALE_WORD( GLYPH_BBOX.yMax, SCALE_HEIGHT ); break; } @@ -169,7 +169,7 @@ static void CalcTransformMatrix( TextStyle stylesToImplement, transMatrix->TM_matrix.yx = ITALIC_FACTOR; /* fake script style */ - if( stylesToImplement & TS_SUBSCRIPT || stylesToImplement & TS_SUBSCRIPT ) + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUBSCRIPT ) ) { transMatrix->TM_matrix.xx = GrMulWWFixed( transMatrix->TM_matrix.xx, SCRIPT_FACTOR ); transMatrix->TM_matrix.yy = GrMulWWFixed( transMatrix->TM_matrix.yy, SCRIPT_FACTOR ); From 591af5de02b11eaf271508580f574bea4cfb8283 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 21 Sep 2023 20:04:42 +0200 Subject: [PATCH 222/246] Rendering of glyphs in FontMagick and Banner fixed. --- Driver/Font/TrueType/Adapter/ttmetrics.c | 55 +++++++++++++++++++++--- Driver/Font/TrueType/Adapter/ttwidths.c | 11 ++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttmetrics.c b/Driver/Font/TrueType/Adapter/ttmetrics.c index 9941891be..8cd95edac 100644 --- a/Driver/Font/TrueType/Adapter/ttmetrics.c +++ b/Driver/Font/TrueType/Adapter/ttmetrics.c @@ -59,6 +59,7 @@ static void CalcScaleForWidths( TRUETYPE_VARS, * ---- ---- ----------- * 23/12/22 JK Initial Revision *******************************************************************/ + void _pascal TrueType_Char_Metrics( word character, GCM_info info, @@ -66,7 +67,7 @@ void _pascal TrueType_Char_Metrics( const OutlineEntry* outlineEntry, TextStyle stylesToImplement, WWFixedAsDWord pointSize, - dword* result, + WWFixedAsDWord* result, MemHandle varBlock ) { TrueTypeOutlineEntry* trueTypeOutline; @@ -112,19 +113,19 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); { case GCMI_MIN_X: case GCMI_MIN_X_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.xMin, SCALE_WIDTH ); + *result = GrMulWWFixed( MakeWWFixed( GLYPH_BBOX.xMin ), SCALE_WIDTH ); break; case GCMI_MIN_Y: case GCMI_MIN_Y_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.yMin, SCALE_HEIGHT ); + *result = GrMulWWFixed( MakeWWFixed( GLYPH_BBOX.yMin ), SCALE_HEIGHT ); break; case GCMI_MAX_X: case GCMI_MAX_X_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.xMax, SCALE_WIDTH ); + *result = GrMulWWFixed( MakeWWFixed( GLYPH_BBOX.xMax ), SCALE_WIDTH ); break; case GCMI_MAX_Y: case GCMI_MAX_Y_ROUNDED: - *result = SCALE_WORD( GLYPH_BBOX.yMax, SCALE_HEIGHT ); + *result = GrMulWWFixed( MakeWWFixed( GLYPH_BBOX.yMax ), SCALE_HEIGHT ); break; } @@ -136,8 +137,29 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); } -static void CalcScaleForWidths( TRUETYPE_VARS, WWFixedAsDWord pointSize, - TextStyle stylesToImplement ) +/******************************************************************** + * CalcScaleForWidths + ******************************************************************** + * SYNOPSIS: Fills scale factors in chached variables for calculating + * FontBuf and ChatTableEntries. + * + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. + * pointSize Desired point size. + * stylesToImplement Desired text style. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/07/23 JK Initial Revision + *******************************************************************/ + +static void CalcScaleForWidths( TRUETYPE_VARS, + WWFixedAsDWord pointSize, + TextStyle stylesToImplement ) { SCALE_HEIGHT = GrUDivWWFixed( pointSize, MakeWWFixed( FACE_PROPERTIES.header->Units_Per_EM ) ); SCALE_WIDTH = SCALE_HEIGHT; @@ -150,6 +172,25 @@ static void CalcScaleForWidths( TRUETYPE_VARS, WWFixedAsDWord pointSize, } +/******************************************************************** + * CalcTransformMatrix + ******************************************************************** + * SYNOPSIS: Calculates the transformation matrix for missing + * style attributes and weights. + * + * PARAMETERS: styleToImplement Styles that must be added. + * *transMatrix Pointer to TransformMatrix. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 20/12/22 JK Initial Revision + *******************************************************************/ + static void CalcTransformMatrix( TextStyle stylesToImplement, TransformMatrix* transMatrix ) { diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 4cd6c208f..4bc33c77e 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -682,7 +682,8 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, if( fontMatrix->FM_flags & TF_ROTATED ) { - sword savedHeightY = transMatrix->TM_heightY; + sword savedHeightY = transMatrix->TM_scriptY; + //sword savedHeightY = transMatrix->TM_heightY; /* adjust FB_pixHeight, FB_minTSB */ fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( @@ -693,13 +694,13 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, /* adjust script and height */ transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yy ) ); - transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yy ) ); + /*transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yy ) );*/ transMatrix->TM_heightX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.xy ) ); - transMatrix->TM_scriptX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) ); + /*transMatrix->TM_scriptX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) );*/ } fontMatrix->FM_12 = -fontMatrix->FM_12; From da2eedfce1f73f6b561c2d2f981951a9430cb282 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 21 Sep 2023 20:07:05 +0200 Subject: [PATCH 223/246] truetypeMetrics in last commit forgotten --- Driver/Font/TrueType/Main/truetypeMetrics.asm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index 08dbb9b71..cff8472fa 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -55,9 +55,9 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TrueTypeCharMetrics proc far - uses ax, bx, cx, si, di, ds + uses bx, cx, si, di, ds -resultAXDX local dword +resultDXAX local dword .enter @@ -84,26 +84,26 @@ resultAXDX local dword push ax push ss ; pass ptr to result dword in ss - lea cx, resultAXDX + lea cx, resultDXAX push cx segmov ds, dgroup, cx push ds:variableHandle call TRUETYPE_CHAR_METRICS - mov ax, {word} resultAXDX - mov dx, {word} resultAXDX+2 + mov ax, {word} resultDXAX + mov dx, {word} resultDXAX+2 test si, GCMI_ROUNDED jnz roundToInt - rndwwbf axdx + rndwwbf dxax done: clc .leave ret roundToInt: - rndwwf dxcx + rndwwf dxax jmp done TrueTypeCharMetrics endp From 58b77021be2100cd3f0636bf3e86c47f635004cd Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 23 Sep 2023 22:25:07 +0200 Subject: [PATCH 224/246] Small improvements on superscript ans supscipt with rotation. --- Driver/Font/TrueType/Adapter/ttwidths.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 4bc33c77e..c980f78fb 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -683,7 +683,6 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, if( fontMatrix->FM_flags & TF_ROTATED ) { sword savedHeightY = transMatrix->TM_scriptY; - //sword savedHeightY = transMatrix->TM_heightY; /* adjust FB_pixHeight, FB_minTSB */ fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( @@ -694,13 +693,13 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, /* adjust script and height */ transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yy ) ); - /*transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yy ) );*/ + transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yy ) ); transMatrix->TM_heightX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.xy ) ); - /*transMatrix->TM_scriptX = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) );*/ + transMatrix->TM_scriptX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) ); } fontMatrix->FM_12 = -fontMatrix->FM_12; From 548c22807ff6a72d3acaf6b132bbd8b93382e68a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 2 Oct 2023 22:35:46 +0200 Subject: [PATCH 225/246] Begin to implement TT_Gen_Path and TT_Gen_In_Region. --- Driver/Font/TrueType/Adapter/ttpath.c | 23 ++++++++- Driver/Font/TrueType/Adapter/ttpath.h | 55 +++++++++++++++++++++ Driver/Font/TrueType/Main/mainManager.asm | 12 +++-- Driver/Font/TrueType/Main/truetypePath.asm | 57 ++++++++++++++++++++-- 4 files changed, 137 insertions(+), 10 deletions(-) create mode 100644 Driver/Font/TrueType/Adapter/ttpath.h diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 81973ff50..6b460953f 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -41,9 +41,21 @@ * 20/12/22 JK Initial Revision *******************************************************************/ -void _pascal TrueType_Gen_Path( ) +void _pascal TrueType_Gen_Path( + GStateHandle gstate, + FontGenPathFlags pathFlags, + word character, + WWFixedAsDWord pointSize, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + MemHandle varBlock ) { +EC( ECCheckGStateHandle( gstate ) ); +EC( ECCheckBounds( (void*)fontInfo ) ); +EC( ECCheckBounds( (void*)outlineEntry ) ); +EC( ECCheckMemHandle( varBlock ) ); + } @@ -68,7 +80,14 @@ void _pascal TrueType_Gen_Path( ) * 20/12/22 JK Initial Revision *******************************************************************/ -void _pascal TrueType_Gen_In_Region( ) +void _pascal TrueType_Gen_In_Region( + GStateHandle gstate, + Handle regionPath, + word character, + WWFixedAsDWord pointSize, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + MemHandle varBlock ) { } diff --git a/Driver/Font/TrueType/Adapter/ttpath.h b/Driver/Font/TrueType/Adapter/ttpath.h new file mode 100644 index 000000000..b68aafdbc --- /dev/null +++ b/Driver/Font/TrueType/Adapter/ttpath.h @@ -0,0 +1,55 @@ +/*********************************************************************** + * + * Copyright FreeGEOS-Project + * + * PROJECT: FreeGEOS + * MODULE: TrueType font driver + * FILE: ttpath.h + * + * AUTHOR: Jirka Kunze: August 25 2023 + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 25/08/23 JK Initial version + * + * DESCRIPTION: + * Declarations of types and functions for the driver function + * DR_FONT_GEN_WIDTHS. + ***********************************************************************/ + +#ifndef _TTPATH_H_ +#define _TTPATH_H_ + +#include "../FreeType/freetype.h" +#include "ttadapter.h" + + +/*********************************************************************** + * structues + ***********************************************************************/ + + +/*********************************************************************** + * functions called by driver + ***********************************************************************/ + +void _pascal TrueType_Gen_Path( + GStateHandle gstate, + FontGenPathFlags pathFlags, + word character, + WWFixedAsDWord pointSize, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + MemHandle varBlock ); + +void _pascal TrueType_Gen_In_Region( + GStateHandle gstate, + Handle regionPath, + word character, + WWFixedAsDWord pointSize, + const FontInfo* fontInfo, + const OutlineEntry* outlineEntry, + MemHandle varBlock ); + +#endif /* _TTPAHT_H_ */ diff --git a/Driver/Font/TrueType/Main/mainManager.asm b/Driver/Font/TrueType/Main/mainManager.asm index fee63fe36..e68418bdc 100644 --- a/Driver/Font/TrueType/Main/mainManager.asm +++ b/Driver/Font/TrueType/Main/mainManager.asm @@ -108,10 +108,12 @@ CharMod ends ;routines from GEOS adapter global INIT_FREETYPE:far global EXIT_FREETYPE:far -global TRUETYPE_INITFONTS:far -global TRUETYPE_GEN_CHARS:far -global TRUETYPE_CHAR_METRICS:far -global TRUETYPE_GEN_WIDTHS:far +global TRUETYPE_INITFONTS:far +global TRUETYPE_GEN_CHARS:far +global TRUETYPE_CHAR_METRICS:far +global TRUETYPE_GEN_WIDTHS:far +global TRUETYPE_GEN_PATH:far +global TRUETYPE_GEN_IN_REGION:far global bitmapHandle:hptr global bitmapSize:word @@ -132,7 +134,7 @@ include ../FontCom/fontcomEscape.asm InitMod ends include truetypeEC.asm -include ansic_runtime.asm +include ansic_runtime.asm include ansic_memory.asm include ttmemory_asm.asm diff --git a/Driver/Font/TrueType/Main/truetypePath.asm b/Driver/Font/TrueType/Main/truetypePath.asm index 1b9950368..8669a40be 100644 --- a/Driver/Font/TrueType/Main/truetypePath.asm +++ b/Driver/Font/TrueType/Main/truetypePath.asm @@ -41,7 +41,7 @@ PASS: ds - seg addr of font info block Type 1 or Type 3 font. FGPF_SAVE_STATE - do save/restore for GState RETURN: none -DESTROYED: ax, bx, di (on the way here) +DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: @@ -53,9 +53,35 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TrueTypeGenPath proc far - uses cx, dx, si, ds, es + uses ax, bx, ds, es .enter + push di ;pass gstate handle + mov ch, 0 + push cx ;pass FontGenPathFlags + push dx ;pass characters code + clr al + mov es, di ;es <- seg addr of gstate + movwbf dxah, es:GS_fontAttr.FCA_pointsize + push dx ;pass point size + push ax + + mov cx, es:GS_fontAttr.FCA_fontID + call FontDrFindFontInfo + push ds ;pass ptr to FontInfo + push di + + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_HEADER + call FontDrFindOutlineData + push ds ;pass ptr to OutlineEntry + push di + + segmov ds, dgroup, ax + push ds:variableHandle ;pass handle to truetype block + call TRUETYPE_GEN_PATH + .leave ret TrueTypeGenPath endp @@ -97,9 +123,34 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TrueTypeGenInRegion proc far - uses cx, dx, si, ds, es + uses ax, bx, ds, es .enter + push di ;pass gstate handle + push cx ;pass regionpath handle + push dx ;pass character code + clr al + mov es, di ;es <- seg addr of gstate + movwbf dxah, es:GS_fontAttr.FCA_pointsize + push dx ;pass point size + push ax + + mov cx, es:GS_fontAttr.FCA_fontID + call FontDrFindFontInfo + push ds ;pass ptr to FontInfo + push di + + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_HEADER + call FontDrFindOutlineData + push ds ;pass ptr to OutlineEntry + push di + + segmov ds, dgroup, ax + push ds:variableHandle ;pass handle to truetype block + call TRUETYPE_GEN_IN_REGION + .leave ret TrueTypeGenInRegion endp From 5d3658d9f007c3adb0e0d68416ec77f1798cd157 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 4 Oct 2023 20:11:35 +0200 Subject: [PATCH 226/246] First step implement TrueType_Gen_Path. --- Driver/Font/TrueType/Adapter/ttpath.c | 60 +++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 6b460953f..4d2c38353 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -23,15 +23,21 @@ /******************************************************************** * TrueType_Gen_Path ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: - * - * RETURNS: + * SYNOPSIS: Draw outline of the given charcode to gstate. * - * SIDE EFFECTS: none + * PARAMETERS: gstate GStateHande in which the outline + * of the character is written. + * pathFlags FGPF_POSTSCRIPT - transform for + * use as Postscript Type 1 or Type 3 font. + * FGPF_SAVE_STATE - do save/restore for GState + * character Character to build (GEOS Char). + * pointSize Desired point size. + * *fontInfo Pointer to FontInfo structure. + * *outlineEntry Ptr. to outline entry containing + * TrueTypeOutlineEntry. + * varBlock Memory handle to var block. * - * CONDITION: + * RETURNS: void * * STRATEGY: * @@ -50,12 +56,52 @@ void _pascal TrueType_Gen_Path( const OutlineEntry* outlineEntry, MemHandle varBlock ) { + TrueTypeVars* trueTypeVars; + TrueTypeOutlineEntry* trueTypeOutline; + TT_UShort charIndex; + EC( ECCheckGStateHandle( gstate ) ); EC( ECCheckBounds( (void*)fontInfo ) ); EC( ECCheckBounds( (void*)outlineEntry ) ); EC( ECCheckMemHandle( varBlock ) ); + /* get trueTypeVar block */ + trueTypeVars = MemLock( varBlock ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); + + /* open face, create instance and glyph */ + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) + goto Fail; + + TT_New_Glyph( FACE, &GLYPH ); + + /* get TT char index */ + charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); + + /* set pointsize and get metrics */ + TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); + + /* load glyph and load glyphs outline */ + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, TTLOAD_DEFAULT ); + TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + + /* write prologue */ + if( pathFlags & FGPF_SAVE_STATE ) + GrSaveState( gstate ); + + + //TODO + + + /* write epilogue */ + if( pathFlags & FGPF_SAVE_STATE ) + GrRestoreState( gstate ); + + TT_Done_Glyph( GLYPH ); + +Fail: + MemUnlock( varBlock ); } From 48020da89fa039662e3bfdc2db12e63adad30a56 Mon Sep 17 00:00:00 2001 From: mgroeber9110 Date: Sun, 15 Oct 2023 17:26:39 +0200 Subject: [PATCH 227/246] Add missing ps2pdf.geo to target image (fixes #215) --- Tools/build/product/bbxensem/bbxensem.filetree | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/build/product/bbxensem/bbxensem.filetree b/Tools/build/product/bbxensem/bbxensem.filetree index 8e6a0939c..f0962ccb9 100644 --- a/Tools/build/product/bbxensem/bbxensem.filetree +++ b/Tools/build/product/bbxensem/bbxensem.filetree @@ -376,6 +376,7 @@ DIR (ensemble) { Library/Breadbox/CDAudio/cdaudio{ec}.geo Library/Breadbox/ThumbDB/thumbdb{ec}.geo Library/Breadbox/HtmlPars/htmlpars{ec}.geo + Library/Breadbox/ps2pdf/ps2pdf{ec}.geo Library/dil/bbxmail/bbxmlib{ec}.geo From 1638d9f68c48d45cde92b28595f760f64b01c0f6 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 15 Oct 2023 19:37:33 +0200 Subject: [PATCH 228/246] TRUETYPE_GEN_PATH partially implemented. --- Driver/Font/TrueType/Adapter/ttadapter.h | 2 + Driver/Font/TrueType/Adapter/ttchars.c | 2 +- Driver/Font/TrueType/Adapter/ttpath.c | 140 +++++++++++++++++- Driver/Font/TrueType/Adapter/ttpath.h | 1 - Driver/Font/TrueType/Adapter/ttwidths.c | 8 +- Driver/Font/TrueType/Main/truetypeChars.asm | 10 +- Driver/Font/TrueType/Main/truetypeMetrics.asm | 24 +-- Driver/Font/TrueType/Main/truetypePath.asm | 26 ++-- Driver/Font/TrueType/Main/truetypeWidths.asm | 12 +- 9 files changed, 179 insertions(+), 46 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 7e6a892d4..25e4f04b9 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -66,6 +66,8 @@ extern TEngine_Instance engineInstance; #define MAX_KERN_TABLE_LENGTH 6000 +#define STANDARD_GRIDSIZE 1000 + /*********************************************************************** * structures diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 5ba950a1e..c0b1ec52c 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -79,7 +79,7 @@ void _pascal TrueType_Gen_Chars( TrueTypeVars* trueTypeVars; TransformMatrix* transformMatrix; void* charData; - word width, height, size; + sword width, height, size; EC( ECCheckBounds( (void*)fontBuf ) ); diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 4d2c38353..80ab91845 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -18,6 +18,14 @@ ***********************************************************************/ #include "ttadapter.h" +#include "ttpath.h" +#include "ttcharmapper.h" +#include + + +static void CalcTransformMatrix( TransformMatrix* transMatrix ); + +static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ); /******************************************************************** @@ -51,14 +59,18 @@ void _pascal TrueType_Gen_Path( GStateHandle gstate, FontGenPathFlags pathFlags, word character, - WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, MemHandle varBlock ) { TrueTypeVars* trueTypeVars; TrueTypeOutlineEntry* trueTypeOutline; + TransformMatrix transMatrix; + TransMatrix mat; TT_UShort charIndex; + WWFixedAsDWord pointSize; + WWFixedAsDWord scalePointSize; + XYValueAsDWord cursorPos; EC( ECCheckGStateHandle( gstate ) ); @@ -70,6 +82,8 @@ EC( ECCheckMemHandle( varBlock ) ); trueTypeVars = MemLock( varBlock ); EC( ECCheckBounds( (void*)trueTypeVars ) ); + trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); + /* open face, create instance and glyph */ if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) goto Fail; @@ -79,20 +93,50 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* get TT char index */ charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); - /* set pointsize and get metrics */ - TT_Set_Instance_CharSize( INSTANCE, ( pointSize >> 10 ) ); - - /* load glyph and load glyphs outline */ - TT_Load_Glyph( INSTANCE, GLYPH, charIndex, TTLOAD_DEFAULT ); - TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + /* calc scaling factor */ + GrGetFont( gstate, &pointSize ); + scalePointSize = GrUDivWWFixed( pointSize, STANDARD_GRIDSIZE ); /* write prologue */ if( pathFlags & FGPF_SAVE_STATE ) GrSaveState( gstate ); + /* load glyph and scale its outline to 1000 units per em */ + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); + TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + ScaleOutline( trueTypeVars, GrUDivWWFixed( STANDARD_GRIDSIZE, UNITS_PER_EM ) ); - //TODO + /* write comment with glyph parameters */ + WriteComment( trueTypeVars, gstate ); + /* translate to current cursor position */ + cursorPos = GrGetCurPos( gstate ); + GrApplyTranslationDWord( gstate, DWORD_X( cursorPos ), DWORD_Y( cursorPos ) ); + + if( pathFlags & FGPF_POSTSCRIPT ) + { + //TODO: + //pointSize = GrGetFont() + //scalePointsize = pointSize / UnitsPerEM + + //accent = FontHeader.FH_accent * scaleGrid + //ascent = FontHeader.FH_ascent * scaleGrid + + //translation = (accent + ascent) + //Translate( gstate, 0, translation ) + //Scaliere( gstate, 1, -1 ); + } + + /* calc tranfomation matrix and apply it */ + CalcTransformMatrix( &transMatrix ); + TT_Transform_Outline( &OUTLINE, &transMatrix.TM_matrix ); + + //TODO: + //setze Pointsize + //scaliere Glyph + //iteriere über Outline + // iteriere über Konturen + // wandle Segmente in Gr... Kommandos /* write epilogue */ if( pathFlags & FGPF_SAVE_STATE ) @@ -137,3 +181,83 @@ void _pascal TrueType_Gen_In_Region( { } + +/******************************************************************** + * ScaleOutline + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 14/10/23 JK Initial Revision + *******************************************************************/ + +static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ) +{ + TT_Matrix matrix = { 0, 0, 0, 0}; + + matrix.xx = scale; + matrix.yy = scale; + + TT_Transform_Outline( 0, &matrix ); +} + + +static void CalcTransformMatrix( TransformMatrix* transMatrix ) +{ + transMatrix->TM_matrix.xx = 1L << 16; + transMatrix->TM_matrix.xy = 0; + transMatrix->TM_matrix.yx = 0; + transMatrix->TM_matrix.yy = 1L << 16; + + //TODO +} + + +/******************************************************************** + * WriteComment + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 14/10/23 JK Initial Revision + *******************************************************************/ + +#define NUM_PARAMS 6 +static void WriteComment( TRUETYPE_VARS, GStateHandle gstate ) +{ + word params[NUM_PARAMS]; + + + TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); + params[0] = GLYPH_BBOX.xMax - GLYPH_BBOX.xMin; //width + params[1] = 0; //GLYPH_BBOX.yMax - GLYPH_BBOX.yMin; //height + params[2] = GLYPH_BBOX.xMin; + params[3] = GLYPH_BBOX.yMin; + params[4] = GLYPH_BBOX.xMax; + params[5] = GLYPH_BBOX.yMax; + GrComment( gstate, ¶ms, NUM_PARAMS ); +} diff --git a/Driver/Font/TrueType/Adapter/ttpath.h b/Driver/Font/TrueType/Adapter/ttpath.h index b68aafdbc..517e55970 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.h +++ b/Driver/Font/TrueType/Adapter/ttpath.h @@ -38,7 +38,6 @@ void _pascal TrueType_Gen_Path( GStateHandle gstate, FontGenPathFlags pathFlags, word character, - WWFixedAsDWord pointSize, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, MemHandle varBlock ); diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index c980f78fb..e5d225129 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -693,13 +693,13 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, /* adjust script and height */ transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yy ) ); - transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yy ) ); + transMatrix->TM_scriptY = 0; /*INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yx ) );*/ transMatrix->TM_heightX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.xy ) ); - transMatrix->TM_scriptX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) ); + transMatrix->TM_scriptX = 0; /*-INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) );*/ } fontMatrix->FM_12 = -fontMatrix->FM_12; diff --git a/Driver/Font/TrueType/Main/truetypeChars.asm b/Driver/Font/TrueType/Main/truetypeChars.asm index 0c5485402..67dda19da 100644 --- a/Driver/Font/TrueType/Main/truetypeChars.asm +++ b/Driver/Font/TrueType/Main/truetypeChars.asm @@ -65,7 +65,7 @@ TrueTypeGenChar proc far mov ax, 0 ; with segment offset 0 push ax - mov es, bp ; es <- seg addr of gstate + mov es, bp ; es <- seg addr of gstate clr al movwbf dxah, es:GS_fontAttr.FCA_pointsize @@ -77,9 +77,9 @@ TrueTypeGenChar proc far push ds ; pass ptr to FontInfo push di - clr ah - mov al, es:GS_fontAttr.FCA_textStyle - mov bx, ODF_HEADER + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_HEADER call FontDrFindOutlineData push ds ; pass ptr to OutlineEntry push di @@ -90,7 +90,7 @@ TrueTypeGenChar proc far call TRUETYPE_GEN_CHARS ; deref font block (may have moved) - pop bx + pop bx call MemDerefES err: diff --git a/Driver/Font/TrueType/Main/truetypeMetrics.asm b/Driver/Font/TrueType/Main/truetypeMetrics.asm index cff8472fa..1c45936e2 100644 --- a/Driver/Font/TrueType/Main/truetypeMetrics.asm +++ b/Driver/Font/TrueType/Main/truetypeMetrics.asm @@ -61,41 +61,41 @@ resultDXAX local dword .enter - mov si, cx + mov si, cx push dx ; pass character code push cx ; pass GCM_info - mov cx, es:GS_fontAttr.FCA_fontID + mov cx, es:GS_fontAttr.FCA_fontID call FontDrFindFontInfo push ds ; pass ptr to FontInfo push di - clr ah - mov al, es:GS_fontAttr.FCA_textStyle - mov bx, ODF_HEADER + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_HEADER call FontDrFindOutlineData push ds ; pass ptr to OutlineEntry push di push ax ; pass stylesToImplement - clr al + clr al movwbf dxah, es:GS_fontAttr.FCA_pointsize push dx ; pass point size push ax push ss ; pass ptr to result dword in ss - lea cx, resultDXAX + lea cx, resultDXAX push cx segmov ds, dgroup, cx push ds:variableHandle call TRUETYPE_CHAR_METRICS - mov ax, {word} resultDXAX - mov dx, {word} resultDXAX+2 + mov ax, {word} resultDXAX + mov dx, {word} resultDXAX+2 test si, GCMI_ROUNDED - jnz roundToInt + jnz roundToInt rndwwbf dxax done: clc @@ -103,7 +103,7 @@ done: ret roundToInt: - rndwwf dxax - jmp done + rndwwf dxax + jmp done TrueTypeCharMetrics endp diff --git a/Driver/Font/TrueType/Main/truetypePath.asm b/Driver/Font/TrueType/Main/truetypePath.asm index 8669a40be..90065df3e 100644 --- a/Driver/Font/TrueType/Main/truetypePath.asm +++ b/Driver/Font/TrueType/Main/truetypePath.asm @@ -56,23 +56,28 @@ TrueTypeGenPath proc far uses ax, bx, ds, es .enter - push di ;pass gstate handle + xchg di, ax ;ax <- handle of GState + mov di, 400 + call ThreadBorrowStackSpace + push di + + push ax ;pass gstate handle mov ch, 0 push cx ;pass FontGenPathFlags push dx ;pass characters code - clr al - mov es, di ;es <- seg addr of gstate - movwbf dxah, es:GS_fontAttr.FCA_pointsize - push dx ;pass point size - push ax - + + mov bx, ax + call MemLock + mov es, ax ;es <- seg addr of gstate mov cx, es:GS_fontAttr.FCA_fontID + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + call MemUnlock + call FontDrFindFontInfo push ds ;pass ptr to FontInfo push di - clr ah - mov al, es:GS_fontAttr.FCA_textStyle mov bx, ODF_HEADER call FontDrFindOutlineData push ds ;pass ptr to OutlineEntry @@ -82,6 +87,9 @@ TrueTypeGenPath proc far push ds:variableHandle ;pass handle to truetype block call TRUETYPE_GEN_PATH + pop di + call ThreadReturnStackSpace + .leave ret TrueTypeGenPath endp diff --git a/Driver/Font/TrueType/Main/truetypeWidths.asm b/Driver/Font/TrueType/Main/truetypeWidths.asm index 01692b79e..539d4be5a 100644 --- a/Driver/Font/TrueType/Main/truetypeWidths.asm +++ b/Driver/Font/TrueType/Main/truetypeWidths.asm @@ -16,7 +16,7 @@ EXT TrueTypeGenWidths Generate font header and widths for a font. REVISION HISTORY: Name Date Description ---- ---- ----------- - FR 29/1/21 Initial revision + FR 29/1/21 Initial revision DESCRIPTION: Implements a font driver for: @@ -63,11 +63,11 @@ TrueTypeGenWidths proc far .enter xchg di, ax - mov di, 800 + mov di, 800 call ThreadBorrowStackSpace push di - push ax ; pass fonthandel + push ax ; pass seg addr to fontBuf push bx ; send tMatrix ptr push cx @@ -98,7 +98,7 @@ TrueTypeGenWidths proc far mov al, es:GS_fontAttr.FCA_textStyle mov bx, ODF_PART1 call FontDrFindOutlineData - push ds ; pass ptr to OutlineEntry + push ds ; pass ptr to FontHeader push di push ax ; pass stylesToImplement @@ -110,10 +110,10 @@ TrueTypeGenWidths proc far call MemDerefDS segmov ax, ds - pop di + pop di call ThreadReturnStackSpace - clc ;indicate no error + clc ;indicate no error .leave ret From e1c4bd4399e0853ce85f23dfd63aa7809c896e47 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 16 Oct 2023 22:08:24 +0200 Subject: [PATCH 229/246] One small step forward. --- Driver/Font/TrueType/Adapter/ttpath.c | 54 ++++++++++++++------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 80ab91845..6d60ceaeb 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -65,8 +65,7 @@ void _pascal TrueType_Gen_Path( { TrueTypeVars* trueTypeVars; TrueTypeOutlineEntry* trueTypeOutline; - TransformMatrix transMatrix; - TransMatrix mat; + TransMatrix transMatrix; TT_UShort charIndex; WWFixedAsDWord pointSize; WWFixedAsDWord scalePointSize; @@ -90,13 +89,9 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); TT_New_Glyph( FACE, &GLYPH ); - /* get TT char index */ + /* get TT char index */ charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); - /* calc scaling factor */ - GrGetFont( gstate, &pointSize ); - scalePointSize = GrUDivWWFixed( pointSize, STANDARD_GRIDSIZE ); - /* write prologue */ if( pathFlags & FGPF_SAVE_STATE ) GrSaveState( gstate ); @@ -104,7 +99,8 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* load glyph and scale its outline to 1000 units per em */ TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); - ScaleOutline( trueTypeVars, GrUDivWWFixed( STANDARD_GRIDSIZE, UNITS_PER_EM ) ); + ScaleOutline( trueTypeVars, GrUDivWWFixed( + (dword)STANDARD_GRIDSIZE << 16, (dword)UNITS_PER_EM << 16 ) ); /* write comment with glyph parameters */ WriteComment( trueTypeVars, gstate ); @@ -113,30 +109,36 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); cursorPos = GrGetCurPos( gstate ); GrApplyTranslationDWord( gstate, DWORD_X( cursorPos ), DWORD_Y( cursorPos ) ); + /* calc scaling factor and calculate transformation matrix */ + GrGetFont( gstate, &pointSize ); + GrGetTransform( gstate, &transMatrix ); + scalePointSize = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); + transMatrix.TM_e11.WWF_frac = scalePointSize & 0x0000ffff; + transMatrix.TM_e11.WWF_int = scalePointSize >> 16; + transMatrix.TM_e22.WWF_frac = scalePointSize & 0x0000ffff; + transMatrix.TM_e22.WWF_int = scalePointSize >> 16; + if( pathFlags & FGPF_POSTSCRIPT ) { - //TODO: - //pointSize = GrGetFont() - //scalePointsize = pointSize / UnitsPerEM - - //accent = FontHeader.FH_accent * scaleGrid - //ascent = FontHeader.FH_ascent * scaleGrid - - //translation = (accent + ascent) - //Translate( gstate, 0, translation ) - //Scaliere( gstate, 1, -1 ); + //TODO: translation = (FontHeader.FH_accent + FontHeader.FH_ascent) * scalePointSize + word translation = 600; //nur zum Test + GrApplyTranslationDWord( gstate, 0, translation ); + + /* flip on x-axis */ + GrApplyScale( gstate, 1L << 16, -1L << 16 ); } - /* calc tranfomation matrix and apply it */ - CalcTransformMatrix( &transMatrix ); - TT_Transform_Outline( &OUTLINE, &transMatrix.TM_matrix ); + GrApplyTransform( gstate, &transMatrix ); - //TODO: - //setze Pointsize - //scaliere Glyph - //iteriere über Outline - // iteriere über Konturen + //TODO: iteriere über Outline + // iteriere über Konturen // wandle Segmente in Gr... Kommandos + // Test mit Bindestrich + GrMoveTo( gstate, 198, 303 ); + GrDrawVLineTo( gstate, 269 ); + GrDrawHLineTo( gstate, 401 ); + GrDrawVLineTo( gstate, 303 ); + GrDrawHLineTo( gstate, 198 ); /* write epilogue */ if( pathFlags & FGPF_SAVE_STATE ) From 134cd17bbf9d01f5b12e1c1ad974589d38a16eb6 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 23 Oct 2023 21:46:22 +0200 Subject: [PATCH 230/246] FontHeader and stylesToImplement passes to TrueType_Gen_Path. --- Driver/Font/TrueType/Adapter/ttpath.c | 159 +++++++++++++++------ Driver/Font/TrueType/Adapter/ttpath.h | 2 + Driver/Font/TrueType/Main/truetypePath.asm | 22 ++- 3 files changed, 139 insertions(+), 44 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 6d60ceaeb..e52568ceb 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -23,10 +23,14 @@ #include -static void CalcTransformMatrix( TransformMatrix* transMatrix ); +static void CalcTransformMatrix( TransMatrix* transMatrix, + WWFixedAsDWord pointSize, + TextStyle stylesToImplement ); static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ); +static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ); + /******************************************************************** * TrueType_Gen_Path @@ -39,7 +43,6 @@ static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ); * use as Postscript Type 1 or Type 3 font. * FGPF_SAVE_STATE - do save/restore for GState * character Character to build (GEOS Char). - * pointSize Desired point size. * *fontInfo Pointer to FontInfo structure. * *outlineEntry Ptr. to outline entry containing * TrueTypeOutlineEntry. @@ -61,6 +64,8 @@ void _pascal TrueType_Gen_Path( word character, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, + const OutlineEntry* firstEntry, + TextStyle stylesToImplement, MemHandle varBlock ) { TrueTypeVars* trueTypeVars; @@ -75,6 +80,7 @@ void _pascal TrueType_Gen_Path( EC( ECCheckGStateHandle( gstate ) ); EC( ECCheckBounds( (void*)fontInfo ) ); EC( ECCheckBounds( (void*)outlineEntry ) ); +EC( ECCheckBounds( (void*)firstEntry ) ); EC( ECCheckMemHandle( varBlock ) ); /* get trueTypeVar block */ @@ -85,7 +91,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* open face, create instance and glyph */ if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) - goto Fail; + goto Fin; TT_New_Glyph( FACE, &GLYPH ); @@ -100,53 +106,71 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); ScaleOutline( trueTypeVars, GrUDivWWFixed( - (dword)STANDARD_GRIDSIZE << 16, (dword)UNITS_PER_EM << 16 ) ); + ((dword)STANDARD_GRIDSIZE) << 16, ((dword)UNITS_PER_EM) << 16 ) ); /* write comment with glyph parameters */ WriteComment( trueTypeVars, gstate ); - /* translate to current cursor position */ + /* Here's the sequence of operation we should need to perform */ + /* on an arbitrary point in the font outline */ + /* 1) Transform by font TransMatrix */ + /* 2) Flip on X-axis (scale by -1 in Y) */ + /* 3) Translate by font height */ + /* 4) Translate by current position */ + /* 5) Transform by current matrix */ + /* */ + /* Remember that since the order of matrix multiplication is */ + /* extremely important, we must perform these transformations */ + /* in reverse order. Step 5 is, of course, already in the GState. */ + + /* translate by current cursor position */ cursorPos = GrGetCurPos( gstate ); GrApplyTranslationDWord( gstate, DWORD_X( cursorPos ), DWORD_Y( cursorPos ) ); - /* calc scaling factor and calculate transformation matrix */ - GrGetFont( gstate, &pointSize ); - GrGetTransform( gstate, &transMatrix ); - scalePointSize = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); - transMatrix.TM_e11.WWF_frac = scalePointSize & 0x0000ffff; - transMatrix.TM_e11.WWF_int = scalePointSize >> 16; - transMatrix.TM_e22.WWF_frac = scalePointSize & 0x0000ffff; - transMatrix.TM_e22.WWF_int = scalePointSize >> 16; - - if( pathFlags & FGPF_POSTSCRIPT ) + /* we only perform steps 2 & 3 if the POSTSCRIPT flag wasn't passed */ + if( !(pathFlags & FGPF_POSTSCRIPT) ) { - //TODO: translation = (FontHeader.FH_accent + FontHeader.FH_ascent) * scalePointSize - word translation = 600; //nur zum Test - GrApplyTranslationDWord( gstate, 0, translation ); - + GrGetFont( gstate, &pointSize ); + scalePointSize = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); + + //TODO: + //ascent und accent laden + //translation = ( accent + ascent ) * scalePointsize + //AppyTranslate( 0, translation ) + + //Test + GrApplyTranslationDWord( gstate, 0, 199 ); + /* flip on x-axis */ GrApplyScale( gstate, 1L << 16, -1L << 16 ); + } + /* calc scaling factor and calculate transformation matrix */ + GrGetTransform( gstate, &transMatrix ); + + //TODO: auslagern und korrigieren + transMatrix.TM_e11.WWF_frac = 16384; + transMatrix.TM_e11.WWF_int = 0; + transMatrix.TM_e22.WWF_frac = 16384; + transMatrix.TM_e22.WWF_int = 0; + transMatrix.TM_e31.DWF_frac = 0; + transMatrix.TM_e31.DWF_int = 0; + transMatrix.TM_e32.DWF_frac = 0; + transMatrix.TM_e32.DWF_int = 0; GrApplyTransform( gstate, &transMatrix ); - //TODO: iteriere über Outline - // iteriere über Konturen - // wandle Segmente in Gr... Kommandos - // Test mit Bindestrich - GrMoveTo( gstate, 198, 303 ); - GrDrawVLineTo( gstate, 269 ); - GrDrawHLineTo( gstate, 401 ); - GrDrawVLineTo( gstate, 303 ); - GrDrawHLineTo( gstate, 198 ); + /* convert outline into GrDraw...() calls */ + ConvertOutline( gstate, &OUTLINE); /* write epilogue */ if( pathFlags & FGPF_SAVE_STATE ) GrRestoreState( gstate ); +Fail: TT_Done_Glyph( GLYPH ); -Fail: +Fin: MemUnlock( varBlock ); } @@ -184,6 +208,50 @@ void _pascal TrueType_Gen_In_Region( } + +/******************************************************************** + * ConvertOutline + ******************************************************************** + * SYNOPSIS: + * + * PARAMETERS: + * + * RETURNS: + * + * SIDE EFFECTS: none + * + * CONDITION: + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 22/10/23 JK Initial Revision + *******************************************************************/ + +static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) +{ + if( outline->contours <= 0 || outline->points == 0 ) + return; + + //TODO: iteriere über Konturen + // wandle Segmente in Gr... Kommandos + + + + + + + // Test mit Bindestrich + GrMoveTo( gstate, 198, 303 ); + GrDrawVLineTo( gstate, 269 ); + GrDrawHLineTo( gstate, 401 ); + GrDrawVLineTo( gstate, 303 ); + GrDrawHLineTo( gstate, 198 ); + +} + /******************************************************************** * ScaleOutline ******************************************************************** @@ -212,18 +280,25 @@ static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ) matrix.xx = scale; matrix.yy = scale; - TT_Transform_Outline( 0, &matrix ); + TT_Transform_Outline( &OUTLINE, &matrix ); } -static void CalcTransformMatrix( TransformMatrix* transMatrix ) +static void CalcTransformMatrix( TransMatrix* transMatrix, + WWFixedAsDWord pointSize, + TextStyle stylesToImplement ) { - transMatrix->TM_matrix.xx = 1L << 16; - transMatrix->TM_matrix.xy = 0; - transMatrix->TM_matrix.yx = 0; - transMatrix->TM_matrix.yy = 1L << 16; + WWFixedAsDWord scale = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); + + + transMatrix->TM_e11.WWF_frac = scale & 0x0000ffff; + transMatrix->TM_e11.WWF_int = scale >> 16; + transMatrix->TM_e22.WWF_frac = scale & 0x0000ffff; + transMatrix->TM_e22.WWF_int = scale >> 16; - //TODO + + + //TODO Styles einbauen } @@ -255,11 +330,13 @@ static void WriteComment( TRUETYPE_VARS, GStateHandle gstate ) TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); - params[0] = GLYPH_BBOX.xMax - GLYPH_BBOX.xMin; //width + params[0] = 600; //GLYPH_METRICS.advance;// GLYPH_BBOX.xMax - GLYPH_BBOX.xMin; //width params[1] = 0; //GLYPH_BBOX.yMax - GLYPH_BBOX.yMin; //height - params[2] = GLYPH_BBOX.xMin; - params[3] = GLYPH_BBOX.yMin; - params[4] = GLYPH_BBOX.xMax; - params[5] = GLYPH_BBOX.yMax; + params[2] = 198; //GLYPH_BBOX.xMin; + params[3] = 269; //GLYPH_BBOX.yMin; + params[4] = 401; //GLYPH_BBOX.xMax; + params[5] = 303; //GLYPH_BBOX.yMax; + + GrComment( gstate, ¶ms, NUM_PARAMS ); } diff --git a/Driver/Font/TrueType/Adapter/ttpath.h b/Driver/Font/TrueType/Adapter/ttpath.h index 517e55970..b8337a79b 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.h +++ b/Driver/Font/TrueType/Adapter/ttpath.h @@ -40,6 +40,8 @@ void _pascal TrueType_Gen_Path( word character, const FontInfo* fontInfo, const OutlineEntry* outlineEntry, + const OutlineEntry* firstEntry, + TextStyle stylesToImplement, MemHandle varBlock ); void _pascal TrueType_Gen_In_Region( diff --git a/Driver/Font/TrueType/Main/truetypePath.asm b/Driver/Font/TrueType/Main/truetypePath.asm index 90065df3e..989e50d10 100644 --- a/Driver/Font/TrueType/Main/truetypePath.asm +++ b/Driver/Font/TrueType/Main/truetypePath.asm @@ -53,7 +53,7 @@ REVISION HISTORY: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TrueTypeGenPath proc far - uses ax, bx, ds, es + uses ax, bx, cx, si, ds, es .enter xchg di, ax ;ax <- handle of GState @@ -67,22 +67,38 @@ TrueTypeGenPath proc far push dx ;pass characters code mov bx, ax - call MemLock + call MemLock ;lock gstate block mov es, ax ;es <- seg addr of gstate mov cx, es:GS_fontAttr.FCA_fontID clr ah mov al, es:GS_fontAttr.FCA_textStyle - call MemUnlock call FontDrFindFontInfo push ds ;pass ptr to FontInfo push di + mov cx, ds ;save ptr to FontInfo + mov dx, di + + mov si, bx ;si <-> handle of GState mov bx, ODF_HEADER call FontDrFindOutlineData push ds ;pass ptr to OutlineEntry push di + mov ds, cx + mov di, dx + + clr ah + mov al, es:GS_fontAttr.FCA_textStyle + mov bx, ODF_PART1 + call FontDrFindOutlineData + push ds ;pass ptr to FontHeader + push di + push ax ;pass stylesToImplement + mov bx, si ;bx <- handle of GState + call MemUnlock ;unlock gstate block + segmov ds, dgroup, ax push ds:variableHandle ;pass handle to truetype block call TRUETYPE_GEN_PATH From 4dddbd9e0b23bdbb1bacce87d62796fee1e75b6f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 27 Oct 2023 19:41:40 +0200 Subject: [PATCH 231/246] Handling size of BitmapBlock optimized. --- Driver/Font/TrueType/Adapter/ttchars.c | 94 +++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 11 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index c0b1ec52c..8dccdb02a 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -33,7 +33,7 @@ static void AdjustPointers( CharTableEntry* charTableEntries, word numOfChars ); static word ShiftCharData( FontBuf* fontBuf, CharData* charData ); static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ); -static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ); +static void* EnsureBitmapBlock( MemHandle bitmapHandle, word size ); /******************************************************************** @@ -135,7 +135,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; /* get pointer to bitmapBlock */ - charData = ensureBitmapBlock( bitmapHandle, size ); + charData = EnsureBitmapBlock( bitmapHandle, size ); /* init RASTER_MAP */ RASTER_MAP.rows = height; @@ -166,7 +166,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); size = height * ( ( width + 7 ) / 8 ) + SIZE_CHAR_HEADER; /* get pointer to bitmapBlock */ - charData = ensureBitmapBlock( bitmapHandle, size ); + charData = EnsureBitmapBlock( bitmapHandle, size ); /* init rasterMap */ RASTER_MAP.rows = height; @@ -216,6 +216,28 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); * CopyChar ******************************************************************** * + * SYNOPSIS: + * + * PARAMETERS: character Character to build (Chars). + * *fontBuf Ptr to font data structure. + * pointsize Desired point size. + * *fontInfo Pointer to FontInfo structure. + * *outlineEntry Ptr. to outline entry containing + * TrueTypeOutlineEntry. + * bitmapHandle Memory handle to bitmapblock. + * varBlock Memory handle to var block. + * + * + * RETURNS: void + * + * STRATEGY: - find font-file for the requested style from fontInfo + * - open outline of character in founded font-file + * - calculate requested metrics and return it + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision *******************************************************************/ static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word charDataSize ) { @@ -235,7 +257,28 @@ static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word char /******************************************************************** * ShrinkFontBuf ******************************************************************** - * + * SYNOPSIS: Generate one character for a font. + * + * PARAMETERS: character Character to build (Chars). + * *fontBuf Ptr to font data structure. + * pointsize Desired point size. + * *fontInfo Pointer to FontInfo structure. + * *outlineEntry Ptr. to outline entry containing + * TrueTypeOutlineEntry. + * bitmapHandle Memory handle to bitmapblock. + * varBlock Memory handle to var block. + * + * + * RETURNS: void + * + * STRATEGY: - find font-file for the requested style from fontInfo + * - open outline of character in founded font-file + * - calculate requested metrics and return it + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision *******************************************************************/ static void ShrinkFontBuf( FontBuf* fontBuf ) { @@ -353,21 +396,50 @@ static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ) return size; } -static void* ensureBitmapBlock( MemHandle bitmapHandle, word size ) + +/******************************************************************** + * EnsureBitmapBlock + ******************************************************************** + * SYNOPSIS: Ensures that the required space is available in the + * bitmap block. + * + * PARAMETERS: bitmapHandle Memory handle to bitmap block. + * size Required size of bitmap block. + * + + * RETURNS: void* Pointer to locked bitmap block. + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision + *******************************************************************/ + +static void* EnsureBitmapBlock( MemHandle bitmapHandle, word size ) { void* bitmapData = MemLock( bitmapHandle ); + if( bitmapData == NULL ) { - MemReAlloc( bitmapHandle, MAX( size, BITMAP_BLOCKSIZE ), HAF_NO_ERR ); - bitmapData = MemLock( bitmapHandle ); + MemReAlloc( bitmapHandle, MAX( size, BITMAP_BLOCKSIZE ), HAF_ZERO_INIT | HAF_NO_ERR ); + return MemLock( bitmapHandle ); } else { - if( MemGetInfo( bitmapHandle, MGIT_SIZE ) < size ) + word bitmapBlockSize = MemGetInfo( bitmapHandle, MGIT_SIZE ); + + if( bitmapBlockSize < size ) + { + MemReAlloc( bitmapHandle, size, HAF_ZERO_INIT | HAF_NO_ERR ); + return MemLock( bitmapHandle ); + } + + if( size < BITMAP_BLOCKSIZE ) { - MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); - bitmapData = MemLock( bitmapHandle ); + MemReAlloc( bitmapHandle, BITMAP_BLOCKSIZE, HAF_ZERO_INIT | HAF_NO_ERR ); + return MemLock( bitmapHandle ); } } - memset( bitmapData, 0, size ); return bitmapData; } From 1d979bd7e442a81242d8aaa67b1c89aaa3d36d5d Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 27 Oct 2023 19:57:53 +0200 Subject: [PATCH 232/246] Update comments. --- Driver/Font/TrueType/Adapter/ttchars.c | 37 +++++++++----------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 8dccdb02a..4056e79d3 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -216,29 +216,25 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); * CopyChar ******************************************************************** * - * SYNOPSIS: + * SYNOPSIS: Copies a rendered glyph from the BitmapBlock to the + * fontbuf and updates the CharTableEntry. * - * PARAMETERS: character Character to build (Chars). - * *fontBuf Ptr to font data structure. - * pointsize Desired point size. - * *fontInfo Pointer to FontInfo structure. - * *outlineEntry Ptr. to outline entry containing - * TrueTypeOutlineEntry. - * bitmapHandle Memory handle to bitmapblock. - * varBlock Memory handle to var block. + * PARAMETERS: *fontBuf Ptr to font data structure. + * geosChar Code of character to copy. + * *charData Ptr to bitmap block. + * charDataSize Number of bytes to copy. * * * RETURNS: void * - * STRATEGY: - find font-file for the requested style from fontInfo - * - open outline of character in founded font-file - * - calculate requested metrics and return it + * STRATEGY: * * REVISION HISTORY: * Date Name Description * ---- ---- ----------- * 12/23/22 JK Initial Revision *******************************************************************/ + static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word charDataSize ) { word indexGeosChar = geosChar - fontBuf->FB_firstChar; @@ -257,29 +253,20 @@ static void CopyChar( FontBuf* fontBuf, word geosChar, void* charData, word char /******************************************************************** * ShrinkFontBuf ******************************************************************** - * SYNOPSIS: Generate one character for a font. + * SYNOPSIS: Shrint FontBuf if it is to large. * - * PARAMETERS: character Character to build (Chars). - * *fontBuf Ptr to font data structure. - * pointsize Desired point size. - * *fontInfo Pointer to FontInfo structure. - * *outlineEntry Ptr. to outline entry containing - * TrueTypeOutlineEntry. - * bitmapHandle Memory handle to bitmapblock. - * varBlock Memory handle to var block. - * + * PARAMETERS: *fontBuf Ptr to font data structure. * * RETURNS: void * - * STRATEGY: - find font-file for the requested style from fontInfo - * - open outline of character in founded font-file - * - calculate requested metrics and return it + * STRATEGY: * * REVISION HISTORY: * Date Name Description * ---- ---- ----------- * 12/23/22 JK Initial Revision *******************************************************************/ + static void ShrinkFontBuf( FontBuf* fontBuf ) { word numOfChars = fontBuf->FB_lastChar - fontBuf->FB_firstChar + 1; From 13e8c633ed86f7d43da4bd2c349638e85d3ca205 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 27 Oct 2023 22:16:10 +0200 Subject: [PATCH 233/246] Update more comments. --- Driver/Font/TrueType/Adapter/ttchars.c | 69 ++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 4056e79d3..8c166610c 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -302,11 +302,25 @@ static void ShrinkFontBuf( FontBuf* fontBuf ) } } + /******************************************************************** * FindLRUChar ******************************************************************** - * + * SYNOPSIS: Find least recently used char in FontBuf. + * + * PARAMETERS: *fontBuf Ptr to font data structure. + * numOfChars Number of chars in FontBuf. + * + * RETURNS: int Index of lru char. + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision *******************************************************************/ + static int FindLRUChar( FontBuf* fontBuf, int numOfChars ) { word lru = 0xffff; @@ -332,10 +346,27 @@ static int FindLRUChar( FontBuf* fontBuf, int numOfChars ) return indexLRUChar; } + /******************************************************************** * AdjustPointers ******************************************************************** - * + * SYNOPSIS: Adjust pointers after removing a rendered glyph + * from FontBuf. + * + * PARAMETERS: *charTableEntries Ptr to first CharTableEntry. + * *lruEntry Ptr to CharTableEntry of + * removed rendered glyph. + * sizeLRUEntry Size of removed rendered glyph. + * numOfChars Number of chars in FontBuf. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision *******************************************************************/ static void AdjustPointers( CharTableEntry* charTableEntries, CharTableEntry* lruEntry, @@ -349,11 +380,27 @@ static void AdjustPointers( CharTableEntry* charTableEntries, charTableEntries[i].CTE_dataOffset -= sizeLRUEntry; } + /******************************************************************** * ShiftCharData ******************************************************************** - * + * SYNOPSIS: Shift rendered glyphs as bitmap to fill gaps after + * removing a glyph from FontBuf. + * + * PARAMETERS: *fontBuf Ptr to font data structure. + * *charData Ptr to removed rendered glyph + * as bitmap. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision *******************************************************************/ + static word ShiftCharData( FontBuf* fontBuf, CharData* charData ) { word size = charData->CD_pictureWidth * @@ -369,7 +416,21 @@ static word ShiftCharData( FontBuf* fontBuf, CharData* charData ) /******************************************************************** * ShiftRegionCharData ******************************************************************** - * + *SYNOPSIS: Shift rendered glyphs as region to fill gaps after + * removing a glyph from FontBuf. + * + * PARAMETERS: *fontBuf Ptr to font data structure. + * *charData Ptr to removed rendered glyph + * as region. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 12/23/22 JK Initial Revision *******************************************************************/ static word ShiftRegionCharData( FontBuf* fontBuf, RegionCharData* charData ) { From d179c77577ac405110d9b4d007a97ef25e22616a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Tue, 31 Oct 2023 19:19:33 +0100 Subject: [PATCH 234/246] Further work on TrueType_Gen_Path implementation. --- Driver/Font/TrueType/Adapter/ttadapter.h | 1 + Driver/Font/TrueType/Adapter/ttchars.c | 2 +- Driver/Font/TrueType/Adapter/ttpath.c | 163 ++++++++++------------- Driver/Font/TrueType/Adapter/ttwidths.h | 4 +- 4 files changed, 77 insertions(+), 93 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index 25e4f04b9..bd84022b4 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -60,6 +60,7 @@ extern TEngine_Instance engineInstance; #define MAX_BITMAP_SIZE 125 #define MAX_FONTBUF_SIZE 10 * 1024 #define BITMAP_BLOCKSIZE 2 * 1024 +#define REGION_SAFETY 400 #define FAMILY_NAME_LENGTH 20 #define STYLE_NAME_LENGTH 16 diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 8c166610c..2b6aa02dc 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -132,7 +132,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); TT_Matrix flipmatrix = HORIZONTAL_FLIP_MATRIX; /* We calculate with an average of 4 on/off points, line number and line end code. */ - size = height * 6 * sizeof( word ) + SIZE_REGION_HEADER; + size = height * 6 * sizeof( word ) + REGION_SAFETY + SIZE_REGION_HEADER; /* get pointer to bitmapBlock */ charData = EnsureBitmapBlock( bitmapHandle, size ); diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index e52568ceb..f8b68a964 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -27,8 +27,6 @@ static void CalcTransformMatrix( TransMatrix* transMatrix, WWFixedAsDWord pointSize, TextStyle stylesToImplement ); -static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ); - static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ); @@ -70,10 +68,10 @@ void _pascal TrueType_Gen_Path( { TrueTypeVars* trueTypeVars; TrueTypeOutlineEntry* trueTypeOutline; + FontHeader* fontHeader; TransMatrix transMatrix; TT_UShort charIndex; WWFixedAsDWord pointSize; - WWFixedAsDWord scalePointSize; XYValueAsDWord cursorPos; @@ -82,12 +80,18 @@ EC( ECCheckBounds( (void*)fontInfo ) ); EC( ECCheckBounds( (void*)outlineEntry ) ); EC( ECCheckBounds( (void*)firstEntry ) ); EC( ECCheckMemHandle( varBlock ) ); +EC( ECCheckStack() ); /* get trueTypeVar block */ trueTypeVars = MemLock( varBlock ); EC( ECCheckBounds( (void*)trueTypeVars ) ); trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); +EC( ECCheckBounds( (void*)trueTypeOutline ) ); + + /* get pointer to FontHeader */ + fontHeader = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), firstEntry->OE_handle ); +EC( ECCheckBounds( (void*)fontHeader ) ); /* open face, create instance and glyph */ if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) @@ -105,8 +109,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* load glyph and scale its outline to 1000 units per em */ TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); - ScaleOutline( trueTypeVars, GrUDivWWFixed( - ((dword)STANDARD_GRIDSIZE) << 16, ((dword)UNITS_PER_EM) << 16 ) ); /* write comment with glyph parameters */ WriteComment( trueTypeVars, gstate ); @@ -127,37 +129,25 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); cursorPos = GrGetCurPos( gstate ); GrApplyTranslationDWord( gstate, DWORD_X( cursorPos ), DWORD_Y( cursorPos ) ); + /* get pointsize for scaling */ + GrGetFont( gstate, &pointSize ); + /* we only perform steps 2 & 3 if the POSTSCRIPT flag wasn't passed */ if( !(pathFlags & FGPF_POSTSCRIPT) ) { - GrGetFont( gstate, &pointSize ); - scalePointSize = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); + word translation = fontHeader->FH_accent + fontHeader->FH_ascent; + WWFixedAsDWord scale = GrUDivWWFixed( pointSize, ((dword)UNITS_PER_EM) << 16 ); - //TODO: - //ascent und accent laden - //translation = ( accent + ascent ) * scalePointsize - //AppyTranslate( 0, translation ) - //Test - GrApplyTranslationDWord( gstate, 0, 199 ); + /* translate to baseline */ + GrApplyTranslation( gstate, 0, GrMulWWFixed( ((dword)translation) << 16, scale ) ); /* flip on x-axis */ GrApplyScale( gstate, 1L << 16, -1L << 16 ); - } - /* calc scaling factor and calculate transformation matrix */ - GrGetTransform( gstate, &transMatrix ); - - //TODO: auslagern und korrigieren - transMatrix.TM_e11.WWF_frac = 16384; - transMatrix.TM_e11.WWF_int = 0; - transMatrix.TM_e22.WWF_frac = 16384; - transMatrix.TM_e22.WWF_int = 0; - transMatrix.TM_e31.DWF_frac = 0; - transMatrix.TM_e31.DWF_int = 0; - transMatrix.TM_e32.DWF_frac = 0; - transMatrix.TM_e32.DWF_int = 0; + /* calculate transformation matrix and apply it */ + CalcTransformMatrix( &transMatrix, pointSize, stylesToImplement ); GrApplyTransform( gstate, &transMatrix ); /* convert outline into GrDraw...() calls */ @@ -184,10 +174,6 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); * * RETURNS: * - * SIDE EFFECTS: none - * - * CONDITION: - * * STRATEGY: * * REVISION HISTORY: @@ -212,15 +198,13 @@ void _pascal TrueType_Gen_In_Region( /******************************************************************** * ConvertOutline ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: + * SYNOPSIS: Convert glyphs outline into GrDraw..() calls. * - * RETURNS: - * - * SIDE EFFECTS: none + * PARAMETERS: gstate GStateHande in which the outline + * of the character is written. + * *outline Ptr. to glyphs outline. * - * CONDITION: + * RETURNS: void * * STRATEGY: * @@ -240,9 +224,6 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) - - - // Test mit Bindestrich GrMoveTo( gstate, 198, 303 ); GrDrawVLineTo( gstate, 269 ); @@ -252,68 +233,68 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) } -/******************************************************************** - * ScaleOutline - ******************************************************************** - * SYNOPSIS: - * - * PARAMETERS: - * - * RETURNS: - * - * SIDE EFFECTS: none - * - * CONDITION: - * - * STRATEGY: - * - * REVISION HISTORY: - * Date Name Description - * ---- ---- ----------- - * 14/10/23 JK Initial Revision - *******************************************************************/ - -static void ScaleOutline( TRUETYPE_VARS, WWFixedAsDWord scale ) -{ - TT_Matrix matrix = { 0, 0, 0, 0}; - - matrix.xx = scale; - matrix.yy = scale; - - TT_Transform_Outline( &OUTLINE, &matrix ); -} - static void CalcTransformMatrix( TransMatrix* transMatrix, WWFixedAsDWord pointSize, TextStyle stylesToImplement ) { - WWFixedAsDWord scale = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); + WWFixedAsDWord scalePointSize = GrUDivWWFixed( pointSize, MakeWWFixed( STANDARD_GRIDSIZE ) ); + + transMatrix->TM_e11.WWF_frac = FractionOf( scalePointSize ); + transMatrix->TM_e11.WWF_int = IntegerOf( scalePointSize ); + transMatrix->TM_e12.WWF_frac = 0; + transMatrix->TM_e12.WWF_int = 0; + transMatrix->TM_e21.WWF_frac = 0; + transMatrix->TM_e21.WWF_int = 0; + transMatrix->TM_e22.WWF_frac = FractionOf( scalePointSize ); + transMatrix->TM_e22.WWF_int = IntegerOf( scalePointSize ); + transMatrix->TM_e31.DWF_frac = 0; + transMatrix->TM_e31.DWF_int = 0; + transMatrix->TM_e32.DWF_frac = 0; + transMatrix->TM_e32.DWF_int = 0; + + /* add styles if needed */ + if( stylesToImplement & TS_BOLD ) + { + WWFixedAsDWord scaleScript = GrMulWWFixed( scalePointSize, BOLD_FACTOR ); + + transMatrix->TM_e11.WWF_frac = FractionOf( scaleScript ); + transMatrix->TM_e11.WWF_int = IntegerOf( scaleScript ); + } - transMatrix->TM_e11.WWF_frac = scale & 0x0000ffff; - transMatrix->TM_e11.WWF_int = scale >> 16; - transMatrix->TM_e22.WWF_frac = scale & 0x0000ffff; - transMatrix->TM_e22.WWF_int = scale >> 16; + if( stylesToImplement & TS_ITALIC ) + { + transMatrix->TM_e12.WWF_frac = FractionOf( ITALIC_FACTOR ); + transMatrix->TM_e12.WWF_int = IntegerOf( ITALIC_FACTOR ); + } + + if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) + { + WWFixedAsDWord scaleScript = GrMulWWFixed( scalePointSize, SCRIPT_FACTOR ); + transMatrix->TM_e11.WWF_frac = FractionOf( scaleScript ); + transMatrix->TM_e11.WWF_int = IntegerOf( scaleScript ); + transMatrix->TM_e22.WWF_frac = FractionOf( scaleScript ); + transMatrix->TM_e22.WWF_int = IntegerOf( scaleScript ); - //TODO Styles einbauen + //TODO: tm_e31 und tm_e32 füllen + } + + //TODO: + //width & weight einarbeiten } /******************************************************************** * WriteComment ******************************************************************** - * SYNOPSIS: + * SYNOPSIS: Write glyphbox to gstate as comment. * * PARAMETERS: * - * RETURNS: - * - * SIDE EFFECTS: none - * - * CONDITION: + * RETURNS: void * * STRATEGY: * @@ -326,17 +307,19 @@ static void CalcTransformMatrix( TransMatrix* transMatrix, #define NUM_PARAMS 6 static void WriteComment( TRUETYPE_VARS, GStateHandle gstate ) { - word params[NUM_PARAMS]; + word params[NUM_PARAMS]; + WWFixedAsDWord scale = GrUDivWWFixed( ((dword)STANDARD_GRIDSIZE) << 16, ((dword)UNITS_PER_EM) << 16 ); TT_Get_Glyph_Metrics( GLYPH, &GLYPH_METRICS ); - params[0] = 600; //GLYPH_METRICS.advance;// GLYPH_BBOX.xMax - GLYPH_BBOX.xMin; //width - params[1] = 0; //GLYPH_BBOX.yMax - GLYPH_BBOX.yMin; //height - params[2] = 198; //GLYPH_BBOX.xMin; - params[3] = 269; //GLYPH_BBOX.yMin; - params[4] = 401; //GLYPH_BBOX.xMax; - params[5] = 303; //GLYPH_BBOX.yMax; + /* the glyph box must be scaled to 1000 units per em */ + params[0] = IntegerOf( GrMulWWFixed( ((dword)GLYPH_METRICS.advance) << 16, scale ) ); + params[1] = 0; + params[2] = IntegerOf( GrMulWWFixed( ((dword)GLYPH_BBOX.xMin) << 16, scale ) ); + params[3] = IntegerOf( GrMulWWFixed( ((dword)GLYPH_BBOX.yMin) << 16, scale ) ); + params[4] = IntegerOf( GrMulWWFixed( ((dword)GLYPH_BBOX.xMax) << 16, scale ) ); + params[5] = IntegerOf( GrMulWWFixed( ((dword)GLYPH_BBOX.yMax) << 16, scale ) ); GrComment( gstate, ¶ms, NUM_PARAMS ); } diff --git a/Driver/Font/TrueType/Adapter/ttwidths.h b/Driver/Font/TrueType/Adapter/ttwidths.h index 428e81c4f..e62e62c87 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.h +++ b/Driver/Font/TrueType/Adapter/ttwidths.h @@ -15,7 +15,7 @@ * * DESCRIPTION: * Declarations of types and functions for the driver function - * DR_FONT_GEN_WIDTHS. + * DR_FONT_GEN_WIDTHS. ***********************************************************************/ #ifndef _TTWIDTHS_H_ @@ -38,7 +38,7 @@ MemHandle _pascal TrueType_Gen_Widths( MemHandle fontHandle, FontMatrix* fontMatrix, WWFixedAsDWord pointSize, - const FontInfo* fontInfo, + const FontInfo* fontInfo, const OutlineEntry* headerEntry, const OutlineEntry* firstEntry, TextStyle stylesToImplement, From 1aa25d3e5b319366e0564a277269edf6a8beef06 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Wed, 1 Nov 2023 22:01:49 +0100 Subject: [PATCH 235/246] fix: clean bitmapBlock before rendering new glyph. --- Driver/Font/TrueType/Adapter/ttchars.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 2b6aa02dc..853c36b93 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -471,23 +471,24 @@ static void* EnsureBitmapBlock( MemHandle bitmapHandle, word size ) if( bitmapData == NULL ) { - MemReAlloc( bitmapHandle, MAX( size, BITMAP_BLOCKSIZE ), HAF_ZERO_INIT | HAF_NO_ERR ); - return MemLock( bitmapHandle ); + MemReAlloc( bitmapHandle, MAX( size, BITMAP_BLOCKSIZE ), HAF_NO_ERR ); + bitmapData = MemLock( bitmapHandle ); } else { word bitmapBlockSize = MemGetInfo( bitmapHandle, MGIT_SIZE ); if( bitmapBlockSize < size ) { - MemReAlloc( bitmapHandle, size, HAF_ZERO_INIT | HAF_NO_ERR ); - return MemLock( bitmapHandle ); + MemReAlloc( bitmapHandle, size, HAF_NO_ERR ); + bitmapData = MemLock( bitmapHandle ); } if( size < BITMAP_BLOCKSIZE ) { - MemReAlloc( bitmapHandle, BITMAP_BLOCKSIZE, HAF_ZERO_INIT | HAF_NO_ERR ); - return MemLock( bitmapHandle ); + MemReAlloc( bitmapHandle, BITMAP_BLOCKSIZE, HAF_NO_ERR ); + bitmapData = MemLock( bitmapHandle ); } } + memset( bitmapData, 0, size ); return bitmapData; } From 12323ee9d5aa3d99c16b44118962505df7ec5ef1 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 3 Nov 2023 21:10:40 +0100 Subject: [PATCH 236/246] Better solution for sub- ans superscript. --- Driver/Font/TrueType/Adapter/ttwidths.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index e5d225129..4c5c2f7fb 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -53,8 +53,7 @@ static void CalcTransform( TRUETYPE_VARS, TransformMatrix* transMatrix, FontMatrix* fontMatrix, WWFixedAsDWord pointSize, - TextStyle stylesToImplement, - FontBuf* fontBuf ); + TextStyle stylesToImplement ); static void AdjustFontBuf( TransformMatrix* transMatrix, FontMatrix* fontMatrix, @@ -183,7 +182,7 @@ EC( ECCheckBounds( (void*)trueTypeVars ) ); /* calculate the transformation matrix and copy it into the FontBlock */ transMatrix = (TransformMatrix*)(((byte*)fontBuf) + sizeof( FontBuf ) + fontHeader->FH_numChars * sizeof( CharTableEntry )); - CalcTransform( trueTypeVars, transMatrix, fontMatrix, pointSize, stylesToImplement, fontBuf ); + CalcTransform( trueTypeVars, transMatrix, fontMatrix, pointSize, stylesToImplement ); //TODO: adjust FB_height, FB_minTSB, FB_pixHeight and FB_baselinePos AdjustFontBuf( transMatrix, fontMatrix, stylesToImplement, fontBuf ); @@ -417,7 +416,6 @@ static void CalcScaleForWidths( TRUETYPE_VARS, WWFixedAsDWord pointSize, * *transMatrix Pointer to TransformMatrix. * *fontMatrix Systems transformation matrix. * styleToImplement Styles that must be added. - * *fontBuf Ptr. to FontBuf structure. * * RETURNS: void * @@ -433,8 +431,7 @@ static void CalcTransform( TRUETYPE_VARS, TransformMatrix* transMatrix, FontMatrix* fontMatrix, WWFixedAsDWord pointSize, - TextStyle stylesToImplement, - FontBuf* fontBuf ) + TextStyle stylesToImplement ) { TT_Matrix tempMatrix; @@ -469,15 +466,11 @@ EC( ECCheckBounds( (void*)fontMatrix ) ); if( stylesToImplement & TS_SUBSCRIPT ) { - transMatrix->TM_scriptY = GrMulWWFixed( - SUBSCRIPT_OFFSET, pointSize ) >> 16; + transMatrix->TM_scriptY = GrMulWWFixed( SUBSCRIPT_OFFSET, pointSize ) >> 16; } else { - transMatrix->TM_scriptY = GrMulWWFixed( - SUPERSCRIPT_OFFSET, pointSize ) - - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos ) - - WBFIXED_TO_WWFIXEDASDWORD( fontBuf->FB_baseAdjust ) >> 16; + transMatrix->TM_scriptY = -( GrMulWWFixed( SUPERSCRIPT_OFFSET, pointSize ) ) >> 16; } } From 54eab12a511d23872a19cf567ed2f7288bd1722b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sat, 4 Nov 2023 20:06:15 +0100 Subject: [PATCH 237/246] Some little improvements. --- Driver/Font/TrueType/Adapter/ttpath.c | 47 +++++++++++++++++++++---- Driver/Font/TrueType/Adapter/ttwidths.c | 12 ++++--- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index f8b68a964..3b6b3355b 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -73,6 +73,7 @@ void _pascal TrueType_Gen_Path( TT_UShort charIndex; WWFixedAsDWord pointSize; XYValueAsDWord cursorPos; + word baseline; EC( ECCheckGStateHandle( gstate ) ); @@ -125,6 +126,9 @@ EC( ECCheckBounds( (void*)fontHeader ) ); /* extremely important, we must perform these transformations */ /* in reverse order. Step 5 is, of course, already in the GState. */ + /* calculate baseline for further use */ + baseline = fontHeader->FH_accent + fontHeader->FH_ascent; + /* translate by current cursor position */ cursorPos = GrGetCurPos( gstate ); GrApplyTranslationDWord( gstate, DWORD_X( cursorPos ), DWORD_Y( cursorPos ) ); @@ -135,12 +139,11 @@ EC( ECCheckBounds( (void*)fontHeader ) ); /* we only perform steps 2 & 3 if the POSTSCRIPT flag wasn't passed */ if( !(pathFlags & FGPF_POSTSCRIPT) ) { - word translation = fontHeader->FH_accent + fontHeader->FH_ascent; WWFixedAsDWord scale = GrUDivWWFixed( pointSize, ((dword)UNITS_PER_EM) << 16 ); /* translate to baseline */ - GrApplyTranslation( gstate, 0, GrMulWWFixed( ((dword)translation) << 16, scale ) ); + GrApplyTranslation( gstate, 0, GrMulWWFixed( ((dword)baseline) << 16, scale ) ); /* flip on x-axis */ GrApplyScale( gstate, 1L << 16, -1L << 16 ); @@ -234,6 +237,26 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) } +/******************************************************************** + * CalcTransformMatrix + ******************************************************************** + * SYNOPSIS: Calculate tranformation matrix for scale and styles. + * + * PARAMETERS: *transmatrix Ptr. to transformation matrix + * to fill. + * pointsize Desired point size. + * stylesToImplement Styles that must be added. + * + * RETURNS: void + * + * STRATEGY: + * + * REVISION HISTORY: + * Date Name Description + * ---- ---- ----------- + * 22/10/23 JK Initial Revision + *******************************************************************/ + static void CalcTransformMatrix( TransMatrix* transMatrix, WWFixedAsDWord pointSize, TextStyle stylesToImplement ) @@ -271,15 +294,25 @@ static void CalcTransformMatrix( TransMatrix* transMatrix, if( stylesToImplement & ( TS_SUBSCRIPT | TS_SUPERSCRIPT ) ) { - WWFixedAsDWord scaleScript = GrMulWWFixed( scalePointSize, SCRIPT_FACTOR ); - + WWFixedAsDWord translation; + WWFixedAsDWord scaleScript; + + /* scaleScript = GrMulWWFixed( scaleScript, ); transMatrix->TM_e11.WWF_frac = FractionOf( scaleScript ); transMatrix->TM_e11.WWF_int = IntegerOf( scaleScript ); + transMatrix->TM_e22.WWF_frac = FractionOf( scaleScript ); transMatrix->TM_e22.WWF_int = IntegerOf( scaleScript ); - //TODO: tm_e31 und tm_e32 füllen + if( stylesToImplement & TS_SUPERSCRIPT ) + translation = GrMulWWFixed( SUPERSCRIPT_OFFSET, scalePointSize ); + + if( stylesToImplement & TS_SUBSCRIPT ) + translation = -GrMulWWFixed( SUBSCRIPT_OFFSET, scalePointSize ); + + transMatrix->TM_e32.DWF_frac = FractionOf( translation ); + transMatrix->TM_e32.DWF_int = IntegerOf( translation ); */ } //TODO: @@ -292,7 +325,9 @@ static void CalcTransformMatrix( TransMatrix* transMatrix, ******************************************************************** * SYNOPSIS: Write glyphbox to gstate as comment. * - * PARAMETERS: + * PARAMETERS: TRUETYPE_VARS Cached variables needed by driver. + * gstate GStateHande in which the comment + * is written. * * RETURNS: void * diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 4c5c2f7fb..8cd27beac 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -661,7 +661,12 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, TextStyle stylesToImplement, FontBuf* fontBuf ) { + sword savedHeightY = transMatrix->TM_heightY; + sword savedScriptY = transMatrix->TM_scriptY; + + transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), fontMatrix->FM_22 ) ) + 1; + transMatrix->TM_scriptY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( transMatrix->TM_scriptY ), fontMatrix->FM_22 ) ); if( fontMatrix->FM_flags & TF_COMPLEX ) { @@ -675,7 +680,6 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, if( fontMatrix->FM_flags & TF_ROTATED ) { - sword savedHeightY = transMatrix->TM_scriptY; /* adjust FB_pixHeight, FB_minTSB */ fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( @@ -686,13 +690,13 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, /* adjust script and height */ transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yy ) ); - transMatrix->TM_scriptY = 0; /*INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yx ) );*/ - transMatrix->TM_heightX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.xy ) ); transMatrix->TM_scriptX = 0; /*-INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) );*/ + + transMatrix->TM_scriptY = 0; /*INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yx ) );*/ } fontMatrix->FM_12 = -fontMatrix->FM_12; From 0fb355390e58fbd96a428cbc795f194c49fa0a2b Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 5 Nov 2023 12:02:22 +0100 Subject: [PATCH 238/246] Clean up ttwidths.c --- Driver/Font/TrueType/Adapter/ttwidths.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttwidths.c b/Driver/Font/TrueType/Adapter/ttwidths.c index 8cd27beac..0880f2878 100644 --- a/Driver/Font/TrueType/Adapter/ttwidths.c +++ b/Driver/Font/TrueType/Adapter/ttwidths.c @@ -662,7 +662,6 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, FontBuf* fontBuf ) { sword savedHeightY = transMatrix->TM_heightY; - sword savedScriptY = transMatrix->TM_scriptY; transMatrix->TM_heightY = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), fontMatrix->FM_22 ) ) + 1; @@ -680,7 +679,6 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, if( fontMatrix->FM_flags & TF_ROTATED ) { - /* adjust FB_pixHeight, FB_minTSB */ fontBuf->FB_pixHeight = INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_height.WBF_int ), transMatrix->TM_matrix.yy ) ); @@ -692,11 +690,12 @@ static void AdjustFontBuf( TransformMatrix* transMatrix, WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.yy ) ); transMatrix->TM_heightX = -INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( fontBuf->FB_baselinePos.WBF_int ), transMatrix->TM_matrix.xy ) ); + transMatrix->TM_scriptX = 0; /*-INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.xy ) );*/ - transMatrix->TM_scriptY = 0; /*INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( - WORD_TO_WWFIXEDASDWORD( savedHeightY ), transMatrix->TM_matrix.yx ) );*/ + transMatrix->TM_scriptY = 0; /* INTEGER_OF_WWFIXEDASDWORD( GrMulWWFixed( + WORD_TO_WWFIXEDASDWORD( savedHeightY - transMatrix->TM_heightY + transMatrix->TM_scriptY ), -transMatrix->TM_matrix.yx ) );*/ } fontMatrix->FM_12 = -fontMatrix->FM_12; From 0ad5690dbae2bf8658d3dcbe3dd5c1fd3739965c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Mon, 6 Nov 2023 21:31:27 +0100 Subject: [PATCH 239/246] First working implementation of TrueType_Gen_Path. --- Driver/Font/TrueType/Adapter/ttpath.c | 29 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 3b6b3355b..26e6e91f1 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -219,21 +219,32 @@ void _pascal TrueType_Gen_In_Region( static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) { + word contour = 0; + word point = 0; + + if( outline->contours <= 0 || outline->points == 0 ) return; - //TODO: iteriere über Konturen - // wandle Segmente in Gr... Kommandos - + /* iterate over contours */ + for( contour = 0; contour < outline->n_contours; contour++ ) + { + TT_Vector* startPoint = &outline->points[point]; + TT_UShort endPoint = outline->contours[contour]; + /* move to first point of contour */ + GrMoveTo( gstate, outline->points[point].x, outline->points[point].y ); + - // Test mit Bindestrich - GrMoveTo( gstate, 198, 303 ); - GrDrawVLineTo( gstate, 269 ); - GrDrawHLineTo( gstate, 401 ); - GrDrawVLineTo( gstate, 303 ); - GrDrawHLineTo( gstate, 198 ); + while( endPoint != point ) + { + ++point; + GrDrawLineTo( gstate, outline->points[point].x, outline->points[point].y ); + } + ++point; + GrDrawLineTo( gstate, startPoint->x, startPoint->y ); + } } From 822c8dd743df56b33b493815f6a42b0cc5abad6f Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 12 Nov 2023 11:53:56 +0100 Subject: [PATCH 240/246] Use bezier curves to render Glyph. --- Driver/Font/TrueType/Adapter/ttpath.c | 93 +++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 11 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 26e6e91f1..0226f0f91 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -30,6 +30,15 @@ static void CalcTransformMatrix( TransMatrix* transMatrix, static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ); +static void move_to( GStateHandle gstate, TT_Vector* v ); + +static void line_to( GStateHandle gstate, TT_Vector* v ); + +static void conic_to( GStateHandle gstate, TT_Vector* v_control, TT_Vector* v ); + +static void cubic_to( GStateHandle gstate, TT_Vector* v1, TT_Vector* v2, TT_Vector* vec ); + + /******************************************************************** * TrueType_Gen_Path ******************************************************************** @@ -217,37 +226,99 @@ void _pascal TrueType_Gen_In_Region( * 22/10/23 JK Initial Revision *******************************************************************/ +#define CURVE_TAG_ON 0x01 +#define CURVE_TAG_CONIC 0x00 +#define CURVE_TAG_CUBIC 0x02 static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) { word contour = 0; word point = 0; - if( outline->contours <= 0 || outline->points == 0 ) + if( outline->n_contours <= 0 || outline->n_points == 0 ) return; /* iterate over contours */ for( contour = 0; contour < outline->n_contours; contour++ ) { - TT_Vector* startPoint = &outline->points[point]; - TT_UShort endPoint = outline->contours[contour]; + TT_UShort startPoint = contour == 0 ? 0 : outline->contours[contour - 1] + 1; + TT_UShort endPoint = outline->contours[contour]; + + //TODO: erster und letzter Punkt einer Kontour kann ein Kontrollpunkt sein /* move to first point of contour */ - GrMoveTo( gstate, outline->points[point].x, outline->points[point].y ); - + GrMoveTo( gstate, outline->points[startPoint].x, outline->points[startPoint].y ); - while( endPoint != point ) + /* iterate over points of contour */ + for( point = startPoint + 1; point <= endPoint; point++ ) { - ++point; - GrDrawLineTo( gstate, outline->points[point].x, outline->points[point].y ); + TT_UShort pointTo; + + + switch (outline->flags[point] & 3) + { + case CURVE_TAG_ON: + line_to( gstate, &outline->points[point]); + if( point == endPoint ) + line_to( gstate, &outline->points[startPoint]); + break; + + case CURVE_TAG_CONIC: + pointTo = point == endPoint ? startPoint : point + 1; + conic_to( gstate, &outline->points[point], &outline->points[pointTo] ); + point++; + break; + + case CURVE_TAG_CUBIC: + pointTo = point + 1 == endPoint ? startPoint : point + 2; + cubic_to( gstate, &outline->points[point], &outline->points[point + 1], &outline->points[pointTo] ); + point += 2; + break; + } } - - ++point; - GrDrawLineTo( gstate, startPoint->x, startPoint->y ); } } +static void move_to( GStateHandle gstate, TT_Vector* v ) +{ + GrMoveTo( gstate, v->x, v->y ); +} + +static void line_to( GStateHandle gstate, TT_Vector* v ) +{ + GrDrawLineTo( gstate, v->x, v->y ); +} + +static void conic_to( GStateHandle gstate, TT_Vector* v_control, TT_Vector* v ) +{ + Point p[3]; + + + p[0].P_x = v_control->x; + p[0].P_y = v_control->y; + p[1].P_x = p[2].P_x = v->x; + p[1].P_y = p[2].P_y = v->y; + + GrDrawCurveTo( gstate, p ); +} + +static void cubic_to( GStateHandle gstate, TT_Vector* v1, TT_Vector* v2, TT_Vector* vec ) +{ + Point p[3]; + + + p[0].P_x = v1->x; + p[0].P_y = v1->y; + p[1].P_x = v2->x; + p[1].P_y = v2->y; + p[2].P_x = vec->x; + p[2].P_y = vec->y; + + GrDrawCurveTo( gstate, p ); +} + + /******************************************************************** * CalcTransformMatrix ******************************************************************** From 337751a75c551789702d295e7310d63476f8db2a Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 12 Nov 2023 15:29:02 +0100 Subject: [PATCH 241/246] Unneeded code removed. --- Driver/Font/TrueType/FreeType/freetype.h | 17 ------- Driver/Font/TrueType/FreeType/ttapi.c | 62 ------------------------ 2 files changed, 79 deletions(-) diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index a86b4be7a..d251f837c 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -618,16 +618,6 @@ typedef int TT_Error; - /* Flags for control path generation for FreeGEOS. */ - - #ifdef __GEOS__ - - #define GEOS_TTF_POSTSCRIPT 0x0002 - #define GEOS_TTF_SAVE_STATE 0x0001 - - #endif /* __GEOS__ */ - - /*******************************************************************/ /* */ /* FreeType API */ @@ -904,13 +894,6 @@ MemHandle bitmapBlock, Handle regionPath ); - /* Render the glyphs outline into the passsed GStateHandle */ - - EXPORT_DEF - TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, - GStateHandle gstate, - TT_UShort controlFlags ); - /* ----------------------- outline support ------------------------ */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 47b3eae7b..2aa50d869 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -1208,68 +1208,6 @@ extern TEngine_Instance engineInstance; return TT_Err_Ok; } - - /******************************************************************* - * - * Function : TT_Get_Glyph_Path - * - * Description : Renders glyphs outline into the given GStateHandle. - * - * Input : glyph the glyph container's handle - * gstate handle to the graphic state - * controlFlags controls how the outline should be rendered - * - * Output : Error code. - * - * MT-Safe : NO! Glyph containers can't be shared. - * - ******************************************************************/ - - EXPORT_FUNC - TT_Error TT_Get_Glyph_Path( TT_Glyph glyph, - GStateHandle gstate, - TT_UShort controlFlags ) - { - PEngine_Instance _engine; - TT_Error error; - PGlyph _glyph = HANDLE_Glyph( glyph ); - - TT_Outline outline; - - if ( !_glyph ) - return TT_Err_Invalid_Glyph_Handle; - - _engine = _glyph->face->engine; - - outline = _glyph->outline; - - // if SAVE_STATE set save gstate - - // set Comment with glyphs boundig box - - // translate by current x,y position - - // if POSTSCRIPT set -> transform by hight and flip outline - - // transform by font matrix - - // iterate over contours - - // iterate over segments of current contour - - // switch over current segment - - // LINE_SEGMENT --> GrDrawHLine(), GrDrawVLine() or GrDrawLine() - // CURVE_SEGMENT --> GrDrawCurve() - // ... - - // restore glyphs outline - - // if SAVE_STATE set restore gstate - - return TT_Err_Ok; - } - #endif /* __GEOS__ */ From eca18f01e10e9f9a59a8eea8e463db02bd7d6163 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Sun, 12 Nov 2023 21:38:02 +0100 Subject: [PATCH 242/246] We do not need support for cubic curves. --- Driver/Font/TrueType/Adapter/ttpath.c | 29 ++++----------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 0226f0f91..3808c4f79 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -36,8 +36,6 @@ static void line_to( GStateHandle gstate, TT_Vector* v ); static void conic_to( GStateHandle gstate, TT_Vector* v_control, TT_Vector* v ); -static void cubic_to( GStateHandle gstate, TT_Vector* v1, TT_Vector* v2, TT_Vector* vec ); - /******************************************************************** * TrueType_Gen_Path @@ -228,7 +226,6 @@ void _pascal TrueType_Gen_In_Region( #define CURVE_TAG_ON 0x01 #define CURVE_TAG_CONIC 0x00 -#define CURVE_TAG_CUBIC 0x02 static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) { word contour = 0; @@ -245,6 +242,10 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) TT_UShort endPoint = outline->contours[contour]; //TODO: erster und letzter Punkt einer Kontour kann ein Kontrollpunkt sein + if( outline->flags[startPoint] & 3 == CURVE_TAG_CONIC ) + { + startPoint++; + } /* move to first point of contour */ GrMoveTo( gstate, outline->points[startPoint].x, outline->points[startPoint].y ); @@ -262,18 +263,11 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) if( point == endPoint ) line_to( gstate, &outline->points[startPoint]); break; - case CURVE_TAG_CONIC: pointTo = point == endPoint ? startPoint : point + 1; conic_to( gstate, &outline->points[point], &outline->points[pointTo] ); point++; break; - - case CURVE_TAG_CUBIC: - pointTo = point + 1 == endPoint ? startPoint : point + 2; - cubic_to( gstate, &outline->points[point], &outline->points[point + 1], &outline->points[pointTo] ); - point += 2; - break; } } } @@ -303,21 +297,6 @@ static void conic_to( GStateHandle gstate, TT_Vector* v_control, TT_Vector* v ) GrDrawCurveTo( gstate, p ); } -static void cubic_to( GStateHandle gstate, TT_Vector* v1, TT_Vector* v2, TT_Vector* vec ) -{ - Point p[3]; - - - p[0].P_x = v1->x; - p[0].P_y = v1->y; - p[1].P_x = v2->x; - p[1].P_y = v2->y; - p[2].P_x = vec->x; - p[2].P_y = vec->y; - - GrDrawCurveTo( gstate, p ); -} - /******************************************************************** * CalcTransformMatrix From e2c9d339e8d6889df00071dc5d742cb1a2111225 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Thu, 16 Nov 2023 10:52:32 +0100 Subject: [PATCH 243/246] Using bezier curve in in TrueType_Gen_Path. --- Driver/Font/TrueType/Adapter/ttpath.c | 127 +++++++++++++++++++------- 1 file changed, 96 insertions(+), 31 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 3808c4f79..7de62c18c 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -29,7 +29,6 @@ static void CalcTransformMatrix( TransMatrix* transMatrix, static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ); - static void move_to( GStateHandle gstate, TT_Vector* v ); static void line_to( GStateHandle gstate, TT_Vector* v ); @@ -228,50 +227,116 @@ void _pascal TrueType_Gen_In_Region( #define CURVE_TAG_CONIC 0x00 static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) { - word contour = 0; - word point = 0; + TT_Vector v_last; + TT_Vector v_control; + TT_Vector v_start; + + TT_Vector* point; + TT_Vector* limit; + char* tags; + + TT_Int n; + TT_Int first; + TT_Int last; + TT_Int tag; + + + last = -1; + for ( n = 0; n < outline->n_contours; ++n ) + { + first = last + 1; + last = outline->contours[n]; + if ( last < first ) + return; + limit = outline->points + last; + v_start = outline->points[first]; + v_last = outline->points[last]; - if( outline->n_contours <= 0 || outline->n_points == 0 ) - return; + v_control = v_start; - /* iterate over contours */ - for( contour = 0; contour < outline->n_contours; contour++ ) - { - TT_UShort startPoint = contour == 0 ? 0 : outline->contours[contour - 1] + 1; - TT_UShort endPoint = outline->contours[contour]; + point = outline->points + first; + tags = outline->flags + first; + tag = tags[0] & 1; - //TODO: erster und letzter Punkt einer Kontour kann ein Kontrollpunkt sein - if( outline->flags[startPoint] & 3 == CURVE_TAG_CONIC ) + /* check first point to determine origin */ + if ( tag & CURVE_TAG_CONIC ) { - startPoint++; - } + /* first point is conic control. Yes, this happens. */ + if ( outline->flags[last] & CURVE_TAG_ON ) + { + /* start at last point if it is on the curve */ + v_start = v_last; + --limit; + } + else + { + /* if both first and last points are conic, */ + /* start at their middle and record its position */ + v_start.x = ( v_start.x + v_last.x ) / 2; + v_start.y = ( v_start.y + v_last.y ) / 2; + } + --point; + --tags; + } + + move_to( gstate, &v_start ); - /* move to first point of contour */ - GrMoveTo( gstate, outline->points[startPoint].x, outline->points[startPoint].y ); + while ( point < limit ) + { + ++point; + ++tags; - /* iterate over points of contour */ - for( point = startPoint + 1; point <= endPoint; point++ ) + tag = tags[0] & 1; + switch ( tag ) { - TT_UShort pointTo; + case CURVE_TAG_ON: /* emit a single line_to */ + { + line_to( gstate, point ); + continue; + } + case CURVE_TAG_CONIC: /* consume conic arcs */ + v_control.x = point->x; + v_control.y = point->y; - switch (outline->flags[point] & 3) - { - case CURVE_TAG_ON: - line_to( gstate, &outline->points[point]); - if( point == endPoint ) - line_to( gstate, &outline->points[startPoint]); - break; - case CURVE_TAG_CONIC: - pointTo = point == endPoint ? startPoint : point + 1; - conic_to( gstate, &outline->points[point], &outline->points[pointTo] ); - point++; + Do_Conic: + if ( point < limit ) + { + TT_Vector vec; + TT_Vector v_middle; + + + ++point; + ++tags; + + vec.x = point->x; + vec.y = point->y; + + if ( tags[0] & CURVE_TAG_ON ) + { + conic_to( gstate, &v_control, &vec ); + continue; + } + + v_middle.x = ( v_control.x + vec.x ) / 2; + v_middle.y = ( v_control.y + vec.y ) / 2; + + conic_to( gstate, &v_control, &v_middle ); + + v_control = vec; + goto Do_Conic; + } + + conic_to( gstate, &v_control, &v_start ); break; } } + + /* close the contour with a line segment */ + line_to( gstate, &v_start ); } -} +} static void move_to( GStateHandle gstate, TT_Vector* v ) From 540b0f14b11cb966d9e7516564526e438f0ad80c Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 17 Nov 2023 21:14:22 +0100 Subject: [PATCH 244/246] swat.rc removed --- Installed/Driver/Font/TrueType/swat.rc | 2 -- 1 file changed, 2 deletions(-) diff --git a/Installed/Driver/Font/TrueType/swat.rc b/Installed/Driver/Font/TrueType/swat.rc index cce03f86c..db6b637bd 100644 --- a/Installed/Driver/Font/TrueType/swat.rc +++ b/Installed/Driver/Font/TrueType/swat.rc @@ -1,5 +1,3 @@ -send truetype spawn truetype -brk TrueType_Gen_Widths c From 2449438d9d059c784ce46dc2275fc4edd3297964 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 17 Nov 2023 21:21:38 +0100 Subject: [PATCH 245/246] Some clean up. --- Driver/Font/TrueType/Adapter/ttpath.c | 69 ++++++++++++++++++++---- Driver/Font/TrueType/FreeType/freetype.h | 4 +- Driver/Font/TrueType/FreeType/ttapi.c | 4 +- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttpath.c b/Driver/Font/TrueType/Adapter/ttpath.c index 7de62c18c..93b79b27a 100644 --- a/Driver/Font/TrueType/Adapter/ttpath.c +++ b/Driver/Font/TrueType/Adapter/ttpath.c @@ -35,6 +35,10 @@ static void line_to( GStateHandle gstate, TT_Vector* v ); static void conic_to( GStateHandle gstate, TT_Vector* v_control, TT_Vector* v ); +static void WriteComment( TRUETYPE_VARS, GStateHandle gstate ); + +static void ScaleOutline( TRUETYPE_VARS, TT_Outline* outline ); + /******************************************************************** * TrueType_Gen_Path @@ -116,6 +120,7 @@ EC( ECCheckBounds( (void*)fontHeader ) ); /* load glyph and scale its outline to 1000 units per em */ TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + //TODO: auf 1000 Units per EM skalieren /* write comment with glyph parameters */ WriteComment( trueTypeVars, gstate ); @@ -200,7 +205,42 @@ void _pascal TrueType_Gen_In_Region( const OutlineEntry* outlineEntry, MemHandle varBlock ) { + TrueTypeVars* trueTypeVars; + TrueTypeOutlineEntry* trueTypeOutline; + TT_UShort charIndex; + +EC( ECCheckGStateHandle( gstate ) ); +EC( ECCheckBounds( (void*) fontInfo ) ); +EC( ECCheckBounds( (void*) outlineEntry ) ); +EC( ECCheckMemHandle( varBlock ) ); + + /* get trueTypeVar block */ + trueTypeVars = MemLock( varBlock ); +EC( ECCheckBounds( (void*)trueTypeVars ) ); + + trueTypeOutline = LMemDerefHandles( MemPtrToHandle( (void*)fontInfo ), outlineEntry->OE_handle ); +EC( ECCheckBounds( (void*)trueTypeOutline ) ); + + /* open face, create instance and glyph */ + if( TrueType_Lock_Face(trueTypeVars, trueTypeOutline) ) + goto Fin; + + TT_New_Glyph( FACE, &GLYPH ); + + TT_Load_Glyph( INSTANCE, GLYPH, charIndex, 0 ); + TT_Get_Glyph_Outline( GLYPH, &OUTLINE ); + + /* get TT char index */ + charIndex = TT_Char_Index( CHAR_MAP, GeosCharToUnicode( character ) ); + + + +Fail: + TT_Done_Glyph( GLYPH ); + +Fin: + MemUnlock( varBlock ); } @@ -257,10 +297,9 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) point = outline->points + first; tags = outline->flags + first; - tag = tags[0] & 1; /* check first point to determine origin */ - if ( tag & CURVE_TAG_CONIC ) + if ( *tags & CURVE_TAG_CONIC ) { /* first point is conic control. Yes, this happens. */ if ( outline->flags[last] & CURVE_TAG_ON ) @@ -273,8 +312,8 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) { /* if both first and last points are conic, */ /* start at their middle and record its position */ - v_start.x = ( v_start.x + v_last.x ) / 2; - v_start.y = ( v_start.y + v_last.y ) / 2; + v_start.x = ( v_start.x + v_last.x ) >> 1; + v_start.y = ( v_start.y + v_last.y ) >> 1; } --point; --tags; @@ -287,8 +326,7 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) ++point; ++tags; - tag = tags[0] & 1; - switch ( tag ) + switch ( *tags & 1 ) { case CURVE_TAG_ON: /* emit a single line_to */ { @@ -313,14 +351,14 @@ static void ConvertOutline( GStateHandle gstate, TT_Outline* outline ) vec.x = point->x; vec.y = point->y; - if ( tags[0] & CURVE_TAG_ON ) + if ( *tags & CURVE_TAG_ON ) { conic_to( gstate, &v_control, &vec ); continue; } - v_middle.x = ( v_control.x + vec.x ) / 2; - v_middle.y = ( v_control.y + vec.y ) / 2; + v_middle.x = ( v_control.x + vec.x ) >> 1; + v_middle.y = ( v_control.y + vec.y ) >> 1; conic_to( gstate, &v_control, &v_middle ); @@ -484,3 +522,16 @@ static void WriteComment( TRUETYPE_VARS, GStateHandle gstate ) GrComment( gstate, ¶ms, NUM_PARAMS ); } + + +static void ScaleOutline( TRUETYPE_VARS, TT_Outline* outline ) +{ + TT_Matrix scaleMatrix = { 0, 0, 0, 0 }; + WWFixedAsDWord scaleFactor = GrUDivWWFixed( STANDARD_GRIDSIZE, UNITS_PER_EM << 16 ); + + + scaleMatrix.xx = scaleFactor; + scaleMatrix.yy = scaleFactor; + + TT_Transform_Outline( outline, &scaleFactor ); +} \ No newline at end of file diff --git a/Driver/Font/TrueType/FreeType/freetype.h b/Driver/Font/TrueType/FreeType/freetype.h index d251f837c..aaf3bfdf1 100644 --- a/Driver/Font/TrueType/FreeType/freetype.h +++ b/Driver/Font/TrueType/FreeType/freetype.h @@ -888,11 +888,11 @@ /* Render the glyph into the passed GEOS regionpath. */ - + /* EXPORT_DEF TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, MemHandle bitmapBlock, - Handle regionPath ); + Handle regionPath ); */ /* ----------------------- outline support ------------------------ */ diff --git a/Driver/Font/TrueType/FreeType/ttapi.c b/Driver/Font/TrueType/FreeType/ttapi.c index 2aa50d869..be79fb439 100644 --- a/Driver/Font/TrueType/FreeType/ttapi.c +++ b/Driver/Font/TrueType/FreeType/ttapi.c @@ -1170,7 +1170,7 @@ extern TEngine_Instance engineInstance; * MT-Safe : NO! Glyph containers can't be shared. * ******************************************************************/ - +/* EXPORT_FUNC TT_Error TT_Get_Glyph_In_Region( TT_Glyph glyph, MemHandle bitmapBlock, @@ -1207,7 +1207,7 @@ extern TEngine_Instance engineInstance; return TT_Err_Ok; } - +*/ #endif /* __GEOS__ */ From ffabd328e7bf9533a0fe7ec3c84cf3b1455326f3 Mon Sep 17 00:00:00 2001 From: Jirka Kunze Date: Fri, 17 Nov 2023 22:56:21 +0100 Subject: [PATCH 246/246] EnsureBitmapBlock in ttchars.c fixed. --- Driver/Font/TrueType/Adapter/ttadapter.h | 2 +- Driver/Font/TrueType/Adapter/ttchars.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Driver/Font/TrueType/Adapter/ttadapter.h b/Driver/Font/TrueType/Adapter/ttadapter.h index bd84022b4..ac6aeb2d6 100644 --- a/Driver/Font/TrueType/Adapter/ttadapter.h +++ b/Driver/Font/TrueType/Adapter/ttadapter.h @@ -59,7 +59,7 @@ extern TEngine_Instance engineInstance; #define MAX_BITMAP_SIZE 125 #define MAX_FONTBUF_SIZE 10 * 1024 -#define BITMAP_BLOCKSIZE 2 * 1024 +#define INITIAL_BITMAP_BLOCKSIZE 2 * 1024 #define REGION_SAFETY 400 #define FAMILY_NAME_LENGTH 20 diff --git a/Driver/Font/TrueType/Adapter/ttchars.c b/Driver/Font/TrueType/Adapter/ttchars.c index 853c36b93..256532590 100644 --- a/Driver/Font/TrueType/Adapter/ttchars.c +++ b/Driver/Font/TrueType/Adapter/ttchars.c @@ -471,7 +471,7 @@ static void* EnsureBitmapBlock( MemHandle bitmapHandle, word size ) if( bitmapData == NULL ) { - MemReAlloc( bitmapHandle, MAX( size, BITMAP_BLOCKSIZE ), HAF_NO_ERR ); + MemReAlloc( bitmapHandle, MAX( size, INITIAL_BITMAP_BLOCKSIZE ), HAF_NO_ERR ); bitmapData = MemLock( bitmapHandle ); } else { word bitmapBlockSize = MemGetInfo( bitmapHandle, MGIT_SIZE ); @@ -482,9 +482,9 @@ static void* EnsureBitmapBlock( MemHandle bitmapHandle, word size ) bitmapData = MemLock( bitmapHandle ); } - if( size < BITMAP_BLOCKSIZE ) + if( size < INITIAL_BITMAP_BLOCKSIZE && bitmapBlockSize > INITIAL_BITMAP_BLOCKSIZE ) { - MemReAlloc( bitmapHandle, BITMAP_BLOCKSIZE, HAF_NO_ERR ); + MemReAlloc( bitmapHandle, INITIAL_BITMAP_BLOCKSIZE, HAF_NO_ERR ); bitmapData = MemLock( bitmapHandle ); } }