325
// create new letter:
326
RS_FontChar* letter =
327
new RS_FontChar(NULL, ch, RS_Vector(0.0, 0.0));
329
// Read entities of this letter:
326
QStringList fontData;
334
328
line = ts.readLine();
336
if (line.isEmpty()) {
329
if(line.isEmpty()) break;
330
fontData.push_back(line);
332
if(fontData.size()>0) {
333
rawLffFontList[QString(ch)]=fontData;
342
void RS_Font::generateAllFonts(){
343
QMap<QString, QStringList>::const_iterator i = rawLffFontList.constBegin();
344
while (i != rawLffFontList.constEnd()) {
345
generateLffFont(i.key());
350
RS_Block* RS_Font::generateLffFont(const QString& ch){
351
if(rawLffFontList.contains(ch) == false ){
352
RS_DEBUG->print("RS_Font::generateLffFont(QChar %s ) : can not find the letter in given lff font file",qPrintable(ch));
355
// create new letter:
356
RS_FontChar* letter =
357
new RS_FontChar(NULL, ch, RS_Vector(0.0, 0.0));
359
// Read entities of this letter:
362
QStringList fontData=rawLffFontList[ch];
365
while(fontData.isEmpty() == false) {
366
line = fontData.takeFirst();
368
if (line.isEmpty()) {
373
if (line.at(0)=='C') {
375
int uCode = line.toInt(NULL, 16);
376
QChar ch = QChar(uCode);
377
RS_Block* bk = letterList.find(ch);
378
if (bk == NULL && rawLffFontList.contains(ch) == true) {
380
bk = letterList.find(ch);
383
RS_Entity* bk2 = bk->clone();
384
bk2->setPen(RS_Pen(RS2::FlagInvalid));
386
letter->addEntity(bk2);
391
vertex = line.split(';', QString::SkipEmptyParts);
392
//at least is required two vertex
395
RS_Polyline* pline = new RS_Polyline(letter, RS_PolylineData());
396
pline->setPen(RS_Pen(RS2::FlagInvalid));
397
pline->setLayer(NULL);
398
for (int i = 0; i < vertex.size(); ++i) {
402
coords = vertex.at(i).split(',', QString::SkipEmptyParts);
403
//at least X,Y is required
341
if (line.at(0)=='C') {
343
int uCode = line.toInt(NULL, 16);
344
QChar ch = QChar(uCode);
345
RS_Block* bk = letterList.find(ch);
347
RS_Entity* bk2 = bk->clone();
348
bk2->setPen(RS_Pen(RS2::FlagInvalid));
350
letter->addEntity(bk2);
355
vertex = line.split(';', QString::SkipEmptyParts);
356
//at least is required two vertex
359
RS_Polyline* pline = new RS_Polyline(letter, RS_PolylineData());
360
pline->setPen(RS_Pen(RS2::FlagInvalid));
361
pline->setLayer(NULL);
362
for (int i = 0; i < vertex.size(); ++i) {
366
coords = vertex.at(i).split(',', QString::SkipEmptyParts);
367
//at least X,Y is required
370
x1 = coords.at(0).toDouble();
371
y1 = coords.at(1).toDouble();
372
//check presence of bulge
373
if (coords.size() == 3 && coords.at(2).at(0) == QChar('A')){
374
QString bulgeStr = coords.at(2);
375
bulge = bulgeStr.remove(0,1).toDouble();
377
pline->setNextBulge(bulge);
378
pline->addVertex(RS_Vector(x1, y1), bulge);
380
letter->addEntity(pline);
383
} while (!line.isEmpty());
385
if (letter->isEmpty()) {
388
letter->calculateBorders();
389
letterList.add(letter);
406
x1 = coords.at(0).toDouble();
407
y1 = coords.at(1).toDouble();
408
//check presence of bulge
409
if (coords.size() == 3 && coords.at(2).at(0) == QChar('A')){
410
QString bulgeStr = coords.at(2);
411
bulge = bulgeStr.remove(0,1).toDouble();
413
pline->setNextBulge(bulge);
414
pline->addVertex(RS_Vector(x1, y1), bulge);
416
letter->addEntity(pline);
421
if (letter->isEmpty()) {
425
letter->calculateBorders();
426
letterList.add(letter);
431
RS_Block* RS_Font::findLetter(const QString& name) {
432
RS_Block* ret= letterList.find(name);
433
if (ret != NULL) return ret;
434
return generateLffFont(name);
398
438
* Dumps the fonts data to stdout.