freetype2/src/sfnt/ttgpos.h

54 lines
1.2 KiB
C
Raw Normal View History

Add support for kerning from 'GPOS' tables. This commit adds support for kerning from 'GPOS' tables, while maintaining support for basic 'kern' tables. `FT_HAS_KERNING` will be true for a font with either available and `FT_Get_Kerning` will still use the basic 'kern' table data if avilable, otherwise check the GPOS 'kern' feature. This feature is disabled by default; it can be enabled with the `TT_CONFIG_OPTION_GPOS_KERNING` flag. Only basic kerning (pair positioning with just an x advance) is supported from the GPOS layout features; support for that was added to make the existing `FT_Get_Kerning` API more consistently functional. FreeType does not intend to extend itself to further GPOS functionality though; a higher-level library like HarfBuzz can be used instead for that. * include/freetype/config/ftoption.h, include/devel/ftoption.h (TT_CONFIG_OPTION_GPOS_KERNING): New configuration option. * include/freetype/internal/fttrace.h: Add `ttgpos` trace handler. * include/freetype/internal/sfnt.h (SFNT_Interface): Add `load_gpos` and `get_gpos_kerning` fields. (FT_DEFINE_SFNT_INTERFACE): Updated. * include/freetype/internal/tttypes.h: Include `fttypes.h`. (TT_FaceRec) [TT_CONFIG_OPTION_GPOS_KERNING]: Add `gpos_table` and `gpos_kerning_available` fields. * src/sfnt/ttgpos.c, src/sfnt/ttgpos.h: New files. * src/sfnt/sfdriver.c [TT_CONFIG_OPTION_GPOS_KERNING]: Include `ttgpos.h`. (sfnt_interface): Updated. * src/sfnt/sfnt.c: Include `ttgpos.c`. * src/sfnt/sfobjs.c [TT_CONFIG_OPTION_GPOS_KERNING]: Include `ttgpos.h`. (sfnt_load_face) [TT_CONFIG_OPTION_GPOS_KERNING]: Load and free GPOS kerning data; check GPOS kerning availability. * src/truetype/ttdriver.c (tt_get_kerning): Use GPOS kerning if there's no 'kern' table.
2024-01-20 01:42:48 +01:00
/****************************************************************************
*
* ttgpos.c
*
* Load the TrueType GPOS table. The only GPOS layout feature this
* currently supports is kerning, from x advances in the pair adjustment
* layout feature.
*
* Copyright (C) 2024 by
* David Saltzman
*
* 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 TTGPOS_H_
#define TTGPOS_H_
#include <freetype/internal/ftstream.h>
#include <freetype/internal/tttypes.h>
FT_BEGIN_HEADER
#ifdef TT_CONFIG_OPTION_GPOS_KERNING
FT_LOCAL( FT_Error )
tt_face_load_gpos( TT_Face face,
FT_Stream stream );
FT_LOCAL( void )
tt_face_done_gpos( TT_Face face );
FT_LOCAL( FT_Int )
tt_face_get_gpos_kerning( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph );
#endif /* TT_CONFIG_OPTION_GPOS_KERNING */
FT_END_HEADER
#endif /* TTGPOS_H_ */
/* END */