Skip to content

Comments

Add some CoreText stub definitions#40

Merged
CuriousTommy merged 1 commit intodarlinghq:masterfrom
jlucfarias:add-missing-coretext-definitions
May 10, 2025
Merged

Add some CoreText stub definitions#40
CuriousTommy merged 1 commit intodarlinghq:masterfrom
jlucfarias:add-missing-coretext-definitions

Conversation

@jlucfarias
Copy link

@jlucfarias jlucfarias commented Sep 21, 2024

I've tried to add all constants of CTFont (unfortunatelfy I do not have time to add constants and stubs for other files) but I've keeped constants unused at this time commented to be uncommented later.

One suggestion is to move all frameworks from here (and other darling projects) to darling repo (or a darling specific repo for frameworks) to keep only one place with all frameworks. IMHO this is a more maintainable action to get darling project more active.
A lot of definitions can be get from the abandoned project darling-coregraphics and I used for reference for this changes.

Fixes darling#797
Fixes darling#798
Fixes darling#1527

Copy link

@CuriousTommy CuriousTommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes I need you to fix first before I can merge this.

On a side note, is there a particular reason why you want to keep most of the new changes commented out? I think it would be better if we left them un-commented.

@jlucfarias
Copy link
Author

@CuriousTommy I think I fixed all requested changes: reverted the formatting changes, uncomment constants and moved from constants.c to the new file.
My reasons for keep commented was that it is not used right now to issues I'm trying to fix, but I wanted to add these constants to be available to anyone that want to contribute with the project in the future

Copy link

@CuriousTommy CuriousTommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long to review your new changes. Been feeling burned out lately...

@CuriousTommy
Copy link

@jlucfarias Did you get a chance to build and run your changes? I'm getting some errors:

