[base] Introduce `FT_New_Glyph'.
This function facilitates access to full capabilities of FreeType rendering engine for custom glyphs. This can be quite useful for consistent rendering of mathematical and chemical formulas, e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=757078 * include/freetype/ftglyph.h, src/base/ftglyph.c (FT_New_Glyph): New function.
This commit is contained in:
parent
e13599a036
commit
b1a3c59f8d
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2018-06-17 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||
|
||||
[base] Introduce `FT_New_Glyph'.
|
||||
|
||||
This function facilitates access to full capabilities of FreeType
|
||||
rendering engine for custom glyphs. This can be quite useful for
|
||||
consistent rendering of mathematical and chemical formulas, e.g.
|
||||
|
||||
https://bugs.chromium.org/p/chromium/issues/detail?id=757078
|
||||
|
||||
* include/freetype/ftglyph.h, src/base/ftglyph.c (FT_New_Glyph): New
|
||||
function.
|
||||
|
||||
2018-06-17 Armin Hasitzka <prince.cherusker@gmail.com>
|
||||
|
||||
[bdf] Fix underflow of an unsigned value.
|
||||
|
|
|
@ -223,6 +223,35 @@ FT_BEGIN_HEADER
|
|||
} FT_OutlineGlyphRec;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_New_Glyph
|
||||
*
|
||||
* @description:
|
||||
* A function used to create a new empty glyph image. Note that
|
||||
* the created @FT_Glyph object must be released with @FT_Done_Glyph.
|
||||
*
|
||||
* @input:
|
||||
* library :: A handle to the FreeType library object.
|
||||
*
|
||||
* format :: The format of the glyph's image.
|
||||
*
|
||||
* @output:
|
||||
* aglyph :: A handle to the glyph object.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @since
|
||||
* 2.10
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Glyph( FT_Library library,
|
||||
FT_Glyph_Format format,
|
||||
FT_Glyph *aglyph );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
|
|
|
@ -358,37 +358,28 @@
|
|||
|
||||
/* documentation is in ftglyph.h */
|
||||
|
||||
FT_EXPORT_DEF( FT_Error )
|
||||
FT_Get_Glyph( FT_GlyphSlot slot,
|
||||
FT_Glyph *aglyph )
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Glyph( FT_Library library,
|
||||
FT_Glyph_Format format,
|
||||
FT_Glyph *aglyph )
|
||||
{
|
||||
FT_Library library;
|
||||
FT_Error error;
|
||||
FT_Glyph glyph;
|
||||
|
||||
const FT_Glyph_Class* clazz = NULL;
|
||||
|
||||
|
||||
if ( !slot )
|
||||
return FT_THROW( Invalid_Slot_Handle );
|
||||
|
||||
library = slot->library;
|
||||
|
||||
if ( !aglyph )
|
||||
if ( !library || !aglyph )
|
||||
return FT_THROW( Invalid_Argument );
|
||||
|
||||
/* if it is a bitmap, that's easy :-) */
|
||||
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
|
||||
if ( format == FT_GLYPH_FORMAT_BITMAP )
|
||||
clazz = &ft_bitmap_glyph_class;
|
||||
|
||||
/* if it is an outline */
|
||||
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
||||
else if ( format == FT_GLYPH_FORMAT_OUTLINE )
|
||||
clazz = &ft_outline_glyph_class;
|
||||
|
||||
else
|
||||
{
|
||||
/* try to find a renderer that supports the glyph image format */
|
||||
FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 );
|
||||
FT_Renderer render = FT_Lookup_Renderer( library, format, 0 );
|
||||
|
||||
|
||||
if ( render )
|
||||
|
@ -396,13 +387,31 @@
|
|||
}
|
||||
|
||||
if ( !clazz )
|
||||
{
|
||||
error = FT_THROW( Invalid_Glyph_Format );
|
||||
goto Exit;
|
||||
}
|
||||
return FT_THROW( Invalid_Glyph_Format );
|
||||
|
||||
/* create FT_Glyph object */
|
||||
error = ft_new_glyph( library, clazz, &glyph );
|
||||
return ft_new_glyph( library, clazz, aglyph );
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in ftglyph.h */
|
||||
|
||||
FT_EXPORT_DEF( FT_Error )
|
||||
FT_Get_Glyph( FT_GlyphSlot slot,
|
||||
FT_Glyph *aglyph )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Glyph glyph;
|
||||
|
||||
|
||||
if ( !slot )
|
||||
return FT_THROW( Invalid_Slot_Handle );
|
||||
|
||||
if ( !aglyph )
|
||||
return FT_THROW( Invalid_Argument );
|
||||
|
||||
/* create FT_Glyph object */
|
||||
error = FT_New_Glyph( slot->library, slot->format, &glyph );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
|
||||
|
@ -426,7 +435,7 @@
|
|||
glyph->advance.y = slot->advance.y * 1024;
|
||||
|
||||
/* now import the image from the glyph slot */
|
||||
error = clazz->glyph_init( glyph, slot );
|
||||
error = glyph->clazz->glyph_init( glyph, slot );
|
||||
|
||||
Exit2:
|
||||
/* if an error occurred, destroy the glyph */
|
||||
|
|
Loading…
Reference in New Issue