Kaydet (Commit) f17a2a00 authored tarafından Caolán McNamara's avatar Caolán McNamara

remove various casts from ServerFont to FreetypeServeFont

i.e. add the missing api directly to ServerFont
üst 85147fab
...@@ -36,6 +36,10 @@ $(eval $(call gb_Library_set_include,vclplug_svp,\ ...@@ -36,6 +36,10 @@ $(eval $(call gb_Library_set_include,vclplug_svp,\
-I$(OUTDIR)/inc \ -I$(OUTDIR)/inc \
)) ))
$(eval $(call gb_Library_add_cxxflags,vclplug_svp,\
$$(FREETYPE_CFLAGS) \
))
$(eval $(call gb_Library_add_defs,vclplug_svp,\ $(eval $(call gb_Library_add_defs,vclplug_svp,\
-DVCLPLUG_SVP_IMPLEMENTATION \ -DVCLPLUG_SVP_IMPLEMENTATION \
)) ))
......
...@@ -57,6 +57,13 @@ class RawBitmap; ...@@ -57,6 +57,13 @@ class RawBitmap;
class ServerFontLayout; class ServerFontLayout;
#include <sallayout.hxx> #include <sallayout.hxx>
#ifdef ENABLE_GRAPHITE
class GraphiteFaceWrapper;
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
namespace vcl namespace vcl
{ {
struct FontCapabilities; struct FontCapabilities;
...@@ -191,7 +198,10 @@ public: ...@@ -191,7 +198,10 @@ public:
const ImplFontSelectData& GetFontSelData() const { return maFontSelData; } const ImplFontSelectData& GetFontSelData() const { return maFontSelData; }
virtual void FetchFontMetric( ImplFontMetricData&, long& rFactor ) const = 0; virtual void FetchFontMetric( ImplFontMetricData&, long& rFactor ) const = 0;
virtual sal_uLong GetKernPairs( ImplKernPairData** ) const = 0; virtual sal_uLong GetKernPairs( ImplKernPairData** ) const = 0;
virtual const unsigned char* GetTable( const char* pName, sal_uLong* pLength ) = 0;
virtual int GetEmUnits() const = 0;
virtual const FT_Size_Metrics& GetMetricsFT() const = 0;
virtual int GetGlyphKernValue( int, int ) const = 0; virtual int GetGlyphKernValue( int, int ) const = 0;
virtual const ImplFontCharMap* GetImplFontCharMap() const = 0; virtual const ImplFontCharMap* GetImplFontCharMap() const = 0;
virtual bool GetFontCapabilities(vcl::FontCapabilities &) const = 0; virtual bool GetFontCapabilities(vcl::FontCapabilities &) const = 0;
...@@ -200,8 +210,13 @@ public: ...@@ -200,8 +210,13 @@ public:
GlyphData& GetGlyphData( int nGlyphIndex ); GlyphData& GetGlyphData( int nGlyphIndex );
const GlyphMetric& GetGlyphMetric( int nGlyphIndex ) const GlyphMetric& GetGlyphMetric( int nGlyphIndex )
{ return GetGlyphData( nGlyphIndex ).GetMetric(); } { return GetGlyphData( nGlyphIndex ).GetMetric(); }
#ifdef ENABLE_GRAPHITE
virtual GraphiteFaceWrapper* GetGraphiteFace() const = 0;
#endif
virtual int GetGlyphIndex( sal_UCS4 ) const = 0; virtual int GetGlyphIndex( sal_UCS4 ) const = 0;
virtual int GetRawGlyphIndex( sal_UCS4 ) const = 0;
virtual int FixupGlyphIndex( int nGlyphIndex, sal_UCS4 ) const = 0;
virtual bool GetGlyphOutline( int nGlyphIndex, ::basegfx::B2DPolyPolygon& ) const = 0; virtual bool GetGlyphOutline( int nGlyphIndex, ::basegfx::B2DPolyPolygon& ) const = 0;
virtual bool GetAntialiasAdvice( void ) const = 0; virtual bool GetAntialiasAdvice( void ) const = 0;
bool IsGlyphInvisible( int nGlyphIndex ); bool IsGlyphInvisible( int nGlyphIndex );
......
...@@ -95,7 +95,7 @@ public: ...@@ -95,7 +95,7 @@ public:
virtual ~GraphiteServerFontLayout() throw(); virtual ~GraphiteServerFontLayout() throw();
static bool IsGraphiteEnabledFont(ServerFont * pServerFont); static bool IsGraphiteEnabledFont(ServerFont& rServerFont);
// For use with PspGraphics // For use with PspGraphics
const sal_Unicode* getTextPtr() const { return mpStr; }; const sal_Unicode* getTextPtr() const { return mpStr; };
int getMinCharPos() const { return mnMinCharPos; } int getMinCharPos() const { return mnMinCharPos; }
......
...@@ -200,22 +200,22 @@ public: ...@@ -200,22 +200,22 @@ public:
virtual const ImplFontCharMap* GetImplFontCharMap( void ) const; virtual const ImplFontCharMap* GetImplFontCharMap( void ) const;
virtual int GetGlyphIndex( sal_UCS4 ) const; virtual int GetGlyphIndex( sal_UCS4 ) const;
int GetRawGlyphIndex( sal_UCS4 ) const; virtual int GetRawGlyphIndex( sal_UCS4 ) const;
int FixupGlyphIndex( int nGlyphIndex, sal_UCS4 ) const; virtual int FixupGlyphIndex( int nGlyphIndex, sal_UCS4 ) const;
virtual bool GetAntialiasAdvice( void ) const; virtual bool GetAntialiasAdvice( void ) const;
virtual bool GetGlyphBitmap1( int nGlyphIndex, RawBitmap& ) const; virtual bool GetGlyphBitmap1( int nGlyphIndex, RawBitmap& ) const;
virtual bool GetGlyphBitmap8( int nGlyphIndex, RawBitmap& ) const; virtual bool GetGlyphBitmap8( int nGlyphIndex, RawBitmap& ) const;
virtual bool GetGlyphOutline( int nGlyphIndex, ::basegfx::B2DPolyPolygon& ) const; virtual bool GetGlyphOutline( int nGlyphIndex, ::basegfx::B2DPolyPolygon& ) const;
virtual int GetGlyphKernValue( int nLeftGlyph, int nRightGlyph ) const; virtual int GetGlyphKernValue( int nLeftGlyph, int nRightGlyph ) const;
virtual sal_uLong GetKernPairs( ImplKernPairData** ) const; virtual sal_uLong GetKernPairs( ImplKernPairData** ) const;
const unsigned char* GetTable( const char* pName, sal_uLong* pLength ) virtual const unsigned char* GetTable( const char* pName, sal_uLong* pLength )
{ return mpFontInfo->GetTable( pName, pLength ); } { return mpFontInfo->GetTable( pName, pLength ); }
int GetEmUnits() const; virtual int GetEmUnits() const;
const FT_Size_Metrics& GetMetricsFT() const { return maSizeFT->metrics; } virtual const FT_Size_Metrics& GetMetricsFT() const { return maSizeFT->metrics; }
#ifdef ENABLE_GRAPHITE #ifdef ENABLE_GRAPHITE
GraphiteFaceWrapper* GetGraphiteFace() const { return mpFontInfo->GetGraphiteFace(); } virtual GraphiteFaceWrapper* GetGraphiteFace() const { return mpFontInfo->GetGraphiteFace(); }
#endif #endif
protected: protected:
......
...@@ -101,7 +101,7 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs ) ...@@ -101,7 +101,7 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
bool ServerFontLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rArgs ) bool ServerFontLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rArgs )
{ {
FreetypeServerFont& rFont = static_cast<FreetypeServerFont&>(rLayout.GetServerFont()); ServerFont& rFont = rLayout.GetServerFont();
Point aNewPos( 0, 0 ); Point aNewPos( 0, 0 );
int nOldGlyphId = -1; int nOldGlyphId = -1;
...@@ -193,10 +193,10 @@ class IcuFontFromServerFont ...@@ -193,10 +193,10 @@ class IcuFontFromServerFont
: public LEFontInstance : public LEFontInstance
{ {
private: private:
FreetypeServerFont& mrServerFont; ServerFont& mrServerFont;
public: public:
IcuFontFromServerFont( FreetypeServerFont& rFont ) IcuFontFromServerFont( ServerFont& rFont )
: mrServerFont( rFont ) : mrServerFont( rFont )
{} {}
...@@ -361,7 +361,7 @@ private: ...@@ -361,7 +361,7 @@ private:
LayoutEngine* mpIcuLE; LayoutEngine* mpIcuLE;
public: public:
IcuLayoutEngine( FreetypeServerFont& ); IcuLayoutEngine( ServerFont& );
virtual ~IcuLayoutEngine(); virtual ~IcuLayoutEngine();
virtual bool operator()( ServerFontLayout&, ImplLayoutArgs& ); virtual bool operator()( ServerFontLayout&, ImplLayoutArgs& );
...@@ -369,7 +369,7 @@ public: ...@@ -369,7 +369,7 @@ public:
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
IcuLayoutEngine::IcuLayoutEngine( FreetypeServerFont& rServerFont ) IcuLayoutEngine::IcuLayoutEngine( ServerFont& rServerFont )
: maIcuFont( rServerFont ), : maIcuFont( rServerFont ),
meScriptCode( USCRIPT_INVALID_CODE ), meScriptCode( USCRIPT_INVALID_CODE ),
mpIcuLE( NULL ) mpIcuLE( NULL )
...@@ -417,7 +417,7 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr ...@@ -417,7 +417,7 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
le_int32* pCharIndices = (le_int32*)((char*)pIcuGlyphs + nGlyphCapacity * sizeof(LEGlyphID) ); le_int32* pCharIndices = (le_int32*)((char*)pIcuGlyphs + nGlyphCapacity * sizeof(LEGlyphID) );
IcuPosition* pGlyphPositions = (IcuPosition*)((char*)pCharIndices + nGlyphCapacity * sizeof(le_int32) ); IcuPosition* pGlyphPositions = (IcuPosition*)((char*)pCharIndices + nGlyphCapacity * sizeof(le_int32) );
FreetypeServerFont& rFont = reinterpret_cast<FreetypeServerFont&>(rLayout.GetServerFont()); ServerFont& rFont = rLayout.GetServerFont();
UErrorCode rcI18n = U_ZERO_ERROR; UErrorCode rcI18n = U_ZERO_ERROR;
LEErrorCode rcIcu = LE_NO_ERROR; LEErrorCode rcIcu = LE_NO_ERROR;
......
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId) float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId)
{ {
FreetypeServerFont * pServerFont = ServerFont * pServerFont =
const_cast<FreetypeServerFont*> const_cast<ServerFont*>
(reinterpret_cast<const FreetypeServerFont*>(appFontHandle)); (reinterpret_cast<const ServerFont*>(appFontHandle));
if (pServerFont) if (pServerFont)
{ {
return static_cast<float>(pServerFont->GetGlyphMetric(glyphId).GetCharWidth()); return static_cast<float>(pServerFont->GetGlyphMetric(glyphId).GetCharWidth());
...@@ -63,23 +63,22 @@ float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId) ...@@ -63,23 +63,22 @@ float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId)
// An implementation of the GraphiteLayout interface to enable Graphite enabled fonts to be used. // An implementation of the GraphiteLayout interface to enable Graphite enabled fonts to be used.
// //
GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) throw() GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) throw()
: ServerFontLayout(rServerFont), : ServerFontLayout(rServerFont),
maImpl(dynamic_cast<FreetypeServerFont&>(rServerFont).GetGraphiteFace()->face(), maImpl(rServerFont.GetGraphiteFace()->face(),
rServerFont), rServerFont),
mpFeatures(NULL) mpFeatures(NULL)
{ {
FreetypeServerFont& rFTServerFont = dynamic_cast<FreetypeServerFont&>(rServerFont); gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight);
gr_font * pFont = rFTServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight);
if (!pFont) if (!pFont)
{ {
pFont = gr_make_font_with_advance_fn( pFont = gr_make_font_with_advance_fn(
// need to use mnHeight here, mfExactHeight can give wrong values // need to use mnHeight here, mfExactHeight can give wrong values
static_cast<float>(rServerFont.GetFontSelData().mnHeight), static_cast<float>(rServerFont.GetFontSelData().mnHeight),
&rFTServerFont, &rServerFont,
freetypeServerFontAdvance, freetypeServerFontAdvance,
rFTServerFont.GetGraphiteFace()->face()); rServerFont.GetGraphiteFace()->face());
rFTServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont); rServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont);
} }
maImpl.SetFont(pFont); maImpl.SetFont(pFont);
rtl::OString aLang(""); rtl::OString aLang("");
...@@ -92,7 +91,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr ...@@ -92,7 +91,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr
rServerFont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 ); rServerFont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 );
#ifdef DEBUG #ifdef DEBUG
printf("GraphiteServerFontLayout %lx %s size %d %f\n", (long unsigned int)this, name.getStr(), printf("GraphiteServerFontLayout %lx %s size %d %f\n", (long unsigned int)this, name.getStr(),
rFTServerFont.GetMetricsFT().x_ppem, rServerFont.GetMetricsFT().x_ppem,
rServerFont.GetFontSelData().mfExactHeight); rServerFont.GetFontSelData().mfExactHeight);
#endif #endif
sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1; sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1;
...@@ -100,7 +99,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr ...@@ -100,7 +99,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr
{ {
rtl::OString aFeat = name.copy(nFeat, name.getLength() - nFeat); rtl::OString aFeat = name.copy(nFeat, name.getLength() - nFeat);
mpFeatures = new grutils::GrFeatureParser( mpFeatures = new grutils::GrFeatureParser(
rFTServerFont.GetGraphiteFace()->face(), aFeat, aLang); rServerFont.GetGraphiteFace()->face(), aFeat, aLang);
#ifdef DEBUG #ifdef DEBUG
if (mpFeatures) if (mpFeatures)
printf("GraphiteServerFontLayout %s/%s/%s %x language %d features %d errors\n", printf("GraphiteServerFontLayout %s/%s/%s %x language %d features %d errors\n",
...@@ -117,7 +116,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr ...@@ -117,7 +116,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr
else else
{ {
mpFeatures = new grutils::GrFeatureParser( mpFeatures = new grutils::GrFeatureParser(
rFTServerFont.GetGraphiteFace()->face(), aLang); rServerFont.GetGraphiteFace()->face(), aLang);
} }
maImpl.SetFeatures(mpFeatures); maImpl.SetFeatures(mpFeatures);
} }
...@@ -128,18 +127,14 @@ GraphiteServerFontLayout::~GraphiteServerFontLayout() throw() ...@@ -128,18 +127,14 @@ GraphiteServerFontLayout::~GraphiteServerFontLayout() throw()
mpFeatures = NULL; mpFeatures = NULL;
} }
bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont * pServerFont) bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont& rServerFont)
{ {
FreetypeServerFont * pFtServerFont = dynamic_cast<FreetypeServerFont*>(pServerFont); if (rServerFont.GetGraphiteFace())
if (pFtServerFont)
{ {
if (pFtServerFont->GetGraphiteFace())
{
#ifdef DEBUG #ifdef DEBUG
printf("IsGraphiteEnabledFont\n"); printf("IsGraphiteEnabledFont\n");
#endif #endif
return true; return true;
}
} }
return false; return false;
} }
......
...@@ -991,7 +991,7 @@ SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ...@@ -991,7 +991,7 @@ SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel
{ {
#ifdef ENABLE_GRAPHITE #ifdef ENABLE_GRAPHITE
// Is this a Graphite font? // Is this a Graphite font?
if (GraphiteServerFontLayout::IsGraphiteEnabledFont(m_pServerFont[nFallbackLevel])) if (GraphiteServerFontLayout::IsGraphiteEnabledFont(*m_pServerFont[nFallbackLevel]))
{ {
pLayout = new GraphiteServerFontLayout(*m_pServerFont[nFallbackLevel]); pLayout = new GraphiteServerFontLayout(*m_pServerFont[nFallbackLevel]);
} }
......
...@@ -1101,7 +1101,7 @@ SalLayout* X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe ...@@ -1101,7 +1101,7 @@ SalLayout* X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
#ifdef ENABLE_GRAPHITE #ifdef ENABLE_GRAPHITE
// Is this a Graphite font? // Is this a Graphite font?
if (!bDisableGraphite_ && if (!bDisableGraphite_ &&
GraphiteServerFontLayout::IsGraphiteEnabledFont(mpServerFont[nFallbackLevel])) GraphiteServerFontLayout::IsGraphiteEnabledFont(*mpServerFont[nFallbackLevel]))
{ {
pLayout = new GraphiteServerFontLayout(*mpServerFont[nFallbackLevel]); pLayout = new GraphiteServerFontLayout(*mpServerFont[nFallbackLevel]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment