From 947ebe27b2874ddd6661cbb7b19e30385ab8da85 Mon Sep 17 00:00:00 2001 From: Edwin Flores Date: Thu, 6 Sep 2012 16:58:47 +1200 Subject: [PATCH] Bug 719286 - Implement GetFontTable for downloaded fonts in linux r=karl --- gfx/thebes/gfxPangoFonts.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp index 2b023ed3a0c..ec7a8c14f28 100644 --- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -44,6 +44,8 @@ #include #include +#include FT_TRUETYPE_TABLES_H + #ifdef MOZ_WIDGET_GTK #include #endif @@ -533,6 +535,9 @@ public: // lifetime of the FontEntry. PangoCoverage *GetPangoCoverage(); + virtual nsresult + GetFontTable(uint32_t aTableTag, FallibleTArray& aBuffer) MOZ_OVERRIDE; + protected: void InitPattern(); @@ -748,6 +753,29 @@ gfxDownloadedFcFontEntry::GetPangoCoverage() return mPangoCoverage; } +nsresult +gfxDownloadedFcFontEntry::GetFontTable(uint32_t aTableTag, + FallibleTArray& aBuffer) +{ + FT_ULong length = 0; + FT_Error error = FT_Load_Sfnt_Table(mFace, aTableTag, 0, nullptr, &length); + if (error) { + return NS_ERROR_NOT_AVAILABLE; + } + + if (!aBuffer.SetLength(length)) { + return NS_ERROR_OUT_OF_MEMORY; + } + + error = FT_Load_Sfnt_Table(mFace, aTableTag, 0, aBuffer.Elements(), &length); + if (error) { + aBuffer.Clear(); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + /* * gfxFcFont *