1614 } |
1613 } |
1615 // -3 to offset EScriptDefault, EScriptNone and EScriptOther |
1614 // -3 to offset EScriptDefault, EScriptNone and EScriptOther |
1616 // being the first three elements in TScript. |
1615 // being the first three elements in TScript. |
1617 return TPtrC(KTScript2GlyphSample[aScript - 3]); |
1616 return TPtrC(KTScript2GlyphSample[aScript - 3]); |
1618 } |
1617 } |
1619 |
|
1620 |
|
1621 EXPORT_C RFontTable::RFontTable():iTableContent(0), iLength(0), |
|
1622 iFont(NULL), iTag(0) |
|
1623 { |
|
1624 // a null constructor. |
|
1625 } |
|
1626 |
|
1627 EXPORT_C TInt |
|
1628 RFontTable::Open(CFont& aFont, TUint32 aTag) |
|
1629 { |
|
1630 TGetFontTableParam param; |
|
1631 param.iTag = aTag; |
|
1632 |
|
1633 // remember the parameters, to be used when releasing the font table. |
|
1634 iFont = &aFont; |
|
1635 iTag = aTag; |
|
1636 |
|
1637 TInt ret = aFont.ExtendedFunction(KFontGetFontTable, (TAny *)¶m); |
|
1638 if (KErrNone == ret) |
|
1639 { |
|
1640 iTableContent = (TAny *)param.iContent; |
|
1641 iLength = param.iLength; |
|
1642 } |
|
1643 return ret; |
|
1644 } |
|
1645 |
|
1646 EXPORT_C TInt |
|
1647 RFontTable::TableLength() const |
|
1648 { |
|
1649 return iLength; |
|
1650 } |
|
1651 |
|
1652 EXPORT_C const TUint8* |
|
1653 RFontTable::TableContent() const |
|
1654 { |
|
1655 return (TUint8*)iTableContent; |
|
1656 } |
|
1657 |
|
1658 EXPORT_C void |
|
1659 RFontTable::Close() |
|
1660 { |
|
1661 if (NULL != iFont) |
|
1662 { |
|
1663 (void)iFont->ExtendedFunction(KFontReleaseFontTable, (TAny *)&iTag); |
|
1664 } |
|
1665 iTableContent = 0; |
|
1666 iLength = 0; |
|
1667 iFont = NULL; |
|
1668 iTag = 0; |
|
1669 } |
|
1670 |
|
1671 EXPORT_C |
|
1672 RGlyphOutlineIterator::RGlyphOutlineIterator():iOutlines(0), iLengths(0), |
|
1673 iCursor(-1), iCount(0), iFont(NULL), iCodes(NULL), iHinted(EFalse) |
|
1674 { |
|
1675 // a null constructor. |
|
1676 } |
|
1677 |
|
1678 EXPORT_C TInt |
|
1679 RGlyphOutlineIterator::Open(CFont& aFont, const TUint* aCodes, TInt aCount, TBool aHinted) |
|
1680 { |
|
1681 if (NULL == aCodes || 0 == aCount) |
|
1682 { |
|
1683 return KErrArgument; |
|
1684 } |
|
1685 TGetGlyphOutlineParam param; |
|
1686 iLengths = (TInt *)User::Alloc(sizeof(TInt) * aCount); |
|
1687 if (NULL == iLengths) |
|
1688 { |
|
1689 return KErrNoMemory; |
|
1690 } |
|
1691 iOutlines = (TAny **)User::Alloc(sizeof(TAny *) * aCount); |
|
1692 if (NULL == iOutlines) |
|
1693 { |
|
1694 User::Free(iLengths); |
|
1695 iLengths = NULL; |
|
1696 return KErrNoMemory; |
|
1697 } |
|
1698 |
|
1699 param.iLengths = iLengths; |
|
1700 param.iCount = aCount; |
|
1701 param.iCodes = aCodes; |
|
1702 param.iHinted = aHinted; |
|
1703 param.iOutlines = iOutlines; |
|
1704 |
|
1705 /* information needed in Close() */ |
|
1706 iCodes = (TUint *)User::Alloc(sizeof(TUint) * aCount); |
|
1707 if (NULL == iCodes) |
|
1708 { |
|
1709 User::Free(iLengths); |
|
1710 User::Free(iOutlines); |
|
1711 iLengths = NULL; |
|
1712 iOutlines = NULL; |
|
1713 return KErrNoMemory; |
|
1714 } |
|
1715 Mem::Copy(iCodes, aCodes, aCount*sizeof(TUint)); |
|
1716 iFont = &aFont; |
|
1717 iHinted = aHinted; |
|
1718 iCount = aCount; |
|
1719 |
|
1720 TInt ret = aFont.ExtendedFunction(KFontGetGlyphOutline, (TAny *)¶m); |
|
1721 if (KErrNone != ret) |
|
1722 { |
|
1723 User::Free(iLengths); |
|
1724 User::Free(iOutlines); |
|
1725 User::Free(iCodes); |
|
1726 iLengths = NULL; |
|
1727 iOutlines = NULL; |
|
1728 iCodes = NULL; |
|
1729 iFont = NULL; |
|
1730 } |
|
1731 else |
|
1732 { |
|
1733 iCursor = 0; |
|
1734 } |
|
1735 |
|
1736 return ret; |
|
1737 } |
|
1738 |
|
1739 EXPORT_C const TUint8* |
|
1740 RGlyphOutlineIterator::Outline() const |
|
1741 { |
|
1742 GDI_ASSERT_ALWAYS(iCursor >= 0, EGdiPanic_Unknown); |
|
1743 |
|
1744 if (iLengths[iCursor] < 0) |
|
1745 { |
|
1746 return NULL; |
|
1747 } |
|
1748 else |
|
1749 { |
|
1750 return (const TUint8*)iOutlines[iCursor]; |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 EXPORT_C TInt |
|
1755 RGlyphOutlineIterator::OutlineLength() const |
|
1756 { |
|
1757 GDI_ASSERT_ALWAYS(iCursor >= 0, EGdiPanic_Unknown); |
|
1758 |
|
1759 if (iLengths[iCursor] < 0) |
|
1760 { |
|
1761 return KErrGeneral; |
|
1762 } |
|
1763 else |
|
1764 { |
|
1765 return iLengths[iCursor]; |
|
1766 } |
|
1767 } |
|
1768 |
|
1769 EXPORT_C TInt |
|
1770 RGlyphOutlineIterator::Next() |
|
1771 { |
|
1772 if (iCursor >= 0 && iCursor < iCount-1) |
|
1773 { |
|
1774 ++iCursor; |
|
1775 return KErrNone; |
|
1776 } |
|
1777 else |
|
1778 { |
|
1779 iCursor = -1; |
|
1780 // if the iterator goes beyond the last element [when |
|
1781 // Next() returns KErrNotFound], the next call |
|
1782 // to Outline() or OutlineLength() will panic. |
|
1783 |
|
1784 return KErrNotFound; |
|
1785 } |
|
1786 } |
|
1787 |
|
1788 EXPORT_C void |
|
1789 RGlyphOutlineIterator::Close() |
|
1790 { |
|
1791 TReleaseGlyphOutlineParam param; |
|
1792 param.iCount = iCount; |
|
1793 param.iHinted = iHinted; |
|
1794 param.iCodes = iCodes; |
|
1795 |
|
1796 if (NULL != iFont) |
|
1797 { |
|
1798 iFont->ExtendedFunction(KFontReleaseGlyphOutline, (TAny *)¶m); |
|
1799 } |
|
1800 |
|
1801 iFont = NULL; |
|
1802 iCount = 0; |
|
1803 User::Free(iLengths); |
|
1804 iLengths = NULL; |
|
1805 iCursor = -1; |
|
1806 User::Free(iCodes); |
|
1807 iCodes = NULL; |
|
1808 User::Free(iOutlines); |
|
1809 iOutlines = NULL; |
|
1810 } |
|