mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 03:19:15 +02:00
fpvectorial: Fixes the reading of math symbols to use UTF-8 and improves the formula positioning
git-svn-id: trunk@37874 -
This commit is contained in:
parent
3d6521cf19
commit
9ac98e00f4
@ -1734,6 +1734,8 @@ begin
|
||||
end;
|
||||
|
||||
case Kind of
|
||||
fekMultiplication: Result := 0;
|
||||
//
|
||||
fekFraction:
|
||||
begin
|
||||
Formula.CalculateWidth(ADest);
|
||||
@ -1797,7 +1799,11 @@ begin
|
||||
fekVariable: ADest.TextOut(LeftC, TopC, Text);
|
||||
fekEqual: ADest.TextOut(LeftC, TopC, '=');
|
||||
fekSubtraction: ADest.TextOut(LeftC, TopC, '-');
|
||||
fekMultiplication: ADest.TextOut(LeftC, TopC, '×'); // Unicode times symbol
|
||||
fekMultiplication:
|
||||
begin
|
||||
// Don't draw anything, leave an empty space, it looks better
|
||||
//ADest.TextOut(LeftC, TopC, 'x'); // × -> Unicode times symbol
|
||||
end;
|
||||
fekSum: ADest.TextOut(LeftC, TopC, '+');
|
||||
fekPlusMinus:ADest.TextOut(LeftC, TopC, '±');
|
||||
fekLessThan: ADest.TextOut(LeftC, TopC, '<');
|
||||
@ -1857,7 +1863,8 @@ var
|
||||
lDBGItem, lDBGFormula, lDBGFormulaBottom: Pointer;
|
||||
lStr: string;
|
||||
begin
|
||||
lStr := Self.AsText() + Format(' Left=%f Top=%f Width=%f Height=%f', [Left, Top, Width, Height]);
|
||||
lStr := Format('%s [%s]', [Self.AsText(), GetEnumName(TypeInfo(TvFormulaElementKind), integer(Kind))]);
|
||||
lStr := lStr + Format(' Left=%f Top=%f Width=%f Height=%f', [Left, Top, Width, Height]);
|
||||
lDBGItem := ADestRoutine(lStr, APageItem);
|
||||
|
||||
case Kind of
|
||||
@ -1887,7 +1894,7 @@ constructor TvFormula.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
FElements := TFPList.Create;
|
||||
SpacingBetweenElementsX := 10;
|
||||
SpacingBetweenElementsX := 5;
|
||||
end;
|
||||
|
||||
destructor TvFormula.Destroy;
|
||||
@ -1975,7 +1982,8 @@ begin
|
||||
lElement := GetFirstElement();
|
||||
while lElement <> nil do
|
||||
begin
|
||||
Result := Result + lElement.CalculateWidth(ADest) + SpacingBetweenElementsX;
|
||||
if lElement.Kind <> fekMultiplication then
|
||||
Result := Result + lElement.CalculateWidth(ADest) + SpacingBetweenElementsX;
|
||||
lElement := GetNextElement;
|
||||
end;
|
||||
// Remove an extra spacing, since it is added even to the last item
|
||||
@ -2004,7 +2012,7 @@ begin
|
||||
while lElement <> nil do
|
||||
begin
|
||||
lElement.Left := Left + lPosX;
|
||||
lPosX := lPosX + lElement.Width;
|
||||
lPosX := lPosX + lElement.Width + SpacingBetweenElementsX;
|
||||
lElement.Top := Top;
|
||||
lMaxHeight := Max(lMaxHeight, lElement.Height);
|
||||
|
||||
@ -2105,7 +2113,6 @@ var
|
||||
lFormulaElement: TvFormulaElement;
|
||||
lStr: string;
|
||||
begin
|
||||
// Result := inherited GenerateDebugTree(ADestRoutine, APageItem);
|
||||
lStr := Format('[%s]', [Self.ClassName]);
|
||||
lStr := lStr + Format(' Left=%f Top=%f Width=%f Height=%f', [Left, Top, Width, Height]);
|
||||
Result := ADestRoutine(lStr, APageItem);
|
||||
|
@ -64,6 +64,7 @@ var
|
||||
lFormElem: TvFormulaElement;
|
||||
lMFracRow: TDOMNode;
|
||||
lSubNodeNameStr: DOMString;
|
||||
lNodeTextLen: Integer;
|
||||
begin
|
||||
lNodeName := ANode.NodeName;
|
||||
if ANode.FirstChild <> nil then
|
||||
@ -85,17 +86,18 @@ begin
|
||||
// <mo>=</mo>
|
||||
else if lNodeName = 'mo' then
|
||||
begin
|
||||
lNodeTextLen := Length(lNodeText);
|
||||
// equal
|
||||
if lNodeText = '=' then
|
||||
AFormula.AddElementWithKind(fekEqual)
|
||||
// minus
|
||||
else if (lNodeText = '−') or (lNodeText = #$22#$12) then
|
||||
else if (lNodeText = '−') or (lNodeText = #$E2#$88#$92) or (lNodeText = '-') then
|
||||
AFormula.AddElementWithKind(fekSubtraction)
|
||||
// ⁢
|
||||
else if (lNodeText = '⁢') or (lNodeText = #$20#$62) then
|
||||
else if (lNodeText = '⁢') or (lNodeText = #$E2#$81#$A2) then
|
||||
AFormula.AddElementWithKind(fekMultiplication)
|
||||
// ±
|
||||
else if (lNodeText = '±') or (lNodeText = #$00#$B1) then
|
||||
else if (lNodeText = '±') or (lNodeText = #$C2#$B1) or (lNodeText = '±') then
|
||||
AFormula.AddElementWithKind(fekPlusMinus)
|
||||
//
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user