diff --git a/lcl/include/font.inc b/lcl/include/font.inc index 87969d34c2..0e2848e442 100644 --- a/lcl/include/font.inc +++ b/lcl/include/font.inc @@ -328,7 +328,7 @@ var Result:=FW_DONTCARE; end; -var l, FaceNameMax, PixelSize, PointSize, Resolution: integer; +var l, FaceNameMax, PixelSize, PointSize, Resolution, AverageWidth: integer; begin FillChar(Result,SizeOf(TLogFont),0); ItemEnd:=0; @@ -387,15 +387,6 @@ begin Resolution:=StrToIntDef(Item,0); if Resolution<=0 then Resolution:=72; - if PixelSize=0 then begin - if PointSize<=0 then - Result.lfWidth:=(12*Resolution) div 72 - else - Result.lfWidth:=(PointSize*Resolution) div 72; - end else begin - Result.lfWidth:=PixelSize; - end; - GetNextItem; // read Spacing {M Monospaced (fixed pitch) P Proportional spaced (variable pitch) @@ -410,7 +401,8 @@ begin Result.lfPitchAndFamily:=VARIABLE_PITCH; GetNextItem; // read AverageWidth - // ToDo + AverageWidth := StrToIntDef(Item,0); + Result.lfWidth := AverageWidth div 10; GetNextItem; // read CharSetRegistry // ToDo @@ -608,6 +600,12 @@ begin if lfUnderline <> 0 then Include(AStyle, fsUnderline); if lfStrikeOut <> 0 then Include(AStyle, fsStrikeOut); end; + if (FIXED_PITCH and lfPitchAndFamily) <> 0 then + Pitch := fpFixed + else if (VARIABLE_PITCH and lfPitchAndFamily) <> 0 then + Pitch := fpVariable + else + Pitch := fpDefault; Style := AStyle; Name := ALogFont.lfFaceName; end; @@ -1100,6 +1098,9 @@ end; { ============================================================================= $Log$ + Revision 1.29 2005/03/05 14:44:00 mattias + fixed gtk1 font rotating from C Western + Revision 1.28 2005/01/10 18:44:44 mattias implemented the fpCanvas support for the LCL - Compile with -dUseFPCanvas diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index 2dcb532887..23d2a42bad 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -4411,6 +4411,13 @@ end; ------------------------------------------------------------------------------} procedure TGtkWidgetSet.InitializeFontDialog(FontDialog: TFontDialog; var SelWidget: PGtkWidget; Title: PChar); +{$IFDEF GTK1} +var + SpacingFilter: PPgchar; + FontType: TGtkFontType; +const + FixedFilter: array [0..2] of PChar = ( 'c', 'm', nil ); +{$ENDIF} begin SelWidget := gtk_font_selection_dialog_new(Title); @@ -4433,10 +4440,24 @@ begin PGtkFontSelectionDialog(SelWidget),PChar(FontDialog.PreviewText)); // set font name in XLFD format - if IsFontNameXLogicalFontDesc(FontDialog.Name) then + if IsFontNameXLogicalFontDesc(FontDialog.Font.Name) then gtk_font_selection_dialog_set_font_name(PGtkFontSelectionDialog(SelWidget), - PChar(FontDialog.Name)); + PChar(FontDialog.Font.Name)); + {$IFDEF GTK1} + { This functionality does not seem to be available in GTK2 } + // Honor selected TFontDialogOption flags + SpacingFilter := nil; + if fdFixedPitchOnly in FontDialog.Options then + SpacingFilter := @FixedFilter[0]; + FontType := GTK_FONT_ALL; + if fdScalableOnly in FontDialog.Options then + FontType := GTK_FONT_SCALABLE; + gtk_font_selection_dialog_set_filter (PGtkFontSelectionDialog(SelWidget), + GTK_FONT_FILTER_BASE, FontType, + nil, nil, nil, nil, SpacingFilter, nil); + {$ENDIF} + InitializeCommonDialog(TCommonDialog(FontDialog),SelWidget); end; @@ -6998,6 +7019,9 @@ end; { ============================================================================= $Log$ + Revision 1.637 2005/03/05 14:44:00 mattias + fixed gtk1 font rotating from C Western + Revision 1.636 2005/03/04 12:28:11 mattias fixed gtk2 intf scrollbar handling from Danny Milosavljevic diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index b6ae56e8fb..85bc2ed255 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -1325,6 +1325,7 @@ var PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth, CharSetRegistry, CharSetCoding: string; n: Integer; + sn, cs: Float; CachedFont: TGdkFontCacheDescriptor; function LoadFont: boolean; @@ -1547,7 +1548,7 @@ begin end; // SetWidthName := '*'; - + {$IFDEF OLD_ROTATION} if AddStyleName='*' then begin // calculate Style name extentions (=rotation) // API XLFD @@ -1562,11 +1563,25 @@ begin else AddStyleName := Format('+%d', [n]); end; end; + {$ENDIF} if (PixelSize='*') and (PointSize='*') then begin // TODO: make more accurate (implement the meaning of // positive and negative height values. PixelSize := IntToStr(Abs(lfHeight)); + {$IFNDEF OLD_ROTATION} + if lfOrientation <> 0 then begin + SinCos(lfOrientation/1800.*Pi, sn, cs); + cs := cs*Abs(lfHeight); + sn := sn*Abs(lfHeight); + PixelSize := Format('[%.3f %.3f %.3f %.3f]', [cs, sn, -sn, cs]); + repeat + n := Pos('-', PixelSize); + if n > 0 then + PixelSize[n] := '~'; + until n <= 0; + end; + {$ENDIF} // Since we use pixelsize, it isn't allowed to give a value here PointSize := '*'; @@ -8937,6 +8952,9 @@ end; { ============================================================================= $Log$ + Revision 1.405 2005/03/05 14:44:01 mattias + fixed gtk1 font rotating from C Western + Revision 1.404 2005/03/04 13:50:09 mattias fixed Arc and changed x,y to Left,Top to make meaning more clear