/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:189:14: error: redefinition of 'CTFontTableOptions'
  189 | typedef enum CTFontTableOptions : uint32_t {
      |              ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:124:30: note: previous definition is here
  124 | typedef CF_OPTIONS(uint32_t, CTFontTableOptions) {
      |                              ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:190:5: error: redefinition of enumerator 'kCTFontTableOptionNoOptions'
  190 |     kCTFontTableOptionNoOptions = 0,
      |     ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:125:5: note: previous definition is here
  125 |     kCTFontTableOptionNoOptions        = 0,
      |     ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:191:5: error: redefinition of enumerator 'kCTFontTableOptionExcludeSynthetic'
  191 |     kCTFontTableOptionExcludeSynthetic = (1 << 0) // Deprecated
      |     ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:126:5: note: previous definition is here
  126 |     kCTFontTableOptionExcludeSynthetic = 1,
      |     ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:192:3: error: typedef redefinition with different types ('enum (unnamed enum at /home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:189:14)' vs 'enum CTFontTableOptions')
  192 | } CTFontTableOptions;
      |   ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:124:30: note: previous definition is here
  124 | typedef CF_OPTIONS(uint32_t, CTFontTableOptions) {
      |                              ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:219:125: error: unknown type name 'CTFontSymbolicTraits'
  219 | CORETEXT_EXPORT CTFontRef CTFontCreateCopyWithSymbolicTraits(CTFontRef font, CGFloat size, const CGAffineTransform *matrix, CTFontSymbolicTraits symTraitValue, CTFontSymbolicTraits symTraitMask);
      |                                                                                                                             ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:219:161: error: unknown type name 'CTFontSymbolicTraits'
  219 | CORETEXT_EXPORT CTFontRef CTFontCreateCopyWithSymbolicTraits(CTFontRef font, CGFloat size, const CGAffineTransform *matrix, CTFontSymbolicTraits symTraitValue, CTFontSymbolicTraits symTraitMask);
      |                                                                                                                                                                 ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:228:17: error: unknown type name 'CTFontSymbolicTraits'
  228 | CORETEXT_EXPORT CTFontSymbolicTraits CTFontGetSymbolicTraits(CTFontRef font);
      |                 ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:260:72: error: unknown type name 'CTFontOrientation'
  260 | CORETEXT_EXPORT CGRect CTFontGetBoundingRectsForGlyphs(CTFontRef font, CTFontOrientation orientation, const CGGlyph *glyphs, CGRect *boundingRects, CFIndex count);
      |                                                                        ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:261:67: error: unknown type name 'CTFontOrientation'
  261 | CORETEXT_EXPORT double CTFontGetAdvancesForGlyphs(CTFontRef font, CTFontOrientation orientation,
      |                                                                   ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:282:17: error: unknown type name 'ATSFontRef'; did you mean 'CTFontRef'?
  282 | CORETEXT_EXPORT ATSFontRef CTFontGetPlatformFont(CTFontRef font, CTFontDescriptorRef  _Nullable *attributes); // Deprecated
      |                 ^~~~~~~~~~
      |                 CTFontRef
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:27:44: note: 'CTFontRef' declared here
   27 | typedef struct CF_BRIDGED_TYPE(id) KTFont *CTFontRef;
      |                                            ^
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:283:56: error: unknown type name 'ATSFontRef'; did you mean 'CTFontRef'?
  283 | CORETEXT_EXPORT CTFontRef CTFontCreateWithPlatformFont(ATSFontRef platformFont, CGFloat size, const CGAffineTransform *matrix, CTFontDescriptorRef attributes); // Deprecated
      |                                                        ^~~~~~~~~~
      |                                                        CTFontRef
/home/thomasa/Downloads/darling2/framework-include/CoreText/CTFont.h:27:44: note: 'CTFontRef' declared here
   27 | typedef struct CF_BRIDGED_TYPE(id) KTFont *CTFontRef;
      |                                            ^
3 warnings and 11 errors generated.

@jlucfarias
Copy link
Author

@CuriousTommy sorry for the late response. I couldn't build at the moment I sent my changes, but now I builded and fixed all errors related to Coretext changes. Please, try again

@jlucfarias jlucfarias changed the title Add some CoreText stub definitions but keep most commented Add some CoreText stub definitions Dec 10, 2024
Copy link

@CuriousTommy CuriousTommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some additional fixes you might need to do, but here is what I found.

Copy link

@CuriousTommy CuriousTommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more fixes needed:

https://github.com/darlinghq/darling-cocotron/blob/master/CoreGraphics/include/CoreGraphics/CGContext.h#L22

/home/[user]/Downloads/darling2/framework-include/CoreGraphics/CGContext.h:23:32: error: typedef redefinition with different types ('struct CF_BRIDGED_TYPE' vs 'id')
   23 | typedef struct CF_BRIDGED_TYPE(id) O2Context *CGContextRef;
      |                                ^

https://github.com/darlinghq/darling-cocotron/blob/master/CoreText/stubs.c#L3-L6

[ 45%] Linking C shared library CoreText
ld: warning: OS dylibs should not add rpaths (linker option: -rpath) (Xcode build setting: LD_RUNPATH_SEARCH_PATHS)
duplicate symbol '_CTFontCreateWithFontDescriptor' in:
    CMakeFiles/CoreText.dir/CTFont.m.o
    CMakeFiles/CoreText.dir/stubs.c.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@Lazerbeak12345

This comment was marked as resolved.

@CuriousTommy
Copy link

CuriousTommy commented Apr 28, 2025

That's to be expected, there are some fixes that jlucfarias needs to do before I can merge this.

@Lazerbeak12345
Copy link

Lazerbeak12345 commented Apr 28, 2025

yep! That's fine. I was just hoping to give it a spin, see if I notice anything, if it works etc.

@Lazerbeak12345
Copy link

Lazerbeak12345 commented May 2, 2025

If I apply this patch to this branch, the branch compiles successfully, and my test program prints this near the end of it's logs (it crashes because of stubs, instead of missing symbols, so this is desired).

diff --git a/CoreGraphics/include/CoreGraphics/CGContext.h b/CoreGraphics/include/CoreGraphics/CGContext.h
index 12a110e5..973670ba 100644
--- a/CoreGraphics/include/CoreGraphics/CGContext.h
+++ b/CoreGraphics/include/CoreGraphics/CGContext.h
@@ -18,6 +18,7 @@ AN ACTION OF CONTRACT,TORT OR OTHERWISE,ARISING FROM,OUT OF OR IN CONNECTION
 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

 #import <CoreGraphics/CoreGraphicsExport.h>
+#import <CoreFoundation/CFBase.h>

 typedef struct CF_BRIDGED_TYPE(id) O2Context *CGContextRef;

Here's the (successful) stubs in-use, logged from the software:

STUB CTFontCollectionRef CTFontCollectionCreateFromAvailableFonts(CFDictionaryRef)
STUB CFArrayRef CTFontCollectionCreateMatchingFontDescriptors(CTFontCollectionRef)

This patch is needed because the dependency was removed from CoreText/include/CoreText/CTFontDescriptor.h, and is next needed in CoreGraphics/include/CoreGraphics/CGContext.h. (this is the cause of the error that CuriousTommy noticed earlier)

Thanks so much for working on this!

@jlucfarias
Copy link
Author

jlucfarias commented May 3, 2025

Sorry for the late response. Many thanks, @Lazerbeak12345. I was unable to search the solution for the error that CuriousTommy noticed and your patch worked like a charm. I've posted and made you as co-author of the commit because the change was your, not mine. @CuriousTommy, please review again

@CuriousTommy
Copy link

I was able to build without any build failures occurring. My only final request is that your combine your commits. After that, I'll merge it in.

Co-authored-by: Lazerbeak12345 <A02313752@aggies.usu.edu>
@jlucfarias jlucfarias force-pushed the add-missing-coretext-definitions branch from 66d0865 to 29338b1 Compare May 10, 2025 12:57
@jlucfarias
Copy link
Author

@CuriousTommy done

@CuriousTommy CuriousTommy dismissed their stale review May 10, 2025 17:46

All issues resolved!

@CuriousTommy CuriousTommy merged commit f4564d8 into darlinghq:master May 10, 2025
@CuriousTommy
Copy link

Thank you for your contribution!

@jlucfarias jlucfarias deleted the add-missing-coretext-definitions branch May 10, 2025 18:42
CuriousTommy added a commit to darlinghq/darling that referenced this pull request May 11, 2025
darlinghq/darling-cocotron#40 | Add some CoreText stub definitions
CuriousTommy added a commit to darlinghq/darling that referenced this pull request May 15, 2025
darlinghq/darling-cocotron#40 | Add some CoreText stub definitions
darlinghq/darling-cocotron#42 | Fix NSWindowTemplate logic not applying to both keyed and unkeyed decoding
CuriousTommy added a commit to darlinghq/darling that referenced this pull request May 16, 2025
darlinghq/darling-cocotron#40 | Add some CoreText stub definitions
darlinghq/darling-cocotron#42 | Fix NSWindowTemplate logic not applying to both keyed and unkeyed decoding
darlinghq/darling-cocotron#43 | fix(CoreText): missing kCTFontOpenTypeFeature Key and Value
CuriousTommy added a commit to darlinghq/darling that referenced this pull request May 17, 2025
darlinghq/darling-cocotron#40 | Add some CoreText stub definitions
darlinghq/darling-cocotron#42 | Fix NSWindowTemplate logic not applying to both keyed and unkeyed decoding
darlinghq/darling-cocotron#43 | fix(CoreText): missing kCTFontOpenTypeFeature Key and Value
darlinghq/darling-cocotron#44 | several missing symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants