• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
katefont.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2002 Christian Couder <christian@kdevelop.org>
3  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
4  Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
5  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License version 2 as published by the Free Software Foundation.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "katefont.h"
23 
24 #include <tdeglobalsettings.h>
25 
26 #include <tqfontinfo.h>
27 
28 //
29 // KateFontMetrics implementation
30 //
31 
32 KateFontMetrics::KateFontMetrics(const TQFont& f) : TQFontMetrics(f)
33 {
34  for (int i=0; i<256; i++) warray[i]=0;
35 }
36 
37 KateFontMetrics::~KateFontMetrics()
38 {
39  for (int i=0; i<256; i++)
40  delete[] warray[i];
41 }
42 
43 short * KateFontMetrics::createRow (short *wa, uchar row)
44 {
45  wa=warray[row]=new short[256];
46 
47  for (int i=0; i<256; i++) wa[i]=-1;
48 
49  return wa;
50 }
51 
52 int KateFontMetrics::width(TQChar c)
53 {
54  uchar cell=c.cell();
55  uchar row=c.row();
56  short *wa=warray[row];
57 
58  if (!wa)
59  wa = createRow (wa, row);
60 
61  if (wa[cell]<0) wa[cell]=(short) TQFontMetrics::width(c);
62 
63  return (int)wa[cell];
64 }
65 
66 //
67 // KateFontStruct implementation
68 //
69 
70 KateFontStruct::KateFontStruct()
71 : myFont(TDEGlobalSettings::fixedFont()),
72  myFontBold(TDEGlobalSettings::fixedFont()),
73  myFontItalic(TDEGlobalSettings::fixedFont()),
74  myFontBI(TDEGlobalSettings::fixedFont()),
75  myFontMetrics(myFont),
76  myFontMetricsBold(myFontBold),
77  myFontMetricsItalic(myFontItalic),
78  myFontMetricsBI(myFontBI),
79  m_fixedPitch (false)
80 {
81  updateFontData ();
82 }
83 
84 KateFontStruct::~KateFontStruct()
85 {
86 }
87 
88 void KateFontStruct::updateFontData ()
89 {
90  int maxAscent = myFontMetrics.ascent();
91  int maxDescent = myFontMetrics.descent();
92 
93  fontHeight = maxAscent + maxDescent + 1;
94  fontAscent = maxAscent;
95 
96  m_fixedPitch = TQFontInfo( myFont ).fixedPitch();
97 }
98 
99 void KateFontStruct::setFont (const TQFont & font)
100 {
101  TQFontMetrics testFM (font);
102 
103  // no valid font tried
104  if ((testFM.ascent() + testFM.descent() + 1) < 1)
105  return;
106 
107  myFont = font;
108 
109  myFontBold = TQFont (font);
110  myFontBold.setBold (true);
111 
112  myFontItalic = TQFont (font);
113  myFontItalic.setItalic (true);
114 
115  myFontBI = TQFont (font);
116  myFontBI.setBold (true);
117  myFontBI.setItalic (true);
118 
119  myFontMetrics = KateFontMetrics (myFont);
120  myFontMetricsBold = KateFontMetrics (myFontBold);
121  myFontMetricsItalic = KateFontMetrics (myFontItalic);
122  myFontMetricsBI = KateFontMetrics (myFontBI);
123 
124  updateFontData ();
125 }
TDEGlobalSettings

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.1
This website is maintained by Timothy Pearson.