class KCharsets

Charset font and encoder/decoder handling. More...

Definition#include <kcharsets.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Protected Methods


Detailed Description

Charset font and encoder/decoder handling.

This is needed, because Qt's font matching algorithm gives the font family a higher priority than the charset. For many applications this is not acceptable, since it can totally obscure the output, in languages which use non iso-8859-1 charsets.

 KCharsets ()

KCharsets

[protected]

protected constructor. If you need the kcharsets object, use KGlobal::charsets() instead.

 ~KCharsets ()

~KCharsets

[virtual]

QTextCodeccodecForName (const QString &name)

codecForName

[const]

provided for compitibility.

QTextCodeccodecForName (const QString &n, bool &ok)

codecForName

[const]

tries to find a QTextCodec to convert the given encoding from and to Unicode. If no codec could be found the latin1 codec will be returned an ok will be set to false.

QFont::CharSet  charsetForEncoding (const QString &encoding)

charsetForEncoding

[const]

Returns: the charset that fits a given encoding best (that can display a file in the given encoding)

QFont::CharSet  charsetForEncoding (const QString &e, bool noUnicode)

charsetForEncoding

[const]

overloaded member function. Usually you don't mind getting unicode charsets, so this method should rarely be needed.

QChar  fromEntity (const QString &str)

fromEntity

[const]

converts an entity to a character. The string must contain only the entity without the trailing ';'.

Returns: QChar::null if the entity could not be decoded.

QChar  fromEntity (const QString &str, int &len)

fromEntity

[const]

Overloaded member function. Tries to find an entity in the QString str.

Parameters:
lenis a return value, that gives the length of the decoded entity.

Returns: a decoded entity if one could be found, QChar::null otherwise

QString  toEntity (const QChar &ch)

toEntity

[const]

converts a QChar to an entity. The returned string does already contain the leading '&' and the trailing ';'.

QList  availableCharsets (QString family = QString::null)

availableCharsets

lists all available charsets for a given family. if family is omitted, it will return all charsets available.

It is the resonsability of the caller to delete the items in the list.

QStringList  availableCharsetNames (QString family = QString::null)

availableCharsetNames

as above, but returns the names of the charsets

QStringList  availableEncodingNames ()

availableEncodingNames

Lists all available encodings as names.

QStringList  descriptiveEncodingNames ()

descriptiveEncodingNames

Lists the available encoding names together with a more descriptive language.

QString  languageForEncoding ( const QString &encoding )

languageForEncoding

returns the language the encoding is used for.

QString  encodingForName ( const QString &descriptiveName )

encodingForName

returns the encoding for a string obtained with descriptiveEncodingNames()

QFont  fontForChar ( const QChar &ch, const QFont &f )

fontForChar

[const]

Returns: a QFont, which can print the character given, and is closest to the font given. if no mathing font could be found, the returned font will have the charset QFont::Any.

QStringList  availableFamilies ( QFont::CharSet ch )

availableFamilies

Returns: all families that have a font in the give charset

void  setQFont (QFont &f, QFont::CharSet charset = QFont::Unicode)

setQFont

[const]

sets the QFont f to the charset given in charset. Opposed to QFont's setCharset() function, this function will do it's best to find a font which can display the given charset. It might change the font's family for this purpose, but care is taken to find a family which is as close as possible to the font given.

void  setQFont (QFont &f, QString charset)

setQFont

[const]

overloaded member function. Provided for convenience.

QString  name (const QFont &f)

name

Returns: the name of the charset f is set to.

QString  name (QFont::CharSet c)

name

Returns: the name of the Charset c.

bool  isAvailable (QFont::CharSet charset)

isAvailable

is a font with the given charset available?

bool  isAvailable (const QString &charset)

isAvailable

overloaded member function. Provided for convenience.

QFont::CharSet  charsetForLocale ()

charsetForLocale

Returns: the charset for the locale.

bool  hasUnicode (QString family)

hasUnicode

[const]

does the given font family have a unicode encoding?

bool  hasUnicode (QFont &font)

hasUnicode

[const]

does given font exist with a unicode encoding?

bool  supportsScript ( const QFont &f, QFont::CharSet charset )

supportsScript

does the give font support the script given by charset? This can return tru in two cases: Either the font is in the right charset or it is a unicode font containing glyphs to display this charset.

There are some exceptions. A 8859-6 font will return false if asked if it supports the 8859-6 charset, because we need a unicode font to properly display arabic.

enum FixedType { FixedUnknown, Fixed, Proportional }

FixedType

enum WeightType { WeightUnknown, Medium, Bold }

WeightType

enum SlantType { SlantUnknown, Normal, Italic }

SlantType

QString  xCharsetName (QFont::CharSet)

xCharsetName

[const]

QFont::CharSet  nameToID (QString name)

nameToID

[const]

QFont::CharSet  xNameToID (QString name)

xNameToID

[const]