Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-07

Character spacing doubled in R58529 on MacOSX/Cocoa

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Ring

I today build Lazarus MacOSX/Cocoa**from svn and realized that all characters in the editor seem to have an extra space between each character.

I did a little compiling of older SVN's and found out that the problem appeared first in revision 58529.

This change in 58529 seems to kill the cat:

Index: lcl/interfaces/cocoa/cocoagdiobjects.pas
=================================================================== --- lcl/interfaces/cocoa/cocoagdiobjects.pas    (revision 58528) +++ lcl/interfaces/cocoa/cocoagdiobjects.pas    (working copy) @@ -559,6 +559,7 @@
   Win32Weight, LoopCount: Integer;
   CocoaWeight: NSInteger;
   FTmpFont: NSFont;
+  IsDefault: Boolean;
 begin
   inherited Create(AGlobal);

@@ -570,7 +571,18 @@
     // because otherwise the result is wrong in Mac OS X 10.11, see bug 30300
     // Code used for 10.10 or inferior:
     // FName := NSStringToString(NSFont.systemFontOfSize(0).familyName); -    if IsFontNameDefault(FName) then
+    //
+    // There's a differnet issue with not using systemFont. +    // NSComboBox, if assigned a manually created font have an odd ascending-offset
+    // (easily seen in Xcode interface builder as well). systemFonts() +    // don't have such bug 33626
+    // the fix below (detecting "default" font and use systemFont()) is a potential
+    // regression for bug 30300.
+    //
+    // There might font properties (i.e. Transform Matrix) to adjust the position of
+    // the font. But at this time, it's safer to use systemFont() method +    IsDefault := IsFontNameDefault(FName);
+    if not IsDefault then
     begin
       FTmpFont :=
NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);
       FName := NSStringToString(FTmpFont.familyName); @@ -594,14 +606,14 @@
       include(FStyle, cfs_StrikeOut);

      // If this is not a "systemFont" Create the font ourselves
-    FontName := NSStringUTF8(FName);
-    Attributes := NSDictionary.dictionaryWithObjectsAndKeys(
-          FontName, NSFontFamilyAttribute,
-          NSNumber.numberWithFloat(FSize), NSFontSizeAttribute,
-          nil);
-    FontName.release;
-    Descriptor :=
NSFontDescriptor.fontDescriptorWithFontAttributes(Attributes);
-    FFont := NSFont.fontWithDescriptor_textTransform(Descriptor, nil);
+    if IsDefault then
+    begin
+      FFont := NSFont.systemFontOfSize( FSize );
+    end else begin
+      FontName := NSStringUTF8(FName);
+      FFont := NSFont.fontWithName_size(FontName, FSize);
+      FontName.release;
+    end;

     if FFont = nil then
     begin
@@ -620,7 +632,6 @@
         exit;
       end;
     end;
-
     // we could use NSFontTraitsAttribute to request the desired font style (Bold/Italic)
     // but in this case we may get NIL as result. This way is safer.      if cfs_Italic in Style then

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180715/ca10341f/attachment.html>

Reply by email

Dmitry Boyarintsev
to Michael Ring

You need to use 58531

On Sunday, July 15, 2018, Michael Ring via Lazarus <

Show quoted text 83 lines
wrote: I today build Lazarus MacOSX/Cocoa from svn and realized that all characters in the editor seem to have an extra space between each character. I did a little compiling of older SVN's and found out that the problem appeared first in revision 58529. This change in 58529 seems to kill the cat: Index: lcl/interfaces/cocoa/cocoagdiobjects.pas =================================================================== --- lcl/interfaces/cocoa/cocoagdiobjects.pas (revision 58528) +++ lcl/interfaces/cocoa/cocoagdiobjects.pas (working copy) @@ -559,6 +559,7 @@ Win32Weight, LoopCount: Integer; CocoaWeight: NSInteger; FTmpFont: NSFont; + IsDefault: Boolean; begin inherited Create(AGlobal); @@ -570,7 +571,18 @@ // because otherwise the result is wrong in Mac OS X 10.11, see bug 30300 // Code used for 10.10 or inferior: // FName := NSStringToString(NSFont.systemFontOfSize(0).familyName); - if IsFontNameDefault(FName) then + // + // There's a differnet issue with not using systemFont. + // NSComboBox, if assigned a manually created font have an odd ascending-offset + // (easily seen in Xcode interface builder as well). systemFonts() + // don't have such bug 33626 + // the fix below (detecting "default" font and use systemFont()) is a potential + // regression for bug 30300. + // + // There might font properties (i.e. Transform Matrix) to adjust the position of + // the font. But at this time, it's safer to use systemFont() method + IsDefault := IsFontNameDefault(FName); + if not IsDefault then begin FTmpFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0); FName := NSStringToString(FTmpFont.familyName); @@ -594,14 +606,14 @@ include(FStyle, cfs_StrikeOut); // If this is not a "systemFont" Create the font ourselves - FontName := NSStringUTF8(FName); - Attributes := NSDictionary.dictionaryWithObjectsAndKeys( - FontName, NSFontFamilyAttribute, - NSNumber.numberWithFloat(FSize), NSFontSizeAttribute, - nil); - FontName.release; - Descriptor := NSFontDescriptor.fontDescriptorWithFontAttribut es(Attributes); - FFont := NSFont.fontWithDescriptor_textTransform(Descriptor, nil); + if IsDefault then + begin + FFont := NSFont.systemFontOfSize( FSize ); + end else begin + FontName := NSStringUTF8(FName); + FFont := NSFont.fontWithName_size(FontName, FSize); + FontName.release; + end; if FFont = nil then begin @@ -620,7 +632,6 @@ exit; end; end; - // we could use NSFontTraitsAttribute to request the desired font style (Bold/Italic) // but in this case we may get NIL as result. This way is safer. if cfs_Italic in Style then

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180715/dcd82b03/attachment-0001.html>

Reply by email

Michael Ring
to Dmitry Boyarintsev

Problem fixed, thank you very much!

Michael

Dmitry Boyarintsev wrote 93 lines
You need to use 58531 On Sunday, July 15, 2018, Michael Ring via Lazarus < <mailto:>> wrote: I today build Lazarus MacOSX/Cocoa**from svn and realized that all characters in the editor seem to have an extra space between each character. I did a little compiling of older SVN's and found out that the problem appeared first in revision 58529. This change in 58529 seems to kill the cat: Index: lcl/interfaces/cocoa/cocoagdiobjects.pas =================================================================== --- lcl/interfaces/cocoa/cocoagdiobjects.pas (revision 58528) +++ lcl/interfaces/cocoa/cocoagdiobjects.pas (working copy) @@ -559,6 +559,7 @@    Win32Weight, LoopCount: Integer;    CocoaWeight: NSInteger;    FTmpFont: NSFont; +  IsDefault: Boolean;  begin    inherited Create(AGlobal); @@ -570,7 +571,18 @@      // because otherwise the result is wrong in Mac OS X 10.11, see bug 30300      // Code used for 10.10 or inferior:      // FName := NSStringToString(NSFont.systemFontOfSize(0).familyName); -    if IsFontNameDefault(FName) then +    // +    // There's a differnet issue with not using systemFont. +    // NSComboBox, if assigned a manually created font have an odd ascending-offset +    // (easily seen in Xcode interface builder as well). systemFonts() +    // don't have such bug 33626 +    // the fix below (detecting "default" font and use systemFont()) is a potential +    // regression for bug 30300. +    // +    // There might font properties (i.e. Transform Matrix) to adjust the position of +    // the font. But at this time, it's safer to use systemFont() method +    IsDefault := IsFontNameDefault(FName); +    if not IsDefault then      begin        FTmpFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);        FName := NSStringToString(FTmpFont.familyName); @@ -594,14 +606,14 @@        include(FStyle, cfs_StrikeOut);      // If this is not a "systemFont" Create the font ourselves -    FontName := NSStringUTF8(FName); -    Attributes := NSDictionary.dictionaryWithObjectsAndKeys( -          FontName, NSFontFamilyAttribute, -          NSNumber.numberWithFloat(FSize), NSFontSizeAttribute, -          nil); -    FontName.release; -    Descriptor := NSFontDescriptor.fontDescriptorWithFontAttributes(Attributes); -    FFont := NSFont.fontWithDescriptor_textTransform(Descriptor, nil); +    if IsDefault then +    begin +      FFont := NSFont.systemFontOfSize( FSize ); +    end else begin +      FontName := NSStringUTF8(FName); +      FFont := NSFont.fontWithName_size(FontName, FSize); +      FontName.release; +    end;      if FFont = nil then      begin @@ -620,7 +632,6 @@          exit;        end;      end; -      // we could use NSFontTraitsAttribute to request the desired font style (Bold/Italic)      // but in this case we may get NIL as result. This way is safer.      if cfs_Italic in Style then

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20180715/9f642b75/attachment.html>

Reply by email