/gfx/thebes/gfxGDIFont.h

http://github.com/zpao/v8monkey · C Header · 120 lines · 47 code · 26 blank · 47 comment · 2 complexity · d2bd771a8ccc41af9dcda4098f984fa2 MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. * ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Mozilla Foundation code.
  16. *
  17. * The Initial Developer of the Original Code is Mozilla Foundation.
  18. * Portions created by the Initial Developer are Copyright (C) 2005-2010
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Stuart Parmenter <stuart@mozilla.com>
  23. * Masayuki Nakano <masayuki@d-toybox.com>
  24. * John Daggett <jdaggett@mozilla.com>
  25. * Jonathan Kew <jfkthame@gmail.com>
  26. *
  27. * Alternatively, the contents of this file may be used under the terms of
  28. * either the GNU General Public License Version 2 or later (the "GPL"), or
  29. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30. * in which case the provisions of the GPL or the LGPL are applicable instead
  31. * of those above. If you wish to allow use of your version of this file only
  32. * under the terms of either the GPL or the LGPL, and not to allow others to
  33. * use your version of this file under the terms of the MPL, indicate your
  34. * decision by deleting the provisions above and replace them with the notice
  35. * and other provisions required by the GPL or the LGPL. If you do not delete
  36. * the provisions above, a recipient may use your version of this file under
  37. * the terms of any one of the MPL, the GPL or the LGPL.
  38. *
  39. * ***** END LICENSE BLOCK ***** */
  40. #ifndef GFX_GDIFONT_H
  41. #define GFX_GDIFONT_H
  42. #include "gfxFont.h"
  43. #include "gfxGDIFontList.h"
  44. #include "nsDataHashtable.h"
  45. #include "nsHashKeys.h"
  46. #include "cairo.h"
  47. class gfxGDIFont : public gfxFont
  48. {
  49. public:
  50. gfxGDIFont(GDIFontEntry *aFontEntry,
  51. const gfxFontStyle *aFontStyle,
  52. bool aNeedsBold,
  53. AntialiasOption anAAOption = kAntialiasDefault);
  54. virtual ~gfxGDIFont();
  55. HFONT GetHFONT() { if (!mMetrics) Initialize(); return mFont; }
  56. gfxFloat GetAdjustedSize() { if (!mMetrics) Initialize(); return mAdjustedSize; }
  57. cairo_font_face_t *CairoFontFace() { return mFontFace; }
  58. cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; }
  59. /* overrides for the pure virtual methods in gfxFont */
  60. virtual const gfxFont::Metrics& GetMetrics();
  61. virtual PRUint32 GetSpaceGlyph();
  62. virtual bool SetupCairoFont(gfxContext *aContext);
  63. /* override Measure to add padding for antialiasing */
  64. virtual RunMetrics Measure(gfxTextRun *aTextRun,
  65. PRUint32 aStart, PRUint32 aEnd,
  66. BoundingBoxType aBoundingBoxType,
  67. gfxContext *aContextForTightBoundingBox,
  68. Spacing *aSpacing);
  69. /* required for MathML to suppress effects of ClearType "padding" */
  70. virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
  71. virtual bool ProvidesGlyphWidths() { return true; }
  72. // get hinted glyph width in pixels as 16.16 fixed-point value
  73. virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
  74. protected:
  75. virtual void CreatePlatformShaper();
  76. /* override to check for uniscribe failure and fall back to GDI */
  77. virtual bool ShapeWord(gfxContext *aContext,
  78. gfxShapedWord *aShapedWord,
  79. const PRUnichar *aString,
  80. bool aPreferPlatformShaping = false);
  81. void Initialize(); // creates metrics and Cairo fonts
  82. void FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize);
  83. // mPlatformShaper is used for the GDI shaper, mUniscribeShaper
  84. // for the Uniscribe version if needed
  85. nsAutoPtr<gfxFontShaper> mUniscribeShaper;
  86. HFONT mFont;
  87. cairo_font_face_t *mFontFace;
  88. Metrics *mMetrics;
  89. PRUint32 mSpaceGlyph;
  90. bool mNeedsBold;
  91. // cache of glyph widths in 16.16 fixed-point pixels
  92. nsDataHashtable<nsUint32HashKey,PRInt32> mGlyphWidths;
  93. };
  94. #endif /* GFX_GDIFONT_H */