label 可以帶多個字型嗎?

請問cc.label要怎麼實現css的 (font-family: Arial, ‘新細明體’, sans-serif;)引用多個字型的效果

对于TTF字体,系统使用的freetype解析,只解析了第0个face,所以暂时不支持同一个字体多个字形。
代码实现:

https://github.com/cocos2d/cocos2d-x/blob/42c2ff27e097e25879f38174cfd0b431ae85f9ec/cocos/2d/CCFontFreeType.cpp#L144

相关知识,FreeType文档:https://www.freetype.org/freetype2/docs/tutorial/step1.html#section-4

Create a new face object by calling FT_New_Face. A face describes a given typeface and style. For example, ‘Times New Roman Regular’ and ‘Times New Roman Italic’ correspond to two different faces.

FT_Library  library;   /* handle to library     */
FT_Face     face;      /* handle to face object */


error = FT_Init_FreeType( &library );
if ( error ) { ... }

error = FT_New_Face( library,
                     "/usr/share/fonts/truetype/arial.ttf",
                     0,
                     &face );
if ( error == FT_Err_Unknown_File_Format )
{
  ... the font file could be opened and read, but it appears
  ... that its font format is unsupported
}
else if ( error )
{
  ... another error code means that the font file could not
  ... be opened or read, or that it is broken...
}
As you can certainly imagine, FT_New_Face opens a font file, then tries to extract one face from it. Its parameters are as follows.

library
A handle to the FreeType library instance where the face object is created.
filepathname
The font file pathname (a standard C string).
face_index
Certain font formats allow several font faces to be embedded in a single file.

This index tells which face you want to load. An error is returned if its value is too large.

Index 0 always works, though.

face
A pointer to the handle that is set to describe the new face object.

It is set to NULL in case of error.

To know how many faces a given font file contains, set face_index to -1, then check the value of face->num_faces, which indicates how many faces are embedded in the font file