mirror of https://github.com/axmolengine/axmol.git
use freetype
This commit is contained in:
parent
ea72e046c6
commit
e4af13f1f6
|
@ -1 +1 @@
|
|||
5849b6db4793caca0d24d7114bb5c2d694379b56
|
||||
ec5e1afbe876b72e97277ce13b4b1f8b1835eaea
|
|
@ -101,6 +101,10 @@ THE SOFTWARE.
|
|||
#include "label_nodes/CCLabelBMFontNew.h"
|
||||
#include "label_nodes/CCStringTTF.h"
|
||||
|
||||
// carloX
|
||||
#include "label_nodes/CCFontRenderFreeType.h"
|
||||
|
||||
|
||||
|
||||
// layers_scenes_transitions_nodes
|
||||
#include "layers_scenes_transitions_nodes/CCLayer.h"
|
||||
|
|
|
@ -6,13 +6,16 @@
|
|||
//
|
||||
//
|
||||
|
||||
#ifndef _FontIOS_h
|
||||
#define _FontIOS_h
|
||||
|
||||
#include <CoreText/CTFont.h>
|
||||
#ifndef _FontFreetype_h
|
||||
#define _FontFreetype_h
|
||||
|
||||
#include "CCFont.h"
|
||||
|
||||
|
||||
#include "ft2build.h"
|
||||
#include "CCStdC.h"
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class FontFreeType : public Font
|
||||
|
|
|
@ -10,8 +10,27 @@
|
|||
#include "CCTextImage.h"
|
||||
#include "CCFontRenderFreeType.h"
|
||||
|
||||
#include "ft2build.h"
|
||||
#include "CCStdC.h"
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FT_Library library;
|
||||
|
||||
void FontRenderFreeType::testRendering()
|
||||
{
|
||||
// begin freetype
|
||||
//FT_Init_FreeType( &library );
|
||||
|
||||
|
||||
|
||||
// end freetype
|
||||
//FT_Done_FreeType(library);
|
||||
|
||||
}
|
||||
|
||||
|
||||
unsigned char * FontRenderFreeType::preparePageGlyphData(TextPageDef *thePage, char *fontName, int fontSize)
|
||||
{
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
|
||||
virtual ~FontRenderFreeType() {}
|
||||
virtual unsigned char * preparePageGlyphData(TextPageDef *thePage, char *fontName, int fontSize);
|
||||
static void testRendering();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -109,17 +109,19 @@ void StringTTF::setLineBreakWithoutSpace(bool breakWithoutSpace)
|
|||
void StringTTF::setScale(float scale)
|
||||
{
|
||||
Node::setScale(scale);
|
||||
|
||||
alignText();
|
||||
}
|
||||
|
||||
void StringTTF::setScaleX(float scaleX)
|
||||
{
|
||||
Node::setScaleX(scaleX);
|
||||
alignText();
|
||||
}
|
||||
|
||||
void StringTTF::setScaleY(float scaleY)
|
||||
{
|
||||
Node::setScaleY(scaleY);
|
||||
alignText();
|
||||
}
|
||||
|
||||
void StringTTF::alignText()
|
||||
|
@ -349,16 +351,14 @@ Sprite * StringTTF::getSpriteForChar(unsigned short int theChar, int spriteIndex
|
|||
|
||||
float StringTTF::getLetterPosXLeft( Sprite* sp )
|
||||
{
|
||||
float scaleX = 1.0f;
|
||||
float scaleX = _scaleX;
|
||||
return sp->getPosition().x * scaleX - (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x);
|
||||
}
|
||||
|
||||
float StringTTF::getLetterPosXRight( Sprite* sp )
|
||||
{
|
||||
float scaleX = 1.0f;
|
||||
float retVal = 0;
|
||||
retVal = sp->getPosition().x * scaleX + (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x);
|
||||
return retVal;
|
||||
float scaleX = _scaleX;
|
||||
return sp->getPosition().x * scaleX + (sp->getContentSize().width * scaleX * sp->getAnchorPoint().x);
|
||||
}
|
||||
|
||||
int StringTTF::getCommonLineHeight()
|
||||
|
@ -484,4 +484,72 @@ void StringTTF::setLabelContentSize(const Size &newSize)
|
|||
setContentSize(newSize);
|
||||
}
|
||||
|
||||
|
||||
// RGBA protocol
|
||||
|
||||
|
||||
bool StringTTF::isOpacityModifyRGB() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void StringTTF::setOpacityModifyRGB(bool isOpacityModifyRGB)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned char StringTTF::getOpacity() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char StringTTF::getDisplayedOpacity() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void StringTTF::setOpacity(GLubyte opacity)
|
||||
{
|
||||
}
|
||||
void StringTTF::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
}
|
||||
|
||||
bool StringTTF::isCascadeOpacityEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void StringTTF::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
const Color3B& StringTTF::getColor(void) const
|
||||
{
|
||||
Color3B temp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
const Color3B& StringTTF::getDisplayedColor() const
|
||||
{
|
||||
Color3B temp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
void StringTTF::setColor(const Color3B& color)
|
||||
{
|
||||
}
|
||||
|
||||
void StringTTF::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
}
|
||||
|
||||
bool StringTTF::isCascadeColorEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void StringTTF::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class StringTTF : public Node , public LabelTextFormatProtocol
|
||||
class StringTTF : public Node , public LabelTextFormatProtocol, public RGBAProtocol
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
bool setText(char *pStringToRender, float lineWidth, TextAlignment alignment = kTextAlignmentLeft, bool lineBreakWithoutSpaces = false);
|
||||
|
||||
|
||||
// main interface
|
||||
virtual void setAlignment(TextAlignment alignment);
|
||||
virtual void setWidth(float width);
|
||||
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
||||
|
@ -48,7 +48,22 @@ public:
|
|||
virtual void setScaleX(float scaleX);
|
||||
virtual void setScaleY(float scaleY);
|
||||
|
||||
|
||||
// RGBAProtocol
|
||||
|
||||
virtual bool isOpacityModifyRGB() const;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||
virtual unsigned char getOpacity() const;
|
||||
virtual unsigned char getDisplayedOpacity() const;
|
||||
virtual void setOpacity(GLubyte opacity);
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||
virtual bool isCascadeOpacityEnabled() const;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||
virtual const Color3B& getColor(void) const;
|
||||
virtual const Color3B& getDisplayedColor() const;
|
||||
virtual void setColor(const Color3B& color);
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||
virtual bool isCascadeColorEnabled() const;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||
|
||||
// CCLabelTextFormat protocol implementation
|
||||
|
||||
|
|
|
@ -1669,6 +1669,12 @@ LabelDyamicTest::LabelDyamicTest()
|
|||
addChild(pTestString);
|
||||
|
||||
pTestString->setPosition(Point(0, size.height/2));
|
||||
|
||||
|
||||
// test freetype
|
||||
FontRenderFreeType::testRendering();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LabelDyamicTest::draw()
|
||||
|
|
|
@ -1 +1 @@
|
|||
a4fb641b06cb677ec70e75590817a11fdbd1822c
|
||||
cf5276283a0b42901ebfa9822cc1a0a7ad2a8663
|
Loading…
Reference in New Issue