add vertical layout as a distinguishing font layout attribute

This commit is contained in:
Caolán McNamara 2011-08-02 14:42:54 +01:00
parent 2bb1ba5c3f
commit ed8134d716
4 changed files with 23 additions and 18 deletions

View file

@ -166,7 +166,7 @@ public:
{ return meAntiAlias == ANTIALIAS_FALSE; }
bool DontUseHinting() const
{ return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); }
virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/) const
virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/, bool /*bVerticalMetrics*/) const
{ return NULL; }
};

View file

@ -72,11 +72,13 @@ public:
const void *mpFace;
const void *mpOptions;
bool mbEmbolden;
bool mbVerticalMetrics;
bool operator ==(const CacheId& rOther) const
{
return mpFace == rOther.mpFace &&
mpOptions == rOther.mpOptions &&
mbEmbolden == rOther.mbEmbolden;
mbEmbolden == rOther.mbEmbolden &&
mbVerticalMetrics == rOther.mbVerticalMetrics;
}
};
private:

View file

@ -870,13 +870,17 @@ public:
{
FcPatternDestroy(mpPattern);
}
virtual void *GetPattern(void * face, bool bEmbolden) const
virtual void *GetPattern(void * face, bool bEmbolden, bool bVerticalLayout) const
{
FcValue value;
value.type = FcTypeFTFace;
value.u.f = face;
FcPatternDel(mpPattern, FC_FT_FACE);
FcPatternAdd (mpPattern, FC_FT_FACE, value, FcTrue);
FcPatternDel(mpPattern, FC_EMBOLDEN);
FcPatternAddBool(mpPattern, FC_EMBOLDEN, bEmbolden ? FcTrue : FcFalse);
FcPatternDel(mpPattern, FC_VERTICAL_LAYOUT);
FcPatternAddBool(mpPattern, FC_VERTICAL_LAYOUT, bVerticalLayout ? FcTrue : FcFalse);
return mpPattern;
}
FcPattern* mpPattern;

View file

@ -371,26 +371,11 @@ void X11SalGraphics::DrawCairoAAFontString( const ServerFontLayout& rLayout )
ServerFont& rFont = rLayout.GetServerFont();
cairo_font_face_t* font_face = NULL;
void* pFace = rFont.GetFtFace();
CairoFontsCache::CacheId aId;
aId.mpFace = pFace;
aId.mpOptions = rFont.GetFontOptions().get();
aId.mbEmbolden = rFont.NeedsArtificialBold();
font_face = (cairo_font_face_t*)m_aCairoFontsCache.FindCachedFont(aId);
if (!font_face)
{
const ImplFontOptions *pOptions = rFont.GetFontOptions().get();
void *pPattern = pOptions ? pOptions->GetPattern(pFace, aId.mbEmbolden) : NULL;
if (pPattern)
font_face = cairo_ft_font_face_create_for_pattern(reinterpret_cast<FcPattern*>(pPattern));
if (!font_face)
font_face = cairo_ft_font_face_create_for_ft_face(reinterpret_cast<FT_Face>(pFace), rFont.GetLoadFlags());
m_aCairoFontsCache.CacheFont(font_face, aId);
}
cairo_set_font_face(cr, font_face);
cairo_matrix_t m;
const ImplFontSelectData& rFSD = rFont.GetFontSelData();
@ -409,6 +394,20 @@ void X11SalGraphics::DrawCairoAAFontString( const ServerFontLayout& rLayout )
size_t nStartIndex = std::distance(aStart, aI);
size_t nLen = std::distance(aI, aNext);
aId.mbVerticalMetrics = nGlyphRotation != 0.0;
cairo_font_face_t* font_face = (cairo_font_face_t*)m_aCairoFontsCache.FindCachedFont(aId);
if (!font_face)
{
const ImplFontOptions *pOptions = rFont.GetFontOptions().get();
void *pPattern = pOptions ? pOptions->GetPattern(pFace, aId.mbEmbolden, aId.mbVerticalMetrics) : NULL;
if (pPattern)
font_face = cairo_ft_font_face_create_for_pattern(reinterpret_cast<FcPattern*>(pPattern));
if (!font_face)
font_face = cairo_ft_font_face_create_for_ft_face(reinterpret_cast<FT_Face>(pFace), rFont.GetLoadFlags());
m_aCairoFontsCache.CacheFont(font_face, aId);
}
cairo_set_font_face(cr, font_face);
cairo_set_font_size(cr, nHeight);
cairo_matrix_init_identity(&m);