GDIFontInstance.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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-2003, International Business Machines
  11. * Corporation and others. All Rights Reserved.
  12. *
  13. *******************************************************************************
  14. * file name: GDIFontInstance.h
  15. *
  16. * created on: 08/09/2000
  17. * created by: Eric R. Mader
  18. */
  19. #ifndef __GDIFONTINSTANCE_H
  20. #define __GDIFONTINSTANCE_H
  21. #include <windows.h>
  22. #include "layout/LETypes.h"
  23. #include "layout/LEFontInstance.h"
  24. #include "RenderingSurface.h"
  25. #include "FontTableCache.h"
  26. #include "cmaps.h"
  27. class GDIFontInstance;
  28. class GDISurface : public RenderingSurface
  29. {
  30. public:
  31. GDISurface(HDC theHDC);
  32. virtual ~GDISurface();
  33. virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count,
  34. const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height);
  35. void setFont(const GDIFontInstance *font);
  36. HDC getHDC() const;
  37. void setHDC(HDC theHDC);
  38. private:
  39. HDC fHdc;
  40. const GDIFontInstance *fCurrentFont;
  41. };
  42. inline HDC GDISurface::getHDC() const
  43. {
  44. return fHdc;
  45. }
  46. class GDIFontInstance : public LEFontInstance, protected FontTableCache
  47. {
  48. protected:
  49. GDISurface *fSurface;
  50. HFONT fFont;
  51. le_int32 fPointSize;
  52. le_int32 fUnitsPerEM;
  53. le_int32 fAscent;
  54. le_int32 fDescent;
  55. le_int32 fLeading;
  56. float fDeviceScaleX;
  57. float fDeviceScaleY;
  58. CMAPMapper *fMapper;
  59. virtual const void *readFontTable(LETag tableTag) const;
  60. virtual LEErrorCode initMapper();
  61. public:
  62. GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status);
  63. GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status);
  64. //GDIFontInstance(GDISurface *surface, le_int16 pointSize);
  65. virtual ~GDIFontInstance();
  66. HFONT getFont() const;
  67. virtual const void *getFontTable(LETag tableTag) const;
  68. virtual le_int32 getUnitsPerEM() const;
  69. virtual le_int32 getAscent() const;
  70. virtual le_int32 getDescent() const;
  71. virtual le_int32 getLeading() const;
  72. virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
  73. virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
  74. virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
  75. float getXPixelsPerEm() const;
  76. float getYPixelsPerEm() const;
  77. float getScaleFactorX() const;
  78. float getScaleFactorY() const;
  79. };
  80. inline HFONT GDIFontInstance::getFont() const
  81. {
  82. return fFont;
  83. }
  84. inline le_int32 GDIFontInstance::getUnitsPerEM() const
  85. {
  86. return fUnitsPerEM;
  87. }
  88. inline le_int32 GDIFontInstance::getAscent() const
  89. {
  90. return fAscent;
  91. }
  92. inline le_int32 GDIFontInstance::getDescent() const
  93. {
  94. return fDescent;
  95. }
  96. inline le_int32 GDIFontInstance::getLeading() const
  97. {
  98. return fLeading;
  99. }
  100. inline LEGlyphID GDIFontInstance::mapCharToGlyph(LEUnicode32 ch) const
  101. {
  102. return fMapper->unicodeToGlyph(ch);
  103. }
  104. inline float GDIFontInstance::getXPixelsPerEm() const
  105. {
  106. return (float) fPointSize;
  107. }
  108. inline float GDIFontInstance::getYPixelsPerEm() const
  109. {
  110. return (float) fPointSize;
  111. }
  112. inline float GDIFontInstance::getScaleFactorX() const
  113. {
  114. return fDeviceScaleX;
  115. }
  116. inline float GDIFontInstance::getScaleFactorY() const
  117. {
  118. return fDeviceScaleY;
  119. }
  120. #endif