mirror of https://github.com/axmolengine/axmol.git
Merge branch 'gles20' of https://github.com/cocos2d/cocos2d-x into gles20
This commit is contained in:
commit
816c1b4362
|
@ -1,5 +1,99 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "scripting\lua\proj.win32\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "samples\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "samples\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28}
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159}
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
|
||||
{929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116}
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}"
|
||||
EndProject
|
||||
|
@ -92,97 +186,3 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosDenshion", "CocosDenshion\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "cocos2dx\proj.win32\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "scripting\lua\proj.win32\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "samples\HelloLua\proj.win32\HelloLua.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "samples\HelloCpp\proj.win32\HelloCpp.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCpp", "samples\TestCpp\proj.win32\TestCpp.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\TestJavascript\proj.win32\TestJavascript.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28}
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159}
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
|
||||
{929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116}
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.Build.0 = Release|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}.Release|Win32.Build.0 = Release|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{DDC3E27F-004D-4DD4-9DD3-931A013D2159}.Release|Win32.Build.0 = Release|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1260,6 +1260,12 @@ void CCLabelBMFont::updateLabel()
|
|||
{
|
||||
float lineWidth = 0.0f;
|
||||
unsigned int line_length = last_line.size();
|
||||
// if last line is empty we must just increase lineNumber and work with next line
|
||||
if (line_length == 0)
|
||||
{
|
||||
lineNumber++;
|
||||
continue;
|
||||
}
|
||||
int index = i + line_length - 1 + lineNumber;
|
||||
if (index < 0) continue;
|
||||
|
||||
|
|
|
@ -22,8 +22,23 @@
|
|||
using namespace std;
|
||||
|
||||
struct TextLine {
|
||||
string sLineStr;
|
||||
int iLineWidth;
|
||||
wchar_t* text;
|
||||
};
|
||||
|
||||
struct FontTableItem {
|
||||
char* family_name;
|
||||
char* style_name;
|
||||
char* filename;
|
||||
};
|
||||
|
||||
const int fontTableItems = 4;
|
||||
const char* fontPath = "/usr/share/fonts/truetype/";
|
||||
FontTableItem fontsTable[fontTableItems] = {
|
||||
{ "Serif", "Medium", "freefont/FreeSerif.ttf" },
|
||||
{ "Sans", "Medium", "freefont/FreeSans.ttf" },
|
||||
{ "WenQuanYi Micro Hei", "Regular", "wqy/wqy-microhei.ttc" },
|
||||
{ "WenQuanYi Zen Hei", "Regular", "wqy/wqy-zenhei.ttc" },
|
||||
};
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -43,89 +58,134 @@ public:
|
|||
// if (m_pData) {
|
||||
// delete m_pData;
|
||||
// }
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
iMaxLineWidth = 0;
|
||||
iMaxLineHeight = 0;
|
||||
vLines.clear();
|
||||
//Free all text lines
|
||||
size_t size = vLines.size();
|
||||
for (int i=0; i<size; ++i) {
|
||||
TextLine line = vLines[i];
|
||||
free(line.text);
|
||||
}
|
||||
vLines.clear();
|
||||
}
|
||||
|
||||
void buildLine(stringstream& ss, FT_Face face, int iCurXCursor, char cLastChar) {
|
||||
TextLine oTempLine;
|
||||
ss << '\0';
|
||||
oTempLine.sLineStr = ss.str();
|
||||
//get last glyph
|
||||
FT_Load_Glyph(face, FT_Get_Char_Index(face, cLastChar),
|
||||
FT_LOAD_DEFAULT);
|
||||
int utf8(char **p)
|
||||
{
|
||||
if ((**p & 0x80) == 0x00)
|
||||
{
|
||||
int a = *((*p)++);
|
||||
|
||||
oTempLine.iLineWidth = iCurXCursor - SHIFT6((face->glyph->metrics.horiAdvance + face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval
|
||||
return a;
|
||||
}
|
||||
if ((**p & 0xE0) == 0xC0)
|
||||
{
|
||||
int a = *((*p)++) & 0x1F;
|
||||
int b = *((*p)++) & 0x3F;
|
||||
|
||||
return (a << 6) | b;
|
||||
}
|
||||
if ((**p & 0xF0) == 0xE0)
|
||||
{
|
||||
int a = *((*p)++) & 0x0F;
|
||||
int b = *((*p)++) & 0x3F;
|
||||
int c = *((*p)++) & 0x3F;
|
||||
|
||||
return (a << 12) | (b << 6) | c;
|
||||
}
|
||||
if ((**p & 0xF8) == 0xF0)
|
||||
{
|
||||
int a = *((*p)++) & 0x07;
|
||||
int b = *((*p)++) & 0x3F;
|
||||
int c = *((*p)++) & 0x3F;
|
||||
int d = *((*p)++) & 0x3F;
|
||||
|
||||
return (a << 18) | (b << 12) | (c << 8) | d;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void buildLine(wchar_t* buf, size_t buf_len, FT_Face face, int iCurXCursor, FT_UInt cLastChar) {
|
||||
TextLine oTempLine;
|
||||
wchar_t* text = (wchar_t*)malloc(sizeof(wchar_t) * (buf_len+1));
|
||||
memcpy(text, buf, sizeof(wchar_t) * buf_len);
|
||||
text[buf_len] = '\0';
|
||||
oTempLine.text = text;
|
||||
|
||||
//get last glyph
|
||||
int iError = FT_Load_Char(face, cLastChar, FT_LOAD_DEFAULT);
|
||||
|
||||
oTempLine.iLineWidth = iCurXCursor;// - SHIFT6((face->glyph->metrics.horiAdvance + face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval
|
||||
iMaxLineWidth = MAX(iMaxLineWidth, oTempLine.iLineWidth);
|
||||
|
||||
ss.clear();
|
||||
ss.str("");
|
||||
vLines.push_back(oTempLine);
|
||||
vLines.push_back(oTempLine);
|
||||
}
|
||||
|
||||
bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) {
|
||||
const char* pText = sText;
|
||||
int iError = 0;
|
||||
int iCurXCursor, iCurYCursor;
|
||||
iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText),
|
||||
FT_LOAD_DEFAULT);
|
||||
const char* pText = sText;
|
||||
|
||||
FT_UInt unicode = utf8((char**)&pText);
|
||||
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||
if (iError) {
|
||||
return false;
|
||||
}
|
||||
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
|
||||
|
||||
//init stringstream
|
||||
stringstream ss;
|
||||
FT_UInt cLastCh = 0;
|
||||
|
||||
int cLastCh = 0;
|
||||
pText = sText;
|
||||
size_t text_len = 0;
|
||||
wchar_t* text_buf = (wchar_t*) malloc(sizeof(wchar_t) * strlen(sText));
|
||||
while (unicode=utf8((char**)&pText)) {
|
||||
if (unicode == '\n') {
|
||||
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
|
||||
text_len = 0;
|
||||
|
||||
while (*pText != '\0') {
|
||||
if (*pText == '\n') {
|
||||
buildLine(ss, face, iCurXCursor, cLastCh);
|
||||
|
||||
pText++;
|
||||
iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText),
|
||||
FT_LOAD_DEFAULT);
|
||||
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||
if (iError) {
|
||||
free(text_buf);
|
||||
return false;
|
||||
}
|
||||
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
|
||||
continue;
|
||||
}
|
||||
|
||||
iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText),
|
||||
FT_LOAD_DEFAULT);
|
||||
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||
|
||||
if (iError) {
|
||||
free(text_buf);
|
||||
return false;
|
||||
//break;
|
||||
}
|
||||
|
||||
//check its width
|
||||
//divide it when exceeding
|
||||
if ((iMaxWidth > 0
|
||||
&& iCurXCursor + SHIFT6(face->glyph->metrics.width)
|
||||
> iMaxWidth)) {
|
||||
buildLine(ss, face , iCurXCursor, cLastCh);
|
||||
buildLine(text_buf, text_len, face , iCurXCursor, cLastCh);
|
||||
text_len = 0;
|
||||
|
||||
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
|
||||
}
|
||||
|
||||
cLastCh = *pText;
|
||||
ss << *pText;
|
||||
cLastCh = unicode;
|
||||
text_buf[text_len] = unicode;
|
||||
++text_len;
|
||||
iCurXCursor += SHIFT6(face->glyph->metrics.horiAdvance) + iInterval;
|
||||
pText++;
|
||||
|
||||
}
|
||||
|
||||
if (iError) {
|
||||
free(text_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
buildLine(ss,face, iCurXCursor, cLastCh);
|
||||
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
|
||||
free(text_buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -137,11 +197,10 @@ public:
|
|||
* while -1 means fail
|
||||
*
|
||||
*/
|
||||
int computeLineStart(FT_Face face, CCImage::ETextAlign eAlignMask, char cText,
|
||||
int computeLineStart(FT_Face face, CCImage::ETextAlign eAlignMask, FT_UInt unicode,
|
||||
int iLineIndex) {
|
||||
int iRet;
|
||||
int iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, cText),
|
||||
FT_LOAD_DEFAULT);
|
||||
int iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||
if (iError) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -179,11 +238,33 @@ public:
|
|||
return iRet;
|
||||
}
|
||||
|
||||
char* getFontFile(const char* family_name) {
|
||||
char* ret = NULL;
|
||||
for (int i=0; i<fontTableItems; ++i) {
|
||||
FontTableItem* item = &fontsTable[i];
|
||||
if (strcmp(item->family_name, family_name) == 0) {
|
||||
size_t len = strlen(fontPath) + strlen(item->filename) + 1;
|
||||
ret = (char*) malloc(len);
|
||||
snprintf(ret, len, "%s%s", fontPath, item->filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return a default font , if font is not found
|
||||
if (ret == NULL) {
|
||||
FontTableItem* item = &fontsTable[0];
|
||||
size_t len = strlen(fontPath) + strlen(item->filename) + 1;
|
||||
ret = (char*) malloc(len);
|
||||
snprintf(ret, len, "%s%s", fontPath, item->filename);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool getBitmap(const char *text, int nWidth, int nHeight, CCImage::ETextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||
FT_Face face;
|
||||
FT_Error iError;
|
||||
|
||||
const char* pText = text;
|
||||
//data will be deleted by CCImage
|
||||
// if (m_pData) {
|
||||
// delete m_pData;
|
||||
|
@ -195,7 +276,9 @@ public:
|
|||
return false;
|
||||
}
|
||||
do {
|
||||
iError = FT_New_Face( library, pFontName, 0, &face );
|
||||
char* fontfile = getFontFile(pFontName);
|
||||
iError = FT_New_Face( library, fontfile, 0, &face );
|
||||
free(fontfile);
|
||||
|
||||
if (iError) {
|
||||
//no valid font found use default
|
||||
|
@ -216,8 +299,7 @@ public:
|
|||
//compute the final line width
|
||||
iMaxLineWidth = MAX(iMaxLineWidth, nWidth);
|
||||
|
||||
iMaxLineHeight = (face->size->metrics.ascender >> 6)
|
||||
- (face->size->metrics.descender >> 6);
|
||||
iMaxLineHeight = (face->size->metrics.ascender >> 6) - (face->size->metrics.descender >> 6);
|
||||
iMaxLineHeight *= vLines.size();
|
||||
|
||||
int txtHeight = iMaxLineHeight;
|
||||
|
@ -230,31 +312,34 @@ public:
|
|||
|
||||
memset(m_pData,0, iMaxLineWidth * iMaxLineHeight*4);
|
||||
|
||||
for (size_t i = 0; i < vLines.size(); i++) {
|
||||
pText = vLines[i].sLineStr.c_str();
|
||||
//initialize the origin cursor
|
||||
iCurXCursor = computeLineStart(face, eAlignMask, *pText, i);
|
||||
size_t lines = vLines.size();
|
||||
for (size_t i = 0; i < lines; i++) {
|
||||
const wchar_t* text_ptr = vLines[i].text;
|
||||
|
||||
while (*pText != 0) {
|
||||
int iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, *pText),
|
||||
FT_LOAD_RENDER);
|
||||
//initialize the origin cursor
|
||||
iCurXCursor = computeLineStart(face, eAlignMask, text_ptr[0], i);
|
||||
|
||||
size_t text_len = wcslen(text_ptr);
|
||||
for (size_t i=0; i<text_len; ++i) {
|
||||
int iError = FT_Load_Char(face, text_ptr[i], FT_LOAD_RENDER);
|
||||
if (iError) {
|
||||
break;
|
||||
}
|
||||
|
||||
// convert glyph to bitmap with 256 gray
|
||||
// and get the bitmap
|
||||
FT_Bitmap & bitmap = face->glyph->bitmap;
|
||||
FT_Bitmap& bitmap = face->glyph->bitmap;
|
||||
|
||||
int yoffset = iCurYCursor - (face->glyph->metrics.horiBearingY >> 6);
|
||||
int xoffset = iCurXCursor + (face->glyph->metrics.horiBearingX >> 6);
|
||||
for (int i = 0; i < bitmap.rows; ++i) {
|
||||
for (int j = 0; j < bitmap.width; ++j) {
|
||||
unsigned char cTemp = bitmap.buffer[i * bitmap.width + j];
|
||||
if (cTemp == 0) continue;
|
||||
|
||||
// if it has gray>0 we set show it as 1, o otherwise
|
||||
int iY = iCurYCursor + i
|
||||
- (face->glyph->metrics.horiBearingY
|
||||
>> 6);
|
||||
int iX = iCurXCursor
|
||||
+ (face->glyph->metrics.horiBearingX
|
||||
>> 6) + j;
|
||||
int iY = yoffset + i;
|
||||
int iX = xoffset + j;
|
||||
|
||||
if (iY>=iMaxLineHeight) {
|
||||
//exceed the height truncate
|
||||
|
@ -270,20 +355,16 @@ public:
|
|||
// bitmap.buffer[i * bitmap.width + j];//G
|
||||
// m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] =
|
||||
// bitmap.buffer[i * bitmap.width + j];//B
|
||||
|
||||
int iTemp = 0;
|
||||
unsigned char cTemp = bitmap.buffer[i
|
||||
* bitmap.width + j];
|
||||
iTemp |= (cTemp ? 0xff : 0)<<24;
|
||||
iTemp |= cTemp << 16 | cTemp << 8 | cTemp;
|
||||
*(int*) &m_pData[(iY * iMaxLineWidth + iX)
|
||||
* 4 + 0] = iTemp;
|
||||
*(int*) &m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = iTemp;
|
||||
}
|
||||
}
|
||||
//step to next glyph
|
||||
iCurXCursor += (face->glyph->metrics.horiAdvance >> 6)
|
||||
+ iInterval;
|
||||
iCurXCursor += (face->glyph->metrics.horiAdvance >> 6) + iInterval;
|
||||
|
||||
pText++;
|
||||
}
|
||||
iCurYCursor += (face->size->metrics.ascender >> 6)
|
||||
- (face->size->metrics.descender >> 6);
|
||||
|
@ -301,9 +382,6 @@ public:
|
|||
FT_Done_Face(face);
|
||||
face = NULL;
|
||||
|
||||
//clear all lines
|
||||
vLines.clear();
|
||||
|
||||
//success;
|
||||
if (iError) {
|
||||
bRet = false;
|
||||
|
@ -344,9 +422,9 @@ bool CCImage::initWithString(
|
|||
|
||||
BitmapDC &dc = sharedBitmapDC();
|
||||
|
||||
const char* pFullFontName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
|
||||
//const char* pFullFontName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
|
||||
|
||||
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFullFontName, nSize));
|
||||
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));
|
||||
|
||||
// assign the dc.m_pData to m_pData in order to save time
|
||||
m_pData = dc.m_pData;
|
||||
|
|
Loading…
Reference in New Issue