Location of TTF font files in cocos2d-x

Source: Internet
Author: User

In the cocos2d-x, the font file needs to be saved in the fonts folder, which is automatically added if the fonts/is not in the fonts path.

If the font name does not have a. TTF suffix, the suffix is automatically added.

Unsigned Char * Ccfreetypefont: loadfont ( Const   Char * Pfontname, ssize_t * Size) {STD ::  String  Lowercase (pfontname); STD ::  String  PATH (pfontname ); For (Unsigned Int I = 0 ; I <lowercase. Length (); ++ I) {lowercase [I] = Tolower (lowercase [I]);}  If (STD :: String : NPOs = lowercase. Find ( "  Fonts/  "  ) {Path = "  Fonts/ "  ; Path + = Pfontname ;}  If (STD :: String : NPOs = lowercase. Find ( "  . TTF  "  ) {Path + = "  . TTF  "  ;} STD ::  String Fullpath = fileutils: getinstance ()->Fullpathforfilename (path. c_str ());  Return Fileutils: sharedfileutils ()-> getfiledata (fullpath. c_str (), "  RB  "  , Size );} 

String: NPOs is-1, indicating that no substring is found. The find method is used to find whether fonts is included in the font name.

Location of TTF font files in cocos2d-x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.