Lines 348-354
Link Here
|
348 |
const unsigned char* p = pBuffer + 12; |
348 |
const unsigned char* p = pBuffer + 12; |
349 |
if( nFormat == 0x74746366 ) // TTC_MAGIC |
349 |
if( nFormat == 0x74746366 ) // TTC_MAGIC |
350 |
p += GetUInt( p + 4 * mnFaceNum ); |
350 |
p += GetUInt( p + 4 * mnFaceNum ); |
351 |
else if( nFormat != 0x00010000 ) // TTF_MAGIC |
351 |
else if( (nFormat!=0x00010000) && (nFormat!=0x74727565) ) // TTF_MAGIC and Apple TTF Magic |
352 |
return NULL; |
352 |
return NULL; |
353 |
|
353 |
|
354 |
// walk table directory until match |
354 |
// walk table directory until match |
Lines 495-502
Link Here
|
495 |
|
495 |
|
496 |
// TODO: prefer unicode names if available |
496 |
// TODO: prefer unicode names if available |
497 |
// TODO: prefer locale specific names if available? |
497 |
// TODO: prefer locale specific names if available? |
498 |
aFontData.maName = String::CreateFromAscii( aFaceFT->family_name ); |
498 |
/* DAN - some fonts returned NULL names, resulting in crash here. */ |
499 |
aFontData.maStyleName = String::CreateFromAscii( aFaceFT->style_name ); |
499 |
if ( aFaceFT->family_name ) |
|
|
500 |
aFontData.maName = String::CreateFromAscii( aFaceFT->family_name ); |
501 |
else |
502 |
aFontData.maName = String::CreateFromAscii( "\0" ); |
503 |
|
504 |
if ( aFaceFT->style_name ) |
505 |
aFontData.maStyleName = String::CreateFromAscii( aFaceFT->style_name ); |
506 |
else |
507 |
aFontData.maStyleName = String::CreateFromAscii( "\0" ); |
508 |
|
509 |
/* DAN - old non-modified code here |
510 |
aFontData.maName = String::CreateFromAscii( aFaceFT->family_name ); |
511 |
aFontData.maStyleName = String::CreateFromAscii( aFaceFT->style_name ); |
512 |
*/ |
500 |
|
513 |
|
501 |
aFontData.mnWidth = 0; |
514 |
aFontData.mnWidth = 0; |
502 |
aFontData.mnHeight = 0; |
515 |
aFontData.mnHeight = 0; |
Lines 1442-1512
Link Here
|
1442 |
const FT_Byte* pBuffer = pKern; |
1455 |
const FT_Byte* pBuffer = pKern; |
1443 |
USHORT nVersion = GetUShort( pBuffer+0 ); |
1456 |
USHORT nVersion = GetUShort( pBuffer+0 ); |
1444 |
USHORT nTableCnt = GetUShort( pBuffer+2 ); |
1457 |
USHORT nTableCnt = GetUShort( pBuffer+2 ); |
1445 |
pBuffer += 4; |
1458 |
|
1446 |
if( nVersion != 0 ) // ignore Apple's versions for now |
1459 |
// Microsoft/Old TrueType style kern table |
1447 |
nTableCnt = 0; |
1460 |
if ( nVersion == 0 ) |
1448 |
for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) |
1461 |
{ |
1449 |
{ |
1462 |
pBuffer += 4; |
1450 |
USHORT nSubVersion = GetUShort( pBuffer+0 ); |
1463 |
|
1451 |
USHORT nSubLength = GetUShort( pBuffer+2 ); |
1464 |
for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) |
1452 |
USHORT nSubCoverage = GetUShort( pBuffer+4 ); |
|
|
1453 |
pBuffer += 6; |
1454 |
if( (nSubCoverage&0x03) != 0x01 ) // no interest in minimum info here |
1455 |
continue; |
1456 |
switch( nSubCoverage >> 8 ) |
1457 |
{ |
1465 |
{ |
1458 |
case 0: // version 0, kerning format 0 |
1466 |
USHORT nSubVersion = GetUShort( pBuffer+0 ); |
|
|
1467 |
USHORT nSubLength = GetUShort( pBuffer+2 ); |
1468 |
USHORT nSubCoverage = GetUShort( pBuffer+4 ); |
1469 |
pBuffer += 6; |
1470 |
if( (nSubCoverage&0x03) != 0x01 ) // no interest in minimum info here |
1471 |
continue; |
1472 |
switch( nSubCoverage >> 8 ) |
1459 |
{ |
1473 |
{ |
1460 |
USHORT nPairs = GetUShort( pBuffer ); |
1474 |
case 0: // version 0, kerning format 0 |
1461 |
pBuffer += 8; // skip search hints |
1475 |
{ |
1462 |
aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); |
1476 |
USHORT nPairs = GetUShort( pBuffer ); |
1463 |
for( int i = 0; i < nPairs; ++i ) |
1477 |
pBuffer += 8; // skip search hints |
|
|
1478 |
aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); |
1479 |
for( int i = 0; i < nPairs; ++i ) |
1480 |
{ |
1481 |
aKernPair.mnChar1 = GetUShort( pBuffer+0 ); |
1482 |
aKernPair.mnChar2 = GetUShort( pBuffer+2 ); |
1483 |
//long nUnscaledKern= GetSShort( pBuffer ); |
1484 |
pBuffer += 6; |
1485 |
aKernGlyphVector.push_back( aKernPair ); |
1486 |
} |
1487 |
} |
1488 |
break; |
1489 |
|
1490 |
case 2: // version 0, kerning format 2 |
1464 |
{ |
1491 |
{ |
1465 |
aKernPair.mnChar1 = GetUShort( pBuffer+0 ); |
1492 |
const FT_Byte* pSubTable = pBuffer; |
1466 |
aKernPair.mnChar2 = GetUShort( pBuffer+2 ); |
1493 |
//USHORT nRowWidth = GetUShort( pBuffer+0 ); |
1467 |
//long nUnscaledKern= GetSShort( pBuffer ); |
1494 |
USHORT nOfsLeft = GetUShort( pBuffer+2 ); |
1468 |
pBuffer += 6; |
1495 |
USHORT nOfsRight = GetUShort( pBuffer+4 ); |
1469 |
aKernGlyphVector.push_back( aKernPair ); |
1496 |
USHORT nOfsArray = GetUShort( pBuffer+6 ); |
|
|
1497 |
pBuffer += 8; |
1498 |
|
1499 |
const FT_Byte* pTmp = pSubTable + nOfsLeft; |
1500 |
USHORT nFirstLeft = GetUShort( pTmp+0 ); |
1501 |
USHORT nLastLeft = GetUShort( pTmp+2 ) + nFirstLeft - 1; |
1502 |
|
1503 |
pTmp = pSubTable + nOfsRight; |
1504 |
USHORT nFirstRight = GetUShort( pTmp+0 ); |
1505 |
USHORT nLastRight = GetUShort( pTmp+2 ) + nFirstRight - 1; |
1506 |
|
1507 |
ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); |
1508 |
aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); |
1509 |
|
1510 |
pTmp = pSubTable + nOfsArray; |
1511 |
for( int nLeft = nFirstLeft; nLeft < nLastLeft; ++nLeft ) |
1512 |
{ |
1513 |
aKernPair.mnChar1 = nLeft; |
1514 |
for( int nRight = 0; nRight < nLastRight; ++nRight ) |
1515 |
{ |
1516 |
if( GetUShort( pTmp ) != 0 ) |
1517 |
{ |
1518 |
aKernPair.mnChar2 = nRight; |
1519 |
aKernGlyphVector.push_back( aKernPair ); |
1520 |
} |
1521 |
pTmp += 2; |
1522 |
} |
1523 |
} |
1470 |
} |
1524 |
} |
|
|
1525 |
break; |
1471 |
} |
1526 |
} |
1472 |
break; |
1527 |
} |
|
|
1528 |
} |
1473 |
|
1529 |
|
1474 |
case 2: // version 0, kerning format 2 |
1530 |
// Apple New style kern table |
1475 |
{ |
1531 |
pBuffer = pKern; |
1476 |
const FT_Byte* pSubTable = pBuffer; |
1532 |
nVersion = NEXT_ULong( pBuffer ); |
1477 |
//USHORT nRowWidth = GetUShort( pBuffer+0 ); |
1533 |
nTableCnt = NEXT_ULong( pBuffer ); |
1478 |
USHORT nOfsLeft = GetUShort( pBuffer+2 ); |
1534 |
if ( nVersion == 0x00010000 ) |
1479 |
USHORT nOfsRight = GetUShort( pBuffer+4 ); |
1535 |
{ |
1480 |
USHORT nOfsArray = GetUShort( pBuffer+6 ); |
1536 |
for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) |
1481 |
pBuffer += 8; |
1537 |
{ |
1482 |
|
1538 |
ULONG nLength = NEXT_ULong( pBuffer ); |
1483 |
const FT_Byte* pTmp = pSubTable + nOfsLeft; |
1539 |
USHORT nCoverage = NEXT_UShort( pBuffer ); |
1484 |
USHORT nFirstLeft = GetUShort( pTmp+0 ); |
1540 |
USHORT nTupleIndex = NEXT_UShort( pBuffer ); |
1485 |
USHORT nLastLeft = GetUShort( pTmp+2 ) + nFirstLeft - 1; |
1541 |
|
1486 |
|
1542 |
// Get kerning type |
1487 |
pTmp = pSubTable + nOfsRight; |
1543 |
sal_Bool bKernVertical = nCoverage & 0x8000; |
1488 |
USHORT nFirstRight = GetUShort( pTmp+0 ); |
1544 |
sal_Bool bKernCrossStream = nCoverage & 0x4000; |
1489 |
USHORT nLastRight = GetUShort( pTmp+2 ) + nFirstRight - 1; |
1545 |
sal_Bool bKernVariation = nCoverage & 0x2000; |
1490 |
|
1546 |
|
1491 |
ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); |
1547 |
// Kerning sub-table format, 0 through 3 |
1492 |
aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); |
1548 |
sal_uInt8 nSubTableFormat = nCoverage & 0x00FF; |
1493 |
|
1549 |
|
1494 |
pTmp = pSubTable + nOfsArray; |
1550 |
switch( nSubTableFormat ) |
1495 |
for( int nLeft = nFirstLeft; nLeft < nLastLeft; ++nLeft ) |
1551 |
{ |
|
|
1552 |
case 0: // version 0, kerning format 0 |
1496 |
{ |
1553 |
{ |
1497 |
aKernPair.mnChar1 = nLeft; |
1554 |
USHORT nPairs = NEXT_UShort( pBuffer ); |
1498 |
for( int nRight = 0; nRight < nLastRight; ++nRight ) |
1555 |
pBuffer += 6; // skip search hints |
|
|
1556 |
aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); |
1557 |
for( int i = 0; i < nPairs; ++i ) |
1499 |
{ |
1558 |
{ |
1500 |
if( GetUShort( pTmp ) != 0 ) |
1559 |
aKernPair.mnChar1 = NEXT_UShort( pBuffer ); |
|
|
1560 |
aKernPair.mnChar2 = NEXT_UShort( pBuffer ); |
1561 |
/*long nUnscaledKern=*/ NEXT_Short( pBuffer ); |
1562 |
aKernGlyphVector.push_back( aKernPair ); |
1563 |
} |
1564 |
} |
1565 |
break; |
1566 |
|
1567 |
case 2: // version 0, kerning format 2 |
1568 |
{ |
1569 |
const FT_Byte* pSubTable = pBuffer; |
1570 |
/*USHORT nRowWidth =*/ NEXT_UShort( pBuffer ); |
1571 |
USHORT nOfsLeft = NEXT_UShort( pBuffer ); |
1572 |
USHORT nOfsRight = NEXT_UShort( pBuffer ); |
1573 |
USHORT nOfsArray = NEXT_UShort( pBuffer ); |
1574 |
|
1575 |
const FT_Byte* pTmp = pSubTable + nOfsLeft; |
1576 |
USHORT nFirstLeft = NEXT_UShort( pTmp ); |
1577 |
USHORT nLastLeft = NEXT_UShort( pTmp ) + nFirstLeft - 1; |
1578 |
|
1579 |
pTmp = pSubTable + nOfsRight; |
1580 |
USHORT nFirstRight = NEXT_UShort( pTmp ); |
1581 |
USHORT nLastRight = NEXT_UShort( pTmp ) + nFirstRight - 1; |
1582 |
|
1583 |
ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); |
1584 |
aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); |
1585 |
|
1586 |
pTmp = pSubTable + nOfsArray; |
1587 |
for( int nLeft = nFirstLeft; nLeft < nLastLeft; ++nLeft ) |
1588 |
{ |
1589 |
aKernPair.mnChar1 = nLeft; |
1590 |
for( int nRight = 0; nRight < nLastRight; ++nRight ) |
1501 |
{ |
1591 |
{ |
1502 |
aKernPair.mnChar2 = nRight; |
1592 |
if( NEXT_Short( pTmp ) != 0 ) |
1503 |
aKernGlyphVector.push_back( aKernPair ); |
1593 |
{ |
|
|
1594 |
aKernPair.mnChar2 = nRight; |
1595 |
aKernGlyphVector.push_back( aKernPair ); |
1596 |
} |
1504 |
} |
1597 |
} |
1505 |
pTmp += 2; |
|
|
1506 |
} |
1598 |
} |
1507 |
} |
1599 |
} |
|
|
1600 |
break; |
1601 |
|
1602 |
default: |
1603 |
fprintf( stderr, "gcach_ftyp.cxx: Found unsupported Apple-style kern subtable type %d.\n", nSubTableFormat ); |
1604 |
break; |
1508 |
} |
1605 |
} |
1509 |
break; |
|
|
1510 |
} |
1606 |
} |
1511 |
} |
1607 |
} |
1512 |
|
1608 |
|