2002-04-20 07:38:33 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* pfrdrivr.c */
|
|
|
|
/* */
|
|
|
|
/* FreeType PFR driver interface (body). */
|
|
|
|
/* */
|
2003-04-23 16:14:06 +02:00
|
|
|
/* Copyright 2002, 2003 by */
|
2002-04-20 07:38:33 +02:00
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2002-04-19 17:13:47 +02:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
2002-10-31 09:30:19 +01:00
|
|
|
#include FT_INTERNAL_PFR_H
|
2002-04-19 17:13:47 +02:00
|
|
|
#include "pfrdrivr.h"
|
|
|
|
#include "pfrobjs.h"
|
|
|
|
|
2003-09-12 22:32:51 +02:00
|
|
|
#include "pfrerror.h"
|
|
|
|
|
2002-04-19 17:13:47 +02:00
|
|
|
|
2002-10-31 09:30:19 +01:00
|
|
|
static FT_Error
|
|
|
|
pfr_get_kerning( PFR_Face face,
|
|
|
|
FT_UInt left,
|
|
|
|
FT_UInt right,
|
|
|
|
FT_Vector *avector )
|
|
|
|
{
|
2003-04-23 21:48:24 +02:00
|
|
|
PFR_PhyFont phys = &face->phy_font;
|
2002-10-31 09:30:19 +01:00
|
|
|
|
2003-04-23 16:14:06 +02:00
|
|
|
|
2003-04-23 21:48:24 +02:00
|
|
|
pfr_face_get_kerning( face, left, right, avector );
|
2003-04-23 16:14:06 +02:00
|
|
|
|
2003-04-23 21:48:24 +02:00
|
|
|
/* convert from metrics to outline units when necessary */
|
|
|
|
if ( phys->outline_resolution != phys->metrics_resolution )
|
|
|
|
{
|
|
|
|
if ( avector->x != 0 )
|
|
|
|
avector->x = FT_MulDiv( avector->x, phys->outline_resolution,
|
|
|
|
phys->metrics_resolution );
|
2002-10-31 09:30:19 +01:00
|
|
|
|
2003-04-23 21:48:24 +02:00
|
|
|
if ( avector->y != 0 )
|
|
|
|
avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
|
|
|
|
phys->metrics_resolution );
|
2002-10-31 09:30:19 +01:00
|
|
|
}
|
2003-04-23 16:14:06 +02:00
|
|
|
|
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in
computation of glyph_index.
(FNT_Size_Set_Pixels): To find a strike, first check pixel_height
only, then try to find a better hit by comparing pixel_width also.
Without this fix it isn't possible to access all strikes.
Also compute metrics.max_advance to be in sync with other bitmap
drivers.
* src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code.
(FT_Set_Pixel_Size): Assign value to `metrics' after validation of
arguments.
Synchronize computation of height and width for bitmap strikes. The
`width' field in the FT_Bitmap_Size structure is now only useful to
enumerate different strikes. The `max_advance' field of the
FT_Size_Metrics structure should be used to get the (maximum) width
of a strike.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single
argument to function.
* src/psnames/psmodule.c (ps_unicode_value): Handle `.' after
`uniXXXX' and `uXXXX[X[X]]'.
* src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/.
* src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c:
s/FT_Err_/FTC_Err_/.
* src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/.
* src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/.
* src/psaux/t1cmap.c: Include psauxerr.h.
s/FT_Err_/PSaux_Err_/.
* src/pshinter/pshnterr.h: New file.
* src/pshinter/rules.mk: Updated.
* src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h.
s/FT_Err_/PSH_Err_/.
* src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c:
s/FT_Err_/PFR_Err_/.
* src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/.
* src/truetype/ttgload.c: s/FT_Err_/TT_Err_/.
* src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define
FT_ERR_PREFIX and FT_ERR_BASE.
s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
|
|
|
return PFR_Err_Ok;
|
2002-10-31 09:30:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
pfr_get_advance( PFR_Face face,
|
|
|
|
FT_UInt gindex,
|
|
|
|
FT_Pos *aadvance )
|
|
|
|
{
|
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in
computation of glyph_index.
(FNT_Size_Set_Pixels): To find a strike, first check pixel_height
only, then try to find a better hit by comparing pixel_width also.
Without this fix it isn't possible to access all strikes.
Also compute metrics.max_advance to be in sync with other bitmap
drivers.
* src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code.
(FT_Set_Pixel_Size): Assign value to `metrics' after validation of
arguments.
Synchronize computation of height and width for bitmap strikes. The
`width' field in the FT_Bitmap_Size structure is now only useful to
enumerate different strikes. The `max_advance' field of the
FT_Size_Metrics structure should be used to get the (maximum) width
of a strike.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single
argument to function.
* src/psnames/psmodule.c (ps_unicode_value): Handle `.' after
`uniXXXX' and `uXXXX[X[X]]'.
* src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/.
* src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c:
s/FT_Err_/FTC_Err_/.
* src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/.
* src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/.
* src/psaux/t1cmap.c: Include psauxerr.h.
s/FT_Err_/PSaux_Err_/.
* src/pshinter/pshnterr.h: New file.
* src/pshinter/rules.mk: Updated.
* src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h.
s/FT_Err_/PSH_Err_/.
* src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c:
s/FT_Err_/PFR_Err_/.
* src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/.
* src/truetype/ttgload.c: s/FT_Err_/TT_Err_/.
* src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define
FT_ERR_PREFIX and FT_ERR_BASE.
s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
|
|
|
FT_Error error = PFR_Err_Bad_Argument;
|
2003-04-23 16:14:06 +02:00
|
|
|
|
2002-10-31 09:30:19 +01:00
|
|
|
|
|
|
|
*aadvance = 0;
|
|
|
|
if ( face )
|
|
|
|
{
|
|
|
|
PFR_PhyFont phys = &face->phy_font;
|
|
|
|
|
2003-04-23 16:14:06 +02:00
|
|
|
|
2002-10-31 09:30:19 +01:00
|
|
|
if ( gindex < phys->num_chars )
|
|
|
|
{
|
|
|
|
*aadvance = phys->chars[ gindex ].advance;
|
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
pfr_get_metrics( PFR_Face face,
|
|
|
|
FT_UInt *aoutline_resolution,
|
|
|
|
FT_UInt *ametrics_resolution,
|
|
|
|
FT_Fixed *ametrics_x_scale,
|
|
|
|
FT_Fixed *ametrics_y_scale )
|
|
|
|
{
|
|
|
|
PFR_PhyFont phys = &face->phy_font;
|
|
|
|
FT_Fixed x_scale, y_scale;
|
|
|
|
FT_Size size = face->root.size;
|
|
|
|
|
2003-04-23 16:14:06 +02:00
|
|
|
|
2002-10-31 09:30:19 +01:00
|
|
|
if ( aoutline_resolution )
|
|
|
|
*aoutline_resolution = phys->outline_resolution;
|
|
|
|
|
|
|
|
if ( ametrics_resolution )
|
|
|
|
*ametrics_resolution = phys->metrics_resolution;
|
|
|
|
|
|
|
|
x_scale = 0x10000L;
|
|
|
|
y_scale = 0x10000L;
|
|
|
|
|
|
|
|
if ( size )
|
|
|
|
{
|
|
|
|
x_scale = FT_DivFix( size->metrics.x_ppem << 6,
|
|
|
|
phys->metrics_resolution );
|
|
|
|
|
|
|
|
y_scale = FT_DivFix( size->metrics.y_ppem << 6,
|
|
|
|
phys->metrics_resolution );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ametrics_x_scale )
|
|
|
|
*ametrics_x_scale = x_scale;
|
|
|
|
|
|
|
|
if ( ametrics_y_scale )
|
|
|
|
*ametrics_y_scale = y_scale;
|
2002-11-06 23:32:54 +01:00
|
|
|
|
|
|
|
return 0;
|
2002-10-31 09:30:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_TABLE_DEF
|
|
|
|
const FT_PFR_ServiceRec pfr_service_rec =
|
|
|
|
{
|
|
|
|
(FT_PFR_GetMetricsFunc) pfr_get_metrics,
|
|
|
|
(FT_PFR_GetKerningFunc) pfr_get_kerning,
|
|
|
|
(FT_PFR_GetAdvanceFunc) pfr_get_advance
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-04-19 17:13:47 +02:00
|
|
|
FT_CALLBACK_TABLE_DEF
|
|
|
|
const FT_Driver_ClassRec pfr_driver_class =
|
|
|
|
{
|
|
|
|
{
|
* include/freetype/ftglyph.h (ft_glyph_bbox_unscaled,
ft_glyph_bbox_subpixels, ft_glyph_bbox_gridfit,
ft_glyph_bbox_truncate, ft_glyph_bbox_pixels): Replaced with
FT_GLYPH_BBOX_UNSCALED, FT_GLYPH_BBOX_SUBPIXELS,
FT_GLYPH_BBIX_GRIDFIT, FT_GLYPH_BBOX_TRUNCATE, FT_GLYPH_BBOX_PIXELS.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* include/freetype/ftmodule.h (ft_module_font_driver,
ft_module_renderer, ft_module_hinter, ft_module_styler,
ft_module_driver_scalable, ft_module_driver_no_outlines,
ft_module_driver_has_hinter): Replaced with FT_MODULE_FONT_DRIVER,
FT_MODULE_RENDERER, FT_MODULE_HINTER, FT_MODULE_STYLER,
FT_MODULE_DRIVER_SCALABLE, FT_MODULE_DRIVER_NO_OUTLINES,
FT_MODULE_DRIVER_HAS_HINTER.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* src/base/ftglyph.c (FT_Glyph_Get_CBox): Handle bbox_mode better
as enumeration.
* src/pcf/pcfdrivr.c (pcf_driver_class), src/winfonts/winfnt.c
(winfnt_driver_class), src/bdf/bdfdrivr.c (bdf_driver_class): Add
the FT_MODULE_DRIVER_NO_OUTLINES flag.
2003-06-17 12:42:27 +02:00
|
|
|
FT_MODULE_FONT_DRIVER |
|
|
|
|
FT_MODULE_DRIVER_SCALABLE,
|
2002-04-19 17:13:47 +02:00
|
|
|
|
|
|
|
sizeof( FT_DriverRec ),
|
|
|
|
|
|
|
|
"pfr",
|
|
|
|
0x10000L,
|
|
|
|
0x20000L,
|
|
|
|
|
2002-10-31 09:30:19 +01:00
|
|
|
(FT_PFR_Service) &pfr_service_rec, /* format interface */
|
2002-04-19 17:13:47 +02:00
|
|
|
|
2002-04-20 07:38:33 +02:00
|
|
|
(FT_Module_Constructor)NULL,
|
|
|
|
(FT_Module_Destructor) NULL,
|
|
|
|
(FT_Module_Requester) NULL
|
2002-04-19 17:13:47 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
sizeof( PFR_FaceRec ),
|
|
|
|
sizeof( PFR_SizeRec ),
|
|
|
|
sizeof( PFR_SlotRec ),
|
|
|
|
|
2002-04-20 07:38:33 +02:00
|
|
|
(FT_Face_InitFunc) pfr_face_init,
|
|
|
|
(FT_Face_DoneFunc) pfr_face_done,
|
|
|
|
(FT_Size_InitFunc) NULL,
|
|
|
|
(FT_Size_DoneFunc) NULL,
|
|
|
|
(FT_Slot_InitFunc) pfr_slot_init,
|
|
|
|
(FT_Slot_DoneFunc) pfr_slot_done,
|
2002-04-19 17:13:47 +02:00
|
|
|
|
2002-04-20 07:38:33 +02:00
|
|
|
(FT_Size_ResetPointsFunc) NULL,
|
|
|
|
(FT_Size_ResetPixelsFunc) NULL,
|
|
|
|
(FT_Slot_LoadFunc) pfr_slot_load,
|
2002-04-19 17:13:47 +02:00
|
|
|
|
2002-10-31 09:30:19 +01:00
|
|
|
(FT_Face_GetKerningFunc) pfr_get_kerning,
|
2002-04-20 07:38:33 +02:00
|
|
|
(FT_Face_AttachFunc) 0,
|
* include/freetype/config/ftoption.h, include/freetype/internal/tttypes.h,
src/base/ftobjs.c, src/bdf/bdfdrivr.c, src/cff/cffobjs.c,
src/pcf/pcfdrivr.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttcmap0.h, src/sfnt/ttload.c, src/type1/t1objs.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: code cleanup,
FT_CONFIG_OPTION_USE_CMAPS is now the default
2002-07-17 23:52:20 +02:00
|
|
|
(FT_Face_GetAdvancesFunc) 0
|
2002-04-19 17:13:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-04-20 07:38:33 +02:00
|
|
|
/* END */
|