Skip to content

Commit

Permalink
Merge pull request #721 from jirkakunze/707-ttf-driver-create-ini-key…
Browse files Browse the repository at this point in the history
…-to-activate-deactivate-bytecode-interpreter

707 ttf driver create ini key to activate deactivate bytecode interpreter
  • Loading branch information
bluewaysw authored Nov 18, 2024
2 parents 85346b5 + d4564e9 commit 33210ca
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 16 deletions.
1 change: 1 addition & 0 deletions Driver/Font/TrueType/Adapter/ttadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ typedef enum {
#define MUL_100_WWFIXED( factor, percentage ) \
GrMulWWFixed( factor, GrUDivWWFixed( ((long)percentage ) << 16, 100L << 16))


/***********************************************************************
* functions
***********************************************************************/
Expand Down
41 changes: 41 additions & 0 deletions Driver/Font/TrueType/Adapter/ttinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static void strcpyname( char* dest, const char* source );

static int strcmp( const char* s1, const char* s2 );

static Boolean activateBytecodeInterpreter();


/********************************************************************
* Init_FreeType
Expand Down Expand Up @@ -106,6 +108,8 @@ TT_Error _pascal Init_FreeType()
if ( error != TT_Err_Ok )
return error;

engineInstance.interpreterActive = activateBytecodeInterpreter();

return TT_Err_Ok;
}

Expand Down Expand Up @@ -1082,6 +1086,43 @@ static char GetDefaultChar( TRUETYPE_VARS, char firstChar )
}


/********************************************************************
* activateBytecodeInterpreter
********************************************************************
* SYNOPSIS: Activates or determines if the bytecode interpreter
* should be active for the TrueType font driver. Reads
* the configuration setting from geos.ini.
*
* PARAMETERS: None
*
* RETURNS: Boolean
* TRUE if the bytecode interpreter should be active
* (default behavior) or the value retrieved from the
* initialization file if it is successfully read.
*
* STRATEGY: - Attempt to read the BYTECODEINTERPRETER_KEY from the
* initialization file under the TTFDRIVER_CATEGORY.
* - If the key is successfully read, return the retrieved value.
* - If reading fails, return TRUE as the default behavior.
*
* REVISION HISTORY:
* Date Name Description
* ---- ---- -----------
* 17.11.24 jk Initial Revision
*******************************************************************/

static Boolean activateBytecodeInterpreter()
{
Boolean bytecodeInterpreterActive;


if( !InitFileReadBoolean( TTFDRIVER_CATEGORY, BYTECODEINTERPRETER_KEY, &bytecodeInterpreterActive ) )
return bytecodeInterpreterActive;

return TRUE;
}


/********************************************************************
* GetKernCount
********************************************************************
Expand Down
13 changes: 11 additions & 2 deletions Driver/Font/TrueType/Adapter/ttinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@


/***********************************************************************
* constants for font mapping
* constants for access to geos.ini
***********************************************************************/

#define FONTMAPPING_CATEGORY "FontMapping"
#define FONTMAPPING_CATEGORY "FontMapping"
#define TTFDRIVER_CATEGORY "ttfDriver"
#define BYTECODEINTERPRETER_KEY "bytecodeInterpreterActive"


/***********************************************************************
Expand Down Expand Up @@ -79,6 +81,13 @@
#define MAKE_FONTID( fontGroup, familyName ) ( FM_TRUETYPE | fontGroup | ( 0x01ff & toHash ( familyName )))


/***********************************************************************
* drivers engineInstance
***********************************************************************/

extern TEngine_Instance engineInstance;


/***********************************************************************
* functions called by driver
***********************************************************************/
Expand Down
9 changes: 5 additions & 4 deletions Driver/Font/TrueType/FreeType/ttengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@
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* raster_component; /* ttraster implementation depedent */
void* raster_component; /* ttraster implementation depedent */
Boolean interpreterActive; /* is bytecodeinterpreter aktive? */
};

/* NOTE : The raster's lock is only acquired by the Render_Glyph and */
Expand Down
6 changes: 3 additions & 3 deletions Driver/Font/TrueType/FreeType/ttobjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ extern TEngine_Instance engineInstance;
exec->top = 0;
exec->callTop = 0;

return RunIns( exec );
return CALL_INTERPRETER;
}


Expand Down Expand Up @@ -813,7 +813,7 @@ extern TEngine_Instance engineInstance;
if ( error )
goto Fin;

error = RunIns( exec );
error = CALL_INTERPRETER;
}
else
error = TT_Err_Ok;
Expand Down Expand Up @@ -934,7 +934,7 @@ extern TEngine_Instance engineInstance;
if ( error )
goto Fin;

error = RunIns( exec );
error = CALL_INTERPRETER;
}
else
error = TT_Err_Ok;
Expand Down
2 changes: 2 additions & 0 deletions Driver/Font/TrueType/FreeType/ttobjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@

#endif

#define CALL_INTERPRETER ( engineInstance.interpreterActive ? RunIns( exec ) : TT_Err_Ok )

/* Rounding function, as used by the interpreter */
typedef TT_F26Dot6 TRound_Function( EXEC_OPS TT_F26Dot6 distance,
TT_F26Dot6 compensation );
Expand Down
7 changes: 4 additions & 3 deletions Driver/Font/TrueType/Main/truetypeVariable.def
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ TrueTypeEngineInstance struct
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_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
;context objects
raster_component fptr ;ttraster implementation depedent
interpreterActive word
TrueTypeEngineInstance ends

;------------------------------------------------------------------------------
Expand Down
20 changes: 16 additions & 4 deletions TechDocs/Markdown/Tools/tini.md
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,19 @@ application.

----------

### 9.2.31 ui
### 9.2.31 ttfDriver

`bytecodeInterpreterActive = <Boolean>`

If false, this key tells the ttf driver that the bytecode interpreter should not
be used. The default value is true.

bytecodeInterpreterActive = true
bytecodeInterpreterActive = false

----------

### 9.2.32 ui

#### autosave

Expand Down Expand Up @@ -2400,7 +2412,7 @@ primarily when developing for small-screen platforms such as Zoomer.

----------

### 9.2.32 *specific ui name*
### 9.2.33 *specific ui name*

Each specific UI may have a category with options; this category should be
named after the specific UI, e.g. [motif].
Expand All @@ -2421,7 +2433,7 @@ when drawing text monikers for gadgets such as menus and buttons.

----------

### 9.2.33 ui features
### 9.2.34 ui features

The ui features category defines the UI configuration used by the
environment application (e.g. Welcome) and all applications on the
Expand Down Expand Up @@ -2732,7 +2744,7 @@ is closed.

----------

### 9.2.34 welcome
### 9.2.35 welcome

The welcome category defines configuration and usage characteristics of the
Welcome environment application. Its keys may be useful to you during
Expand Down

0 comments on commit 33210ca

Please sign in to comment.