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,\
-I$(OUTDIR)/inc \
))
$(eval $(call gb_Library_add_cxxflags,vclplug_svp,\
$$(FREETYPE_CFLAGS) \
))
$(eval $(call gb_Library_add_defs,vclplug_svp,\
-DVCLPLUG_SVP_IMPLEMENTATION \
))
......
......@@ -57,6 +57,13 @@ class RawBitmap;
class ServerFontLayout;
#include <sallayout.hxx>
#ifdef ENABLE_GRAPHITE
class GraphiteFaceWrapper;
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
namespace vcl
{
struct FontCapabilities;
......@@ -191,7 +198,10 @@ public:
const ImplFontSelectData& GetFontSelData() const { return maFontSelData; }
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 const ImplFontCharMap* GetImplFontCharMap() const = 0;
virtual bool GetFontCapabilities(vcl::FontCapabilities &) const = 0;
......@@ -200,8 +210,13 @@ public:
GlyphData& GetGlyphData( int nGlyphIndex );
const GlyphMetric& GetGlyphMetric( int nGlyphIndex )
{ return GetGlyphData( nGlyphIndex ).GetMetric(); }
#ifdef ENABLE_GRAPHITE
virtual GraphiteFaceWrapper* GetGraphiteFace() const = 0;
#endif
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 GetAntialiasAdvice( void ) const = 0;
bool IsGlyphInvisible( int nGlyphIndex );
......
......@@ -95,7 +95,7 @@ public:
virtual ~GraphiteServerFontLayout() throw();
static bool IsGraphiteEnabledFont(ServerFont * pServerFont);
static bool IsGraphiteEnabledFont(ServerFont& rServerFont);
// For use with PspGraphics
const sal_Unicode* getTextPtr() const { return mpStr; };
int getMinCharPos() const { return mnMinCharPos; }
......
......@@ -200,22 +200,22 @@ public:
virtual const ImplFontCharMap* GetImplFontCharMap( void ) const;
virtual int GetGlyphIndex( sal_UCS4 ) const;
int GetRawGlyphIndex( sal_UCS4 ) const;
int FixupGlyphIndex( int nGlyphIndex, sal_UCS4 ) const;
virtual int GetRawGlyphIndex( sal_UCS4 ) const;
virtual int FixupGlyphIndex( int nGlyphIndex, sal_UCS4 ) const;
virtual bool GetAntialiasAdvice( void ) const;
virtual bool GetGlyphBitmap1( int nGlyphIndex, RawBitmap& ) const;
virtual bool GetGlyphBitmap8( int nGlyphIndex, RawBitmap& ) const;
virtual bool GetGlyphOutline( int nGlyphIndex, ::basegfx::B2DPolyPolygon& ) 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 ); }
int GetEmUnits() const;
const FT_Size_Metrics& GetMetricsFT() const { return maSizeFT->metrics; }
virtual int GetEmUnits() const;
virtual const FT_Size_Metrics& GetMetricsFT() const { return maSizeFT->metrics; }
#ifdef ENABLE_GRAPHITE
GraphiteFaceWrapper* GetGraphiteFace() const { return mpFontInfo->GetGraphiteFace(); }
virtual GraphiteFaceWrapper* GetGraphiteFace() const { return mpFontInfo->GetGraphiteFace(); }
#endif
protected:
......
......@@ -101,7 +101,7 @@ void ServerFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
bool ServerFontLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rArgs )
{
FreetypeServerFont& rFont = static_cast<FreetypeServerFont&>(rLayout.GetServerFont());
ServerFont& rFont = rLayout.GetServerFont();
Point aNewPos( 0, 0 );
int nOldGlyphId = -1;
......@@ -193,10 +193,10 @@ class IcuFontFromServerFont
: public LEFontInstance
{
private:
FreetypeServerFont& mrServerFont;
ServerFont& mrServerFont;
public:
IcuFontFromServerFont( FreetypeServerFont& rFont )
IcuFontFromServerFont( ServerFont& rFont )
: mrServerFont( rFont )
{}
......@@ -361,7 +361,7 @@ private:
LayoutEngine* mpIcuLE;
public:
IcuLayoutEngine( FreetypeServerFont& );
IcuLayoutEngine( ServerFont& );
virtual ~IcuLayoutEngine();
virtual bool operator()( ServerFontLayout&, ImplLayoutArgs& );
......@@ -369,7 +369,7 @@ public:
// -----------------------------------------------------------------------
IcuLayoutEngine::IcuLayoutEngine( FreetypeServerFont& rServerFont )
IcuLayoutEngine::IcuLayoutEngine( ServerFont& rServerFont )
: maIcuFont( rServerFont ),
meScriptCode( USCRIPT_INVALID_CODE ),
mpIcuLE( NULL )
......@@ -417,7 +417,7 @@ bool IcuLayoutEngine::operator()( ServerFontLayout& rLayout, ImplLayoutArgs& rAr
le_int32* pCharIndices = (le_int32*)((char*)pIcuGlyphs + nGlyphCapacity * sizeof(LEGlyphID) );
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;
LEErrorCode rcIcu = LE_NO_ERROR;
......
......@@ -49,9 +49,9 @@
float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId)
{
FreetypeServerFont * pServerFont =
const_cast<FreetypeServerFont*>
(reinterpret_cast<const FreetypeServerFont*>(appFontHandle));
ServerFont * pServerFont =
const_cast<ServerFont*>
(reinterpret_cast<const ServerFont*>(appFontHandle));
if (pServerFont)
{
return static_cast<float>(pServerFont->GetGlyphMetric(glyphId).GetCharWidth());
......@@ -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.
//
GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) throw()
GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) throw()
: ServerFontLayout(rServerFont),
maImpl(dynamic_cast<FreetypeServerFont&>(rServerFont).GetGraphiteFace()->face(),
maImpl(rServerFont.GetGraphiteFace()->face(),
rServerFont),
mpFeatures(NULL)
{
FreetypeServerFont& rFTServerFont = dynamic_cast<FreetypeServerFont&>(rServerFont);
gr_font * pFont = rFTServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight);
gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight);
if (!pFont)
{
pFont = gr_make_font_with_advance_fn(
// need to use mnHeight here, mfExactHeight can give wrong values
static_cast<float>(rServerFont.GetFontSelData().mnHeight),
&rFTServerFont,
&rServerFont,
freetypeServerFontAdvance,
rFTServerFont.GetGraphiteFace()->face());
rFTServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont);
rServerFont.GetGraphiteFace()->face());
rServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont);
}
maImpl.SetFont(pFont);
rtl::OString aLang("");
......@@ -92,7 +91,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr
rServerFont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 );
#ifdef DEBUG
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);
#endif
sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1;
......@@ -100,7 +99,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr
{
rtl::OString aFeat = name.copy(nFeat, name.getLength() - nFeat);
mpFeatures = new grutils::GrFeatureParser(
rFTServerFont.GetGraphiteFace()->face(), aFeat, aLang);
rServerFont.GetGraphiteFace()->face(), aFeat, aLang);
#ifdef DEBUG
if (mpFeatures)
printf("GraphiteServerFontLayout %s/%s/%s %x language %d features %d errors\n",
......@@ -117,7 +116,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont & rServerFont) thr
else
{
mpFeatures = new grutils::GrFeatureParser(
rFTServerFont.GetGraphiteFace()->face(), aLang);
rServerFont.GetGraphiteFace()->face(), aLang);
}
maImpl.SetFeatures(mpFeatures);
}
......@@ -128,18 +127,14 @@ GraphiteServerFontLayout::~GraphiteServerFontLayout() throw()
mpFeatures = NULL;
}
bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont * pServerFont)
bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont& rServerFont)
{
FreetypeServerFont * pFtServerFont = dynamic_cast<FreetypeServerFont*>(pServerFont);
if (pFtServerFont)
if (rServerFont.GetGraphiteFace())
{
if (pFtServerFont->GetGraphiteFace())
{
#ifdef DEBUG
printf("IsGraphiteEnabledFont\n");
printf("IsGraphiteEnabledFont\n");
#endif
return true;
}
return true;
}
return false;
}
......
......@@ -991,7 +991,7 @@ SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel
{
#ifdef ENABLE_GRAPHITE
// Is this a Graphite font?
if (GraphiteServerFontLayout::IsGraphiteEnabledFont(m_pServerFont[nFallbackLevel]))
if (GraphiteServerFontLayout::IsGraphiteEnabledFont(*m_pServerFont[nFallbackLevel]))
{
pLayout = new GraphiteServerFontLayout(*m_pServerFont[nFallbackLevel]);
}
......
......@@ -1101,7 +1101,7 @@ SalLayout* X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
#ifdef ENABLE_GRAPHITE
// Is this a Graphite font?
if (!bDisableGraphite_ &&
GraphiteServerFontLayout::IsGraphiteEnabledFont(mpServerFont[nFallbackLevel]))
GraphiteServerFontLayout::IsGraphiteEnabledFont(*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