|
@@ -29,7 +29,6 @@ interface
|
|
|
uses
|
|
|
Classes, SysUtils, Math, FPImage, sortbase,
|
|
|
fpCSSResolver, fpCSSTree, fpCSSParser, FCL.Events,
|
|
|
-// LazLoggerBase,
|
|
|
Fresnel.Classes, Fresnel.Events;
|
|
|
|
|
|
type
|
|
@@ -41,6 +40,7 @@ type
|
|
|
|
|
|
const
|
|
|
FresnelDefaultDPI = 96;
|
|
|
+ FresnelFontWeightNormal = 400;
|
|
|
|
|
|
type
|
|
|
// CSS attributes of the TFresnelElement class
|
|
@@ -312,7 +312,7 @@ type
|
|
|
function GetSize: TFresnelLength;
|
|
|
function GetStyle: string;
|
|
|
function GetVariant: string;
|
|
|
- function GetWeight: string;
|
|
|
+ function GetWeight: TFresnelLength;
|
|
|
function TextSize(const aText: string): TFresnelPoint;
|
|
|
function TextSizeMaxWidth(const aText: string; MaxWidth: TFresnelLength): TFresnelPoint;
|
|
|
function GetTool: TObject;
|
|
@@ -342,7 +342,7 @@ type
|
|
|
Size: TFresnelLength;
|
|
|
Style: string;
|
|
|
Variant_: string;
|
|
|
- Weight: string;
|
|
|
+ Weight: TFresnelLength;
|
|
|
function Compare(const Desc: TFresnelFontDesc): integer;
|
|
|
class function CompareDescriptors(const A, B: TFresnelFontDesc): integer; static;
|
|
|
end;
|
|
@@ -1051,7 +1051,7 @@ begin
|
|
|
if Result<>0 then exit;
|
|
|
Result:=CompareText(Variant_,Desc.Variant_);
|
|
|
if Result<>0 then exit;
|
|
|
- Result:=CompareText(Weight,Desc.Weight);
|
|
|
+ Result:=CompareValue(Weight,Desc.Weight);
|
|
|
end;
|
|
|
|
|
|
class function TFresnelFontDesc.CompareDescriptors(const A, B: TFresnelFontDesc
|
|
@@ -1273,13 +1273,15 @@ var
|
|
|
CSSResolver.Compute(El,El.StyleElements);
|
|
|
El.ComputeCSSInit;
|
|
|
end;
|
|
|
+ // create or free layout nodes
|
|
|
Layouter.ComputeCSS(El);
|
|
|
- if El.GetComputedCSSString(fcaDisplayBox,false)='none' then
|
|
|
- exit;
|
|
|
+
|
|
|
El.ComputeCSSAfterLayoutNode(Layouter);
|
|
|
El.WriteComputedAttributes('TFresnelViewport.ApplyCSS');
|
|
|
+
|
|
|
for i:=0 to El.NodeCount-1 do
|
|
|
Traverse(El.Nodes[i]);
|
|
|
+
|
|
|
Layouter.ComputedChildrenCSS(El);
|
|
|
end;
|
|
|
|
|
@@ -2711,7 +2713,7 @@ begin
|
|
|
if (AttrID<FFresnelElementBaseAttrID) or (AttrID>ord(High(TFresnelCSSAttribute))+FFresnelElementBaseAttrID) then
|
|
|
exit;
|
|
|
Attr:=TFresnelCSSAttribute(AttrID-FFresnelElementBaseAttrID);
|
|
|
- FCSSComputed[Attr]:=Value;
|
|
|
+ SetCSSElComputedAttribute(Attr,Value);
|
|
|
end;
|
|
|
|
|
|
procedure TFresnelElement.SetParent(const AValue: TFresnelElement);
|
|
@@ -3375,7 +3377,7 @@ begin
|
|
|
FFontDesc.Family:=GetComputedCSSString(fcaFontFamily,true);
|
|
|
FFontDesc.Style:=GetComputedCSSString(fcaFontStyle,true);
|
|
|
FFontDesc.Variant_:=GetComputedCSSString(fcaFontVariant,true);
|
|
|
- FFontDesc.Weight:=GetComputedCSSString(fcaFontWeight,true);
|
|
|
+
|
|
|
s:=GetComputedCSSString(fcaFontSize,true);
|
|
|
case s of
|
|
|
'xx-small': FFontDesc.Size:=6;
|
|
@@ -3391,6 +3393,18 @@ begin
|
|
|
if not CSSStrToFloat(s,FFontDesc.Size) then
|
|
|
FFontDesc.Size:=10;
|
|
|
end;
|
|
|
+
|
|
|
+ s:=GetComputedCSSString(fcaFontWeight,true);
|
|
|
+ case s of
|
|
|
+ 'normal': FFontDesc.Weight:=FresnelFontWeightNormal;
|
|
|
+ 'bold': FFontDesc.Weight:=700;
|
|
|
+ 'lighter': FFontDesc.Weight:=300;
|
|
|
+ 'bolder': FFontDesc.Weight:=500;
|
|
|
+ else
|
|
|
+ if not CSSStrToFloat(s,FFontDesc.Weight) then
|
|
|
+ FFontDesc.Weight:=FresnelFontWeightNormal;
|
|
|
+ end;
|
|
|
+
|
|
|
FFontDesc.Kerning:=GetComputedCSSString(fcaFontKerning,true);
|
|
|
if FFont<>nil then
|
|
|
begin
|
|
@@ -4131,10 +4145,21 @@ begin
|
|
|
end;
|
|
|
|
|
|
procedure TFresnelElement.ComputeCSSAfterLayoutNode(Layouter: TFresnelLayouter);
|
|
|
+
|
|
|
+ procedure Convert(Attr: TFresnelCSSAttribute; IsHorizontal: boolean);
|
|
|
+ var
|
|
|
+ Value: String;
|
|
|
+ begin
|
|
|
+ Value:=CSSComputedAttribute[Attr];
|
|
|
+ ConvertCSSValueToPixel(Layouter,Attr,IsHorizontal,Value);
|
|
|
+ CSSComputedAttribute[Attr]:=Value;
|
|
|
+ end;
|
|
|
+
|
|
|
var
|
|
|
Attr: TFresnelCSSAttribute;
|
|
|
- Value: String;
|
|
|
begin
|
|
|
+ Convert(fcaFontSize,false);
|
|
|
+
|
|
|
// convert non-pixel units to pixels
|
|
|
ConvertCSSBorderWidthToPix(fcaBorderLeftWidth);
|
|
|
ConvertCSSBorderWidthToPix(fcaBorderRightWidth);
|
|
@@ -4163,9 +4188,7 @@ begin
|
|
|
fcaPaddingTop,
|
|
|
fcaPaddingBottom] do
|
|
|
begin
|
|
|
- Value:=CSSComputedAttribute[Attr];
|
|
|
- ConvertCSSValueToPixel(Layouter,Attr,true,Value);
|
|
|
- CSSComputedAttribute[Attr]:=Value;
|
|
|
+ Convert(Attr,true);
|
|
|
end;
|
|
|
|
|
|
// simple vertical values
|
|
@@ -4179,9 +4202,7 @@ begin
|
|
|
fcaMinHeight,
|
|
|
fcaMaxHeight] do
|
|
|
begin
|
|
|
- Value:=CSSComputedAttribute[Attr];
|
|
|
- ConvertCSSValueToPixel(Layouter,Attr,false,Value);
|
|
|
- CSSComputedAttribute[Attr]:=Value;
|
|
|
+ Convert(Attr,false);
|
|
|
end;
|
|
|
|
|
|
// compound values
|