Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some CoreText stub definitions #40

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

jlucfarias
Copy link

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.

Trying to fix darling#797, darling#798 and 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.

CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFontDescriptor.m Outdated Show resolved Hide resolved
CoreText/constants.c Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
@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...

CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFontCollection.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Outdated Show resolved Hide resolved
@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.

CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFontDescriptor.m Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Outdated Show resolved Hide resolved
CoreText/include/CoreText/CTFont.h Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
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)

CoreText/include/CoreText/CTFontTraits.h Outdated Show resolved Hide resolved
CoreText/CTFont.m Outdated Show resolved Hide resolved
CoreText/CTFontDescriptor.m Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symbol not found: _kCTFontFullNameKey in CoreText.framework/Versions/A/CoreText
2 participants