Ejemplo n.º 1
0
bool ListFonts::GetFontFromITextRange(ATE::ITextRange currRange)
{
    ATE::ITextRunsIterator iter = currRange.GetTextRunsIterator();
    while (iter.IsNotDone())
    {
        BtAteTextFeatures features(iter.Item().GetUniqueCharFeatures());
        
        featuresList.push_back(features);
        
        iter.Next();
    }
    return true;
}
Ejemplo n.º 2
0
bool FixTextAttributes(ATE::ITextRange theRange, ASReal firstRunBaselineShift) {
	bool isAssigned = FALSE;
	ATE::ITextRunsIterator it = theRange.GetTextRunsIterator();
	
	//If there is stuff to iterate through
	if ( !it.IsEmpty() ) {
		
		bool isFirst = TRUE;
		bool foundGoodFeatures = FALSE;
		ATE::ICharFeatures knownGoodCharFeatures;
		
		ATE::ICharFeatures currCharFeatures;
		
		while (it.IsNotDone()) {
			
			//Loop through all the ranges in the run
			while (it.IsNotDone()) {
				
				//If this is the first range, we need to go through the run and find the first good fill or stroke color
				if (isFirst) {
					while ( foundGoodFeatures == FALSE ) {
						if (it.IsNotDone()) {
							knownGoodCharFeatures = it.Item().GetUniqueCharFeatures();
							
							bool fillAssigned = FALSE;
							bool strokeAssigned = FALSE;
							knownGoodCharFeatures.GetFillColor(&fillAssigned);
							knownGoodCharFeatures.GetStrokeColor(&strokeAssigned);
							
							if (fillAssigned || strokeAssigned) {
								foundGoodFeatures = TRUE;
							}
						}
						it.Next();
					}
					//Put our iterator back to the beginning again
					it.MoveToFirst();
				}
				
				//Now we'll check the color of our current range
				currCharFeatures = it.Item().GetUniqueCharFeatures();
				bool currFillAssigned = FALSE;
				bool currStrokeAssigned = FALSE;
				currCharFeatures.GetFillColor(&currFillAssigned);
				currCharFeatures.GetStrokeColor(&currStrokeAssigned);
								
				//If it has a valid color, we'll store that for the next time
				
				if ( currFillAssigned || currStrokeAssigned) {
					knownGoodCharFeatures = currCharFeatures;
									
					isFirst = FALSE;
				} else {
					//Otherwise, we'll set the color of the range to the known good color
					it.Item().SetLocalCharFeatures(knownGoodCharFeatures);
				}
				
				//Also, we need to adjust the baselineshift here
				ATE::ICharFeatures baselineShiftFeatures(knownGoodCharFeatures);
				ASReal currBaselineShift = currCharFeatures.GetBaselineShift(&isAssigned);
				currBaselineShift -= firstRunBaselineShift;
				baselineShiftFeatures.SetBaselineShift(currBaselineShift);
				it.Item().SetLocalCharFeatures(baselineShiftFeatures);
				
				//Move to the next run
				it.Next();
			}
		}
	}
}