richmemo: simplify flag checks for byte type. corrected gtk2 style read for default font

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4017 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2015-03-12 04:08:37 +00:00
parent 47109b3dd8
commit 26fef957ec
2 changed files with 21 additions and 19 deletions

View File

@ -1317,8 +1317,6 @@ var
PangoDesc: PPangoFontDescription; PangoDesc: PPangoFontDescription;
sz : Integer; sz : Integer;
isSzAbs : Boolean; isSzAbs : Boolean;
style : gint;
attr : PPangoAttrList;
begin begin
gtkobj:=PGDIObject(fontref); gtkobj:=PGDIObject(fontref);
Result:=Assigned(gtkobj) and (gtkobj^.GDIType=gdiFont); Result:=Assigned(gtkobj) and (gtkobj^.GDIType=gdiFont);
@ -1326,25 +1324,30 @@ begin
if gtkobj^.LogFont.lfFaceName = 'default' then begin if gtkobj^.LogFont.lfFaceName = 'default' then begin
pangofont:=GTK2WidgetSet.GetDefaultGtkFont(False); pangofont:=GTK2WidgetSet.GetDefaultGtkFont(False);
if PANGO_IS_LAYOUT(pangofont) then Result:=PANGO_IS_LAYOUT(pangofont);
if Result then
begin begin
// default font name
PangoDesc := pango_layout_get_font_description(pangofont); PangoDesc := pango_layout_get_font_description(pangofont);
if not Assigned(PangoDesc) then if not Assigned(PangoDesc) then
PangoDesc := pango_context_get_font_description(pango_layout_get_context(pangofont)); PangoDesc := pango_context_get_font_description(pango_layout_get_context(pangofont));
params.Name := StrPas(pango_font_description_get_family(PangoDesc)); params.Name := StrPas(pango_font_description_get_family(PangoDesc));
isSzAbs := pango_font_description_get_size_is_absolute(PangoDesc); // default font size
sz := pango_font_description_get_size(PangoDesc); if gtkobj^.LogFont.lfHeight = 0 then begin
if not isSzAbs then isSzAbs := pango_font_description_get_size_is_absolute(PangoDesc);
params.Size := round(sz / PANGO_SCALE) sz := pango_font_description_get_size(PangoDesc);
else if not isSzAbs then
params.Size := round(sz/ScreenInfo.PixelsPerInchY*72); params.Size := round(sz / PANGO_SCALE)
else
params.Size := round(sz/ScreenInfo.PixelsPerInchY*72);
end;
if pango_font_description_get_weight(PangoDesc) > PANGO_WEIGHT_NORMAL then // rely on LogFont structure to be initialiazed (as it seems to be)
Include(params.Style, fsBold); if gtkobj^.LogFont.lfItalic > 0 then Include(params.Style, fsItalic);
style:=pango_font_description_get_style(PangoDesc); if gtkobj^.LogFont.lfWidth >= FW_BOLD then Include(params.Style, fsBold);
if gtkobj^.LogFont.lfUnderline > 0 then Include(params.Style, fsUnderline);
if style and PANGO_STYLE_ITALIC > 0 then Include(params.Style, fsItalic); if gtkobj^.LogFont.lfStrikeOut > 0 then Include(params.Style, fsStrikeOut);
end; end;
end else end else
Result:=false; Result:=false;

View File

@ -305,11 +305,10 @@ begin
with Result, ALogFont do with Result, ALogFont do
begin begin
Height := lfHeight; Height := lfHeight;
if lfWeight >= FW_BOLD then if lfWeight >= FW_BOLD then Include(Style, fsBold);
Include(Style, fsBold); if lfItalic > 0 then Include(Style, fsItalic);
if lfItalic <> 0 then Include(Style, fsItalic); if lfUnderline > 0 then Include(Style, fsUnderline);
if lfUnderline <> 0 then Include(Style, fsUnderline); if lfStrikeOut > 0 then Include(Style, fsStrikeOut);
if lfStrikeOut <> 0 then Include(Style, fsStrikeOut);
Charset := TFontCharset(lfCharSet); Charset := TFontCharset(lfCharSet);
Name := lfFaceName; Name := lfFaceName;
case lfPitchAndFamily and $F of case lfPitchAndFamily and $F of