72#define FONT_UNDERLINE 4
73#define FONT_OVERSTRIKE 5
74#define FONT_NUMFIELDS 6
83#define XLFD_SETWIDTH 4
84#define XLFD_ADD_STYLE 5
85#define XLFD_PIXEL_SIZE 6
86#define XLFD_POINT_SIZE 7
87#define XLFD_RESOLUTION_X 8
88#define XLFD_RESOLUTION_Y 9
89#define XLFD_SPACING 10
90#define XLFD_AVERAGE_WIDTH 11
91#define XLFD_REGISTRY 12
92#define XLFD_ENCODING 13
93#define XLFD_NUMFIELDS 14
267 0, 0, 0, 0, 0, 0, 0,
'a',
'b',
't',
'n',
'v',
'f',
'r', 0
289 Error(
"GetFontMetrics",
"argument may not be 0");
313 Printf(
"TGFont: %s, %s, ref cnt = %u",
363 family =
"Helvetica";
364 }
else if ((
strcasecmp(family,
"Times New Roman") == 0)
367 }
else if ((
strcasecmp(family,
"Courier New") == 0)
370 }
else if (
strcasecmp(family,
"AvantGarde") == 0) {
371 family =
"AvantGarde";
372 }
else if (
strcasecmp(family,
"ZapfChancery") == 0) {
373 family =
"ZapfChancery";
374 }
else if (
strcasecmp(family,
"ZapfDingbats") == 0) {
375 family =
"ZapfDingbats";
400 family = (
char *)
dst->Data() +
len;
402 if (family != (
char *)
dst->Data() +
len) {
404 family = (
char *)
dst->Data() +
len;
406 if (
strcasecmp(family,
"NewCenturySchoolbook") == 0) {
408 dst->Append(
"NewCenturySchlbk");
409 family = (
char *)
dst->Data() +
len;
416 if (
strcmp(family,
"Bookman") == 0) {
418 }
else if (
strcmp(family,
"AvantGarde") == 0) {
420 }
else if (
strcmp(family,
"ZapfChancery") == 0) {
424 if ((
strcmp(family,
"Bookman") == 0)
425 || (
strcmp(family,
"AvantGarde") == 0)) {
438 if ((
strcmp(family,
"Helvetica") == 0)
439 || (
strcmp(family,
"Courier") == 0)
440 || (
strcmp(family,
"AvantGarde") == 0)) {
451 if ((
strcmp(family,
"Times") == 0)
452 || (
strcmp(family,
"NewCenturySchlbk") == 0)
453 || (
strcmp(family,
"Palatino") == 0)) {
454 dst->Append(
"-Roman");
665 const char *start, *end, *
special;
706 for (start =
string; start < end;) {
774 if ((*start ==
'\n') || (*start ==
'\r')) {
779 if (*start ==
'\t') {
833 if (
layout->fChunks[
layout->fNumChunks - 1].fStart[0] ==
'\n') {
835 chunk->fNumDisplayChars = -1;
847 for (
n = 0;
n <
layout->fNumChunks;
n++) {
857 chunk->fX += extra / 2;
867 if (
layout->fNumChunks == 0) {
876 layout->fChunks[0].fStart = string;
877 layout->fChunks[0].fNumChars = 0;
878 layout->fChunks[0].fNumDisplayChars = -1;
879 layout->fChunks[0].fX = 0;
881 layout->fChunks[0].fTotalWidth = 0;
882 layout->fChunks[0].fDisplayWidth = 0;
1046 if (
chunk->fNumDisplayChars < 0) {
1121 if (
chunk->fNumDisplayChars < 0) {
1124 ww =
chunk->fTotalWidth;
1193 Int_t i,
x1,
x2,
y1,
y2,
xDiff,
yDiff, dist,
minDist,
ascent,
descent;
1202 if (
chunk->fStart[0] ==
'\n') {
1217 }
else if (
x >=
x2) {
1225 }
else if (
y >=
y2) {
1261 Int_t left, top, right, bottom;
1277 if (
chunk->fStart[0] ==
'\n') {
1290 if ((right <
x1) || (left >=
x2) || (bottom <
y1) || (top >=
y2)) {
1295 }
else if ((
x1 < left) || (
x2 >= right) || (
y1 < top) || (
y2 >= bottom)) {
1297 }
else if (
result == -1) {
1353 if (
chunk->fNumDisplayChars <= 0) {
1354 if (
chunk->fStart[0] ==
'\t') {
1359 for (
j = 0;
j <
chunk->fNumDisplayChars;
j++) {
1361 if ((
c ==
'(') || (
c ==
')') || (
c ==
'\\') || (
c < 0x20) || (
c >=
UChar_t(0x7f))) {
1426 if (
layout->fNumChunks > 0) {
1428 delete[]
layout->fChunks;
1435 chunk->fStart = start;
1560 if (!font || !*font) {
1561 Error(
"GetFont",
"argument may not be 0 or empty");
1610 f->MeasureChars(
"0", 1, 0, 0, &
f->fTabWidth);
1612 if (!
f->fTabWidth) {
1613 f->fTabWidth =
f->fFM.fMaxWidth;
1620 if (!
f->fTabWidth) {
1629 f->fUnderlineHeight =
f->fFA.fPointsize/10;
1631 if (!
f->fUnderlineHeight) {
1632 f->fUnderlineHeight = 1;
1634 if (
f->fUnderlinePos +
f->fUnderlineHeight >
descent) {
1640 f->fUnderlineHeight =
descent -
f->fUnderlinePos;
1642 if (!
f->fUnderlineHeight) {
1644 f->fUnderlineHeight = 1;
1722 if (
f->RemoveReference() == 0) {
1730 if ((
nf->RemoveReference() == 0) && (
nf->fDeletePending != 0)) {
1749 while ((
f = (
TGFont*) next())) {
1750 if (
f->fFontStruct == font) {
1766 while ((
f = (
TGFont*) next())) {
1767 if (
f->fFontH == font) {
1795 return (
const char *)obj->
GetName();
1808 const char *str = 0;
1848 result[i] =
new char[20];
1893 out <<
" TGFont *ufont; // will reflect user font changes" << std::endl;
1895 out <<
" ufont = gClient->GetFont(" <<
quote <<
GetName() <<
quote <<
");" << std::endl;
1914 while (*
p && ((*
p ==
' ') || (*
p ==
'\t'))) {
1929 while (*
p && (*
p !=
'"')) {
1938 while (*
p && (*
p !=
' ') && (*
p !=
'\t')) {
1970 char *str =
new char[
len];
1973 if (*str ==
'-' || *str ==
'*') {
2065 if (*str ==
'-') str++;
2067 ds.Append((
char *) str);
2068 src = (
char*)
ds.Data();
2071 for (i = 0; *
src !=
'\0';
src++) {
2150 xa->fFA.fPointsize /= 10;
2177 xa->fFA.fPointsize = -
xa->fFA.fPointsize;
2213 for (
m = map;
m->fStrKey != 0;
m++) {
2230 for ( ; map->
fStrKey != 0; map++) {
2256 return (ch !=
'*' && ch !=
'?');
2277 char *family, *end, *
p;
2298 end =
strchr(family,
'-');
2303 for (
p = family; *
p !=
'\0';
p++) {
2314 dst =
new char*[entries+1];
2320 while ((obj = next())) {
2339 for (i = 0;
f[i] != 0; ++i) {
2365 const char *
fmt, *family;
2387 fmt =
"-*-%.240s-*-*-*-*-*-*-*-*-*-*-*-*";
2437 if (!
xa.fFA.fPointsize) {
2517 str =
strchr(str + 1,
'-');
2521 rest =
strchr(rest + 1,
'-');
2613 if (
newFont->fFA.fPointsize < 0) {
2617 d = -
newFont->fFA.fPointsize * 72/25.4;
2641 for (i = 0; i < 256; i++) {
2642 if ((i == 160) || (i == 173) || (i == 177) ||
2655 char ch[2] = {0, 0};
2657 for (i = 0; i < 256; i++) {
2686 for (i = 0; i < 256; i++) {
2702 if (
newFont->fBarHeight == 0) {
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Handle_t GContext_t
Graphics context handle.
Handle_t Drawable_t
Drawable handle.
Handle_t FontStruct_t
Pointer to font structure.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Int_t gErrorIgnoreLevel
Error handling routines.
static const FontStateMap_t gWeightMap[]
static char * GetToken(char *str)
static const FontStateMap_t gXlfdCharsetMap[]
static const FontStateMap_t gUnderlineMap[]
static const FontStateMap_t gOverstrikeMap[]
static int GetControlCharSubst(int c, char buf[4])
When displaying text in a widget, a backslashed escape sequence is substituted for control characters...
static const FontStateMap_t gXlfdSlantMap[]
static const FontStateMap_t gSlantMap[]
static const FontStateMap_t gXlfdgWeightMap[]
static const FontStateMap_t gXlfdSetwidthMap[]
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char y1
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
Provides a pool of fonts.
Bool_t ParseFontName(const char *string, FontAttributes_t *fa)
Converts a string into a set of font attributes that can be used to construct a font.
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
const char * NameOfFont(TGFont *font)
Given a font, return a textual string identifying it.
char ** GetFontFamilies()
Return information about the font families that are available on the current display.
TGFontPool(const TGFontPool &fp)=delete
Bool_t ParseXLFD(const char *string, XLFDAttributes_t *xa)
Break up a fully specified XLFD into a set of font attributes.
int FindStateNum(const FontStateMap_t *map, const char *strKey)
Given a lookup table, map a string to a number in the table.
TGFont * GetNativeFont(const char *name, Bool_t fixedDefault=kTRUE)
The return value is a pointer to an TGFont object that represents the native font.
const char * GetUid(const char *string)
Given a string, this procedure returns a unique identifier for the string.
Bool_t FieldSpecified(const char *field)
Helper function for ParseXLFD().
TGFont * FindFontByHandle(FontH_t font) const
Find font based on its font handle. Returns 0 if font is not found.
void FreeFont(const TGFont *font)
Free font. If ref count is 0 delete font.
char ** GetAttributeInfo(const FontAttributes_t *fa)
Return information about the font attributes as an array of strings.
const char * FindStateString(const FontStateMap_t *map, int numKey)
Given a lookup table, map a number to a string in the table.
void FreeFontFamilies(char **f)
Delete an array of families allocated GetFontFamilies() method.
TGFont * GetFontFromAttributes(FontAttributes_t *fa, TGFont *fontPtr)
Given a desired set of attributes for a font, find a font with the closest matching attributes and cr...
TGFont * MakeFont(TGFont *font, FontStruct_t fontStruct, const char *fontName)
Helper for GetNativeFont() and GetFontFromAttributes().
~TGFontPool() override
Cleanup font pool.
TGFont * FindFont(FontStruct_t font) const
Find font based on its font struct. Returns 0 if font is not found.
void Print(Option_t *option="") const override
List all fonts in the pool.
void FreeAttributeInfo(char **info)
Free attributes info.
Encapsulate fonts used in the GUI system.
char fTypes[256]
Array giving types of all characters in the font, used when displaying control characters.
void GetFontMetrics(FontMetrics_t *m) const
Get font metrics.
void UnderlineChars(Drawable_t dst, GContext_t gc, const char *string, Int_t x, Int_t y, Int_t firstChar, Int_t lastChar) const
This procedure draws an underline for a given range of characters in a given string.
friend class TGTextLayout
void DrawCharsExp(Drawable_t dst, GContext_t gc, const char *source, Int_t numChars, Int_t x, Int_t y) const
Draw a string of characters on the screen.
Int_t fBarHeight
Height of underline or overstrike bar (used for simulating a native underlined or strikeout font).
TObjString * fNamedHash
Pointer to the named object TGFont was based on.
Int_t fWidths[256]
Array giving widths of all possible characters in the font.
Int_t MeasureChars(const char *source, Int_t numChars, Int_t maxLength, Int_t flags, Int_t *length) const
Determine the number of characters from the string that will fit in the given horizontal span.
~TGFont() override
Delete font.
Int_t fTabWidth
Width of tabs in this font (pixels).
Int_t TextWidth(const char *string, Int_t numChars=-1) const
A wrapper function for the more complicated interface of MeasureChars.
Int_t fUnderlineHeight
Height of underline bar (used for drawing underlines on a non-underlined font).
FontStruct_t operator()() const
Not inline due to a bug in g++ 2.96 20000731 (Red Hat Linux 7.0)
FontAttributes_t fFA
Actual font attributes obtained when the font was created.
LayoutChunk_t * NewChunk(TGTextLayout *layout, int *maxPtr, const char *start, int numChars, int curX, int newX, int y) const
Helper function for ComputeTextLayout().
FontMetrics_t fFM
Cached font metrics.
Int_t XTextWidth(const char *string, Int_t numChars=-1) const
Return text width in pixels.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save the used font as a C++ statement(s) on output stream out.
TGTextLayout * ComputeTextLayout(const char *string, Int_t numChars, Int_t wrapLength, Int_t justify, Int_t flags, UInt_t *width, UInt_t *height) const
Computes the amount of screen space needed to display a multi-line, justified string of text.
Int_t fUnderlinePos
Offset from baseline to origin of underline bar (used for drawing underlines on a non-underlined font...
Int_t PostscriptFontName(TString *dst) const
Return the name of the corresponding Postscript font for this TGFont.
void DrawChars(Drawable_t dst, GContext_t gc, const char *source, Int_t numChars, Int_t x, Int_t y) const
Perform a quick sanity check to ensure we won't overflow the X coordinate space.
FontStruct_t fFontStruct
Low level graphics fontstruct.
void Print(Option_t *option="") const override
Print font info.
TGClient * fClient
Connection to display server.
Is used to keep track of string measurement information when using the text layout facilities.
void DrawText(Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t firstChar, Int_t lastChar) const
Use the information in the TGTextLayout object to display a multi-line, justified string of text.
Int_t PointToChar(Int_t x, Int_t y) const
Use the information in the TGTextLayout token to determine the character closest to the given point.
Int_t IntersectText(Int_t x, Int_t y, Int_t w, Int_t h) const
Determines whether a text layout lies entirely inside, entirely outside, or overlaps a given rectangl...
const TGFont * fFont
The font used when laying out the text.
void ToPostscript(TString *dst) const
Outputs the contents of a text layout in Postscript format.
Int_t fNumChunks
Number of chunks actually used in following array.
Int_t DistanceToText(Int_t x, Int_t y) const
Computes the distance in pixels from the given point to the given text layout.
Int_t CharBbox(Int_t index, Int_t *x, Int_t *y, Int_t *w, Int_t *h) const
Use the information in the TGTextLayout token to return the bounding box for the character specified ...
LayoutChunk_t * fChunks
Array of chunks. The actual size will be maxChunks.
Int_t fWidth
The maximum width of all lines in the text layout.
void UnderlineChar(Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t underline) const
Use the information in the TGTextLayout object to display an underline below an individual character.
const char * fString
The string that was laid out.
~TGTextLayout() override
destructor
THashTable implements a hash table to store TObject's.
void Add(TObject *obj) override
Add object to the hash table.
TObject * Remove(TObject *obj) override
Remove object from the hashtable.
TObject * FindObject(const char *name) const override
Find object using its name.
void Print(Option_t *option, Int_t recurse) const override
Print the collection header and its elements.
const char * GetName() const override
Returns name of object.
Collectable string class.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definitions for TRefCnt, base class for reference counted objects.
UInt_t References() const
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Double_t Hypot(Double_t x, Double_t y)
Returns sqrt(x*x + y*y)
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.