[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-dev] Text rendering implementation (3)
- From: Martin Wuerthner <lists@xxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 09:48:53 +0200
- Subject: [XaraXtreme-dev] Text rendering implementation (3)
Finally, the remaining changes to enable text rendering.
Kernel/fontcomp.cpp:
enabled font matching calls
Kernel/nodetext.cpp:
enabled path creation and rendering calls
Kernel/nodetxtl.cpp:
enabled metrics and FormatRegion
Kernel/nodetxtl.h:
enabled FormatRegion
Kernel/nodetxts.cpp:
enabled TextStory functionality (formatting)
Kernel/rndrgn.cpp:
enabled text-related rendering functionality
Kernel/main.cpp:
enabled font cache finalisation
Kernel/main3.cpp:
enabled font cache initialisation
Martin
Index: Kernel/fontcomp.cpp
===================================================================
--- Kernel/fontcomp.cpp (Revision 748)
+++ Kernel/fontcomp.cpp (Arbeitskopie)
@@ -1061,8 +1061,8 @@
if (ok) ok = pRec->ReadCCPanose( &(pItem->mPanoseNumber) );
- PORTNOTETRACE("text","FontComponent::ReadFontTrueType - removed ImportCacheFont call");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","FontComponent::ReadFontTrueType - removed ImportCacheFont call");
+#ifndef DISABLE_TEXT_RENDERING
if (ok) ok = ImportCacheFont(pItem); // do all our clever matching
if (ok) pFontList->AddTail(pItem);
@@ -1094,8 +1094,8 @@
if (ok) ok = pRec->ReadCCPanose( &(pItem->mPanoseNumber) );
- PORTNOTETRACE("text","FontComponent::ReadFontATM - removed ImportCacheFont call");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","FontComponent::ReadFontATM - removed ImportCacheFont call");
+#ifndef DISABLE_TEXT_RENDERING
if (ok) ok = ImportCacheFont(pItem); // do all our clever matching
if (ok) pFontList->AddTail(pItem);
@@ -1499,8 +1499,8 @@
// the font has been deinstalled during this session of Camelot. So
// we find a replacement font now...
- PORTNOTETRACE("text","FontComponent::ImportCacheFont - Removed FindClosestFont usage");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","FontComponent::ImportCacheFont - Removed FindClosestFont usage");
+#ifndef DISABLE_TEXT_RENDERING
CachedFontItem *pCachedFontItem = pFontManager->GetFont(FontHandle);
WORD BestFontHandle = pFontManager->FindClosestFont(pItem->mPanoseNumber);
@@ -1516,8 +1516,8 @@
if (FontHandle==ILLEGALFHANDLE)
{
-#ifndef EXCLUDE_FROM_XARALX
- PORTNOTETRACE("text","FontComponent::ImportCacheFont - Removed FindClosestFont usage");
+ PORTNOTE("text","FontComponent::ImportCacheFont - Removed FindClosestFont usage");
+#ifndef DISABLE_TEXT_RENDERING
// Failed again, so we try to find the closest font using PANOSE font matching.
WORD BestFontHandle = pFontManager->FindClosestFont(pItem->mPanoseNumber);
@@ -1537,7 +1537,7 @@
if (FontHandle==ILLEGALFHANDLE)
{
- // something has gone wrong. camplain, and fix the error
+ // something has gone wrong. complain, and fix the error
ERROR2(FALSE, "Unable to find a font!.");
FontHandle = DEFAULTHANDLE;
}
Index: Kernel/nodetext.cpp
===================================================================
--- Kernel/nodetext.cpp (Revision 748)
+++ Kernel/nodetext.cpp (Arbeitskopie)
@@ -1561,7 +1561,7 @@
void AbstractTextChar::RenderObjectBlobs(RenderRegion* pRenderRegion)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
Path* pPath=CreateMetricsRectPath();
if (pPath!=NULL && pRenderRegion!=NULL)
{
@@ -1587,7 +1587,7 @@
void AbstractTextChar::RenderTinyBlobs(RenderRegion* pRenderRegion)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
Path* pPath=CreateMetricsRectPath();
if (pPath!=NULL && pRenderRegion!=NULL)
{
@@ -1744,8 +1744,8 @@
BOOL AbstractTextChar::ReCacheMetrics(FormatRegion* pFormatRegion)
{
- PORTNOTETRACE("text","AbstractTextChar::ReCacheMetrics - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","AbstractTextChar::ReCacheMetrics - do nothing");
+#ifndef DISABLE_TEXT_RENDERING
// get metrics for this char with current attribute stack
CharMetrics metrics;
if (pFormatRegion->GetCharMetrics(&metrics,GetUnicodeValue())==FALSE)
@@ -2004,10 +2004,11 @@
BOOL TextChar::RenderCore(RenderRegion* pRenderRegion)
{
- PORTNOTETRACE("text","TextChar::RenderCore - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","TextChar::RenderCore - do nothing");
+#ifndef DISABLE_TEXT_RENDERING
ERROR2IF(pRenderRegion == NULL, FALSE, "TextChar::RenderCore() - pRenderRegion == NULL");
+ // TRACEUSER("wuerthne", _T("TextChar::RenderCore %04x"), GetUnicodeValue());
// If the render region is being used for hit detection then render bounds
// BODGE TEXT - should be in the render region RenderChar function
if (pRenderRegion->IsHitDetect() &&
@@ -2028,6 +2029,9 @@
if (GetStoryAndCharMatrix(&matrix) == FALSE) return FALSE;
// render the character through the matrix with current attributes in RenderRegion
+
+PORTNOTE("other", "printing and AI export deactivated")
+#ifndef EXCLUDE_FROM_XARALX
// If the render region is a printing region then maybe print as shapes.
if (pRenderRegion->IsPrinting())
{
@@ -2060,6 +2064,7 @@
}
}
}
+#endif
// Render into the given region region as characters
BOOL Result = pRenderRegion->RenderChar(GetUnicodeValue(), &matrix);
@@ -2087,8 +2092,9 @@
#endif // EXPORT_TEXT
return Result;
+#else
+ return FALSE;
#endif
- return false;
}
@@ -2103,6 +2109,7 @@
void TextChar::RenderEorDrag(RenderRegion* pRenderRegion)
{
+PORTNOTE("text", "so far, enabling this crashes when a text object is moved and an EOR display is attempted")
#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
// Before rendering the character we need to render it's applied *TEXT* attributes
// into the render region as EOR drag render regions dosen't maintain an attribute stack
@@ -2132,7 +2139,7 @@
pRenderRegion->RestoreContext();
}
- delete pAttribMap;
+ if (pAttribMap!=NULL) delete pAttribMap;
#endif
}
@@ -2196,8 +2203,8 @@
BOOL TextChar::CreateNodePath(NodePath** ppNodePath, FormatRegion* pFormatRegion)
{
- PORTNOTETRACE("text","TextChar::CreateNodePath - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","TextChar::CreateNodePath - do nothing");
+#ifndef DISABLE_TEXT_RENDERING
ERROR2IF(pFormatRegion==NULL,FALSE,"TextChar::CreateNodePath() - pFormatRegion==NULL");
ERROR2IF( ppNodePath==NULL,FALSE,"TextChar::CreateNodePath() - ppNodePath==NULL");
@@ -2256,7 +2263,7 @@
BOOL Snapped = FALSE;
PORTNOTETRACE("text","TextChar::Snap - do nothing");
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
MILLIPOINT SnapDist = CSnap::GetSnapDist();
MILLIPOINT SqrSnapDist = SnapDist*SnapDist;
@@ -2422,8 +2429,6 @@
********************************************************************************************/
MILLIPOINT TextChar::GetAutoKernSize(FormatRegion* pFormatRegion)
{
- PORTNOTETRACE("text","TextChar::GetAutoKernSize - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
TextChar* pNextTC = FindNextTextCharInStory();
if (pNextTC)
@@ -2514,9 +2519,6 @@
}
else
return 0; // No kern
-#else
- return 0;
-#endif
}
/////////////////////////////////////////////////////////////////////////////////////////////
@@ -3400,7 +3402,7 @@
void EOLNode::RenderTinyBlobs(RenderRegion* pRenderRegion)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
RenderObjectBlobs(pRenderRegion);
#endif
}
@@ -3418,7 +3420,7 @@
BOOL EOLNode::GetBlobPath(Path* pPath)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
ERROR2IF(pPath==NULL, FALSE, "Path pointer was NULL");
TextLine* pParentLine = this->FindParentLine();
ERROR2IF(pParentLine==NULL, FALSE, "EOLNode didn't have a parent TextLine");
Index: Kernel/nodetxtl.cpp
===================================================================
--- Kernel/nodetxtl.cpp (Revision 748)
+++ Kernel/nodetxtl.cpp (Arbeitskopie)
@@ -708,12 +708,9 @@
BOOL TextLine::ReCacheMetrics(FormatRegion* pFormatRegion)
{
- PORTNOTETRACE("text","TextLine::ReCacheMetrics - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
SetJustification( pFormatRegion->GetJustification());
SetLineSpacing( pFormatRegion->GetLineSpacing());
SetLineSpaceRatio(pFormatRegion->GetLineSpaceRatio());
-#endif
return TRUE;
}
@@ -1705,8 +1702,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////
// FormatRegion
-PORTNOTE("text","Removed FormatRegion impl.")
-#ifndef EXCLUDE_FROM_XARALX
/********************************************************************************************
> FormatRegion::FormatRegion()
@@ -1776,7 +1771,7 @@
StartRender();
// Get the attributes
- if (FirstNode==NULL)
+ if (pFirstNode==NULL)
return TRUE;
CCAttrMap *pAttribMap = new CCAttrMap(30);
@@ -1866,5 +1861,3 @@
return kern;
}
-
-#endif
Index: Kernel/nodetxtl.h
===================================================================
--- Kernel/nodetxtl.h (Revision 748)
+++ Kernel/nodetxtl.h (Arbeitskopie)
@@ -129,8 +129,6 @@
{
CC_DECLARE_DYNAMIC(FormatRegion)
-PORTNOTE("text","FormatRegion stripped")
-#ifndef EXCLUDE_FROM_XARALX
FormatRegion();
~FormatRegion();
@@ -181,7 +179,6 @@
private:
std::auto_ptr<wxDC> m_pFormatDC;
-#endif
};
Index: Kernel/nodetxts.cpp
===================================================================
--- Kernel/nodetxts.cpp (Revision 748)
+++ Kernel/nodetxts.cpp (Arbeitskopie)
@@ -286,8 +286,8 @@
BOOL BaseTextClass::ReCacheNodeAndDescendantsMetrics(FormatRegion* pFormatRegion)
{
- PORTNOTETRACE("text","BaseTextClass::ReCacheNodeAndDescendantsMetrics - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","BaseTextClass::ReCacheNodeAndDescendantsMetrics - do nothing");
+#ifndef DISABLE_TEXT_RENDERING
BOOL ok=TRUE;
if (NodeOrDescendantModifiedByOp())
{
@@ -313,7 +313,7 @@
return ok;
#else
- return false;
+ return FALSE;
#endif
}
@@ -1986,7 +1986,7 @@
void TextStory::RenderObjectBlobs(RenderRegion* pRenderRegion)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
if (pRenderRegion != NULL)
{
pRenderRegion->SetLineColour(COLOUR_NONE);
@@ -2011,7 +2011,7 @@
void TextStory::RenderTinyBlobs(RenderRegion* pRenderRegion)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
if (pRenderRegion != NULL)
{
pRenderRegion->SetLineColour(COLOUR_NONE);
@@ -2057,7 +2057,7 @@
DocCoord TextStory::GetBlobPosAndSize(INT32* pSize)
{
-#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
+#if !defined(EXCLUDE_FROM_RALPH)
// Get the bounds of the text story
DocRect StoryBounds=GetBoundingRect();
@@ -2687,8 +2687,8 @@
BOOL TextStory::FormatAndChildren(UndoableOperation* pUndoOp, BOOL UseNodeFlags, BOOL WordWrap)
{
- PORTNOTETRACE("text","TextStory::FormatAndChildren - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
+ PORTNOTE("text","TextStory::FormatAndChildren - do nothing");
+#ifndef DISABLE_TEXT_RENDERING
// if whole story is affected, just flag all children as 'ModifiedByOp'
if (UseNodeFlags==FALSE)
FlagNodeAndDescendantsModifiedByOpAndParentsHaveDescendantModifiedByOp();
Index: Kernel/rndrgn.cpp
===================================================================
--- Kernel/rndrgn.cpp (Revision 748)
+++ Kernel/rndrgn.cpp (Arbeitskopie)
@@ -5905,8 +5905,6 @@
BOOL RenderRegion::GetAttrdCharBounds(DocRect* pBounds, WCHAR ch)
{
- PORTNOTETRACE("text","RenderRegion::GetAttrdCharBounds - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
ERROR2IF(pBounds==NULL,FALSE,"RenderRegion::GetAttrdCharBounds() - pBounds==NULL");
// get defualt bounds from cache
@@ -5924,9 +5922,6 @@
pBounds->MakeEmpty();
return ok;
-#else
- return FALSE;
-#endif
}
@@ -5945,8 +5940,6 @@
Path* RenderRegion::CreateCharPath(WCHAR ch, Matrix* pMatrix)
{
- PORTNOTETRACE("text","RenderRegion::CreateCharPath - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
// get overall matrix - attribute matrix concatenated with given matrix if supplied
Matrix matrix;
if (GetCharAttributeMatrix(&matrix)==FALSE)
@@ -5974,9 +5967,6 @@
}
return pPath;
-#else
- return NULL;
-#endif
}
@@ -6688,7 +6678,7 @@
256, *Palette, Fill->GetProfile());
return;
}
-
+PORTNOTE("other", "RenderRegion: no colour correction for paletted bitmaps");
#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
// --- If it's a paletted bitmap, then we just colour-correct the palette
if (Info->bmiHeader.biBitCount <= 8)
Index: Kernel/main.cpp
===================================================================
--- Kernel/main.cpp (Revision 748)
+++ Kernel/main.cpp (Arbeitskopie)
@@ -352,8 +352,7 @@
#if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
HotKey::Deinit();
#endif
-PORTNOTE("text","Removed FontCache usage")
-#ifndef EXCLUDE_FROM_XARALX
+#ifndef DISABLE_TEXT_RENDERING
FontCache::DeInit();
#endif
#ifndef EXCLUDE_GALS
Index: Kernel/main3.cpp
===================================================================
--- Kernel/main3.cpp (Revision 748)
+++ Kernel/main3.cpp (Arbeitskopie)
@@ -287,8 +287,12 @@
AttrFillGeometry::Init() && // Initialise the fill editing operations
EPSFilter::InitPrefs() && // Initialise default font mappings and
- // EPS export prefs
+ // EPS export prefs
+#endif
+#ifndef DISABLE_TEXT_RENDERING
FontCache::Init() &&
+#endif
+#ifndef EXCLUDE_FROM_XARALX
TunedMemory::Init() && // declare prefs for the memory manager
OILRuler::Init() && // set the ruler widths depending on .ini font settings