< prev index next >
src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c
Print this page
*** 1,21 ****
! /***************************************************************************/
! /* */
! /* cffdrivr.c */
! /* */
! /* OpenType font driver implementation (body). */
! /* */
! /* Copyright 1996-2018 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 <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_DEBUG_H
--- 1,21 ----
! /****************************************************************************
! *
! * cffdrivr.c
! *
! * OpenType font driver implementation (body).
! *
! * Copyright (C) 1996-2019 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 <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_DEBUG_H
*** 40,65 ****
#include FT_SERVICE_MULTIPLE_MASTERS_H
#include FT_SERVICE_METRICS_VARIATIONS_H
#endif
#include "cfferrs.h"
- #include "cffpic.h"
#include FT_SERVICE_FONT_FORMAT_H
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_PROPERTIES_H
#include FT_DRIVER_H
! /*************************************************************************/
! /* */
! /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
! /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
! /* messages during execution. */
! /* */
#undef FT_COMPONENT
! #define FT_COMPONENT trace_cffdriver
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
--- 40,64 ----
#include FT_SERVICE_MULTIPLE_MASTERS_H
#include FT_SERVICE_METRICS_VARIATIONS_H
#endif
#include "cfferrs.h"
#include FT_SERVICE_FONT_FORMAT_H
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_PROPERTIES_H
#include FT_DRIVER_H
! /**************************************************************************
! *
! * The macro FT_COMPONENT is used in trace mode. It is an implicit
! * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
! * messages during execution.
! */
#undef FT_COMPONENT
! #define FT_COMPONENT cffdriver
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
*** 71,112 ****
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
! /*************************************************************************/
! /* */
! /* <Function> */
! /* cff_get_kerning */
! /* */
! /* <Description> */
! /* A driver method used to return the kerning vector between two */
! /* glyphs of the same face. */
! /* */
! /* <Input> */
! /* face :: A handle to the source face object. */
! /* */
! /* left_glyph :: The index of the left glyph in the kern pair. */
! /* */
! /* right_glyph :: The index of the right glyph in the kern pair. */
! /* */
! /* <Output> */
! /* kerning :: The kerning vector. This is in font units for */
! /* scalable formats, and in pixels for fixed-sizes */
! /* formats. */
! /* */
! /* <Return> */
! /* FreeType error code. 0 means success. */
! /* */
! /* <Note> */
! /* Only horizontal layouts (left-to-right & right-to-left) are */
! /* supported by this function. Other layouts, or more sophisticated */
! /* kernings, are out of scope of this method (the basic driver */
! /* interface is meant to be simple). */
! /* */
! /* They can be implemented by format-specific interfaces. */
! /* */
FT_CALLBACK_DEF( FT_Error )
cff_get_kerning( FT_Face ttface, /* TT_Face */
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
--- 70,115 ----
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
! /**************************************************************************
! *
! * @Function:
! * cff_get_kerning
! *
! * @Description:
! * A driver method used to return the kerning vector between two
! * glyphs of the same face.
! *
! * @Input:
! * face ::
! * A handle to the source face object.
! *
! * left_glyph ::
! * The index of the left glyph in the kern pair.
! *
! * right_glyph ::
! * The index of the right glyph in the kern pair.
! *
! * @Output:
! * kerning ::
! * The kerning vector. This is in font units for
! * scalable formats, and in pixels for fixed-sizes
! * formats.
! *
! * @Return:
! * FreeType error code. 0 means success.
! *
! * @Note:
! * Only horizontal layouts (left-to-right & right-to-left) are
! * supported by this function. Other layouts, or more sophisticated
! * kernings, are out of scope of this method (the basic driver
! * interface is meant to be simple).
! *
! * They can be implemented by format-specific interfaces.
! */
FT_CALLBACK_DEF( FT_Error )
cff_get_kerning( FT_Face ttface, /* TT_Face */
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
*** 123,158 ****
return FT_Err_Ok;
}
! /*************************************************************************/
! /* */
! /* <Function> */
! /* cff_glyph_load */
! /* */
! /* <Description> */
! /* A driver method used to load a glyph within a given glyph slot. */
! /* */
! /* <Input> */
! /* slot :: A handle to the target slot object where the glyph */
! /* will be loaded. */
! /* */
! /* size :: A handle to the source face size at which the glyph */
! /* must be scaled, loaded, etc. */
! /* */
! /* glyph_index :: The index of the glyph in the font file. */
! /* */
! /* load_flags :: A flag indicating what to load for this glyph. The */
! /* FT_LOAD_??? constants can be used to control the */
! /* glyph loading process (e.g., whether the outline */
! /* should be scaled, whether to load bitmaps or not, */
! /* whether to hint the outline, etc). */
! /* */
! /* <Return> */
! /* FreeType error code. 0 means success. */
! /* */
FT_CALLBACK_DEF( FT_Error )
cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */
FT_Size cffsize, /* CFF_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
--- 126,165 ----
return FT_Err_Ok;
}
! /**************************************************************************
! *
! * @Function:
! * cff_glyph_load
! *
! * @Description:
! * A driver method used to load a glyph within a given glyph slot.
! *
! * @Input:
! * slot ::
! * A handle to the target slot object where the glyph
! * will be loaded.
! *
! * size ::
! * A handle to the source face size at which the glyph
! * must be scaled, loaded, etc.
! *
! * glyph_index ::
! * The index of the glyph in the font file.
! *
! * load_flags ::
! * A flag indicating what to load for this glyph. The
! * FT_LOAD_??? constants can be used to control the
! * glyph loading process (e.g., whether the outline
! * should be scaled, whether to load bitmaps or not,
! * whether to hint the outline, etc).
! *
! * @Return:
! * FreeType error code. 0 means success.
! */
FT_CALLBACK_DEF( FT_Error )
cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */
FT_Size cffsize, /* CFF_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
*** 339,360 ****
else
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from a CFF2 font\n"
" "
! " without the `PSNames' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
}
if ( !font->psnames )
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from CFF & CEF fonts\n"
" "
! " without the `PSNames' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
/* first, locate the sid in the charset table */
--- 346,367 ----
else
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from a CFF2 font\n"
" "
! " without the `psnames' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
}
if ( !font->psnames )
{
FT_ERROR(( "cff_get_glyph_name:"
" cannot get glyph name from CFF & CEF fonts\n"
" "
! " without the `psnames' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
/* first, locate the sid in the charset table */
*** 406,416 ****
else
{
FT_ERROR(( "cff_get_name_index:"
" cannot get glyph index from a CFF2 font\n"
" "
! " without the `PSNames' module\n" ));
return 0;
}
}
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
--- 413,423 ----
else
{
FT_ERROR(( "cff_get_name_index:"
" cannot get glyph index from a CFF2 font\n"
" "
! " without the `psnames' module\n" ));
return 0;
}
}
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
*** 652,663 ****
FT_Face face = FT_CMAP_FACE( cmap );
FT_Library library = FT_FACE_LIBRARY( face );
! if ( cmap->clazz != &CFF_CMAP_ENCODING_CLASS_REC_GET &&
! cmap->clazz != &CFF_CMAP_UNICODE_CLASS_REC_GET )
{
FT_Module sfnt = FT_Get_Module( library, "sfnt" );
FT_Service_TTCMaps service =
(FT_Service_TTCMaps)ft_module_get_service( sfnt,
FT_SERVICE_ID_TT_CMAP,
--- 659,670 ----
FT_Face face = FT_CMAP_FACE( cmap );
FT_Library library = FT_FACE_LIBRARY( face );
! if ( cmap->clazz != &cff_cmap_encoding_class_rec &&
! cmap->clazz != &cff_cmap_unicode_class_rec )
{
FT_Module sfnt = FT_Get_Module( library, "sfnt" );
FT_Service_TTCMaps service =
(FT_Service_TTCMaps)ft_module_get_service( sfnt,
FT_SERVICE_ID_TT_CMAP,
*** 786,796 ****
{
error = FT_THROW( Invalid_Argument );
goto Fail;
}
! if ( glyph_index > cff->num_glyphs )
{
error = FT_THROW( Invalid_Argument );
goto Fail;
}
--- 793,803 ----
{
error = FT_THROW( Invalid_Argument );
goto Fail;
}
! if ( glyph_index >= cff->num_glyphs )
{
error = FT_THROW( Invalid_Argument );
goto Fail;
}
*** 859,868 ****
--- 866,899 ----
return mm->get_mm_blend( FT_FACE( face ), num_coords, coords );
}
static FT_Error
+ cff_set_mm_weightvector( CFF_Face face,
+ FT_UInt len,
+ FT_Fixed* weightvector )
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
+
+
+ return mm->set_mm_weightvector( FT_FACE( face ), len, weightvector );
+ }
+
+
+ static FT_Error
+ cff_get_mm_weightvector( CFF_Face face,
+ FT_UInt* len,
+ FT_Fixed* weightvector )
+ {
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
+
+
+ return mm->get_mm_weightvector( FT_FACE( face ), len, weightvector );
+ }
+
+
+ static FT_Error
cff_get_mm_var( CFF_Face face,
FT_MM_Var* *master )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
*** 912,924 ****
(FT_Get_MM_Func) NULL, /* get_mm */
(FT_Set_MM_Design_Func) NULL, /* set_mm_design */
(FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */
(FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */
(FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */
! (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */
! (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */
(FT_Set_Instance_Func) cff_set_instance, /* set_instance */
(FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */
(FT_Done_Blend_Func) cff_done_blend /* done_blend */
)
--- 943,957 ----
(FT_Get_MM_Func) NULL, /* get_mm */
(FT_Set_MM_Design_Func) NULL, /* set_mm_design */
(FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */
(FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */
(FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */
! (FT_Set_Var_Design_Func) cff_set_var_design, /* set_var_design */
! (FT_Get_Var_Design_Func) cff_get_var_design, /* get_var_design */
(FT_Set_Instance_Func) cff_set_instance, /* set_instance */
+ (FT_Set_MM_WeightVector_Func)cff_set_mm_weightvector, /* set_mm_weightvector */
+ (FT_Get_MM_WeightVector_Func)cff_get_mm_weightvector, /* get_mm_weightvector */
(FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */
(FT_Done_Blend_Func) cff_done_blend /* done_blend */
)
*** 999,1056 ****
defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC10(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
! FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
! FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
! FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
! FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
! FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
! FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
! FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
! FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
! FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
! FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
! FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC9(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
! FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
! FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
! FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
! FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
! FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#else
FT_DEFINE_SERVICEDESCREC7(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
! FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
! FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
! FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
! FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#endif
FT_CALLBACK_DEF( FT_Module_Interface )
--- 1032,1089 ----
defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC10(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters,
! FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_variations,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name,
! FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict,
! FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info,
! FT_SERVICE_ID_CID, &cff_service_cid_info,
! FT_SERVICE_ID_PROPERTIES, &cff_service_properties,
! FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load
)
#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name,
! FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict,
! FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info,
! FT_SERVICE_ID_CID, &cff_service_cid_info,
! FT_SERVICE_ID_PROPERTIES, &cff_service_properties,
! FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC9(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters,
! FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_var,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name,
! FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info,
! FT_SERVICE_ID_CID, &cff_service_cid_info,
! FT_SERVICE_ID_PROPERTIES, &cff_service_properties,
! FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load
)
#else
FT_DEFINE_SERVICEDESCREC7(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
! FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info,
! FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name,
! FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info,
! FT_SERVICE_ID_CID, &cff_service_cid_info,
! FT_SERVICE_ID_PROPERTIES, &cff_service_properties,
! FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load
)
#endif
FT_CALLBACK_DEF( FT_Module_Interface )
*** 1060,1090 ****
FT_Library library;
FT_Module sfnt;
FT_Module_Interface result;
! /* CFF_SERVICES_GET dereferences `library' in PIC mode */
! #ifdef FT_CONFIG_OPTION_PIC
! if ( !driver )
! return NULL;
! library = driver->library;
! if ( !library )
! return NULL;
! #endif
!
! result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface );
if ( result )
return result;
! /* `driver' is not yet evaluated in non-PIC mode */
! #ifndef FT_CONFIG_OPTION_PIC
if ( !driver )
return NULL;
library = driver->library;
if ( !library )
return NULL;
- #endif
/* we pass our request to the `sfnt' module */
sfnt = FT_Get_Module( library, "sfnt" );
return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
--- 1093,1112 ----
FT_Library library;
FT_Module sfnt;
FT_Module_Interface result;
! result = ft_service_list_lookup( cff_services, module_interface );
if ( result )
return result;
! /* `driver' is not yet evaluated */
if ( !driver )
return NULL;
library = driver->library;
if ( !library )
return NULL;
/* we pass our request to the `sfnt' module */
sfnt = FT_Get_Module( library, "sfnt" );
return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
< prev index next >