Kaydet (Commit) 0ed14401 authored tarafından Martin Hosken's avatar Martin Hosken Kaydeden (comit) Caolán McNamara

Resolves: tdf#89252 Fix bold, regular font spacing bug for Graphite fonts

Change-Id: I31a09fa753ed15e302e5407ce8a0c46f3b13e099
Reviewed-on: https://gerrit.libreoffice.org/14380Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 605494fd
...@@ -48,7 +48,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) thro ...@@ -48,7 +48,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) thro
, mpFeatures(NULL) , mpFeatures(NULL)
, mpStr(NULL) , mpStr(NULL)
{ {
gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight); gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight, rServerFont.NeedsArtificialBold(), rServerFont.NeedsArtificialItalic());
if (!pFont) if (!pFont)
{ {
pFont = gr_make_font_with_advance_fn( pFont = gr_make_font_with_advance_fn(
...@@ -57,7 +57,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) thro ...@@ -57,7 +57,7 @@ GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) thro
&rServerFont, &rServerFont,
freetypeServerFontAdvance, freetypeServerFontAdvance,
rServerFont.GetGraphiteFace()->face()); rServerFont.GetGraphiteFace()->face());
rServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont); rServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont, rServerFont.NeedsArtificialBold(), rServerFont.NeedsArtificialItalic());
} }
maImpl.SetFont(pFont); maImpl.SetFont(pFont);
OString aLang(""); OString aLang("");
......
...@@ -52,7 +52,8 @@ namespace grutils { class GrFeatureParser; } ...@@ -52,7 +52,8 @@ namespace grutils { class GrFeatureParser; }
class GraphiteFaceWrapper class GraphiteFaceWrapper
{ {
public: public:
typedef std::map<int, gr_font*> GrFontMap; typedef std::pair<int, int> GrFontMapKey;
typedef std::map<GrFontMapKey, gr_font*> GrFontMap;
GraphiteFaceWrapper(gr_face * pFace) : m_pFace(pFace) {} GraphiteFaceWrapper(gr_face * pFace) : m_pFace(pFace) {}
~GraphiteFaceWrapper() ~GraphiteFaceWrapper()
{ {
...@@ -63,18 +64,21 @@ public: ...@@ -63,18 +64,21 @@ public:
gr_face_destroy(m_pFace); gr_face_destroy(m_pFace);
} }
const gr_face * face() const { return m_pFace; } const gr_face * face() const { return m_pFace; }
gr_font * font(int ppm) const gr_font * font(int ppm, bool isBold, bool isItalic) const
{ {
GrFontMap::const_iterator i = m_fonts.find(ppm); int styleKey = int(isBold) | (int(isItalic) << 1);
GrFontMap::const_iterator i = m_fonts.find(GrFontMapKey(ppm, styleKey));
if (i != m_fonts.end()) if (i != m_fonts.end())
return i->second; return i->second;
return NULL; return NULL;
}; };
void addFont(int ppm, gr_font * pFont) void addFont(int ppm, gr_font * pFont, bool isBold, bool isItalic)
{ {
if (m_fonts[ppm]) int styleKey = int(isBold) | (int(isItalic) << 1);
gr_font_destroy(m_fonts[ppm]); GrFontMapKey key(ppm, styleKey);
m_fonts[ppm] = pFont; if (m_fonts[key])
gr_font_destroy(m_fonts[key]);
m_fonts[key] = pFont;
} }
private: private:
gr_face * m_pFace; gr_face * m_pFace;
......
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