GnomeFontInstance.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. *******************************************************************************
  3. *
  4. * © 2016 and later: Unicode, Inc. and others.
  5. * License & terms of use: http://www.unicode.org/copyright.html#License
  6. *
  7. *******************************************************************************
  8. *******************************************************************************
  9. *
  10. * Copyright (C) 1999-2006, International Business Machines
  11. * Corporation and others. All Rights Reserved.
  12. *
  13. *******************************************************************************
  14. * file name: GnomeFontInstance.h
  15. *
  16. * created on: 08/30/2001
  17. * created by: Eric R. Mader
  18. */
  19. #ifndef __GNOMEFONTINSTANCE_H
  20. #define __GNOMEFONTINSTANCE_H
  21. #include <gnome.h>
  22. #include <ft2build.h>
  23. #include FT_FREETYPE_H
  24. #include FT_GLYPH_H
  25. #include <cairo.h>
  26. #include "layout/LETypes.h"
  27. #include "layout/LEFontInstance.h"
  28. #include "RenderingSurface.h"
  29. #include "FontTableCache.h"
  30. #include "cmaps.h"
  31. class GnomeSurface : public RenderingSurface
  32. {
  33. public:
  34. GnomeSurface(GtkWidget *theWidget);
  35. virtual ~GnomeSurface();
  36. virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count,
  37. const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height);
  38. GtkWidget *getWidget() const;
  39. void setWidget(GtkWidget *theWidget);
  40. private:
  41. GtkWidget *fWidget;
  42. cairo_t *fCairo;
  43. };
  44. class GnomeFontInstance : public LEFontInstance, protected FontTableCache
  45. {
  46. protected:
  47. FT_Face fFace;
  48. // FT_Glyph fGlyph;
  49. cairo_font_face_t *fCairoFace;
  50. le_int32 fPointSize;
  51. le_int32 fUnitsPerEM;
  52. le_int32 fAscent;
  53. le_int32 fDescent;
  54. le_int32 fLeading;
  55. float fDeviceScaleX;
  56. float fDeviceScaleY;
  57. CMAPMapper *fMapper;
  58. virtual const void *readFontTable(LETag tableTag) const;
  59. virtual LEErrorCode initMapper();
  60. public:
  61. GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status);
  62. virtual ~GnomeFontInstance();
  63. virtual const void *getFontTable(LETag tableTag) const;
  64. virtual le_int32 getUnitsPerEM() const;
  65. virtual le_int32 getAscent() const;
  66. virtual le_int32 getDescent() const;
  67. virtual le_int32 getLeading() const;
  68. virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
  69. virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
  70. virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
  71. float getXPixelsPerEm() const;
  72. float getYPixelsPerEm() const;
  73. float getScaleFactorX() const;
  74. float getScaleFactorY() const;
  75. void rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions,
  76. le_int32 x, le_int32 y) const;
  77. };
  78. inline GtkWidget *GnomeSurface::getWidget() const
  79. {
  80. return fWidget;
  81. }
  82. inline void GnomeSurface::setWidget(GtkWidget *theWidget)
  83. {
  84. fWidget = theWidget;
  85. }
  86. /*
  87. inline FT_Instance GnomeFontInstance::getFont() const
  88. {
  89. return fInstance;
  90. }
  91. */
  92. inline le_int32 GnomeFontInstance::getUnitsPerEM() const
  93. {
  94. return fUnitsPerEM;
  95. }
  96. inline le_int32 GnomeFontInstance::getAscent() const
  97. {
  98. return fAscent;
  99. }
  100. inline le_int32 GnomeFontInstance::getDescent() const
  101. {
  102. return fDescent;
  103. }
  104. inline le_int32 GnomeFontInstance::getLeading() const
  105. {
  106. return fLeading;
  107. }
  108. inline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const
  109. {
  110. return fMapper->unicodeToGlyph(ch);
  111. }
  112. inline float GnomeFontInstance::getXPixelsPerEm() const
  113. {
  114. return (float) fPointSize;
  115. }
  116. inline float GnomeFontInstance::getYPixelsPerEm() const
  117. {
  118. return (float) fPointSize;
  119. }
  120. inline float GnomeFontInstance::getScaleFactorX() const
  121. {
  122. return fDeviceScaleX;
  123. }
  124. inline float GnomeFontInstance::getScaleFactorY() const
  125. {
  126. return fDeviceScaleY;
  127. }
  128. #endif