Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 4a7e483

Browse files
committed
[[ libskia ]] Add accessor for FreeType face of SkTypeface
This patch adds the function SkTypeface_GetFTFace to allow access to the underlying FT_Face font handle.
1 parent 5ef533b commit 4a7e483

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef SkTypeface_FreeType_DEFINED
2+
#define SkTypeface_FreeType_DEFINED
3+
4+
#include "SkTypeface.h"
5+
6+
#include <ft2build.h>
7+
#include FT_FREETYPE_H
8+
9+
/**
10+
* Obtain access to the underlying FT_Face of a SkTypeface.
11+
* The FT_Face should be released with FT_Done_Face once finished.
12+
**/
13+
SK_API extern FT_Face SkTypeface_GetFTFace(const SkTypeface* face);
14+
15+
#endif // SkTypeface_FreeType_DEFINED

libskia/src/ports/SkFontHost_FreeType.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,20 @@ class AutoFTAccess {
418418

419419
///////////////////////////////////////////////////////////////////////////
420420

421+
extern FT_Face SkTypeface_GetFTFace(const SkTypeface* face);
422+
FT_Face SkTypeface_GetFTFace(const SkTypeface* face)
423+
{
424+
FT_Face t_face;
425+
gFTMutex.acquire();
426+
t_face = ref_ft_face(face);
427+
FT_Reference_Face(t_face);
428+
unref_ft_face(t_face);
429+
gFTMutex.release();
430+
return t_face;
431+
}
432+
433+
///////////////////////////////////////////////////////////////////////////
434+
421435
static bool canEmbed(FT_Face face) {
422436
FT_UShort fsType = FT_Get_FSType_Flags(face);
423437
return (fsType & (FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING |

0 commit comments

Comments
 (0)