kate Library API Documentation

katefont.cpp

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002 Christian Couder <christian@kdevelop.org> 00003 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00004 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> 00005 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License version 2 as published by the Free Software Foundation. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #include "katefont.h" 00023 00024 #include <kglobalsettings.h> 00025 00026 #include <qfontinfo.h> 00027 00028 // 00029 // KateFontMetrics implementation 00030 // 00031 00032 KateFontMetrics::KateFontMetrics(const QFont& f) : QFontMetrics(f) 00033 { 00034 for (int i=0; i<256; i++) warray[i]=0; 00035 } 00036 00037 KateFontMetrics::~KateFontMetrics() 00038 { 00039 for (int i=0; i<256; i++) 00040 delete[] warray[i]; 00041 } 00042 00043 short * KateFontMetrics::createRow (short *wa, uchar row) 00044 { 00045 wa=warray[row]=new short[256]; 00046 00047 for (int i=0; i<256; i++) wa[i]=-1; 00048 00049 return wa; 00050 } 00051 00052 int KateFontMetrics::width(QChar c) 00053 { 00054 uchar cell=c.cell(); 00055 uchar row=c.row(); 00056 short *wa=warray[row]; 00057 00058 if (!wa) 00059 wa = createRow (wa, row); 00060 00061 if (wa[cell]<0) wa[cell]=(short) QFontMetrics::width(c); 00062 00063 return (int)wa[cell]; 00064 } 00065 00066 // 00067 // KateFontStruct implementation 00068 // 00069 00070 KateFontStruct::KateFontStruct() 00071 : myFont(KGlobalSettings::fixedFont()), 00072 myFontBold(KGlobalSettings::fixedFont()), 00073 myFontItalic(KGlobalSettings::fixedFont()), 00074 myFontBI(KGlobalSettings::fixedFont()), 00075 myFontMetrics(myFont), 00076 myFontMetricsBold(myFontBold), 00077 myFontMetricsItalic(myFontItalic), 00078 myFontMetricsBI(myFontBI), 00079 m_fixedPitch (false) 00080 { 00081 updateFontData (); 00082 } 00083 00084 KateFontStruct::~KateFontStruct() 00085 { 00086 } 00087 00088 void KateFontStruct::updateFontData () 00089 { 00090 int maxAscent = myFontMetrics.ascent(); 00091 int maxDescent = myFontMetrics.descent(); 00092 00093 fontHeight = maxAscent + maxDescent + 1; 00094 fontAscent = maxAscent; 00095 00096 m_fixedPitch = QFontInfo( myFont ).fixedPitch(); 00097 } 00098 00099 void KateFontStruct::setFont (const QFont & font) 00100 { 00101 myFont = font; 00102 00103 myFontBold = QFont (font); 00104 myFontBold.setBold (true); 00105 00106 myFontItalic = QFont (font); 00107 myFontItalic.setItalic (true); 00108 00109 myFontBI = QFont (font); 00110 myFontBI.setBold (true); 00111 myFontBI.setItalic (true); 00112 00113 myFontMetrics = KateFontMetrics (myFont); 00114 myFontMetricsBold = KateFontMetrics (myFontBold); 00115 myFontMetricsItalic = KateFontMetrics (myFontItalic); 00116 myFontMetricsBI = KateFontMetrics (myFontBI); 00117 00118 updateFontData (); 00119 } 00120 00121 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE Logo
This file is part of the documentation for kate Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:35:13 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003