RDKit
Open-source cheminformatics and machine learning.
DrawTextCairo.h
Go to the documentation of this file.
1 //
2 // @@ All Rights Reserved @@
3 // This file is part of the RDKit.
4 // The contents are covered by the terms of the BSD license
5 // which is included in the file license.txt, found at the root
6 // of the RDKit source tree.
7 //
8 // Original author: David Cosgrove (CozChemIx) on 29/04/2020.
9 //
10 // A concrete class derived from DrawText that uses the Cairo
11 // toy API to draw text onto a surface.
12 
13 #ifndef RDKIT_DRAWTEXTCAIRO_H
14 #define RDKIT_DRAWTEXTCAIRO_H
15 
16 #include <cairo.h>
17 
19 
20 namespace RDKit {
21 
22 // ****************************************************************************
23 class DrawTextCairo : public DrawText {
24  public:
25  DrawTextCairo(double max_fnt_sz, double min_fnt_sz, cairo_t *dp_cr);
26 
27 #if 0
28  void getStringSize(const std::string &label, double &label_width,
29  double &label_height) const override;
30 #endif
31  void drawChar(char c, const Point2D &cds) override;
32 
33  private:
34  cairo_t *dp_cr_;
35 
36  // return a vector of StringRects, one for each char in text, with
37  // super- and subscripts taken into account. Sizes in pixel coords,
38  // i.e. scaled by fontScale().
39  void getStringRects(const std::string &text,
40  std::vector<std::shared_ptr<StringRect>> &rects,
41  std::vector<TextDrawType> &draw_modes,
42  std::vector<char> &draw_chars) const override;
43 };
44 
45 } // namespace RDKit
46 
47 #endif // RDKIT_DRAWTEXTCAIRO_H
DrawTextCairo(double max_fnt_sz, double min_fnt_sz, cairo_t *dp_cr)
void drawChar(char c, const Point2D &cds) override
virtual void getStringSize(const std::string &label, double &label_width, double &label_height) const
using the current scale, work out the size of the label
Std stuff.
Definition: Abbreviations.h:17