1 // 2 // C++ Interface: fmsharestruct 3 // 4 // Description: 5 // 6 // 7 // Author: Pierre Marchand <pierremarc@oep-h.com>, (C) 2008 8 // 9 // Copyright: See COPYING file that comes with this distribution 10 // 11 // 12 #ifndef FMSHARESTRUCT_H 13 #define FMSHARESTRUCT_H 14 15 #include <QList> 16 // #include <QMap> 17 #include <QPair> 18 #include <QDebug> 19 20 #include <QString> 21 #include <QStringList> 22 23 struct OTFSet 24 { 25 QString script; 26 QString lang; 27 QStringList gpos_features; 28 QStringList gsub_features; OTFSetOTFSet29 OTFSet() {}; OTFSetOTFSet30 OTFSet ( const OTFSet& os ) 31 : script ( os.script ), 32 lang ( os.lang ), 33 gpos_features ( os.gpos_features ), 34 gsub_features ( os.gsub_features ) {}; dumpOTFSet35 QString dump() {return script + "|" +lang+ "|"+ gpos_features.join ( "|" ) + gsub_features.join ( "|" );} isEmptyOTFSet36 bool isEmpty() { return script.isEmpty() && lang.isEmpty() && gpos_features.isEmpty() && gsub_features.isEmpty() ;}; 37 }; 38 39 40 struct RenderedGlyph 41 { 42 int glyph; 43 int log; 44 double xadvance; 45 double yadvance; 46 double xoffset; 47 double yoffset; 48 unsigned short lChar; 49 /** 50 As it’s quite usual with hyphenation, it’s not very clear! 51 hyphenKey indicates if it’s breakable (>0) and is a key to retrieve 52 left and right rendered string of the broken word this glyph belongs. 53 e.g.: rendered word == "[p][u][p][p][y]" and this glyph is index 2 54 We have hyphenKey == 1 and hyphenValue.value(1).first == [p][u][p][-] and hyphenValue.value(1).second == [p][y] 55 If it’s still not clear, e-mail me - pm 56 Agh, it was indeed over complicated! - pm 57 */ 58 // unsigned short hyphenKey; 59 bool isBreak; 60 QPair<QList<RenderedGlyph>, QList<RenderedGlyph> > hyphen; 61 RenderedGlyphRenderedGlyph62 RenderedGlyph():glyph(0),log(0),xadvance(0),yadvance(0),xoffset(0),yoffset(0),lChar(0),isBreak(false){} RenderedGlyphRenderedGlyph63 RenderedGlyph(int g,int l,double xa,double ya,double xo,double yo,unsigned short c,bool b) 64 :glyph(g),log(l),xadvance(xa),yadvance(ya),xoffset(xo),yoffset(yo),lChar(c),isBreak(b){} 65 66 bool operator==( const RenderedGlyph& other ) const{ 67 if(glyph != other.glyph) 68 return false; 69 else if(lChar != other.lChar) 70 return false; 71 else if(xadvance != other.xadvance) 72 return false; 73 else if(yadvance != other.yadvance) 74 return false; 75 else if(xoffset != other.xoffset) 76 return false; 77 else if(yoffset != other.yoffset) 78 return false; 79 else if(isBreak != other.isBreak) 80 return false; 81 return true; 82 } 83 dumpRenderedGlyph84 void dump() const 85 { 86 QString ds("glyph %1; log %2; xadv %3; yadv %4; xof %5; yof %6; char %7; hyph %8"); 87 qDebug() << ds.arg(glyph) 88 .arg(log) 89 .arg(xadvance) 90 .arg(yadvance) 91 .arg(xoffset) 92 .arg(yoffset) 93 .arg(QChar(lChar)) 94 .arg(hyphen.first.count()); 95 } 96 }; 97 98 typedef QList<RenderedGlyph> GlyphList; 99 typedef QPair<QList<RenderedGlyph>, QList<RenderedGlyph> > RenderedHyph; 100 101 102 typedef QMap<int,QMap<int, QString> > FontInfoMap; 103 104 #endif 105