summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-07-04 09:21:13 +0800
committerTor Lillqvist <tml@collabora.com>2016-08-02 16:42:58 +0300
commit1bce27b2dc07e9fac4f425fe286662e1fb7c56e8 (patch)
tree07c3b08182954d934713db3128dcdb9f2b4b5162
parentexplicitly disable partial cell shift with change-tracking, tdf#73335 related (diff)
downloadcore-1bce27b2dc07e9fac4f425fe286662e1fb7c56e8.tar.gz
core-1bce27b2dc07e9fac4f425fe286662e1fb7c56e8.zip
tdf#98710 check the font is bound, substitute FON fonts
If we can't bind the font then we can't proceed with rendering and caching of the glyphs. This may avoid the crash but the font won't be drawn. This happens for old Windows 3.1 bitmap fonts in FON format which Direct Write doesn't support. So in addition substitute "Script" and "Roman" FON fonts with "Times New Roman". Reviewed-on: https://gerrit.libreoffice.org/26885 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit b5cd1220b849a9759dd4446032a7e1affbf151f2) Change-Id: I16b480399b47989738a703ad84c0398493f9f4e3 Reviewed-on: https://gerrit.libreoffice.org/26970 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 901bb8527350a81b1631338abedbfd3f77ffbf35)
-rw-r--r--vcl/win/source/gdi/salgdi3.cxx7
-rw-r--r--vcl/win/source/gdi/winlayout.cxx7
2 files changed, 14 insertions, 0 deletions
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index a802158f14aa..b99914f8a73d 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -1471,6 +1471,13 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontS
// Prefer the scalable 'Microsoft Sans Serif' to the old raster 'MS Sans Serif'
if( ImplSalWICompareAscii( aLogFont.lfFaceName, "MS Sans Serif" ) == 0 )
wcscpy( aLogFont.lfFaceName, L"Microsoft Sans Serif" );
+ // Script and Roman are Win 3.1 bitmap fonts using "FON" font format
+ // which is not supported with "Direct Write" so let's substitute them
+ // with a font that is supported and always available.
+ if (ImplSalWICompareAscii(aLogFont.lfFaceName, "Script") == 0)
+ wcscpy(aLogFont.lfFaceName, L"Times New Roman");
+ if (ImplSalWICompareAscii(aLogFont.lfFaceName, "Roman") == 0)
+ wcscpy(aLogFont.lfFaceName, L"Times New Roman");
// #i47675# limit font requests to MAXFONTHEIGHT
// TODO: share MAXFONTHEIGHT font instance
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index c693085a693f..776dee4522fc 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -370,6 +370,7 @@ bool ImplWinFontEntry::CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex
if (!pTxt->BindFont(hDC))
{
+ SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be supported by Direct Write.");
SelectObject(hDC, hOrigFont);
DeleteDC(hDC);
return false;
@@ -399,6 +400,11 @@ bool ImplWinFontEntry::CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex
// Fetch the ink boxes and calculate the size of the atlas.
if (!bRealGlyphIndices)
{
+ if (!pTxt->GetFontFace())
+ {
+ SAL_WARN("vcl.gdi", "Font face is not available.");
+ return false;
+ }
if (!SUCCEEDED(pTxt->GetFontFace()->GetGlyphIndices(aCodePointsOrGlyphIndices.data(), aCodePointsOrGlyphIndices.size(), aGlyphIndices.data())))
{
pTxt->ReleaseFont();
@@ -409,6 +415,7 @@ bool ImplWinFontEntry::CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex
{
aGlyphIndices[0] = aCodePointsOrGlyphIndices[0];
}
+
Rectangle bounds(0, 0, 0, 0);
auto aInkBoxes = pTxt->GetGlyphInkBoxes(aGlyphIndices.data(), aGlyphIndices.data() + 1);
for (auto &box : aInkBoxes)