Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion graf2d/gpad/inc/TPadPainterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class TPadPainterBase : public TVirtualPadPainter {
TAttLine fAttLine; ///< current line attributes
TAttMarker fAttMarker; ///< current marker attributes
TAttText fAttText; ///< current text attributes
Bool_t fFullyTransparent = kFALSE; ///< if transformed fill attributes fully transparent
Bool_t fFullyTransparent = kFALSE; ///< if transformed fill attributes fully transparent

TAttFill GetAttFillInternal(Bool_t with_transparency);
virtual Double_t GetTTFScale() const { return 1.; }

public:

Expand Down
10 changes: 5 additions & 5 deletions graf2d/gpad/src/TPadPainterBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void TPadPainterBase::GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_
if (!res) {
TTFhandle ttf;
ttf.SetTextFont(font);
ttf.SetTextSize(size);
ttf.SetTextSize(size * GetTTFScale());
ttf.GetTextExtent(w, h, mess);
}
}
Expand All @@ -76,7 +76,7 @@ void TPadPainterBase::GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_
if (!res) {
TTFhandle ttf;
ttf.SetTextFont(font);
ttf.SetTextSize(size);
ttf.SetTextSize(size * GetTTFScale());
ttf.GetTextExtent(w, h, mess);
}
}
Expand All @@ -99,7 +99,7 @@ void TPadPainterBase::GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a
if (!res) {
TTFhandle ttf;
ttf.SetTextFont(font);
ttf.SetTextSize(size);
ttf.SetTextSize(size * GetTTFScale());
UInt_t w, h;
ttf.GetTextExtent(w, h, mess);
a = ttf.GetBox().yMax;
Expand All @@ -126,7 +126,7 @@ void TPadPainterBase::GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a
if (!res) {
TTFhandle ttf;
ttf.SetTextFont(font);
ttf.SetTextSize(size);
ttf.SetTextSize(size * GetTTFScale());
UInt_t w, h;
ttf.GetTextExtent(w, h, mess);
a = ttf.GetBox().yMax;
Expand All @@ -147,7 +147,7 @@ UInt_t TPadPainterBase::GetTextAdvance(Font_t font, Double_t size, const char *m

TTFhandle ttf;
ttf.SetTextFont(font);
ttf.SetTextSize(size);
ttf.SetTextSize(size * GetTTFScale());
ttf.SetKerning(kern);

UInt_t a = 0;
Expand Down
12 changes: 2 additions & 10 deletions graf3d/gl/inc/TGLPadPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ class TGLPadPainter : public TPadPainterBase {
template<class Char_t>
void DrawTextHelper(Double_t x, Double_t y, const Char_t *text, ETextMode mode);

template<class Char_t>
void TextExtentHelper(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const Char_t *text);
protected:

template<class Char_t>
void TextAscentDescentHelper(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const Char_t *text);
Double_t GetTTFScale() const override { return 1./0.93376068; }

public:
TGLPadPainter();
Expand Down Expand Up @@ -117,12 +115,6 @@ class TGLPadPainter : public TPadPainterBase {
void DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode) override;
void DrawTextNDC(Double_t, Double_t, const wchar_t *, ETextMode) override;

void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override;
void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const wchar_t *mess) override;
void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *mess) override;
void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const wchar_t *mess) override;
UInt_t GetTextAdvance(Font_t font, Double_t size, const char *text, Bool_t kern) override;

//jpg, png, gif and bmp output.
void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override;

Expand Down
80 changes: 0 additions & 80 deletions graf3d/gl/src/TGLPadPainter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -846,42 +846,6 @@ void TGLPadPainter::DrawTextHelper(Double_t x, Double_t y, const Char *text, ETe
glMatrixMode(GL_MODELVIEW);
}

////////////////////////////////////////////////////////////////////////////////
/// Helper function to get text extent

template<class Char_t>
void TGLPadPainter::TextExtentHelper(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const Char_t *text)
{
SelectGLFont(font, size);

Float_t llx, lly, llz, urx, ury, urz;
fF.BBox(text, llx, lly, llz, urx, ury, urz);
urx -= llx;
ury -= lly;
w = (UInt_t) (urx > 0. ? urx : 0.);
h = (UInt_t) (ury > 0. ? ury : 0.);
(void) llz;
(void) urz;
}

////////////////////////////////////////////////////////////////////////////////
/// Helper function to get text ascent / descent

template<class Char_t>
void TGLPadPainter::TextAscentDescentHelper(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const Char_t *text)
{
SelectGLFont(font, size);

Float_t llx, lly, llz, urx, ury, urz;
fF.BBox(text, llx, lly, llz, urx, ury, urz);
a = (UInt_t) (ury > 0. ? ury : 0.);
d = (UInt_t) (lly < 0. ? -lly : 0.);
(void) llx;
(void) llz;
(void) urx;
(void) urz;
}

////////////////////////////////////////////////////////////////////////////////
///Draw text. This operation is especially
///dangerous if in locked state -
Expand Down Expand Up @@ -925,50 +889,6 @@ void TGLPadPainter::DrawTextNDC(Double_t u, Double_t v, const char *text, ETextM
DrawText(gPad->GetX1() + u * xRange, gPad->GetY1() + v * yRange, text, mode);
}

////////////////////////////////////////////////////////////////////////////////
/// Get text extent

void TGLPadPainter::GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *text)
{
TextExtentHelper(font, size, w, h, text);
}

////////////////////////////////////////////////////////////////////////////////
/// Get text extent

void TGLPadPainter::GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const wchar_t *text)
{
TextExtentHelper(font, size, w, h, text);
}

////////////////////////////////////////////////////////////////////////////////
/// Get text extent

void TGLPadPainter::GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *text)
{
TextAscentDescentHelper(font, size, a, d, text);
}

////////////////////////////////////////////////////////////////////////////////
/// Get text extent

void TGLPadPainter::GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const wchar_t *text)
{
TextAscentDescentHelper(font, size, a, d, text);
}

////////////////////////////////////////////////////////////////////////////////
/// Get text advance

UInt_t TGLPadPainter::GetTextAdvance(Font_t font, Double_t size, const char *text, Bool_t)
{
SelectGLFont(font, size);

auto advance = fF.Advance(text);

return (UInt_t) (advance > 0. ? advance : 0.);
}

////////////////////////////////////////////////////////////////////////////////
///Draw text in NDC. This operation is especially
///dangerous if in locked state -
Expand Down
Loading