2010-02-25 22:36:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Foundation code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Bas Schouten <bschouten@mozilla.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef GFX_WINDOWSDWRITEFONTS_H
|
|
|
|
#define GFX_WINDOWSDWRITEFONTS_H
|
|
|
|
|
|
|
|
#include <dwrite.h>
|
|
|
|
|
|
|
|
#include "gfxFont.h"
|
|
|
|
#include "gfxUserFontSet.h"
|
|
|
|
#include "cairo-win32.h"
|
|
|
|
|
2010-06-11 12:14:38 -07:00
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
/**
|
|
|
|
* \brief Class representing a font face for a font entry.
|
|
|
|
*/
|
|
|
|
class gfxDWriteFont : public gfxFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
gfxDWriteFont(gfxFontEntry *aFontEntry,
|
2010-03-11 20:25:35 -08:00
|
|
|
const gfxFontStyle *aFontStyle,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNeedsBold = false,
|
2010-06-10 11:19:51 -07:00
|
|
|
AntialiasOption = kAntialiasDefault);
|
2010-02-25 22:36:07 -08:00
|
|
|
~gfxDWriteFont();
|
|
|
|
|
2010-06-10 11:19:51 -07:00
|
|
|
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
|
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
virtual const gfxFont::Metrics& GetMetrics();
|
|
|
|
|
|
|
|
virtual PRUint32 GetSpaceGlyph();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool SetupCairoFont(gfxContext *aContext);
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsValid();
|
2010-03-12 03:57:49 -08:00
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
gfxFloat GetAdjustedSize() {
|
|
|
|
return mAdjustedSize;
|
|
|
|
}
|
2010-03-12 03:57:49 -08:00
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
IDWriteFontFace *GetFontFace();
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2011-06-30 23:38:17 -07:00
|
|
|
/* override Measure to add padding for antialiasing */
|
|
|
|
virtual RunMetrics Measure(gfxTextRun *aTextRun,
|
|
|
|
PRUint32 aStart, PRUint32 aEnd,
|
|
|
|
BoundingBoxType aBoundingBoxType,
|
|
|
|
gfxContext *aContextForTightBoundingBox,
|
|
|
|
Spacing *aSpacing);
|
|
|
|
|
2010-06-11 12:14:38 -07:00
|
|
|
// override gfxFont table access function to bypass gfxFontEntry cache,
|
|
|
|
// use DWrite API to get direct access to system font data
|
|
|
|
virtual hb_blob_t *GetFontTable(PRUint32 aTag);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ProvidesGlyphWidths();
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2011-01-21 02:35:21 -08:00
|
|
|
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
2011-01-04 08:58:31 -08:00
|
|
|
|
2010-04-06 13:19:39 -07:00
|
|
|
protected:
|
2011-01-21 02:35:21 -08:00
|
|
|
friend class gfxDWriteShaper;
|
|
|
|
|
2009-10-07 10:16:52 -07:00
|
|
|
virtual void CreatePlatformShaper();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics);
|
2011-03-23 20:01:14 -07:00
|
|
|
|
2011-06-02 21:31:08 -07:00
|
|
|
void ComputeMetrics(AntialiasOption anAAOption);
|
2010-02-25 22:36:07 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasBitmapStrikeForSize(PRUint32 aSize);
|
2011-01-21 02:36:28 -08:00
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
cairo_font_face_t *CairoFontFace();
|
|
|
|
|
|
|
|
cairo_scaled_font_t *CairoScaledFont();
|
|
|
|
|
2011-04-20 23:29:50 -07:00
|
|
|
gfxFloat MeasureGlyphWidth(PRUint16 aGlyph);
|
|
|
|
|
2010-06-11 12:14:38 -07:00
|
|
|
static void DestroyBlobFunc(void* userArg);
|
|
|
|
|
2011-06-02 21:31:07 -07:00
|
|
|
DWRITE_MEASURING_MODE GetMeasuringMode();
|
2011-06-02 21:31:08 -07:00
|
|
|
bool GetForceGDIClassic();
|
2011-06-02 21:31:07 -07:00
|
|
|
|
2010-02-25 22:36:07 -08:00
|
|
|
nsRefPtr<IDWriteFontFace> mFontFace;
|
|
|
|
cairo_font_face_t *mCairoFontFace;
|
|
|
|
|
2011-01-21 08:44:32 -08:00
|
|
|
gfxFont::Metrics *mMetrics;
|
2011-01-04 08:58:31 -08:00
|
|
|
|
|
|
|
// cache of glyph widths in 16.16 fixed-point pixels
|
|
|
|
nsDataHashtable<nsUint32HashKey,PRInt32> mGlyphWidths;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNeedsOblique;
|
|
|
|
bool mNeedsBold;
|
|
|
|
bool mUseSubpixelPositions;
|
|
|
|
bool mAllowManualShowGlyphs;
|
2010-02-25 22:36:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|