freetype2/src/pfr/pfrdrivr.c

215 lines
5.5 KiB
C
Raw Normal View History

/***************************************************************************/
/* */
/* pfrdrivr.c */
/* */
/* FreeType PFR driver interface (body). */
/* */
2011-11-30 13:10:54 +01:00
/* Copyright 2002-2004, 2006, 2008, 2010, 2011 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_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_SERVICE_PFR_H
#include FT_SERVICE_XFREE86_NAME_H
#include "pfrdrivr.h"
#include "pfrobjs.h"
#include "pfrerror.h"
FT_CALLBACK_DEF( FT_Error )
pfr_get_kerning( FT_Face pfrface, /* PFR_Face */
FT_UInt left,
FT_UInt right,
FT_Vector *avector )
{
PFR_Face face = (PFR_Face)pfrface;
PFR_PhyFont phys = &face->phy_font;
pfr_face_get_kerning( pfrface, left, right, avector );
/* 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 );
if ( avector->y != 0 )
avector->y = FT_MulDiv( avector->x, phys->outline_resolution,
phys->metrics_resolution );
}
* 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;
}
/*
* PFR METRICS SERVICE
*
*/
FT_CALLBACK_DEF( FT_Error )
pfr_get_advance( FT_Face pfrface, /* PFR_Face */
FT_UInt gindex,
2003-11-28 23:01:02 +01:00
FT_Pos *anadvance )
{
PFR_Face face = (PFR_Face)pfrface;
FT_Error error = PFR_Err_Invalid_Argument;
2003-11-28 23:01:02 +01:00
*anadvance = 0;
if ( !gindex )
goto Exit;
gindex--;
if ( face )
{
PFR_PhyFont phys = &face->phy_font;
if ( gindex < phys->num_chars )
{
2003-11-28 23:01:02 +01:00
*anadvance = phys->chars[gindex].advance;
error = PFR_Err_Ok;
}
}
Exit:
return error;
}
FT_CALLBACK_DEF( FT_Error )
pfr_get_metrics( FT_Face pfrface, /* PFR_Face */
2003-11-28 23:01:02 +01:00
FT_UInt *anoutline_resolution,
FT_UInt *ametrics_resolution,
FT_Fixed *ametrics_x_scale,
FT_Fixed *ametrics_y_scale )
{
PFR_Face face = (PFR_Face)pfrface;
PFR_PhyFont phys = &face->phy_font;
FT_Fixed x_scale, y_scale;
FT_Size size = face->root.size;
2003-11-28 23:01:02 +01:00
if ( anoutline_resolution )
*anoutline_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;
return PFR_Err_Ok;
}
FT_CALLBACK_TABLE_DEF
const FT_Service_PfrMetricsRec pfr_metrics_service_rec =
{
pfr_get_metrics,
pfr_face_get_kerning,
pfr_get_advance
};
/*
* SERVICE LIST
*
*/
static const FT_ServiceDescRec pfr_services[] =
{
{ FT_SERVICE_ID_PFR_METRICS, &pfr_metrics_service_rec },
2003-10-23 06:54:14 +02:00
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_PFR },
{ NULL, NULL }
};
FT_CALLBACK_DEF( FT_Module_Interface )
pfr_get_service( FT_Module module,
const FT_String* service_id )
{
FT_UNUSED( module );
return ft_service_list_lookup( pfr_services, service_id );
}
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pfr_driver_class =
{
{
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE,
2011-11-30 10:46:53 +01:00
sizeof ( FT_DriverRec ),
"pfr",
0x10000L,
0x20000L,
NULL,
2011-11-30 13:10:54 +01:00
0, /* FT_Module_Constructor */
0, /* FT_Module_Destructor */
pfr_get_service
},
2011-11-30 10:46:53 +01:00
sizeof ( PFR_FaceRec ),
sizeof ( PFR_SizeRec ),
sizeof ( PFR_SlotRec ),
pfr_face_init,
pfr_face_done,
0, /* FT_Size_InitFunc */
0, /* FT_Size_DoneFunc */
pfr_slot_init,
pfr_slot_done,
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
ft_stub_set_char_sizes,
ft_stub_set_pixel_sizes,
#endif
pfr_slot_load,
pfr_get_kerning,
0, /* FT_Face_AttachFunc */
2011-11-30 10:46:53 +01:00
0, /* FT_Face_GetAdvancesFunc */
0, /* FT_Size_RequestFunc */
0, /* FT_Size_SelectFunc */
};
/* END */