2007-03-22 10:30:00 -07:00
|
|
|
/* vim: set sw=4 sts=4 et cin: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef GFX_OS2_FONTS_H
|
|
|
|
#define GFX_OS2_FONTS_H
|
|
|
|
|
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "gfxFont.h"
|
2007-05-20 06:45:49 -07:00
|
|
|
#include "gfxMatrix.h"
|
|
|
|
#include "nsDataHashtable.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define INCL_GPI
|
|
|
|
#include <os2.h>
|
|
|
|
#include <cairo-os2.h>
|
2007-05-20 06:45:49 -07:00
|
|
|
#include "cairo-ft.h" // includes fontconfig.h, too
|
|
|
|
#include <freetype/tttables.h>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsICharsetConverterManager.h"
|
|
|
|
|
2008-08-07 01:12:45 -07:00
|
|
|
class gfxOS2FontEntry : public gfxFontEntry {
|
|
|
|
public:
|
|
|
|
gfxOS2FontEntry(const nsAString& aName) : gfxFontEntry(aName) {}
|
|
|
|
~gfxOS2FontEntry() {}
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class gfxOS2Font : public gfxFont {
|
|
|
|
public:
|
2008-08-07 01:12:45 -07:00
|
|
|
gfxOS2Font(gfxOS2FontEntry *aFontEntry, const gfxFontStyle *aFontStyle);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~gfxOS2Font();
|
|
|
|
|
|
|
|
virtual const gfxFont::Metrics& GetMetrics();
|
2007-05-20 06:45:49 -07:00
|
|
|
cairo_font_face_t *CairoFontFace();
|
|
|
|
cairo_scaled_font_t *CairoScaledFont();
|
|
|
|
|
|
|
|
// Get the glyphID of a space
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetSpaceGlyph() {
|
2007-05-20 06:45:49 -07:00
|
|
|
if (!mMetrics)
|
|
|
|
GetMetrics();
|
|
|
|
return mSpaceGlyph;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-07-20 11:51:49 -07:00
|
|
|
static already_AddRefed<gfxOS2Font> GetOrMakeFont(const nsAString& aName,
|
|
|
|
const gfxFontStyle *aStyle);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool SetupCairoFont(gfxContext *aContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-11 07:55:31 -07:00
|
|
|
virtual FontType GetType() const { return FONT_TYPE_OS2; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2007-05-20 06:45:49 -07:00
|
|
|
cairo_font_face_t *mFontFace;
|
|
|
|
Metrics *mMetrics;
|
2007-08-19 05:27:23 -07:00
|
|
|
gfxFloat mAdjustedSize;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mSpaceGlyph;
|
2008-05-28 05:38:09 -07:00
|
|
|
int mHinting;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAntialias;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-05-29 14:59:24 -07:00
|
|
|
class gfxOS2FontGroup : public gfxFontGroup {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2008-09-30 20:01:53 -07:00
|
|
|
gfxOS2FontGroup(const nsAString& aFamilies, const gfxFontStyle* aStyle, gfxUserFontSet *aUserFontSet);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~gfxOS2FontGroup();
|
|
|
|
|
2007-05-20 06:45:49 -07:00
|
|
|
virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-20 06:45:49 -07:00
|
|
|
// create and initialize the textRun using FreeType font
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual gfxTextRun *MakeTextRun(const PRUnichar* aString, uint32_t aLength,
|
|
|
|
const Parameters* aParams, uint32_t aFlags);
|
|
|
|
virtual gfxTextRun *MakeTextRun(const uint8_t* aString, uint32_t aLength,
|
|
|
|
const Parameters* aParams, uint32_t aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
gfxOS2Font *GetFontAt(int32_t i) {
|
2008-11-25 15:22:39 -08:00
|
|
|
// If it turns out to be hard for all clients that cache font
|
|
|
|
// groups to call UpdateFontList at appropriate times, we could
|
|
|
|
// instead consider just calling UpdateFontList from someplace
|
|
|
|
// more central (such as here).
|
|
|
|
NS_ASSERTION(!mUserFontSet || mCurrGeneration == GetGeneration(),
|
|
|
|
"Whoever was caching this font group should have "
|
|
|
|
"called UpdateFontList on it");
|
|
|
|
|
2007-05-20 06:45:49 -07:00
|
|
|
#ifdef DEBUG_thebes_2
|
|
|
|
printf("gfxOS2FontGroup[%#x]::GetFontAt(%d), %#x, %#x\n",
|
|
|
|
(unsigned)this, i, (unsigned)&mFonts, (unsigned)&mFonts[i]);
|
|
|
|
#endif
|
2007-07-08 00:08:04 -07:00
|
|
|
return static_cast<gfxOS2Font*>(static_cast<gfxFont*>(mFonts[i]));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
void InitTextRun(gfxTextRun *aTextRun, const uint8_t *aUTF8Text,
|
|
|
|
uint32_t aUTF8Length, uint32_t aUTF8HeaderLength);
|
|
|
|
void CreateGlyphRunsFT(gfxTextRun *aTextRun, const uint8_t *aUTF8,
|
|
|
|
uint32_t aUTF8Length);
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool FontCallback(const nsAString& aFontName,
|
2011-07-31 14:05:14 -07:00
|
|
|
const nsACString& aGenericName,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseFontSet,
|
2011-07-31 14:05:14 -07:00
|
|
|
void *aClosure);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mEnableKerning;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GFX_OS2_FONTS_H */
|